1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
21 #include <com/sun/star/container/XChild.hpp>
22 #include <com/sun/star/drawing/BitmapMode.hpp>
23 #include <com/sun/star/drawing/FillStyle.hpp>
24 #include <com/sun/star/awt/Gradient.hpp>
25 #include <com/sun/star/embed/XClassifiedObject.hpp>
26 #include <com/sun/star/embed/XVisualObject.hpp>
27 #include <com/sun/star/embed/XComponentSupplier.hpp>
28 #include <com/sun/star/embed/EmbedStates.hpp>
29 #include <com/sun/star/embed/Aspects.hpp>
30 #include <com/sun/star/graphic/XGraphicProvider.hpp>
31 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
32 #include <o3tl/any.hxx>
33 #include <svx/svxids.hrc>
34 #include <svx/xfillit0.hxx>
35 #include <svx/xflgrit.hxx>
36 #include <svx/sdtaitm.hxx>
37 #include <svx/xflclit.hxx>
38 #include <tools/globname.hxx>
39 #include <editeng/memberids.hrc>
40 #include <swtypes.hxx>
46 #include <drawdoc.hxx>
47 #include <IDocumentUndoRedo.hxx>
48 #include <IDocumentDrawModelAccess.hxx>
49 #include <IDocumentLayoutAccess.hxx>
50 #include <IDocumentStylePoolAccess.hxx>
54 #include <ndindex.hxx>
56 #include <ndnotxt.hxx>
57 #include <svx/unomid.hxx>
58 #include <unocrsr.hxx>
59 #include <unocrsrhelper.hxx>
60 #include <docstyle.hxx>
61 #include <dcontact.hxx>
62 #include <fmtcnct.hxx>
66 #include <textboxhelper.hxx>
67 #include <unotextrange.hxx>
68 #include <unotextcursor.hxx>
69 #include <unoparagraph.hxx>
71 #include <unoprnms.hxx>
72 #include <unoevent.hxx>
73 #include <com/sun/star/util/XModifyBroadcaster.hpp>
74 #include <com/sun/star/table/ShadowFormat.hpp>
75 #include <com/sun/star/style/GraphicLocation.hpp>
76 #include <com/sun/star/text/GraphicCrop.hpp>
77 #include <com/sun/star/text/TextContentAnchorType.hpp>
78 #include <com/sun/star/text/XTextColumns.hpp>
79 #include <com/sun/star/text/WrapTextMode.hpp>
80 #include <com/sun/star/beans/PropertyAttribute.hpp>
81 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
82 #include <com/sun/star/drawing/PointSequence.hpp>
83 #include <com/sun/star/drawing/ColorMode.hpp>
84 #include <tools/poly.hxx>
86 #include <unostyle.hxx>
87 #include <svx/svdmodel.hxx>
88 #include <svx/svdpage.hxx>
89 #include <editeng/brushitem.hxx>
90 #include <editeng/protitem.hxx>
91 #include <fmtornt.hxx>
92 #include <fmteiro.hxx>
94 #include <editeng/lrspitem.hxx>
95 #include <editeng/ulspitem.hxx>
96 #include <editeng/boxitem.hxx>
97 #include <editeng/opaqitem.hxx>
98 #include <editeng/prntitem.hxx>
99 #include <editeng/shaditem.hxx>
100 #include <fmtsrnd.hxx>
101 #include <fmtfsize.hxx>
102 #include <grfatr.hxx>
103 #include <unoframe.hxx>
104 #include <fmtanchr.hxx>
105 #include <fmtclds.hxx>
106 #include <fmtcntnt.hxx>
107 #include <frmatr.hxx>
110 #include <osl/mutex.hxx>
111 #include <vcl/svapp.hxx>
112 #include <sfx2/printer.hxx>
113 #include <SwStyleNameMapper.hxx>
114 #include <editeng/xmlcnitm.hxx>
115 #include <poolfmt.hxx>
116 #include <pagedesc.hxx>
117 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
118 #include <editeng/frmdiritem.hxx>
119 #include <fmtfollowtextflow.hxx>
120 #include <fmtwrapinfluenceonobjpos.hxx>
121 #include <toolkit/helper/vclunohelper.hxx>
122 #include <calbck.hxx>
123 #include <comphelper/servicehelper.hxx>
124 #include <cppuhelper/supportsservice.hxx>
126 #include <svx/unobrushitemhelper.hxx>
127 #include <svx/xbtmpit.hxx>
128 #include <svx/xgrscit.hxx>
129 #include <svx/xflbmtit.hxx>
130 #include <svx/xflbmpit.hxx>
131 #include <svx/xflbmsxy.hxx>
132 #include <svx/xflftrit.hxx>
133 #include <svx/xsflclit.hxx>
134 #include <svx/xflbmsli.hxx>
135 #include <svx/xflbtoxy.hxx>
136 #include <svx/xflbstit.hxx>
137 #include <svx/xflboxy.hxx>
138 #include <svx/xflbckit.hxx>
139 #include <svx/unoshape.hxx>
140 #include <svx/xflhtit.hxx>
141 #include <svx/xfltrit.hxx>
142 #include <swunohelper.hxx>
145 using namespace ::com::sun::star
;
147 using ::com::sun::star::frame::XModel
;
148 using ::com::sun::star::container::XNameAccess
;
149 using ::com::sun::star::style::XStyleFamiliesSupplier
;
151 const sal_Char sPackageProtocol
[] = "vnd.sun.star.Package:";
152 const sal_Char sGraphicObjectProtocol
[] = "vnd.sun.star.GraphicObject:";
154 class BaseFrameProperties_Impl
156 SwUnoCursorHelper::SwAnyMapHelper aAnyMap
;
159 virtual ~BaseFrameProperties_Impl();
161 void SetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
& rVal
);
162 bool GetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
*& pAny
);
163 bool FillBaseProperties(SfxItemSet
& rToSet
, const SfxItemSet
&rFromSet
, bool& rSizeFound
);
165 virtual bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) = 0;
168 BaseFrameProperties_Impl::~BaseFrameProperties_Impl()
172 void BaseFrameProperties_Impl::SetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
& rVal
)
174 aAnyMap
.SetValue( nWID
, nMemberId
, rVal
);
177 bool BaseFrameProperties_Impl::GetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
*& rpAny
)
179 return aAnyMap
.FillValue( nWID
, nMemberId
, rpAny
);
182 bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet
& rToSet
, const SfxItemSet
& rFromSet
, bool& rSizeFound
)
184 //UUUU assert when the target SfxItemSet has no parent. It *should* have the pDfltFrameFormat
185 // from SwDoc set as parent (or similar) to have the necessary XFILL_NONE in the ItemSet
186 if(!rToSet
.GetParent())
188 OSL_ENSURE(false, "OOps, target SfxItemSet *should* have a parent which contains XFILL_NONE as XFillStyleItem (!)");
192 // always add an anchor to the set
193 SwFormatAnchor
aAnchor ( static_cast < const SwFormatAnchor
& > ( rFromSet
.Get ( RES_ANCHOR
) ) );
195 const ::uno::Any
* pAnchorPgNo
;
196 if(GetProperty(RES_ANCHOR
, MID_ANCHOR_PAGENUM
, pAnchorPgNo
))
197 bRet
&= ((SfxPoolItem
&)aAnchor
).PutValue(*pAnchorPgNo
, MID_ANCHOR_PAGENUM
);
198 const ::uno::Any
* pAnchorType
;
199 if(GetProperty(RES_ANCHOR
, MID_ANCHOR_ANCHORTYPE
, pAnchorType
))
200 bRet
&= ((SfxPoolItem
&)aAnchor
).PutValue(*pAnchorType
, MID_ANCHOR_ANCHORTYPE
);
205 //UUUU check for SvxBrushItem (RES_BACKGROUND) properties
206 const ::uno::Any
* pCol
= nullptr; GetProperty(RES_BACKGROUND
, MID_BACK_COLOR
, pCol
);
207 const ::uno::Any
* pRGBCol
= nullptr; GetProperty(RES_BACKGROUND
, MID_BACK_COLOR_R_G_B
, pRGBCol
);
208 const ::uno::Any
* pColTrans
= nullptr; GetProperty(RES_BACKGROUND
, MID_BACK_COLOR_TRANSPARENCY
, pColTrans
);
209 const ::uno::Any
* pTrans
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_TRANSPARENT
, pTrans
);
210 const ::uno::Any
* pGrLoc
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_POSITION
, pGrLoc
);
211 const ::uno::Any
* pGrURL
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_URL
, pGrURL
);
212 const ::uno::Any
* pGrFilter
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_FILTER
, pGrFilter
);
213 const ::uno::Any
* pGrTranparency
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_TRANSPARENCY
, pGrTranparency
);
214 const bool bSvxBrushItemPropertiesUsed(
224 //UUUU check for FillStyle properties in the range XATTR_FILL_FIRST, XATTR_FILL_LAST
225 const uno::Any
* pXFillStyleItem
= nullptr; GetProperty(XATTR_FILLSTYLE
, 0, pXFillStyleItem
);
226 const uno::Any
* pXFillColorItem
= nullptr; GetProperty(XATTR_FILLCOLOR
, 0, pXFillColorItem
);
228 // XFillGradientItem: two possible slots supported in UNO API
229 const uno::Any
* pXFillGradientItem
= nullptr; GetProperty(XATTR_FILLGRADIENT
, MID_FILLGRADIENT
, pXFillGradientItem
);
230 const uno::Any
* pXFillGradientNameItem
= nullptr; GetProperty(XATTR_FILLGRADIENT
, MID_NAME
, pXFillGradientNameItem
);
232 // XFillHatchItem: two possible slots supported in UNO API
233 const uno::Any
* pXFillHatchItem
= nullptr; GetProperty(XATTR_FILLHATCH
, MID_FILLHATCH
, pXFillHatchItem
);
234 const uno::Any
* pXFillHatchNameItem
= nullptr; GetProperty(XATTR_FILLHATCH
, MID_NAME
, pXFillHatchNameItem
);
236 // XFillBitmapItem: three possible slots supported in UNO API
237 const uno::Any
* pXFillBitmapItem
= nullptr; GetProperty(XATTR_FILLBITMAP
, MID_BITMAP
, pXFillBitmapItem
);
238 const uno::Any
* pXFillBitmapNameItem
= nullptr; GetProperty(XATTR_FILLBITMAP
, MID_NAME
, pXFillBitmapNameItem
);
239 const uno::Any
* pXFillBitmapURLItem
= nullptr; GetProperty(XATTR_FILLBITMAP
, MID_GRAFURL
, pXFillBitmapURLItem
);
241 const uno::Any
* pXFillTransparenceItem
= nullptr; GetProperty(XATTR_FILLTRANSPARENCE
, 0, pXFillTransparenceItem
);
242 const uno::Any
* pXGradientStepCountItem
= nullptr; GetProperty(XATTR_GRADIENTSTEPCOUNT
, 0, pXGradientStepCountItem
);
243 const uno::Any
* pXFillBmpPosItem
= nullptr; GetProperty(XATTR_FILLBMP_POS
, 0, pXFillBmpPosItem
);
244 const uno::Any
* pXFillBmpSizeXItem
= nullptr; GetProperty(XATTR_FILLBMP_SIZEX
, 0, pXFillBmpSizeXItem
);
245 const uno::Any
* pXFillBmpSizeYItem
= nullptr; GetProperty(XATTR_FILLBMP_SIZEY
, 0, pXFillBmpSizeYItem
);
247 // XFillFloatTransparenceItem: two possible slots supported in UNO API
248 const uno::Any
* pXFillFloatTransparenceItem
= nullptr; GetProperty(XATTR_FILLFLOATTRANSPARENCE
, MID_FILLGRADIENT
, pXFillFloatTransparenceItem
);
249 const uno::Any
* pXFillFloatTransparenceNameItem
= nullptr; GetProperty(XATTR_FILLFLOATTRANSPARENCE
, MID_NAME
, pXFillFloatTransparenceNameItem
);
251 const uno::Any
* pXSecondaryFillColorItem
= nullptr; GetProperty(XATTR_SECONDARYFILLCOLOR
, 0, pXSecondaryFillColorItem
);
252 const uno::Any
* pXFillBmpSizeLogItem
= nullptr; GetProperty(XATTR_FILLBMP_SIZELOG
, 0, pXFillBmpSizeLogItem
);
253 const uno::Any
* pXFillBmpTileOffsetXItem
= nullptr; GetProperty(XATTR_FILLBMP_TILEOFFSETX
, 0, pXFillBmpTileOffsetXItem
);
254 const uno::Any
* pXFillBmpTileOffsetYItem
= nullptr; GetProperty(XATTR_FILLBMP_TILEOFFSETY
, 0, pXFillBmpTileOffsetYItem
);
255 const uno::Any
* pXFillBmpPosOffsetXItem
= nullptr; GetProperty(XATTR_FILLBMP_POSOFFSETX
, 0, pXFillBmpPosOffsetXItem
);
256 const uno::Any
* pXFillBmpPosOffsetYItem
= nullptr; GetProperty(XATTR_FILLBMP_POSOFFSETY
, 0, pXFillBmpPosOffsetYItem
);
257 const uno::Any
* pXFillBackgroundItem
= nullptr; GetProperty(XATTR_FILLBACKGROUND
, 0, pXFillBackgroundItem
);
258 const uno::Any
* pOwnAttrFillBmpItem
= nullptr; GetProperty(OWN_ATTR_FILLBMP_MODE
, 0, pOwnAttrFillBmpItem
);
260 // tdf#91140: ignore SOLID fill style for determining if fill style is used
261 // but there is a GraphicURL
262 const bool bFillStyleUsed(pXFillStyleItem
&& pXFillStyleItem
->hasValue() &&
263 (pXFillStyleItem
->get
<drawing::FillStyle
>() != drawing::FillStyle_SOLID
265 SAL_INFO_IF(pXFillStyleItem
&& pXFillStyleItem
->hasValue() && !bFillStyleUsed
,
266 "sw.uno", "FillBaseProperties: ignoring invalid FillStyle");
267 const bool bXFillStyleItemUsed(
270 pXFillGradientItem
|| pXFillGradientNameItem
||
271 pXFillHatchItem
|| pXFillHatchNameItem
||
272 pXFillBitmapItem
|| pXFillBitmapNameItem
|| pXFillBitmapURLItem
||
273 pXFillTransparenceItem
||
274 pXGradientStepCountItem
||
276 pXFillBmpSizeXItem
||
277 pXFillBmpSizeYItem
||
278 pXFillFloatTransparenceItem
|| pXFillFloatTransparenceNameItem
||
279 pXSecondaryFillColorItem
||
280 pXFillBmpSizeLogItem
||
281 pXFillBmpTileOffsetXItem
||
282 pXFillBmpTileOffsetYItem
||
283 pXFillBmpPosOffsetXItem
||
284 pXFillBmpPosOffsetYItem
||
285 pXFillBackgroundItem
||
286 pOwnAttrFillBmpItem
);
288 // use brush items, but *only* if no FillStyle properties are used; if both are used and when applying both
289 // in the obvious order some attributes may be wrong since they are set by the 1st set, but not
290 // redefined as needed by the 2nd set when they are default (and thus no tset) in the 2nd set. If
291 // it is necessary for any reason to set both (it should not) a in-between step will be needed
292 // that resets the items for FillAttributes in rToSet to default.
293 // Note: There are other mechanisms in XMLOFF to pre-sort this relationship already, but this version
294 // was used initially, is tested and works. Keep it to be able to react when another feed adds attributes
296 if(bSvxBrushItemPropertiesUsed
&& !bXFillStyleItemUsed
)
298 //UUUU create a temporary SvxBrushItem, fill the attributes to it and use it to set
299 // the corresponding FillAttributes
300 SvxBrushItem
aBrush(RES_BACKGROUND
);
304 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pCol
,MID_BACK_COLOR
);
309 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pColTrans
, MID_BACK_COLOR_TRANSPARENCY
);
314 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pRGBCol
, MID_BACK_COLOR_R_G_B
);
319 // don't overwrite transparency with a non-transparence flag
320 if(!pColTrans
|| Any2Bool( *pTrans
))
321 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pTrans
, MID_GRAPHIC_TRANSPARENT
);
326 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pGrURL
, MID_GRAPHIC_URL
);
331 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pGrFilter
, MID_GRAPHIC_FILTER
);
336 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pGrLoc
, MID_GRAPHIC_POSITION
);
341 bRet
&= ((SfxPoolItem
&)aBrush
).PutValue(*pGrTranparency
, MID_GRAPHIC_TRANSPARENCY
);
344 setSvxBrushItemAsFillAttributesToTargetSet(aBrush
, rToSet
);
347 if(bXFillStyleItemUsed
)
349 XFillStyleItem aXFillStyleItem
;
350 SvxBrushItem
aBrush(RES_BACKGROUND
);
354 aXFillStyleItem
.PutValue(*pXFillStyleItem
, 0);
355 rToSet
.Put(aXFillStyleItem
);
360 const Color
aNullCol(COL_DEFAULT_SHAPE_FILLING
);
361 XFillColorItem
aXFillColorItem(OUString(), aNullCol
);
363 aXFillColorItem
.PutValue(*pXFillColorItem
, 0);
364 rToSet
.Put(aXFillColorItem
);
365 //set old-school brush color if we later encounter the
366 //MID_BACK_COLOR_TRANSPARENCY case below
367 aBrush
= getSvxBrushItemFromSourceSet(rToSet
, RES_BACKGROUND
, false);
369 else if (aXFillStyleItem
.GetValue() == drawing::FillStyle_SOLID
&& (pCol
|| pRGBCol
))
371 // Fill style is set to solid, but no fill color is given.
372 // On the other hand, we have a BackColor, so use that.
374 aBrush
.PutValue(*pCol
, MID_BACK_COLOR
);
376 aBrush
.PutValue(*pRGBCol
, MID_BACK_COLOR_R_G_B
);
377 setSvxBrushItemAsFillAttributesToTargetSet(aBrush
, rToSet
);
380 if(pXFillGradientItem
|| pXFillGradientNameItem
)
382 if(pXFillGradientItem
)
384 const XGradient
aNullGrad(RGB_Color(COL_BLACK
), RGB_Color(COL_WHITE
));
385 XFillGradientItem
aXFillGradientItem(aNullGrad
);
387 aXFillGradientItem
.PutValue(*pXFillGradientItem
, MID_FILLGRADIENT
);
388 rToSet
.Put(aXFillGradientItem
);
391 if(pXFillGradientNameItem
)
395 if(!(*pXFillGradientNameItem
>>= aTempName
))
397 throw lang::IllegalArgumentException();
400 bool const bSuccess
= SvxShape::SetFillAttribute(
401 XATTR_FILLGRADIENT
, aTempName
, rToSet
);
402 if (aXFillStyleItem
.GetValue() == drawing::FillStyle_GRADIENT
)
403 { // tdf#90946 ignore invalid gradient-name if SOLID
408 SAL_INFO_IF(!bSuccess
, "sw.uno",
409 "FillBaseProperties: ignoring invalid FillGradientName");
414 if(pXFillHatchItem
|| pXFillHatchNameItem
)
418 const Color
aNullCol(COL_DEFAULT_SHAPE_STROKE
);
419 const XHatch
aNullHatch(aNullCol
);
420 XFillHatchItem
aXFillHatchItem(rToSet
.GetPool(), aNullHatch
);
422 aXFillHatchItem
.PutValue(*pXFillHatchItem
, MID_FILLHATCH
);
423 rToSet
.Put(aXFillHatchItem
);
426 if(pXFillHatchNameItem
)
430 if(!(*pXFillHatchNameItem
>>= aTempName
))
432 throw lang::IllegalArgumentException();
435 bRet
&= SvxShape::SetFillAttribute(XATTR_FILLHATCH
, aTempName
, rToSet
);
439 if(pXFillBitmapItem
|| pXFillBitmapNameItem
|| pXFillBitmapURLItem
)
443 const Graphic aNullGraphic
;
444 XFillBitmapItem
aXFillBitmapItem(rToSet
.GetPool(), aNullGraphic
);
446 aXFillBitmapItem
.PutValue(*pXFillBitmapItem
, MID_BITMAP
);
447 rToSet
.Put(aXFillBitmapItem
);
450 if(pXFillBitmapNameItem
)
454 if(!(*pXFillBitmapNameItem
>>= aTempName
))
456 throw lang::IllegalArgumentException();
459 bRet
&= SvxShape::SetFillAttribute(XATTR_FILLBITMAP
, aTempName
, rToSet
);
462 if(pXFillBitmapURLItem
)
464 const Graphic aNullGraphic
;
465 XFillBitmapItem
aXFillBitmapItem(rToSet
.GetPool(), aNullGraphic
);
467 aXFillBitmapItem
.PutValue(*pXFillBitmapURLItem
, MID_GRAFURL
);
468 rToSet
.Put(aXFillBitmapItem
);
472 if (pXFillTransparenceItem
)
474 XFillTransparenceItem aXFillTransparenceItem
;
475 aXFillTransparenceItem
.PutValue(*pXFillTransparenceItem
, 0);
476 rToSet
.Put(aXFillTransparenceItem
);
478 else if (pColTrans
&&
479 !pXFillFloatTransparenceItem
&& !pXFillFloatTransparenceNameItem
)
481 // No fill transparency is given. On the other hand, we have a
482 // BackColorTransparency, so use that.
483 // tdf#90640 tdf#90130: this is necessary for LO 4.4.0 - 4.4.2
484 // that forgot to write draw:opacity into documents
485 // but: the value was *always* wrong for bitmaps! => ignore it
486 sal_Int8
nGraphicTransparency(0);
487 *pColTrans
>>= nGraphicTransparency
;
488 if (aXFillStyleItem
.GetValue() != drawing::FillStyle_BITMAP
)
490 rToSet
.Put(XFillTransparenceItem(nGraphicTransparency
));
492 if (aXFillStyleItem
.GetValue() == drawing::FillStyle_SOLID
)
494 aBrush
.PutValue(*pColTrans
, MID_BACK_COLOR_TRANSPARENCY
);
495 setSvxBrushItemAsFillAttributesToTargetSet(aBrush
, rToSet
);
499 if(pXGradientStepCountItem
)
501 XGradientStepCountItem aXGradientStepCountItem
;
503 aXGradientStepCountItem
.PutValue(*pXGradientStepCountItem
, 0);
504 rToSet
.Put(aXGradientStepCountItem
);
509 XFillBmpPosItem aXFillBmpPosItem
;
511 aXFillBmpPosItem
.PutValue(*pXFillBmpPosItem
, 0);
512 rToSet
.Put(aXFillBmpPosItem
);
515 if(pXFillBmpSizeXItem
)
517 XFillBmpSizeXItem aXFillBmpSizeXItem
;
519 aXFillBmpSizeXItem
.PutValue(*pXFillBmpSizeXItem
, 0);
520 rToSet
.Put(aXFillBmpSizeXItem
);
523 if(pXFillBmpSizeYItem
)
525 XFillBmpSizeYItem aXFillBmpSizeYItem
;
527 aXFillBmpSizeYItem
.PutValue(*pXFillBmpSizeYItem
, 0);
528 rToSet
.Put(aXFillBmpSizeYItem
);
531 if(pXFillFloatTransparenceItem
|| pXFillFloatTransparenceNameItem
)
533 if(pXFillFloatTransparenceItem
)
535 const XGradient
aNullGrad(RGB_Color(COL_BLACK
), RGB_Color(COL_WHITE
));
536 XFillFloatTransparenceItem
aXFillFloatTransparenceItem(rToSet
.GetPool(), aNullGrad
, false);
538 aXFillFloatTransparenceItem
.PutValue(*pXFillFloatTransparenceItem
, MID_FILLGRADIENT
);
539 rToSet
.Put(aXFillFloatTransparenceItem
);
542 if(pXFillFloatTransparenceNameItem
)
546 if(!(*pXFillFloatTransparenceNameItem
>>= aTempName
))
548 throw lang::IllegalArgumentException();
551 bRet
&= SvxShape::SetFillAttribute(XATTR_FILLFLOATTRANSPARENCE
, aTempName
, rToSet
);
555 if(pXSecondaryFillColorItem
)
557 const Color
aNullCol(COL_DEFAULT_SHAPE_FILLING
);
558 XSecondaryFillColorItem
aXSecondaryFillColorItem(OUString(), aNullCol
);
560 aXSecondaryFillColorItem
.PutValue(*pXSecondaryFillColorItem
, 0);
561 rToSet
.Put(aXSecondaryFillColorItem
);
564 if(pXFillBmpSizeLogItem
)
566 XFillBmpSizeLogItem aXFillBmpSizeLogItem
;
568 aXFillBmpSizeLogItem
.PutValue(*pXFillBmpSizeLogItem
, 0);
569 rToSet
.Put(aXFillBmpSizeLogItem
);
572 if(pXFillBmpTileOffsetXItem
)
574 XFillBmpTileOffsetXItem aXFillBmpTileOffsetXItem
;
576 aXFillBmpTileOffsetXItem
.PutValue(*pXFillBmpTileOffsetXItem
, 0);
577 rToSet
.Put(aXFillBmpTileOffsetXItem
);
580 if(pXFillBmpTileOffsetYItem
)
582 XFillBmpTileOffsetYItem aXFillBmpTileOffsetYItem
;
584 aXFillBmpTileOffsetYItem
.PutValue(*pXFillBmpTileOffsetYItem
, 0);
585 rToSet
.Put(aXFillBmpTileOffsetYItem
);
588 if(pXFillBmpPosOffsetXItem
)
590 XFillBmpPosOffsetXItem aXFillBmpPosOffsetXItem
;
592 aXFillBmpPosOffsetXItem
.PutValue(*pXFillBmpPosOffsetXItem
, 0);
593 rToSet
.Put(aXFillBmpPosOffsetXItem
);
596 if(pXFillBmpPosOffsetYItem
)
598 XFillBmpPosOffsetYItem aXFillBmpPosOffsetYItem
;
600 aXFillBmpPosOffsetYItem
.PutValue(*pXFillBmpPosOffsetYItem
, 0);
601 rToSet
.Put(aXFillBmpPosOffsetYItem
);
604 if(pXFillBackgroundItem
)
606 XFillBackgroundItem aXFillBackgroundItem
;
608 aXFillBackgroundItem
.PutValue(*pXFillBackgroundItem
, 0);
609 rToSet
.Put(aXFillBackgroundItem
);
612 if(pOwnAttrFillBmpItem
)
614 drawing::BitmapMode eMode
;
616 if(!(*pOwnAttrFillBmpItem
>>= eMode
))
620 if(!(*pOwnAttrFillBmpItem
>>= nMode
))
622 throw lang::IllegalArgumentException();
625 eMode
= (drawing::BitmapMode
)nMode
;
628 rToSet
.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH
== eMode
));
629 rToSet
.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT
== eMode
));
633 const ::uno::Any
* pCont
= nullptr;
634 GetProperty(RES_PROTECT
, MID_PROTECT_CONTENT
, pCont
);
635 const ::uno::Any
* pPos
= nullptr;
636 GetProperty(RES_PROTECT
,MID_PROTECT_POSITION
, pPos
);
637 const ::uno::Any
* pName
= nullptr;
638 GetProperty(RES_PROTECT
, MID_PROTECT_SIZE
, pName
);
639 if(pCont
||pPos
||pName
)
641 SvxProtectItem
aProt ( static_cast < const ::SvxProtectItem
& > ( rFromSet
.Get ( RES_PROTECT
) ) );
643 bRet
&= ((SfxPoolItem
&)aProt
).PutValue(*pCont
, MID_PROTECT_CONTENT
);
645 bRet
&= ((SfxPoolItem
&)aProt
).PutValue(*pPos
, MID_PROTECT_POSITION
);
647 bRet
&= ((SfxPoolItem
&)aProt
).PutValue(*pName
, MID_PROTECT_SIZE
);
652 const ::uno::Any
* pHori
= nullptr;
653 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_ORIENT
, pHori
);
654 const ::uno::Any
* pHoriP
= nullptr;
655 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_POSITION
|CONVERT_TWIPS
, pHoriP
);
656 const ::uno::Any
* pHoriR
= nullptr;
657 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_RELATION
, pHoriR
);
658 const ::uno::Any
* pPageT
= nullptr;
659 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_PAGETOGGLE
, pPageT
);
660 if(pHori
||pHoriP
||pHoriR
||pPageT
)
662 SwFormatHoriOrient
aOrient ( static_cast < const ::SwFormatHoriOrient
& > ( rFromSet
.Get ( RES_HORI_ORIENT
) ) );
664 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pHori
, MID_HORIORIENT_ORIENT
);
666 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pHoriP
, MID_HORIORIENT_POSITION
|CONVERT_TWIPS
);
668 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pHoriR
, MID_HORIORIENT_RELATION
);
670 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pPageT
, MID_HORIORIENT_PAGETOGGLE
);
676 const ::uno::Any
* pVert
= nullptr;
677 GetProperty(RES_VERT_ORIENT
, MID_VERTORIENT_ORIENT
, pVert
);
678 const ::uno::Any
* pVertP
= nullptr;
679 GetProperty(RES_VERT_ORIENT
, MID_VERTORIENT_POSITION
|CONVERT_TWIPS
, pVertP
);
680 const ::uno::Any
* pVertR
= nullptr;
681 GetProperty(RES_VERT_ORIENT
, MID_VERTORIENT_RELATION
, pVertR
);
682 if(pVert
||pVertP
||pVertR
)
684 SwFormatVertOrient
aOrient ( static_cast < const ::SwFormatVertOrient
& > ( rFromSet
.Get ( RES_VERT_ORIENT
) ) );
686 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pVert
, MID_VERTORIENT_ORIENT
);
688 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pVertP
, MID_VERTORIENT_POSITION
|CONVERT_TWIPS
);
690 bRet
&= ((SfxPoolItem
&)aOrient
).PutValue(*pVertR
, MID_VERTORIENT_RELATION
);
695 const ::uno::Any
* pURL
= nullptr;
696 GetProperty(RES_URL
, MID_URL_URL
, pURL
);
697 const ::uno::Any
* pTarget
= nullptr;
698 GetProperty(RES_URL
, MID_URL_TARGET
, pTarget
);
699 const ::uno::Any
* pHyLNm
= nullptr;
700 GetProperty(RES_URL
, MID_URL_HYPERLINKNAME
, pHyLNm
);
701 const ::uno::Any
* pHySMp
= nullptr;
702 GetProperty(RES_URL
, MID_URL_SERVERMAP
, pHySMp
);
703 if(pURL
||pTarget
||pHyLNm
||pHySMp
)
705 SwFormatURL
aURL ( static_cast < const ::SwFormatURL
& > ( rFromSet
.Get ( RES_URL
) ) );
707 bRet
&= ((SfxPoolItem
&)aURL
).PutValue(*pURL
, MID_URL_URL
);
709 bRet
&= ((SfxPoolItem
&)aURL
).PutValue(*pTarget
, MID_URL_TARGET
);
711 bRet
&= ((SfxPoolItem
&)aURL
).PutValue(*pHyLNm
, MID_URL_HYPERLINKNAME
);
713 bRet
&= ((SfxPoolItem
&)aURL
).PutValue(*pHySMp
, MID_URL_SERVERMAP
);
717 const ::uno::Any
* pL
= nullptr;
718 GetProperty(RES_LR_SPACE
, MID_L_MARGIN
|CONVERT_TWIPS
, pL
);
719 const ::uno::Any
* pR
= nullptr;
720 GetProperty(RES_LR_SPACE
, MID_R_MARGIN
|CONVERT_TWIPS
, pR
);
723 SvxLRSpaceItem
aLR ( static_cast < const ::SvxLRSpaceItem
& > ( rFromSet
.Get ( RES_LR_SPACE
) ) );
725 bRet
&= ((SfxPoolItem
&)aLR
).PutValue(*pL
, MID_L_MARGIN
|CONVERT_TWIPS
);
727 bRet
&= ((SfxPoolItem
&)aLR
).PutValue(*pR
, MID_R_MARGIN
|CONVERT_TWIPS
);
730 const ::uno::Any
* pT
= nullptr;
731 GetProperty(RES_UL_SPACE
, MID_UP_MARGIN
|CONVERT_TWIPS
, pT
);
732 const ::uno::Any
* pB
= nullptr;
733 GetProperty(RES_UL_SPACE
, MID_LO_MARGIN
|CONVERT_TWIPS
, pB
);
736 SvxULSpaceItem
aTB ( static_cast < const ::SvxULSpaceItem
&> ( rFromSet
.Get ( RES_UL_SPACE
) ) );
738 bRet
&= ((SfxPoolItem
&)aTB
).PutValue(*pT
, MID_UP_MARGIN
|CONVERT_TWIPS
);
740 bRet
&= ((SfxPoolItem
&)aTB
).PutValue(*pB
, MID_LO_MARGIN
|CONVERT_TWIPS
);
743 const ::uno::Any
* pOp
;
744 if(GetProperty(RES_OPAQUE
, 0, pOp
))
746 SvxOpaqueItem
aOp ( static_cast < const ::SvxOpaqueItem
& > ( rFromSet
.Get ( RES_OPAQUE
) ) );
747 bRet
&= ((SfxPoolItem
&)aOp
).PutValue(*pOp
, 0);
750 const ::uno::Any
* pPrt
;
751 if(GetProperty(RES_PRINT
, 0, pPrt
))
753 SvxPrintItem
aPrt ( static_cast < const ::SvxPrintItem
& > ( rFromSet
.Get ( RES_PRINT
) ) );
754 bRet
&= ((SfxPoolItem
&)aPrt
).PutValue(*pPrt
, 0);
757 const ::uno::Any
* pSh
;
758 if(GetProperty(RES_SHADOW
, CONVERT_TWIPS
, pSh
))
760 SvxShadowItem
aSh ( static_cast < const ::SvxShadowItem
& > ( rFromSet
.Get ( RES_SHADOW
) ) );
761 bRet
&= ((SfxPoolItem
&)aSh
).PutValue(*pSh
, CONVERT_TWIPS
);
764 const ::uno::Any
* pShTr
;
765 if(GetProperty(RES_SHADOW
, MID_SHADOW_TRANSPARENCE
, pShTr
) && rToSet
.HasItem(RES_SHADOW
))
767 SvxShadowItem
aSh(static_cast<const SvxShadowItem
&>(rToSet
.Get(RES_SHADOW
)));
768 bRet
&= aSh
.PutValue(*pShTr
, MID_SHADOW_TRANSPARENCE
);
771 const ::uno::Any
* pSur
= nullptr;
772 GetProperty(RES_SURROUND
, MID_SURROUND_SURROUNDTYPE
, pSur
);
773 const ::uno::Any
* pSurAnch
= nullptr;
774 GetProperty(RES_SURROUND
, MID_SURROUND_ANCHORONLY
, pSurAnch
);
777 SwFormatSurround
aSrnd ( static_cast < const ::SwFormatSurround
& > ( rFromSet
.Get ( RES_SURROUND
) ) );
779 bRet
&= ((SfxPoolItem
&)aSrnd
).PutValue(*pSur
, MID_SURROUND_SURROUNDTYPE
);
781 bRet
&= ((SfxPoolItem
&)aSrnd
).PutValue(*pSurAnch
, MID_SURROUND_ANCHORONLY
);
784 const ::uno::Any
* pLeft
= nullptr;
785 GetProperty(RES_BOX
, LEFT_BORDER
|CONVERT_TWIPS
, pLeft
);
786 const ::uno::Any
* pRight
= nullptr;
787 GetProperty(RES_BOX
, CONVERT_TWIPS
|RIGHT_BORDER
, pRight
);
788 const ::uno::Any
* pTop
= nullptr;
789 GetProperty(RES_BOX
, CONVERT_TWIPS
|TOP_BORDER
, pTop
);
790 const ::uno::Any
* pBottom
= nullptr;
791 GetProperty(RES_BOX
, CONVERT_TWIPS
|BOTTOM_BORDER
, pBottom
);
792 const ::uno::Any
* pDistance
= nullptr;
793 GetProperty(RES_BOX
, CONVERT_TWIPS
|BORDER_DISTANCE
, pDistance
);
794 const ::uno::Any
* pLeftDistance
= nullptr;
795 GetProperty(RES_BOX
, CONVERT_TWIPS
|LEFT_BORDER_DISTANCE
, pLeftDistance
);
796 const ::uno::Any
* pRightDistance
= nullptr;
797 GetProperty(RES_BOX
, CONVERT_TWIPS
|RIGHT_BORDER_DISTANCE
, pRightDistance
);
798 const ::uno::Any
* pTopDistance
= nullptr;
799 GetProperty(RES_BOX
, CONVERT_TWIPS
|TOP_BORDER_DISTANCE
, pTopDistance
);
800 const ::uno::Any
* pBottomDistance
= nullptr;
801 GetProperty(RES_BOX
, CONVERT_TWIPS
|BOTTOM_BORDER_DISTANCE
, pBottomDistance
);
802 const ::uno::Any
* pLineStyle
= nullptr;
803 GetProperty(RES_BOX
, LINE_STYLE
, pLineStyle
);
804 const ::uno::Any
* pLineWidth
= nullptr;
805 GetProperty(RES_BOX
, LINE_WIDTH
, pLineWidth
);
806 if( pLeft
|| pRight
|| pTop
|| pBottom
|| pDistance
||
807 pLeftDistance
|| pRightDistance
|| pTopDistance
|| pBottomDistance
||
808 pLineStyle
|| pLineWidth
)
810 SvxBoxItem
aBox ( static_cast < const ::SvxBoxItem
& > ( rFromSet
.Get ( RES_BOX
) ) );
812 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pLeft
, CONVERT_TWIPS
|LEFT_BORDER
);
814 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pRight
, CONVERT_TWIPS
|RIGHT_BORDER
);
816 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pTop
, CONVERT_TWIPS
|TOP_BORDER
);
818 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pBottom
, CONVERT_TWIPS
|BOTTOM_BORDER
);
820 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pDistance
, CONVERT_TWIPS
|BORDER_DISTANCE
);
822 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pLeftDistance
, CONVERT_TWIPS
|LEFT_BORDER_DISTANCE
);
824 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pRightDistance
, CONVERT_TWIPS
|RIGHT_BORDER_DISTANCE
);
826 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pTopDistance
, CONVERT_TWIPS
|TOP_BORDER_DISTANCE
);
827 if( pBottomDistance
)
828 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pBottomDistance
, CONVERT_TWIPS
|BOTTOM_BORDER_DISTANCE
);
830 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pLineStyle
, LINE_STYLE
);
832 bRet
&= ((SfxPoolItem
&)aBox
).PutValue(*pLineWidth
, LINE_WIDTH
|CONVERT_TWIPS
);
836 const ::uno::Any
* pRelH
= nullptr;
837 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_HEIGHT
, pRelH
);
838 const ::uno::Any
* pRelHRelation
= nullptr;
839 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_HEIGHT_RELATION
, pRelHRelation
);
840 const ::uno::Any
* pRelW
= nullptr;
841 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_WIDTH
, pRelW
);
842 const ::uno::Any
* pRelWRelation
= nullptr;
843 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_WIDTH_RELATION
, pRelWRelation
);
844 const ::uno::Any
* pSyncWidth
= nullptr;
845 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT
, pSyncWidth
);
846 const ::uno::Any
* pSyncHeight
= nullptr;
847 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH
, pSyncHeight
);
848 const ::uno::Any
* pWidth
= nullptr;
849 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_WIDTH
|CONVERT_TWIPS
, pWidth
);
850 const ::uno::Any
* pHeight
= nullptr;
851 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_HEIGHT
|CONVERT_TWIPS
, pHeight
);
852 const ::uno::Any
* pSize
= nullptr;
853 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_SIZE
|CONVERT_TWIPS
, pSize
);
854 const ::uno::Any
* pSizeType
= nullptr;
855 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_SIZE_TYPE
, pSizeType
);
856 const ::uno::Any
* pWidthType
= nullptr;
857 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_WIDTH_TYPE
, pWidthType
);
858 if( pWidth
|| pHeight
||pRelH
|| pRelHRelation
|| pRelW
|| pRelWRelation
|| pSize
||pSizeType
||
859 pWidthType
||pSyncWidth
|| pSyncHeight
)
862 SwFormatFrameSize
aFrameSz ( static_cast < const ::SwFormatFrameSize
& > ( rFromSet
.Get ( RES_FRM_SIZE
) ) );
864 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pWidth
, MID_FRMSIZE_WIDTH
|CONVERT_TWIPS
);
866 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pHeight
, MID_FRMSIZE_HEIGHT
|CONVERT_TWIPS
);
868 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pRelH
, MID_FRMSIZE_REL_HEIGHT
);
870 bRet
&= const_cast<SwFormatFrameSize
&>(aFrameSz
).PutValue(*pRelHRelation
, MID_FRMSIZE_REL_HEIGHT_RELATION
);
872 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pRelW
, MID_FRMSIZE_REL_WIDTH
);
874 bRet
&= const_cast<SwFormatFrameSize
&>(aFrameSz
).PutValue(*pRelWRelation
, MID_FRMSIZE_REL_WIDTH_RELATION
);
876 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pSyncWidth
, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT
);
878 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pSyncHeight
, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH
);
880 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pSize
, MID_FRMSIZE_SIZE
|CONVERT_TWIPS
);
882 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pSizeType
, MID_FRMSIZE_SIZE_TYPE
);
884 bRet
&= ((SfxPoolItem
&)aFrameSz
).PutValue(*pWidthType
, MID_FRMSIZE_WIDTH_TYPE
);
885 if(!aFrameSz
.GetWidth())
886 aFrameSz
.SetWidth(MINFLY
);
887 if(!aFrameSz
.GetHeight())
888 aFrameSz
.SetHeight(MINFLY
);
889 rToSet
.Put(aFrameSz
);
894 SwFormatFrameSize aFrameSz
;
896 aSize
.Width
= 2 * MM50
;
897 aSize
.Height
= 2 * MM50
;
900 ((SfxPoolItem
&)aFrameSz
).PutValue(aSizeVal
, MID_FRMSIZE_SIZE
|CONVERT_TWIPS
);
901 rToSet
.Put(aFrameSz
);
904 const ::uno::Any
* pFrameDirection
= nullptr;
905 GetProperty(RES_FRAMEDIR
, 0, pFrameDirection
);
908 SvxFrameDirectionItem
aAttr(FRMDIR_HORI_LEFT_TOP
, RES_FRAMEDIR
);
909 aAttr
.PutValue(*pFrameDirection
, 0);
912 const ::uno::Any
* pUnknown
= nullptr;
913 GetProperty(RES_UNKNOWNATR_CONTAINER
, 0, pUnknown
);
916 SvXMLAttrContainerItem
aAttr(RES_UNKNOWNATR_CONTAINER
);
917 aAttr
.PutValue(*pUnknown
, 0);
922 const ::uno::Any
* pFollowTextFlow
= nullptr;
923 GetProperty(RES_FOLLOW_TEXT_FLOW
, 0, pFollowTextFlow
);
924 if ( pFollowTextFlow
)
926 SwFormatFollowTextFlow aFormatFollowTextFlow
;
927 aFormatFollowTextFlow
.PutValue(*pFollowTextFlow
, 0);
928 rToSet
.Put(aFormatFollowTextFlow
);
931 // #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS
932 const ::uno::Any
* pWrapInfluenceOnObjPos
= nullptr;
933 GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS
, MID_WRAP_INFLUENCE
, pWrapInfluenceOnObjPos
);
934 if ( pWrapInfluenceOnObjPos
)
936 SwFormatWrapInfluenceOnObjPos aFormatWrapInfluenceOnObjPos
;
937 aFormatWrapInfluenceOnObjPos
.PutValue( *pWrapInfluenceOnObjPos
, MID_WRAP_INFLUENCE
);
938 rToSet
.Put(aFormatWrapInfluenceOnObjPos
);
942 const ::uno::Any
* pTextVertAdjust
= nullptr;
943 GetProperty(RES_TEXT_VERT_ADJUST
, 0, pTextVertAdjust
);
944 if ( pTextVertAdjust
)
946 SdrTextVertAdjustItem
aTextVertAdjust(static_cast <const ::SdrTextVertAdjustItem
& > ( rFromSet
.Get ( RES_TEXT_VERT_ADJUST
) ));
947 bRet
&= ((SfxPoolItem
&)aTextVertAdjust
).PutValue(*pTextVertAdjust
, 0);
948 rToSet
.Put(aTextVertAdjust
);
955 class SwFrameProperties_Impl
: public BaseFrameProperties_Impl
958 SwFrameProperties_Impl();
959 virtual ~SwFrameProperties_Impl(){}
961 bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) override
;
964 SwFrameProperties_Impl::SwFrameProperties_Impl():
965 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_FRAME)*/ )
969 static inline void lcl_FillCol ( SfxItemSet
&rToSet
, const ::SfxItemSet
&rFromSet
, const ::uno::Any
*pAny
)
973 SwFormatCol
aCol ( static_cast < const ::SwFormatCol
& > ( rFromSet
.Get ( RES_COL
) ) );
974 ((SfxPoolItem
&)aCol
).PutValue( *pAny
, MID_COLUMNS
);
979 bool SwFrameProperties_Impl::AnyToItemSet(SwDoc
*pDoc
, SfxItemSet
& rSet
, SfxItemSet
&, bool& rSizeFound
)
981 //Properties fuer alle Frames
982 const ::uno::Any
*pStyleName
;
983 SwDocStyleSheet
* pStyle
= nullptr;
986 if ( GetProperty ( FN_UNO_FRAME_STYLE_NAME
, 0, pStyleName
) )
989 *pStyleName
>>= sStyle
;
990 SwStyleNameMapper::FillUIName(sStyle
, sStyle
, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
, true);
991 pStyle
= static_cast<SwDocStyleSheet
*>(pDoc
->GetDocShell()->GetStyleSheetPool()->Find(sStyle
,
992 SfxStyleFamily::Frame
));
995 const ::uno::Any
* pColumns
= nullptr;
996 GetProperty (RES_COL
, MID_COLUMNS
, pColumns
);
999 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet( *pStyle
) );
1000 const ::SfxItemSet
*pItemSet
= &xStyle
->GetItemSet();
1001 bRet
= FillBaseProperties( rSet
, *pItemSet
, rSizeFound
);
1002 lcl_FillCol ( rSet
, *pItemSet
, pColumns
);
1006 const ::SfxItemSet
*pItemSet
= &pDoc
->getIDocumentStylePoolAccess().GetFrameFormatFromPool( RES_POOLFRM_FRAME
)->GetAttrSet();
1007 bRet
= FillBaseProperties( rSet
, *pItemSet
, rSizeFound
);
1008 lcl_FillCol ( rSet
, *pItemSet
, pColumns
);
1010 const ::uno::Any
* pEdit
;
1011 if(GetProperty(RES_EDIT_IN_READONLY
, 0, pEdit
))
1013 SwFormatEditInReadonly
item(RES_EDIT_IN_READONLY
);
1014 item
.PutValue(*pEdit
, 0);
1020 class SwGraphicProperties_Impl
: public BaseFrameProperties_Impl
1023 SwGraphicProperties_Impl();
1024 virtual ~SwGraphicProperties_Impl(){}
1026 virtual bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) override
;
1029 SwGraphicProperties_Impl::SwGraphicProperties_Impl( ) :
1030 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_GRAPHIC)*/ )
1034 static inline void lcl_FillMirror ( SfxItemSet
&rToSet
, const ::SfxItemSet
&rFromSet
, const ::uno::Any
*pHEvenMirror
, const ::uno::Any
*pHOddMirror
, const ::uno::Any
*pVMirror
, bool &rRet
)
1036 if(pHEvenMirror
|| pHOddMirror
|| pVMirror
)
1038 SwMirrorGrf
aMirror ( static_cast < const ::SwMirrorGrf
& > ( rFromSet
.Get ( RES_GRFATR_MIRRORGRF
) ) );
1040 rRet
&= ((SfxPoolItem
&)aMirror
).PutValue(*pHEvenMirror
, MID_MIRROR_HORZ_EVEN_PAGES
);
1042 rRet
&= ((SfxPoolItem
&)aMirror
).PutValue(*pHOddMirror
, MID_MIRROR_HORZ_ODD_PAGES
);
1044 rRet
&= ((SfxPoolItem
&)aMirror
).PutValue(*pVMirror
, MID_MIRROR_VERT
);
1045 rToSet
.Put(aMirror
);
1049 bool SwGraphicProperties_Impl::AnyToItemSet(
1051 SfxItemSet
& rFrameSet
,
1055 //Properties fuer alle Frames
1057 const ::uno::Any
*pStyleName
;
1058 SwDocStyleSheet
* pStyle
= nullptr;
1060 if ( GetProperty ( FN_UNO_FRAME_STYLE_NAME
, 0, pStyleName
) )
1063 *pStyleName
>>= sStyle
;
1064 SwStyleNameMapper::FillUIName(sStyle
, sStyle
, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
, true);
1065 pStyle
= static_cast<SwDocStyleSheet
*>(pDoc
->GetDocShell()->GetStyleSheetPool()->Find(sStyle
,
1066 SfxStyleFamily::Frame
));
1069 const ::uno::Any
* pHEvenMirror
= nullptr;
1070 const ::uno::Any
* pHOddMirror
= nullptr;
1071 const ::uno::Any
* pVMirror
= nullptr;
1072 GetProperty(RES_GRFATR_MIRRORGRF
, MID_MIRROR_HORZ_EVEN_PAGES
, pHEvenMirror
);
1073 GetProperty(RES_GRFATR_MIRRORGRF
, MID_MIRROR_HORZ_ODD_PAGES
, pHOddMirror
);
1074 GetProperty(RES_GRFATR_MIRRORGRF
, MID_MIRROR_VERT
, pVMirror
);
1078 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet(*pStyle
) );
1079 const ::SfxItemSet
*pItemSet
= &xStyle
->GetItemSet();
1080 bRet
= FillBaseProperties(rFrameSet
, *pItemSet
, rSizeFound
);
1081 lcl_FillMirror ( rGrSet
, *pItemSet
, pHEvenMirror
, pHOddMirror
, pVMirror
, bRet
);
1085 const ::SfxItemSet
*pItemSet
= &pDoc
->getIDocumentStylePoolAccess().GetFrameFormatFromPool( RES_POOLFRM_GRAPHIC
)->GetAttrSet();
1086 bRet
= FillBaseProperties(rFrameSet
, *pItemSet
, rSizeFound
);
1087 lcl_FillMirror ( rGrSet
, *pItemSet
, pHEvenMirror
, pHOddMirror
, pVMirror
, bRet
);
1090 static const ::sal_uInt16 nIDs
[] =
1093 RES_GRFATR_ROTATION
,
1094 RES_GRFATR_LUMINANCE
,
1095 RES_GRFATR_CONTRAST
,
1096 RES_GRFATR_CHANNELR
,
1097 RES_GRFATR_CHANNELG
,
1098 RES_GRFATR_CHANNELB
,
1101 RES_GRFATR_TRANSPARENCY
,
1102 RES_GRFATR_DRAWMODE
,
1105 const ::uno::Any
* pAny
;
1106 for(sal_Int16 nIndex
= 0; nIDs
[nIndex
]; nIndex
++)
1108 sal_uInt8 nMId
= RES_GRFATR_CROPGRF
== nIDs
[nIndex
] ? CONVERT_TWIPS
: 0;
1109 if(GetProperty(nIDs
[nIndex
], nMId
, pAny
))
1111 SfxPoolItem
* pItem
= ::GetDfltAttr( nIDs
[nIndex
] )->Clone();
1112 bRet
&= pItem
->PutValue(*pAny
, nMId
);
1121 class SwOLEProperties_Impl
: public SwFrameProperties_Impl
1124 SwOLEProperties_Impl() :
1125 SwFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_EMBEDDED_OBJECT)*/ ){}
1126 virtual ~SwOLEProperties_Impl(){}
1128 virtual bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) override
;
1131 bool SwOLEProperties_Impl::AnyToItemSet(
1132 SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
)
1134 const ::uno::Any
* pTemp
;
1135 if(!GetProperty(FN_UNO_CLSID
, 0, pTemp
) && !GetProperty(FN_UNO_STREAM_NAME
, 0, pTemp
)
1136 && !GetProperty(FN_EMBEDDED_OBJECT
, 0, pTemp
) )
1138 SwFrameProperties_Impl::AnyToItemSet( pDoc
, rFrameSet
, rSet
, rSizeFound
);
1143 class SwXFrame::Impl
1146 ::osl::Mutex m_Mutex
; // just for OInterfaceContainerHelper2
1149 uno::WeakReference
<uno::XInterface
> m_wThis
;
1150 ::comphelper::OInterfaceContainerHelper2 m_EventListeners
;
1152 Impl() : m_EventListeners(m_Mutex
) { }
1157 class theSwXFrameUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSwXFrameUnoTunnelId
> {};
1160 const ::uno::Sequence
< sal_Int8
> & SwXFrame::getUnoTunnelId()
1162 return theSwXFrameUnoTunnelId::get().getSeq();
1165 sal_Int64 SAL_CALL
SwXFrame::getSomething( const ::uno::Sequence
< sal_Int8
>& rId
)
1166 throw(uno::RuntimeException
, std::exception
)
1168 if( rId
.getLength() == 16
1169 && 0 == memcmp( getUnoTunnelId().getConstArray(),
1170 rId
.getConstArray(), 16 ) )
1172 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
1178 OUString
SwXFrame::getImplementationName() throw( uno::RuntimeException
, std::exception
)
1180 return OUString("SwXFrame");
1183 sal_Bool
SwXFrame::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
, std::exception
)
1185 return cppu::supportsService(this, rServiceName
);
1188 uno::Sequence
< OUString
> SwXFrame::getSupportedServiceNames() throw( uno::RuntimeException
, std::exception
)
1190 uno::Sequence
< OUString
> aRet(3);
1191 aRet
[0] = "com.sun.star.text.BaseFrame";
1192 aRet
[1] = "com.sun.star.text.TextContent";
1193 aRet
[2] = "com.sun.star.document.LinkTarget";
1197 SwXFrame::SwXFrame(FlyCntType eSet
, const ::SfxItemPropertySet
* pSet
, SwDoc
*pDoc
)
1202 , bIsDescriptor(true)
1203 , m_pCopySource(nullptr)
1205 // Register ourselves as a listener to the document (via the page descriptor)
1206 pDoc
->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD
)->Add(this);
1207 // get the property set for the default style data
1208 // First get the model
1209 uno::Reference
< XModel
> xModel
= pDoc
->GetDocShell()->GetBaseModel();
1210 // Ask the model for its family supplier interface
1211 uno::Reference
< XStyleFamiliesSupplier
> xFamilySupplier ( xModel
, uno::UNO_QUERY
);
1212 // Get the style families
1213 uno::Reference
< XNameAccess
> xFamilies
= xFamilySupplier
->getStyleFamilies();
1214 // Get the Frame family (and keep it for later)
1215 const ::uno::Any aAny
= xFamilies
->getByName ("FrameStyles");
1216 aAny
>>= mxStyleFamily
;
1217 // In the derived class, we'll ask mxStyleFamily for the relevant default style
1218 // mxStyleFamily is initialised in the SwXFrame constructor
1221 case FLYCNTTYPE_FRM
:
1223 uno::Any aAny2
= mxStyleFamily
->getByName ("Frame");
1224 aAny2
>>= mxStyleData
;
1225 pProps
= new SwFrameProperties_Impl( );
1228 case FLYCNTTYPE_GRF
:
1230 uno::Any aAny2
= mxStyleFamily
->getByName ("Graphics");
1231 aAny2
>>= mxStyleData
;
1232 pProps
= new SwGraphicProperties_Impl( );
1235 case FLYCNTTYPE_OLE
:
1237 uno::Any aAny2
= mxStyleFamily
->getByName ("OLE");
1238 aAny2
>>= mxStyleData
;
1239 pProps
= new SwOLEProperties_Impl( );
1249 SwXFrame::SwXFrame(SwFrameFormat
& rFrameFormat
, FlyCntType eSet
, const ::SfxItemPropertySet
* pSet
)
1250 : SwClient( &rFrameFormat
)
1257 bIsDescriptor(false),
1258 m_pCopySource(nullptr)
1263 SwXFrame::~SwXFrame()
1265 SolarMutexGuard aGuard
;
1266 delete m_pCopySource
;
1268 if(GetRegisteredIn())
1269 GetRegisteredIn()->Remove(this);
1272 template<class Interface
, class NameLookupIsHard
>
1273 uno::Reference
<Interface
>
1274 SwXFrame::CreateXFrame(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
1276 assert(!pFrameFormat
|| &rDoc
== pFrameFormat
->GetDoc());
1277 uno::Reference
<Interface
> xFrame
;
1280 xFrame
.set(pFrameFormat
->GetXObject(), uno::UNO_QUERY
); // cached?
1284 NameLookupIsHard
*const pNew((pFrameFormat
)
1285 ? new NameLookupIsHard(*pFrameFormat
)
1286 : new NameLookupIsHard(&rDoc
));
1290 pFrameFormat
->SetXObject(xFrame
);
1292 // need a permanent Reference to initialize m_wThis
1293 pNew
->SwXFrame::m_pImpl
->m_wThis
= xFrame
;
1298 OUString
SwXFrame::getName() throw( uno::RuntimeException
, std::exception
)
1300 SolarMutexGuard aGuard
;
1301 SwFrameFormat
* pFormat
= GetFrameFormat();
1303 return pFormat
->GetName();
1305 throw uno::RuntimeException();
1309 void SwXFrame::setName(const OUString
& rName
) throw( uno::RuntimeException
, std::exception
)
1311 SolarMutexGuard aGuard
;
1312 SwFrameFormat
* pFormat
= GetFrameFormat();
1315 pFormat
->GetDoc()->SetFlyName(static_cast<SwFlyFrameFormat
&>(*pFormat
), rName
);
1316 if(pFormat
->GetName() != rName
)
1318 throw uno::RuntimeException();
1321 else if(bIsDescriptor
)
1324 throw uno::RuntimeException();
1327 uno::Reference
< beans::XPropertySetInfo
> SwXFrame::getPropertySetInfo() throw( uno::RuntimeException
, std::exception
)
1329 uno::Reference
< beans::XPropertySetInfo
> xRef
;
1330 static uno::Reference
< beans::XPropertySetInfo
> xFrameRef
;
1331 static uno::Reference
< beans::XPropertySetInfo
> xGrfRef
;
1332 static uno::Reference
< beans::XPropertySetInfo
> xOLERef
;
1335 case FLYCNTTYPE_FRM
:
1336 if( !xFrameRef
.is() )
1337 xFrameRef
= m_pPropSet
->getPropertySetInfo();
1340 case FLYCNTTYPE_GRF
:
1342 xGrfRef
= m_pPropSet
->getPropertySetInfo();
1345 case FLYCNTTYPE_OLE
:
1347 xOLERef
= m_pPropSet
->getPropertySetInfo();
1356 void SwXFrame::SetSelection(SwPaM
& rCopySource
)
1358 delete m_pCopySource
;
1359 m_pCopySource
= new SwPaM( *rCopySource
.Start() );
1360 m_pCopySource
->SetMark();
1361 *m_pCopySource
->GetMark() = *rCopySource
.End();
1364 SdrObject
*SwXFrame::GetOrCreateSdrObject(SwFlyFrameFormat
&rFormat
)
1366 SdrObject
* pObject
= rFormat
.FindSdrObject();
1369 SwDoc
*pDoc
= rFormat
.GetDoc();
1370 // #i52858# - method name changed
1371 SwDrawModel
* pDrawModel
= pDoc
->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
1372 SwFlyDrawContact
* pContactObject
1373 = new SwFlyDrawContact( &rFormat
, pDrawModel
);
1374 pObject
= pContactObject
->GetMaster();
1376 const ::SwFormatSurround
& rSurround
= rFormat
.GetSurround();
1378 ( SURROUND_THROUGHT
== rSurround
.GetSurround() &&
1379 !rFormat
.GetOpaque().GetValue() ) ? pDoc
->getIDocumentDrawModelAccess().GetHellId()
1380 : pDoc
->getIDocumentDrawModelAccess().GetHeavenId() );
1381 pDrawModel
->GetPage(0)->InsertObject( pObject
);
1387 static SwFrameFormat
*lcl_GetFrameFormat( const ::uno::Any
& rValue
, SwDoc
*pDoc
)
1389 SwFrameFormat
*pRet
= nullptr;
1390 SwDocShell
* pDocSh
= pDoc
->GetDocShell();
1396 SwStyleNameMapper::FillUIName(uTemp
, sStyle
,
1397 nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
, true);
1398 SwDocStyleSheet
* pStyle
=
1399 static_cast<SwDocStyleSheet
*>(pDocSh
->GetStyleSheetPool()->Find(sStyle
,
1400 SfxStyleFamily::Frame
));
1402 pRet
= pStyle
->GetFrameFormat();
1408 void SwXFrame::setPropertyValue(const OUString
& rPropertyName
, const ::uno::Any
& _rValue
)
1409 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
1411 SolarMutexGuard aGuard
;
1412 SwFrameFormat
* pFormat
= GetFrameFormat();
1413 const ::SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
1416 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1419 const sal_uInt8
nMemberId(pEntry
->nMemberId
& (~SFX_METRIC_ITEM
));
1420 uno::Any
aValue(_rValue
);
1422 //UUUU check for needed metric translation
1423 if(pEntry
->nMemberId
& SFX_METRIC_ITEM
)
1427 if(XATTR_FILLBMP_SIZEX
== pEntry
->nWID
|| XATTR_FILLBMP_SIZEY
== pEntry
->nWID
)
1429 // exception: If these ItemTypes are used, do not convert when these are negative
1430 // since this means they are intended as percent values
1431 sal_Int32 nValue
= 0;
1433 if(aValue
>>= nValue
)
1441 const SwDoc
* pDoc
= (IsDescriptor() ? m_pDoc
: GetFrameFormat()->GetDoc());
1442 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
1443 const SfxMapUnit
eMapUnit(rPool
.GetMetric(pEntry
->nWID
));
1445 if(eMapUnit
!= SFX_MAPUNIT_100TH_MM
)
1447 SvxUnoConvertFromMM(eMapUnit
, aValue
);
1454 bool bNextFrame
= false;
1455 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
1456 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1458 SwDoc
* pDoc
= pFormat
->GetDoc();
1459 if ( ((eType
== FLYCNTTYPE_GRF
) && isGRFATR(pEntry
->nWID
)) ||
1460 (FN_PARAM_COUNTOUR_PP
== pEntry
->nWID
) ||
1461 (FN_UNO_IS_AUTOMATIC_CONTOUR
== pEntry
->nWID
) ||
1462 (FN_UNO_IS_PIXEL_CONTOUR
== pEntry
->nWID
) )
1464 const ::SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1467 SwNodeIndex
aIdx(*pIdx
, 1);
1468 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
1469 if(pEntry
->nWID
== FN_PARAM_COUNTOUR_PP
)
1471 drawing::PointSequenceSequence aParam
;
1472 if(!aValue
.hasValue())
1473 pNoText
->SetContour(nullptr);
1474 else if(aValue
>>= aParam
)
1476 tools::PolyPolygon
aPoly((sal_uInt16
)aParam
.getLength());
1477 for(sal_Int32 i
= 0; i
< aParam
.getLength(); i
++)
1479 const ::drawing::PointSequence
* pPointSeq
= aParam
.getConstArray();
1480 sal_Int32 nPoints
= pPointSeq
[i
].getLength();
1481 const ::awt::Point
* pPoints
= pPointSeq
[i
].getConstArray();
1482 tools::Polygon
aSet( (sal_uInt16
)nPoints
);
1483 for(sal_Int32 j
= 0; j
< nPoints
; j
++)
1485 Point
aPoint(pPoints
[j
].X
, pPoints
[j
].Y
);
1486 aSet
.SetPoint(aPoint
, (sal_uInt16
)j
);
1488 // Close polygon if it isn't closed already.
1489 aSet
.Optimize( PolyOptimizeFlags::CLOSE
);
1490 aPoly
.Insert( aSet
);
1492 pNoText
->SetContourAPI( &aPoly
);
1495 throw lang::IllegalArgumentException();
1497 else if(pEntry
->nWID
== FN_UNO_IS_AUTOMATIC_CONTOUR
)
1499 pNoText
->SetAutomaticContour( *o3tl::doAccess
<bool>(aValue
) );
1501 else if(pEntry
->nWID
== FN_UNO_IS_PIXEL_CONTOUR
)
1503 // The IsPixelContour property can only be set if there
1504 // is no contour, or if the contour has been set by the
1505 // API itself (or in other words, if the contour isn't
1507 if( !pNoText
->HasContour_() ||
1508 !pNoText
->IsContourMapModeValid() )
1509 pNoText
->SetPixelContour( *o3tl::doAccess
<bool>(aValue
) );
1511 throw lang::IllegalArgumentException();
1515 SfxItemSet
aSet(pNoText
->GetSwAttrSet());
1516 m_pPropSet
->setPropertyValue(*pEntry
, aValue
, aSet
);
1517 pNoText
->SetAttr(aSet
);
1521 // New attribute Title
1522 else if( FN_UNO_TITLE
== pEntry
->nWID
)
1524 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
1527 // assure that <SdrObject> instance exists.
1528 GetOrCreateSdrObject(rFlyFormat
);
1529 rFlyFormat
.GetDoc()->SetFlyFrameTitle(rFlyFormat
, sTitle
);
1531 // New attribute Description
1532 else if( FN_UNO_DESCRIPTION
== pEntry
->nWID
)
1534 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
1535 OUString sDescription
;
1536 aValue
>>= sDescription
;
1537 // assure that <SdrObject> instance exists.
1538 GetOrCreateSdrObject(rFlyFormat
);
1539 rFlyFormat
.GetDoc()->SetFlyFrameDescription(rFlyFormat
, sDescription
);
1541 else if(FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
)
1543 SwFrameFormat
*pFrameFormat
= lcl_GetFrameFormat( aValue
, pFormat
->GetDoc() );
1546 UnoActionContext
aAction(pFormat
->GetDoc());
1548 SfxItemSet
* pSet
= nullptr;
1549 // #i31771#, #i25798# - No adjustment of
1550 // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ),
1551 // if document is currently in reading mode.
1552 if ( !pFormat
->GetDoc()->IsInReading() )
1554 // see SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point* pDocPos )
1555 SwFlyFrame
*pFly
= nullptr;
1557 const SwFrameFormat
* pFormatXX
= pFormat
;
1558 if (dynamic_cast<const SwFlyFrameFormat
*>( pFormatXX
) )
1559 pFly
= static_cast<const SwFlyFrameFormat
*>(pFormatXX
)->GetFrame();
1563 const ::SfxPoolItem
* pItem
;
1564 if( SfxItemState::SET
== pFrameFormat
->GetItemState( RES_ANCHOR
, false, &pItem
))
1566 pSet
= new SfxItemSet( pDoc
->GetAttrPool(), aFrameFormatSetRange
);
1567 pSet
->Put( *pItem
);
1568 if ( pFormat
->GetDoc()->GetEditShell() != nullptr
1569 && !sw_ChkAndSetNewAnchor( *pFly
, *pSet
) )
1578 pFormat
->GetDoc()->SetFrameFormatToFly( *pFormat
, *pFrameFormat
, pSet
);
1582 throw lang::IllegalArgumentException();
1584 else if( FN_UNO_GRAPHIC_U_R_L
== pEntry
->nWID
||
1585 FN_UNO_GRAPHIC_FILTER
== pEntry
->nWID
)
1589 GraphicObject
*pGrfObj
= nullptr;
1590 SwDoc::GetGrfNms( *static_cast<SwFlyFrameFormat
*>(pFormat
), &sGrfName
, &sFltName
);
1593 UnoActionContext
aAction(pFormat
->GetDoc());
1594 if(FN_UNO_GRAPHIC_U_R_L
== pEntry
->nWID
)
1596 if( sTmp
.startsWith(sPackageProtocol
) )
1598 pGrfObj
= new GraphicObject
;
1599 pGrfObj
->SetUserData( sTmp
);
1602 else if( sTmp
.startsWith(sGraphicObjectProtocol
) )
1604 const OString
sId(OUStringToOString(
1605 sTmp
.copy(sizeof(sGraphicObjectProtocol
)-1),
1606 RTL_TEXTENCODING_ASCII_US
));
1607 pGrfObj
= new GraphicObject( sId
);
1620 const ::SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1623 SwNodeIndex
aIdx(*pIdx
, 1);
1624 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
1628 throw uno::RuntimeException();
1630 SwPaM
aGrfPaM(*pGrfNode
);
1631 pFormat
->GetDoc()->getIDocumentContentOperations().ReRead( aGrfPaM
, sGrfName
, sFltName
, nullptr,
1636 else if( FN_UNO_GRAPHIC
== pEntry
->nWID
)
1638 uno::Reference
< graphic::XGraphic
> xGraphic
;
1639 aValue
>>= xGraphic
;
1642 const ::SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1645 SwNodeIndex
aIdx(*pIdx
, 1);
1646 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
1649 throw uno::RuntimeException();
1651 SwPaM
aGrfPaM(*pGrfNode
);
1652 Graphic
aGraphic( xGraphic
);
1653 pFormat
->GetDoc()->getIDocumentContentOperations().ReRead( aGrfPaM
, OUString(), OUString(), &aGraphic
, nullptr );
1657 else if( FN_UNO_REPLACEMENT_GRAPHIC_URL
== pEntry
->nWID
|| FN_UNO_REPLACEMENT_GRAPHIC
== pEntry
->nWID
)
1659 bool bURL
= FN_UNO_REPLACEMENT_GRAPHIC_URL
== pEntry
->nWID
;
1660 bool bApply
= false;
1664 GraphicObject
*pGrfObj
= nullptr;
1668 // the package URL based graphics are handled in different way currently
1669 // TODO/LATER: actually this is the correct place to handle them
1670 OUString
aGraphicProtocol( sGraphicObjectProtocol
);
1671 if( aGrfUrl
.startsWith( aGraphicProtocol
) )
1673 OString
sId(OUStringToOString(
1674 aGrfUrl
.copy(sizeof(sGraphicObjectProtocol
)-1),
1675 RTL_TEXTENCODING_ASCII_US
));
1676 pGrfObj
= new GraphicObject( sId
);
1677 aGraphic
= pGrfObj
->GetGraphic();
1683 uno::Reference
< graphic::XGraphic
> xGraphic
;
1684 aValue
>>= xGraphic
;
1687 aGraphic
= Graphic( xGraphic
);
1694 const ::SwFormatContent
* pCnt
= &pFormat
->GetContent();
1695 if ( pCnt
->GetContentIdx() && pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ] )
1697 SwOLENode
* pOleNode
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode();
1701 svt::EmbeddedObjectRef
&rObj
= pOleNode
->GetOLEObj().GetObject();
1703 OUString aMediaType
;
1704 rObj
.SetGraphic( aGraphic
, aMediaType
);
1709 else if((bNextFrame
= (rPropertyName
== UNO_NAME_CHAIN_NEXT_NAME
))
1710 || rPropertyName
== UNO_NAME_CHAIN_PREV_NAME
)
1712 OUString sChainName
;
1713 aValue
>>= sChainName
;
1714 if (sChainName
.isEmpty())
1717 pDoc
->Unchain(*pFormat
);
1720 SwFormatChain
aChain( pFormat
->GetChain() );
1721 SwFrameFormat
*pPrev
= aChain
.GetPrev();
1723 pDoc
->Unchain(*pPrev
);
1728 const size_t nCount
= pDoc
->GetFlyCount(FLYCNTTYPE_FRM
);
1730 SwFrameFormat
* pChain
= nullptr;
1731 for( size_t i
= 0; i
< nCount
; ++i
)
1733 SwFrameFormat
* pFormat2
= pDoc
->GetFlyNum(i
, FLYCNTTYPE_FRM
);
1734 if(sChainName
== pFormat2
->GetName() )
1742 SwFrameFormat
* pSource
= bNextFrame
? pFormat
: pChain
;
1743 SwFrameFormat
* pDest
= bNextFrame
? pChain
: pFormat
;
1744 pDoc
->Chain(*pSource
, *pDest
);
1748 else if(FN_UNO_Z_ORDER
== pEntry
->nWID
)
1750 sal_Int32 nZOrder
= - 1;
1753 // Don't set an explicit ZOrder on TextBoxes.
1754 std::set
<const SwFrameFormat
*> aTextBoxes
= SwTextBoxHelper::findTextBoxes(pDoc
);
1755 if( nZOrder
>= 0 && aTextBoxes
.find(pFormat
) == aTextBoxes
.end())
1757 SdrObject
* pObject
=
1758 GetOrCreateSdrObject( static_cast<SwFlyFrameFormat
&>(*pFormat
) );
1759 SwDrawModel
*pDrawModel
= pDoc
->getIDocumentDrawModelAccess().GetDrawModel();
1760 pDrawModel
->GetPage(0)->
1761 SetObjectOrdNum(pObject
->GetOrdNum(), nZOrder
);
1764 else if(RES_ANCHOR
== pEntry
->nWID
&& MID_ANCHOR_ANCHORFRAME
== nMemberId
)
1767 uno::Reference
<text::XTextFrame
> xFrame
;
1768 if(aValue
>>= xFrame
)
1770 uno::Reference
<lang::XUnoTunnel
> xTunnel(xFrame
, uno::UNO_QUERY
);
1771 SwXFrame
* pFrame
= xTunnel
.is() ?
1772 reinterpret_cast< SwXFrame
* >( sal::static_int_cast
< sal_IntPtr
>( xTunnel
->getSomething(SwXFrame::getUnoTunnelId()) ))
1774 if(pFrame
&& this != pFrame
&& pFrame
->GetFrameFormat() && pFrame
->GetFrameFormat()->GetDoc() == pDoc
)
1776 SfxItemSet
aSet( pDoc
->GetAttrPool(),
1777 RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1 );
1778 aSet
.SetParent(&pFormat
->GetAttrSet());
1779 SwFormatAnchor aAnchor
= static_cast<const SwFormatAnchor
&>(aSet
.Get(pEntry
->nWID
));
1781 SwPosition
aPos(*pFrame
->GetFrameFormat()->GetContent().GetContentIdx());
1782 aAnchor
.SetAnchor(&aPos
);
1783 aAnchor
.SetType(FLY_AT_FLY
);
1785 pDoc
->SetFlyFrameAttr( *pFormat
, aSet
);
1790 throw lang::IllegalArgumentException();
1794 // standard UNO API write attributes
1795 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
1796 SfxItemSet
aSet( pDoc
->GetAttrPool(),
1797 RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1,
1798 RES_UNKNOWNATR_CONTAINER
, RES_UNKNOWNATR_CONTAINER
,
1800 //UUUU FillAttribute support
1801 XATTR_FILL_FIRST
, XATTR_FILL_LAST
,
1806 aSet
.SetParent(&pFormat
->GetAttrSet());
1808 if(RES_BACKGROUND
== pEntry
->nWID
)
1810 const SwAttrSet
& rSet
= pFormat
->GetAttrSet();
1811 const SvxBrushItem
aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet
, RES_BACKGROUND
, true, pDoc
->IsInXMLImport()));
1812 SvxBrushItem
aChangedBrushItem(aOriginalBrushItem
);
1814 aChangedBrushItem
.PutValue(aValue
, nMemberId
);
1816 if(!(aChangedBrushItem
== aOriginalBrushItem
))
1818 setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem
, aSet
);
1819 pFormat
->GetDoc()->SetFlyFrameAttr( *pFormat
, aSet
);
1824 else if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
1827 drawing::BitmapMode eMode
;
1829 if(!(aValue
>>= eMode
))
1831 sal_Int32 nMode
= 0;
1833 if(!(aValue
>>= nMode
))
1835 throw lang::IllegalArgumentException();
1838 eMode
= (drawing::BitmapMode
)nMode
;
1841 aSet
.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH
== eMode
));
1842 aSet
.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT
== eMode
));
1843 pFormat
->GetDoc()->SetFlyFrameAttr( *pFormat
, aSet
);
1851 //UUUU when named items get set, replace these with the NameOrIndex items
1852 // which exist already in the pool
1853 switch(pEntry
->nWID
)
1855 case XATTR_FILLGRADIENT
:
1856 case XATTR_FILLHATCH
:
1857 case XATTR_FILLBITMAP
:
1858 case XATTR_FILLFLOATTRANSPARENCE
:
1862 if(!(aValue
>>= aTempName
))
1864 throw lang::IllegalArgumentException();
1867 bDone
= SvxShape::SetFillAttribute(pEntry
->nWID
, aTempName
, aSet
);
1879 //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
1880 switch(pEntry
->nWID
)
1882 case XATTR_FILLBITMAP
:
1884 const Graphic aNullGraphic
;
1885 XFillBitmapItem
aXFillBitmapItem(aSet
.GetPool(), aNullGraphic
);
1887 aXFillBitmapItem
.PutValue(aValue
, nMemberId
);
1888 aSet
.Put(aXFillBitmapItem
);
1907 m_pPropSet
->setPropertyValue(*pEntry
, aValue
, aSet
);
1910 if(RES_ANCHOR
== pEntry
->nWID
&& MID_ANCHOR_ANCHORTYPE
== nMemberId
)
1912 SwFormatAnchor aAnchor
= static_cast<const SwFormatAnchor
&>(aSet
.Get(pEntry
->nWID
));
1913 if(aAnchor
.GetAnchorId() == FLY_AT_FLY
)
1915 const ::SwPosition
* pPosition
= aAnchor
.GetContentAnchor();
1916 SwFrameFormat
* pFlyFormat
= pPosition
? pPosition
->nNode
.GetNode().GetFlyFormat() : nullptr;
1917 if(!pFlyFormat
|| pFlyFormat
->Which() == RES_DRAWFRMFMT
)
1919 lang::IllegalArgumentException aExcept
;
1920 aExcept
.Message
= "Anchor to frame: no frame found";
1925 SwPosition aPos
= *pPosition
;
1926 aPos
.nNode
= *pFlyFormat
->GetContent().GetContentIdx();
1927 aAnchor
.SetAnchor(&aPos
);
1931 else if ((aAnchor
.GetAnchorId() != FLY_AT_PAGE
) &&
1932 !aAnchor
.GetContentAnchor())
1934 SwNode
& rNode
= pDoc
->GetNodes().GetEndOfContent();
1936 aPam
.Move( fnMoveBackward
, fnGoDoc
);
1937 aAnchor
.SetAnchor( aPam
.Start() );
1941 // #i31771#, #i25798# - No adjustment of
1942 // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ),
1943 // if document is currently in reading mode.
1944 if ( !pFormat
->GetDoc()->IsInReading() )
1946 // see SwFEShell::SetFlyFrameAttr( SfxItemSet& rSet )
1947 SwFlyFrame
*pFly
= nullptr;
1948 if (dynamic_cast<SwFlyFrameFormat
*>( pFormat
) )
1949 pFly
= static_cast<SwFlyFrameFormat
*>(pFormat
)->GetFrame();
1952 const ::SfxPoolItem
* pItem
;
1953 if( SfxItemState::SET
== aSet
.GetItemState( RES_ANCHOR
, false, &pItem
))
1956 if ( pFormat
->GetDoc()->GetEditShell() != nullptr )
1958 sw_ChkAndSetNewAnchor( *pFly
, aSet
);
1964 pFormat
->GetDoc()->SetFlyFrameAttr( *pFormat
, aSet
);
1966 else if(FN_UNO_CLSID
== pEntry
->nWID
|| FN_UNO_STREAM_NAME
== pEntry
->nWID
|| FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
1968 throw lang::IllegalArgumentException();
1972 pFormat
->SetFormatAttr(aSet
);
1976 else if(IsDescriptor())
1978 pProps
->SetProperty(pEntry
->nWID
, nMemberId
, aValue
);
1979 if( FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
)
1981 OUString sStyleName
;
1982 aValue
>>= sStyleName
;
1985 uno::Any aAny
= mxStyleFamily
->getByName ( sStyleName
);
1986 aAny
>>= mxStyleData
;
1988 catch ( container::NoSuchElementException
const & )
1991 catch ( lang::WrappedTargetException
const & )
1994 catch ( uno::RuntimeException
const & )
2000 throw uno::RuntimeException();
2003 uno::Any
SwXFrame::getPropertyValue(const OUString
& rPropertyName
)
2004 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2006 SolarMutexGuard aGuard
;
2008 SwFrameFormat
* pFormat
= GetFrameFormat();
2009 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
2011 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2014 const sal_uInt8
nMemberId(pEntry
->nMemberId
& (~SFX_METRIC_ITEM
));
2016 if(FN_UNO_ANCHOR_TYPES
== pEntry
->nWID
)
2018 uno::Sequence
<text::TextContentAnchorType
> aTypes(5);
2019 text::TextContentAnchorType
* pArray
= aTypes
.getArray();
2020 pArray
[0] = text::TextContentAnchorType_AT_PARAGRAPH
;
2021 pArray
[1] = text::TextContentAnchorType_AS_CHARACTER
;
2022 pArray
[2] = text::TextContentAnchorType_AT_PAGE
;
2023 pArray
[3] = text::TextContentAnchorType_AT_FRAME
;
2024 pArray
[4] = text::TextContentAnchorType_AT_CHARACTER
;
2029 if( ((eType
== FLYCNTTYPE_GRF
) || (eType
== FLYCNTTYPE_OLE
)) &&
2030 (isGRFATR(pEntry
->nWID
) ||
2031 pEntry
->nWID
== FN_PARAM_COUNTOUR_PP
||
2032 pEntry
->nWID
== FN_UNO_IS_AUTOMATIC_CONTOUR
||
2033 pEntry
->nWID
== FN_UNO_IS_PIXEL_CONTOUR
))
2035 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2038 SwNodeIndex
aIdx(*pIdx
, 1);
2039 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
2040 if(pEntry
->nWID
== FN_PARAM_COUNTOUR_PP
)
2042 tools::PolyPolygon aContour
;
2043 if( pNoText
->GetContourAPI( aContour
) )
2045 drawing::PointSequenceSequence
aPtSeq(aContour
.Count());
2046 drawing::PointSequence
* pPSeq
= aPtSeq
.getArray();
2047 for(sal_uInt16 i
= 0; i
< aContour
.Count(); i
++)
2049 const tools::Polygon
& rPoly
= aContour
.GetObject(i
);
2050 pPSeq
[i
].realloc(rPoly
.GetSize());
2051 awt::Point
* pPoints
= pPSeq
[i
].getArray();
2052 for(sal_uInt16 j
= 0; j
< rPoly
.GetSize(); j
++)
2054 const Point
& rPoint
= rPoly
.GetPoint(j
);
2055 pPoints
[j
].X
= rPoint
.X();
2056 pPoints
[j
].Y
= rPoint
.Y();
2062 else if(pEntry
->nWID
== FN_UNO_IS_AUTOMATIC_CONTOUR
)
2064 aAny
<<= pNoText
->HasAutomaticContour();
2066 else if(pEntry
->nWID
== FN_UNO_IS_PIXEL_CONTOUR
)
2068 aAny
<<= pNoText
->IsPixelContour();
2072 SfxItemSet
aSet(pNoText
->GetSwAttrSet());
2073 m_pPropSet
->getPropertyValue(*pEntry
, aSet
, aAny
);
2077 else if( FN_UNO_GRAPHIC_U_R_L
== pEntry
->nWID
)
2080 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2083 SwNodeIndex
aIdx(*pIdx
, 1);
2084 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
2086 throw uno::RuntimeException();
2087 if( pGrfNode
->IsGrfLink() )
2089 SwDoc::GetGrfNms( *static_cast<SwFlyFrameFormat
*>(pFormat
), &sGrfName
, nullptr );
2093 OUString
sId(OStringToOUString(
2094 pGrfNode
->GetGrfObj().GetUniqueID(),
2095 RTL_TEXTENCODING_ASCII_US
));
2096 sGrfName
= sGraphicObjectProtocol
+ sId
;
2101 else if( FN_UNO_REPLACEMENT_GRAPHIC_U_R_L
== pEntry
->nWID
)
2104 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2108 SwNodeIndex
aIdx(*pIdx
, 1);
2109 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
2111 throw uno::RuntimeException();
2113 const GraphicObject
* pGraphicObject
= pGrfNode
->GetReplacementGrfObj();
2117 sGrfName
= sGraphicObjectProtocol
2118 + OStringToOUString( pGraphicObject
->GetUniqueID(), RTL_TEXTENCODING_ASCII_US
);
2124 else if( FN_UNO_GRAPHIC_FILTER
== pEntry
->nWID
)
2127 SwDoc::GetGrfNms( *static_cast<SwFlyFrameFormat
*>(pFormat
), nullptr, &sFltName
);
2130 else if( FN_UNO_GRAPHIC
== pEntry
->nWID
)
2132 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2135 SwNodeIndex
aIdx(*pIdx
, 1);
2136 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
2138 throw uno::RuntimeException();
2139 aAny
<<= pGrfNode
->GetGrf().GetXGraphic();
2142 else if(FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
)
2144 aAny
<<= OUString(SwStyleNameMapper::GetProgName(pFormat
->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
) );
2147 else if( FN_UNO_TITLE
== pEntry
->nWID
)
2149 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2150 // assure that <SdrObject> instance exists.
2151 GetOrCreateSdrObject(rFlyFormat
);
2152 aAny
<<= OUString(rFlyFormat
.GetObjTitle());
2154 // New attribute Description
2155 else if( FN_UNO_DESCRIPTION
== pEntry
->nWID
)
2157 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2158 // assure that <SdrObject> instance exists.
2159 GetOrCreateSdrObject(rFlyFormat
);
2160 aAny
<<= OUString(rFlyFormat
.GetObjDescription());
2162 else if(eType
== FLYCNTTYPE_GRF
&&
2163 (rPropertyName
== UNO_NAME_ACTUAL_SIZE
))
2165 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2168 SwNodeIndex
aIdx(*pIdx
, 1);
2169 Size aActSize
= aIdx
.GetNode().GetNoTextNode()->GetTwipSize();
2171 aTmp
.Width
= convertTwipToMm100(aActSize
.Width());
2172 aTmp
.Height
= convertTwipToMm100(aActSize
.Height());
2176 else if(FN_PARAM_LINK_DISPLAY_NAME
== pEntry
->nWID
)
2178 aAny
<<= pFormat
->GetName();
2180 else if(FN_UNO_Z_ORDER
== pEntry
->nWID
)
2182 const SdrObject
* pObj
= pFormat
->FindRealSdrObject();
2183 if( pObj
== nullptr )
2184 pObj
= pFormat
->FindSdrObject();
2187 aAny
<<= (sal_Int32
)pObj
->GetOrdNum();
2190 else if(FN_UNO_CLSID
== pEntry
->nWID
|| FN_UNO_MODEL
== pEntry
->nWID
||
2191 FN_UNO_COMPONENT
== pEntry
->nWID
||FN_UNO_STREAM_NAME
== pEntry
->nWID
||
2192 FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
2194 SwDoc
* pDoc
= pFormat
->GetDoc();
2195 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
2196 OSL_ENSURE( pCnt
->GetContentIdx() &&
2197 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
2198 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
2200 SwOLENode
* pOleNode
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()
2201 ->GetIndex() + 1 ]->GetOLENode();
2202 uno::Reference
< embed::XEmbeddedObject
> xIP
= pOleNode
->GetOLEObj().GetOleRef();
2205 SvGlobalName
aClassName( xIP
->getClassID() );
2206 aHexCLSID
= aClassName
.GetHexName();
2207 if(FN_UNO_CLSID
!= pEntry
->nWID
)
2209 if ( svt::EmbeddedObjectRef::TryRunningState( xIP
) )
2211 uno::Reference
< lang::XComponent
> xComp( xIP
->getComponent(), uno::UNO_QUERY
);
2212 uno::Reference
< frame::XModel
> xModel( xComp
, uno::UNO_QUERY
);
2213 if ( FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
2215 // when exposing the EmbeddedObject, ensure it has a client site
2216 OSL_ENSURE( pDoc
->GetDocShell(), "no doc shell => no client site" );
2217 if ( pDoc
->GetDocShell() )
2218 pDoc
->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP
, embed::Aspects::MSOLE_CONTENT
) );
2221 else if ( xModel
.is() )
2223 else if ( FN_UNO_COMPONENT
== pEntry
->nWID
)
2229 if(FN_UNO_CLSID
== pEntry
->nWID
)
2231 else if(FN_UNO_STREAM_NAME
== pEntry
->nWID
)
2233 aAny
<<= OUString(pOleNode
->GetOLEObj().GetCurrentPersistName());
2235 else if(FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
2237 aAny
<<= pOleNode
->GetOLEObj().GetOleRef();
2240 else if(WID_LAYOUT_SIZE
== pEntry
->nWID
)
2242 // format document completely in order to get correct value
2243 pFormat
->GetDoc()->GetEditShell()->CalcLayout();
2245 SwFrame
* pTmpFrame
= SwIterator
<SwFrame
,SwFormat
>( *pFormat
).First();
2248 OSL_ENSURE( pTmpFrame
->IsValid(), "frame not valid" );
2249 const SwRect
&rRect
= pTmpFrame
->Frame();
2250 Size aMM100Size
= OutputDevice::LogicToLogic(
2251 Size( rRect
.Width(), rRect
.Height() ),
2252 MapMode( MAP_TWIP
), MapMode( MAP_100TH_MM
));
2253 aAny
<<= awt::Size( aMM100Size
.Width(), aMM100Size
.Height() );
2258 // standard UNO API read attributes
2259 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
2260 const SwAttrSet
& rSet
= pFormat
->GetAttrSet();
2263 if(RES_BACKGROUND
== pEntry
->nWID
)
2266 const SvxBrushItem
aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet
, RES_BACKGROUND
));
2268 if(!aOriginalBrushItem
.QueryValue(aAny
, nMemberId
))
2270 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
2275 else if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
2278 const XFillBmpStretchItem
* pStretchItem
= dynamic_cast< const XFillBmpStretchItem
* >(&rSet
.Get(XATTR_FILLBMP_STRETCH
));
2279 const XFillBmpTileItem
* pTileItem
= dynamic_cast< const XFillBmpTileItem
* >(&rSet
.Get(XATTR_FILLBMP_TILE
));
2281 if( pTileItem
&& pTileItem
->GetValue() )
2283 aAny
<<= drawing::BitmapMode_REPEAT
;
2285 else if( pStretchItem
&& pStretchItem
->GetValue() )
2287 aAny
<<= drawing::BitmapMode_STRETCH
;
2291 aAny
<<= drawing::BitmapMode_NO_REPEAT
;
2299 m_pPropSet
->getPropertyValue(*pEntry
, rSet
, aAny
);
2303 else if(IsDescriptor())
2306 throw uno::RuntimeException();
2307 if(WID_LAYOUT_SIZE
!= pEntry
->nWID
) // there is no LayoutSize in a descriptor
2309 const uno::Any
* pAny
= nullptr;
2310 if( !pProps
->GetProperty( pEntry
->nWID
, nMemberId
, pAny
) )
2311 aAny
= mxStyleData
->getPropertyValue( rPropertyName
);
2317 throw uno::RuntimeException();
2320 if(pEntry
&& pEntry
->aType
== ::cppu::UnoType
<sal_Int16
>::get() && pEntry
->aType
!= aAny
.getValueType())
2322 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2323 sal_Int32 nValue
= 0;
2325 aAny
<<= (sal_Int16
)nValue
;
2328 //UUUU check for needed metric translation
2329 if(pEntry
->nMemberId
& SFX_METRIC_ITEM
)
2333 if(XATTR_FILLBMP_SIZEX
== pEntry
->nWID
|| XATTR_FILLBMP_SIZEY
== pEntry
->nWID
)
2335 // exception: If these ItemTypes are used, do not convert when these are negative
2336 // since this means they are intended as percent values
2337 sal_Int32 nValue
= 0;
2347 const SwDoc
* pDoc
= (IsDescriptor() ? m_pDoc
: GetFrameFormat()->GetDoc());
2348 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
2349 const SfxMapUnit
eMapUnit(rPool
.GetMetric(pEntry
->nWID
));
2351 if(eMapUnit
!= SFX_MAPUNIT_100TH_MM
)
2353 SvxUnoConvertToMM(eMapUnit
, aAny
);
2361 void SwXFrame::addPropertyChangeListener(const OUString
& /*PropertyName*/,
2362 const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/)
2363 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2365 OSL_FAIL("not implemented");
2368 void SwXFrame::removePropertyChangeListener(const OUString
& /*PropertyName*/,
2369 const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/)
2370 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2372 OSL_FAIL("not implemented");
2375 void SwXFrame::addVetoableChangeListener(const OUString
& /*PropertyName*/,
2376 const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/)
2377 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2379 OSL_FAIL("not implemented");
2382 void SwXFrame::removeVetoableChangeListener(
2383 const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/)
2384 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2386 OSL_FAIL("not implemented");
2389 beans::PropertyState
SwXFrame::getPropertyState( const OUString
& rPropertyName
)
2390 throw(beans::UnknownPropertyException
, uno::RuntimeException
, std::exception
)
2392 SolarMutexGuard aGuard
;
2393 uno::Sequence
< OUString
> aPropertyNames
{ rPropertyName
};
2394 uno::Sequence
< beans::PropertyState
> aStates
= getPropertyStates(aPropertyNames
);
2395 return aStates
.getConstArray()[0];
2398 uno::Sequence
< beans::PropertyState
> SwXFrame::getPropertyStates(
2399 const uno::Sequence
< OUString
>& aPropertyNames
)
2400 throw(beans::UnknownPropertyException
, uno::RuntimeException
, std::exception
)
2402 SolarMutexGuard aGuard
;
2403 uno::Sequence
< beans::PropertyState
> aStates(aPropertyNames
.getLength());
2404 beans::PropertyState
* pStates
= aStates
.getArray();
2405 SwFrameFormat
* pFormat
= GetFrameFormat();
2408 const OUString
* pNames
= aPropertyNames
.getConstArray();
2409 const SwAttrSet
& rFormatSet
= pFormat
->GetAttrSet();
2410 for(int i
= 0; i
< aPropertyNames
.getLength(); i
++)
2412 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(pNames
[i
]);
2414 throw beans::UnknownPropertyException("Unknown property: " + pNames
[i
], static_cast < cppu::OWeakObject
* > ( this ) );
2416 if(pEntry
->nWID
== FN_UNO_ANCHOR_TYPES
||
2417 pEntry
->nWID
== FN_PARAM_LINK_DISPLAY_NAME
||
2418 FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
||
2419 FN_UNO_GRAPHIC_U_R_L
== pEntry
->nWID
||
2420 FN_UNO_GRAPHIC_FILTER
== pEntry
->nWID
||
2421 FN_UNO_ACTUAL_SIZE
== pEntry
->nWID
||
2422 FN_UNO_ALTERNATIVE_TEXT
== pEntry
->nWID
)
2424 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2426 else if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
2429 if(SfxItemState::SET
== rFormatSet
.GetItemState(XATTR_FILLBMP_STRETCH
, false)
2430 || SfxItemState::SET
== rFormatSet
.GetItemState(XATTR_FILLBMP_TILE
, false))
2432 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2436 pStates
[i
] = beans::PropertyState_AMBIGUOUS_VALUE
;
2439 //UUUU for FlyFrames we need to mark the used properties from type RES_BACKGROUND
2440 // as beans::PropertyState_DIRECT_VALUE to let users of this property call
2441 // getPropertyValue where the member properties will be mapped from the
2442 // fill attributes to the according SvxBrushItem entries
2443 else if (RES_BACKGROUND
== pEntry
->nWID
)
2445 if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFormatSet
, pEntry
->nMemberId
))
2446 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2448 pStates
[i
] = beans::PropertyState_DEFAULT_VALUE
;
2452 if ((eType
== FLYCNTTYPE_GRF
) && isGRFATR(pEntry
->nWID
))
2454 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2457 SwNodeIndex
aIdx(*pIdx
, 1);
2458 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
2459 SfxItemSet
aSet(pNoText
->GetSwAttrSet());
2460 aSet
.GetItemState(pEntry
->nWID
);
2461 if(SfxItemState::SET
== aSet
.GetItemState( pEntry
->nWID
, false ))
2462 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2467 if(SfxItemState::SET
== rFormatSet
.GetItemState( pEntry
->nWID
, false ))
2468 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2470 pStates
[i
] = beans::PropertyState_DEFAULT_VALUE
;
2475 else if(IsDescriptor())
2477 for(int i
= 0; i
< aPropertyNames
.getLength(); i
++)
2478 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2481 throw uno::RuntimeException();
2485 void SwXFrame::setPropertyToDefault( const OUString
& rPropertyName
)
2486 throw(beans::UnknownPropertyException
, uno::RuntimeException
, std::exception
)
2488 SolarMutexGuard aGuard
;
2489 SwFrameFormat
* pFormat
= GetFrameFormat();
2492 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
2494 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2495 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
2496 throw uno::RuntimeException("setPropertyToDefault: property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2499 if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
2502 SwDoc
* pDoc
= pFormat
->GetDoc();
2503 SfxItemSet
aSet(pDoc
->GetAttrPool(), XATTR_FILL_FIRST
, XATTR_FILL_LAST
);
2504 aSet
.SetParent(&pFormat
->GetAttrSet());
2506 aSet
.ClearItem(XATTR_FILLBMP_STRETCH
);
2507 aSet
.ClearItem(XATTR_FILLBMP_TILE
);
2509 pFormat
->SetFormatAttr(aSet
);
2511 else if( pEntry
->nWID
&&
2512 pEntry
->nWID
!= FN_UNO_ANCHOR_TYPES
&&
2513 pEntry
->nWID
!= FN_PARAM_LINK_DISPLAY_NAME
)
2515 if ( (eType
== FLYCNTTYPE_GRF
) && isGRFATR(pEntry
->nWID
) )
2517 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2520 SwNodeIndex
aIdx(*pIdx
, 1);
2521 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
2523 SfxItemSet
aSet(pNoText
->GetSwAttrSet());
2524 aSet
.ClearItem(pEntry
->nWID
);
2525 pNoText
->SetAttr(aSet
);
2530 else if( FN_UNO_TITLE
== pEntry
->nWID
)
2532 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2533 // assure that <SdrObject> instance exists.
2534 GetOrCreateSdrObject(rFlyFormat
);
2535 rFlyFormat
.GetDoc()->SetFlyFrameTitle(rFlyFormat
, aEmptyOUStr
);
2537 // New attribute Description
2538 else if( FN_UNO_DESCRIPTION
== pEntry
->nWID
)
2540 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2541 // assure that <SdrObject> instance exists.
2542 GetOrCreateSdrObject(rFlyFormat
);
2543 rFlyFormat
.GetDoc()->SetFlyFrameDescription(rFlyFormat
, aEmptyOUStr
);
2547 SwDoc
* pDoc
= pFormat
->GetDoc();
2548 SfxItemSet
aSet( pDoc
->GetAttrPool(),
2549 RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1 );
2550 aSet
.SetParent(&pFormat
->GetAttrSet());
2551 aSet
.ClearItem(pEntry
->nWID
);
2552 if(rPropertyName
!= UNO_NAME_ANCHOR_TYPE
)
2553 pFormat
->SetFormatAttr(aSet
);
2556 else if((bNextFrame
= (rPropertyName
== UNO_NAME_CHAIN_NEXT_NAME
))
2557 || rPropertyName
== UNO_NAME_CHAIN_PREV_NAME
)
2559 SwDoc
* pDoc
= pFormat
->GetDoc();
2561 pDoc
->Unchain(*pFormat
);
2564 SwFormatChain
aChain( pFormat
->GetChain() );
2565 SwFrameFormat
*pPrev
= aChain
.GetPrev();
2567 pDoc
->Unchain(*pPrev
);
2571 else if(!IsDescriptor())
2572 throw uno::RuntimeException();
2576 uno::Any
SwXFrame::getPropertyDefault( const OUString
& rPropertyName
)
2577 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
2579 SolarMutexGuard aGuard
;
2581 SwFrameFormat
* pFormat
= GetFrameFormat();
2584 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
2587 if ( pEntry
->nWID
< RES_FRMATR_END
)
2589 const SfxPoolItem
& rDefItem
=
2590 pFormat
->GetDoc()->GetAttrPool().GetDefaultItem(pEntry
->nWID
);
2592 const sal_uInt8
nMemberId(pEntry
->nMemberId
& (~SFX_METRIC_ITEM
));
2594 rDefItem
.QueryValue(aRet
, nMemberId
);
2598 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2600 else if(!IsDescriptor())
2601 throw uno::RuntimeException();
2605 void SAL_CALL
SwXFrame::addEventListener(
2606 const uno::Reference
<lang::XEventListener
> & xListener
)
2607 throw (uno::RuntimeException
, std::exception
)
2609 // no need to lock here as m_pImpl is const and container threadsafe
2610 m_pImpl
->m_EventListeners
.addInterface(xListener
);
2613 void SAL_CALL
SwXFrame::removeEventListener(
2614 const uno::Reference
<lang::XEventListener
> & xListener
)
2615 throw (uno::RuntimeException
, std::exception
)
2617 // no need to lock here as m_pImpl is const and container threadsafe
2618 m_pImpl
->m_EventListeners
.removeInterface(xListener
);
2621 void SwXFrame::Modify(const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
)
2623 ClientModify(this, pOld
, pNew
);
2624 if (GetRegisteredIn())
2626 return; // core object still alive
2628 mxStyleData
.clear();
2629 mxStyleFamily
.clear();
2631 uno::Reference
<uno::XInterface
> const xThis(m_pImpl
->m_wThis
);
2633 { // fdo#72695: if UNO object is already dead, don't revive it with event
2636 lang::EventObject
const ev(xThis
);
2637 m_pImpl
->m_EventListeners
.disposeAndClear(ev
);
2640 void SwXFrame::dispose() throw( uno::RuntimeException
, std::exception
)
2642 SolarMutexGuard aGuard
;
2643 SwFrameFormat
* pFormat
= GetFrameFormat();
2646 SdrObject
* pObj
= pFormat
->FindSdrObject();
2647 // OD 11.09.2003 #112039# - add condition to perform delete of
2648 // format/anchor sign, not only if the object is inserted, but also
2649 // if a contact object is registered, which isn't in the destruction.
2651 ( pObj
->IsInserted() ||
2652 ( pObj
->GetUserCall() &&
2653 !static_cast<SwContact
*>(pObj
->GetUserCall())->IsInDTOR() ) ) )
2655 if (pFormat
->GetAnchor().GetAnchorId() == FLY_AS_CHAR
)
2657 const SwPosition
&rPos
= *(pFormat
->GetAnchor().GetContentAnchor());
2658 SwTextNode
*pTextNode
= rPos
.nNode
.GetNode().GetTextNode();
2659 const sal_Int32 nIdx
= rPos
.nContent
.GetIndex();
2660 pTextNode
->DeleteAttributes( RES_TXTATR_FLYCNT
, nIdx
, nIdx
);
2663 pFormat
->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(pFormat
);
2669 uno::Reference
< text::XTextRange
> SwXFrame::getAnchor() throw( uno::RuntimeException
, std::exception
)
2671 SolarMutexGuard aGuard
;
2672 uno::Reference
< text::XTextRange
> aRef
;
2673 SwFrameFormat
* pFormat
= GetFrameFormat();
2676 const SwFormatAnchor
& rAnchor
= pFormat
->GetAnchor();
2677 // return an anchor for non-page bound frames
2678 // and for page bound frames that have a page no == NULL and a content position
2679 if ((rAnchor
.GetAnchorId() != FLY_AT_PAGE
) ||
2680 (rAnchor
.GetContentAnchor() && !rAnchor
.GetPageNum()))
2682 const SwPosition
&rPos
= *(rAnchor
.GetContentAnchor());
2683 aRef
= SwXTextRange::CreateXTextRange(*pFormat
->GetDoc(), rPos
, nullptr);
2687 throw uno::RuntimeException();
2691 void SwXFrame::ResetDescriptor()
2693 bIsDescriptor
= false;
2694 mxStyleData
.clear();
2695 mxStyleFamily
.clear();
2699 void SwXFrame::attachToRange(const uno::Reference
< text::XTextRange
> & xTextRange
)
2700 throw (lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
2702 SolarMutexGuard aGuard
;
2704 throw uno::RuntimeException();
2705 uno::Reference
<lang::XUnoTunnel
> xRangeTunnel( xTextRange
, uno::UNO_QUERY
);
2706 SwXTextRange
* pRange
= nullptr;
2707 OTextCursorHelper
* pCursor
= nullptr;
2708 if(xRangeTunnel
.is())
2710 pRange
= reinterpret_cast< SwXTextRange
* >(
2711 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( SwXTextRange::getUnoTunnelId()) ));
2712 pCursor
= reinterpret_cast< OTextCursorHelper
* >(
2713 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2716 SwDoc
* pDoc
= pRange
? &pRange
->GetDoc() : pCursor
? pCursor
->GetDoc() : nullptr;
2719 SwUnoInternalPaM
aIntPam(*pDoc
);
2720 // this now needs to return TRUE
2721 ::sw::XTextRangeToSwPaM(aIntPam
, xTextRange
);
2723 SwNode
& rNode
= pDoc
->GetNodes().GetEndOfContent();
2725 aPam
.Move( fnMoveBackward
, fnGoDoc
);
2726 static sal_uInt16
const aFrameAttrRange
[] =
2728 RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
2729 RES_UNKNOWNATR_CONTAINER
, RES_UNKNOWNATR_CONTAINER
,
2731 //UUUU FillAttribute support
2732 XATTR_FILL_FIRST
, XATTR_FILL_LAST
,
2734 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
2737 static sal_uInt16
const aGrAttrRange
[] =
2739 RES_GRFATR_BEGIN
, RES_GRFATR_END
-1,
2742 SfxItemSet
aGrSet(pDoc
->GetAttrPool(), aGrAttrRange
);
2744 SfxItemSet
aFrameSet(pDoc
->GetAttrPool(), aFrameAttrRange
);
2746 //UUUU set correct parent to get the XFILL_NONE FillStyle as needed
2747 aFrameSet
.SetParent(&pDoc
->GetDfltFrameFormat()->GetAttrSet());
2749 // no the related items need to be added to the set
2751 if(!pProps
->AnyToItemSet( pDoc
, aFrameSet
, aGrSet
, bSizeFound
))
2752 throw lang::IllegalArgumentException();
2753 // a TextRange is handled separately
2754 *aPam
.GetPoint() = *aIntPam
.GetPoint();
2755 if(aIntPam
.HasMark())
2758 *aPam
.GetMark() = *aIntPam
.GetMark();
2761 const SfxPoolItem
* pItem
;
2762 RndStdIds eAnchorId
= FLY_AT_PARA
;
2763 if(SfxItemState::SET
== aFrameSet
.GetItemState(RES_ANCHOR
, false, &pItem
) )
2765 eAnchorId
= static_cast<const SwFormatAnchor
*>(pItem
)->GetAnchorId();
2766 if( FLY_AT_FLY
== eAnchorId
&&
2767 !aPam
.GetNode().FindFlyStartNode())
2769 // framebound only where a frame exists
2770 SwFormatAnchor
aAnchor(FLY_AT_PARA
);
2771 aFrameSet
.Put(aAnchor
);
2773 else if ((FLY_AT_PAGE
== eAnchorId
) &&
2774 0 == static_cast<const SwFormatAnchor
*>(pItem
)->GetPageNum() )
2776 SwFormatAnchor
aAnchor( *static_cast<const SwFormatAnchor
*>(pItem
) );
2777 aAnchor
.SetAnchor( aPam
.GetPoint() );
2778 aFrameSet
.Put(aAnchor
);
2782 const ::uno::Any
* pStyle
;
2783 SwFrameFormat
*pParentFrameFormat
= nullptr;
2784 if(pProps
->GetProperty(FN_UNO_FRAME_STYLE_NAME
, 0, pStyle
))
2785 pParentFrameFormat
= lcl_GetFrameFormat( *pStyle
, pDoc
);
2787 SwFlyFrameFormat
* pFormat
= nullptr;
2788 if( eType
== FLYCNTTYPE_FRM
)
2790 UnoActionContext
aCont(pDoc
);
2793 SwFormatAnchor
* pAnchorItem
= nullptr;
2794 // the frame is inserted bound to page
2795 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text
2796 if (eAnchorId
!= FLY_AT_PAGE
)
2798 pAnchorItem
= static_cast<SwFormatAnchor
*>(aFrameSet
.Get(RES_ANCHOR
).Clone());
2799 aFrameSet
.Put( SwFormatAnchor( FLY_AT_PAGE
, 1 ));
2802 aPam
.DeleteMark(); // mark position node will be deleted!
2803 aIntPam
.DeleteMark(); // mark position node will be deleted!
2804 pFormat
= pDoc
->MakeFlyAndMove( *m_pCopySource
, aFrameSet
,
2806 pParentFrameFormat
);
2807 if(pAnchorItem
&& pFormat
)
2809 pFormat
->DelFrames();
2810 pAnchorItem
->SetAnchor( m_pCopySource
->Start() );
2811 SfxItemSet
aAnchorSet( pDoc
->GetAttrPool(), RES_ANCHOR
, RES_ANCHOR
);
2812 aAnchorSet
.Put( *pAnchorItem
);
2813 pDoc
->SetFlyFrameAttr( *pFormat
, aAnchorSet
);
2816 DELETEZ( m_pCopySource
);
2820 pFormat
= pDoc
->MakeFlySection( FLY_AT_PARA
, aPam
.GetPoint(),
2821 &aFrameSet
, pParentFrameFormat
);
2826 if(!m_sName
.isEmpty())
2827 pDoc
->SetFlyName((SwFlyFrameFormat
&)*pFormat
, m_sName
);
2829 // wake up the SwXTextFrame
2830 static_cast<SwXTextFrame
*>(this)->SetDoc( bIsDescriptor
? m_pDoc
: GetFrameFormat()->GetDoc() );
2832 else if( eType
== FLYCNTTYPE_GRF
)
2834 UnoActionContext
aCont(pDoc
);
2835 const ::uno::Any
* pGraphicURL
;
2836 OUString sGraphicURL
;
2837 GraphicObject
*pGrfObj
= nullptr;
2838 if(pProps
->GetProperty(FN_UNO_GRAPHIC_U_R_L
, 0, pGraphicURL
))
2840 (*pGraphicURL
) >>= sGraphicURL
;
2841 if( sGraphicURL
.startsWith(sPackageProtocol
) )
2843 pGrfObj
= new GraphicObject
;
2844 pGrfObj
->SetUserData( sGraphicURL
);
2845 sGraphicURL
.clear();
2847 else if( sGraphicURL
.startsWith(sGraphicObjectProtocol
) )
2849 OString
sId(OUStringToOString(
2850 sGraphicURL
.copy( sizeof(sGraphicObjectProtocol
)-1 ),
2851 RTL_TEXTENCODING_ASCII_US
));
2852 pGrfObj
= new GraphicObject( sId
);
2853 sGraphicURL
.clear();
2857 const ::uno::Any
* pGraphic
;
2858 if( pProps
->GetProperty( FN_UNO_GRAPHIC
, 0, pGraphic
))
2860 uno::Reference
< graphic::XGraphic
> xGraphic
;
2861 (*pGraphic
) >>= xGraphic
;
2862 aGraphic
= Graphic( xGraphic
);
2866 const ::uno::Any
* pFilter
;
2867 if(pProps
->GetProperty(FN_UNO_GRAPHIC_FILTER
, 0, pFilter
))
2869 (*pFilter
) >>= sFltName
;
2873 pGrfObj
? pDoc
->getIDocumentContentOperations().Insert( aPam
, *pGrfObj
, &aFrameSet
, &aGrSet
,
2874 pParentFrameFormat
)
2875 : pDoc
->getIDocumentContentOperations().Insert( aPam
, sGraphicURL
, sFltName
, &aGraphic
,
2876 &aFrameSet
, &aGrSet
, pParentFrameFormat
);
2880 SwGrfNode
*pGrfNd
= pDoc
->GetNodes()[ pFormat
->GetContent().GetContentIdx()
2881 ->GetIndex()+1 ]->GetGrfNode();
2883 pGrfNd
->SetChgTwipSize( !bSizeFound
);
2885 if(!m_sName
.isEmpty())
2886 pDoc
->SetFlyName((SwFlyFrameFormat
&)*pFormat
, m_sName
);
2889 const ::uno::Any
* pSurroundContour
;
2890 if(pProps
->GetProperty(RES_SURROUND
, MID_SURROUND_CONTOUR
, pSurroundContour
))
2891 setPropertyValue(UNO_NAME_SURROUND_CONTOUR
, *pSurroundContour
);
2892 const ::uno::Any
* pContourOutside
;
2893 if(pProps
->GetProperty(RES_SURROUND
, MID_SURROUND_CONTOUROUTSIDE
, pContourOutside
))
2894 setPropertyValue(UNO_NAME_CONTOUR_OUTSIDE
, *pContourOutside
);
2895 const ::uno::Any
* pContourPoly
;
2896 if(pProps
->GetProperty(FN_PARAM_COUNTOUR_PP
, 0, pContourPoly
))
2897 setPropertyValue(UNO_NAME_CONTOUR_POLY_POLYGON
, *pContourPoly
);
2898 const ::uno::Any
* pPixelContour
;
2899 if(pProps
->GetProperty(FN_UNO_IS_PIXEL_CONTOUR
, 0, pPixelContour
))
2900 setPropertyValue(UNO_NAME_IS_PIXEL_CONTOUR
, *pPixelContour
);
2901 const ::uno::Any
* pAutoContour
;
2902 if(pProps
->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR
, 0, pAutoContour
))
2903 setPropertyValue(UNO_NAME_IS_AUTOMATIC_CONTOUR
, *pAutoContour
);
2907 const ::uno::Any
* pCLSID
= nullptr;
2908 const ::uno::Any
* pStreamName
= nullptr;
2909 const ::uno::Any
* pEmbeddedObject
= nullptr;
2910 if(!pProps
->GetProperty(FN_UNO_CLSID
, 0, pCLSID
)
2911 && !pProps
->GetProperty( FN_UNO_STREAM_NAME
, 0, pStreamName
)
2912 && !pProps
->GetProperty( FN_EMBEDDED_OBJECT
, 0, pEmbeddedObject
))
2913 throw uno::RuntimeException();
2917 SvGlobalName aClassName
;
2918 uno::Reference
< embed::XEmbeddedObject
> xIPObj
;
2919 std::unique_ptr
< comphelper::EmbeddedObjectContainer
> pCnt
;
2920 if( (*pCLSID
) >>= aCLSID
)
2922 if( !aClassName
.MakeId( aCLSID
) )
2924 lang::IllegalArgumentException aExcept
;
2925 aExcept
.Message
= "CLSID invalid";
2929 pCnt
.reset( new comphelper::EmbeddedObjectContainer
);
2932 OUString sDocumentBaseURL
= pDoc
->GetPersist()->getDocumentBaseURL();
2933 xIPObj
= pCnt
->CreateEmbeddedObject(aClassName
.GetByteSequence(), aName
,
2938 UnoActionContext
aAction(pDoc
);
2939 pDoc
->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT
, nullptr);
2942 //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode?
2943 sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
;
2945 // TODO/LEAN: VisualArea still needs running state
2946 svt::EmbeddedObjectRef::TryRunningState( xIPObj
);
2948 // set parent to get correct VisArea(in case of object needing parent printer)
2949 uno::Reference
< container::XChild
> xChild( xIPObj
, uno::UNO_QUERY
);
2951 xChild
->setParent( pDoc
->GetDocShell()->GetModel() );
2953 //The Size should be suggested by the OLE server if not manually set
2954 MapUnit aRefMap
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj
->getMapUnit( nAspect
) );
2958 aSize
= xIPObj
->getVisualAreaSize( nAspect
);
2960 catch ( embed::NoVisualAreaSizeException
& )
2962 // the default size will be set later
2965 Size
aSz( aSize
.Width
, aSize
.Height
);
2966 if ( !aSz
.Width() || !aSz
.Height() )
2968 aSz
.Width() = aSz
.Height() = 5000;
2969 aSz
= OutputDevice::LogicToLogic
2970 ( aSz
, MapMode( MAP_100TH_MM
), aRefMap
);
2972 MapMode
aMyMap( MAP_TWIP
);
2973 aSz
= OutputDevice::LogicToLogic( aSz
, aRefMap
, aMyMap
);
2974 SwFormatFrameSize aFrameSz
;
2975 aFrameSz
.SetSize(aSz
);
2976 aFrameSet
.Put(aFrameSz
);
2978 SwFlyFrameFormat
* pFormat2
= nullptr;
2980 // TODO/LATER: Is it the only possible aspect here?
2981 sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
;
2982 ::svt::EmbeddedObjectRef
xObjRef( xIPObj
, nAspect
);
2983 pFormat2
= pDoc
->getIDocumentContentOperations().Insert(aPam
, xObjRef
, &aFrameSet
, nullptr, nullptr );
2984 assert(pFormat2
&& "Doc->Insert(notxt) failed.");
2986 pDoc
->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT
, nullptr);
2987 pFormat2
->Add(this);
2988 if(!m_sName
.isEmpty())
2989 pDoc
->SetFlyName((SwFlyFrameFormat
&)*pFormat2
, m_sName
);
2992 else if( pStreamName
)
2994 OUString sStreamName
;
2995 (*pStreamName
) >>= sStreamName
;
2996 pDoc
->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT
, nullptr);
2998 SwFlyFrameFormat
* pFrameFormat
= nullptr;
2999 pFrameFormat
= pDoc
->getIDocumentContentOperations().InsertOLE( aPam
, sStreamName
, embed::Aspects::MSOLE_CONTENT
, &aFrameSet
, nullptr, nullptr );
3000 pDoc
->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT
, nullptr);
3001 pFrameFormat
->Add(this);
3002 if(!m_sName
.isEmpty())
3003 pDoc
->SetFlyName((SwFlyFrameFormat
&)*pFrameFormat
, m_sName
);
3005 else if (pEmbeddedObject
)
3007 uno::Reference
< embed::XEmbeddedObject
> obj
;
3008 (*pEmbeddedObject
) >>= obj
;
3009 svt::EmbeddedObjectRef xObj
;
3010 xObj
.Assign( obj
, embed::Aspects::MSOLE_CONTENT
);
3012 pDoc
->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT
, nullptr);
3014 // Not sure if these setParent() and InsertEmbeddedObject() calls are really
3015 // needed, it seems to work without, but logic from code elsewhere suggests
3016 // they should be done.
3017 SfxObjectShell
& rPers
= *pDoc
->GetPersist();
3018 uno::Reference
< container::XChild
> xChild( obj
, uno::UNO_QUERY
);
3020 xChild
->setParent( rPers
.GetModel() );
3022 rPers
.GetEmbeddedObjectContainer().InsertEmbeddedObject( obj
, rName
);
3024 SwFlyFrameFormat
* pFrameFormat
= nullptr;
3025 pFrameFormat
= pDoc
->getIDocumentContentOperations().Insert( aPam
, xObj
, &aFrameSet
, nullptr, nullptr );
3026 pDoc
->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT
, nullptr);
3027 pFrameFormat
->Add(this);
3028 if(!m_sName
.isEmpty())
3029 pDoc
->SetFlyName((SwFlyFrameFormat
&)*pFrameFormat
, m_sName
);
3032 if( pFormat
&& pDoc
->getIDocumentDrawModelAccess().GetDrawModel() )
3033 GetOrCreateSdrObject(*pFormat
);
3034 const ::uno::Any
* pOrder
;
3035 if( pProps
->GetProperty(FN_UNO_Z_ORDER
, 0, pOrder
) )
3036 setPropertyValue(UNO_NAME_Z_ORDER
, *pOrder
);
3037 const ::uno::Any
* pReplacement
;
3038 if( pProps
->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC
, 0, pReplacement
) )
3039 setPropertyValue(UNO_NAME_GRAPHIC
, *pReplacement
);
3040 // new attribute Title
3041 const ::uno::Any
* pTitle
;
3042 if ( pProps
->GetProperty(FN_UNO_TITLE
, 0, pTitle
) )
3044 setPropertyValue(UNO_NAME_TITLE
, *pTitle
);
3046 // new attribute Description
3047 const ::uno::Any
* pDescription
;
3048 if ( pProps
->GetProperty(FN_UNO_DESCRIPTION
, 0, pDescription
) )
3050 setPropertyValue(UNO_NAME_DESCRIPTION
, *pDescription
);
3054 const uno::Any
* pFrameIntropgrabbagItem
;
3055 if( pProps
->GetProperty(RES_FRMATR_GRABBAG
, 0, pFrameIntropgrabbagItem
) )
3057 setPropertyValue(UNO_NAME_FRAME_INTEROP_GRAB_BAG
, *pFrameIntropgrabbagItem
);
3061 throw lang::IllegalArgumentException();
3062 // reset the flag and delete Descriptor pointer
3066 void SwXFrame::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
3067 throw (lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
3069 SwFrameFormat
* pFormat
;
3071 attachToRange(xTextRange
);
3072 else if(nullptr != (pFormat
= GetFrameFormat()))
3074 uno::Reference
<lang::XUnoTunnel
> xRangeTunnel( xTextRange
, uno::UNO_QUERY
);
3075 SwDoc
* pDoc
= pFormat
->GetDoc();
3076 SwUnoInternalPaM
aIntPam(*pDoc
);
3077 if (::sw::XTextRangeToSwPaM(aIntPam
, xTextRange
))
3079 SfxItemSet
aSet( pDoc
->GetAttrPool(), RES_ANCHOR
, RES_ANCHOR
);
3080 aSet
.SetParent(&pFormat
->GetAttrSet());
3081 SwFormatAnchor aAnchor
= static_cast<const SwFormatAnchor
&>(aSet
.Get(RES_ANCHOR
));
3082 aAnchor
.SetAnchor( aIntPam
.Start() );
3084 pDoc
->SetFlyFrameAttr( *pFormat
, aSet
);
3087 throw lang::IllegalArgumentException();
3091 awt::Point
SwXFrame::getPosition() throw( uno::RuntimeException
, std::exception
)
3093 SolarMutexGuard aGuard
;
3094 uno::RuntimeException aRuntime
;
3095 aRuntime
.Message
= "position cannot be determined with this method";
3099 void SwXFrame::setPosition(const awt::Point
& /*aPosition*/) throw( uno::RuntimeException
, std::exception
)
3101 SolarMutexGuard aGuard
;
3102 uno::RuntimeException aRuntime
;
3103 aRuntime
.Message
= "position cannot be changed with this method";
3107 awt::Size
SwXFrame::getSize() throw( uno::RuntimeException
, std::exception
)
3109 const ::uno::Any aVal
= getPropertyValue("Size");
3110 awt::Size
const * pRet
= o3tl::doAccess
<awt::Size
>(aVal
);
3114 void SwXFrame::setSize(const awt::Size
& aSize
)
3115 throw( beans::PropertyVetoException
, uno::RuntimeException
, std::exception
)
3117 const ::uno::Any
aVal(&aSize
, ::cppu::UnoType
<awt::Size
>::get());
3118 setPropertyValue("Size", aVal
);
3121 OUString
SwXFrame::getShapeType() throw( uno::RuntimeException
, std::exception
)
3123 return OUString("FrameShape");
3126 SwXTextFrame::SwXTextFrame( SwDoc
*_pDoc
) :
3127 SwXText(nullptr, CURSOR_FRAME
),
3128 SwXFrame(FLYCNTTYPE_FRM
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_FRAME
), _pDoc
)
3132 SwXTextFrame::SwXTextFrame(SwFrameFormat
& rFormat
) :
3133 SwXText(rFormat
.GetDoc(), CURSOR_FRAME
),
3134 SwXFrame(rFormat
, FLYCNTTYPE_FRM
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_FRAME
))
3139 SwXTextFrame::~SwXTextFrame()
3143 uno::Reference
<text::XTextFrame
>
3144 SwXTextFrame::CreateXTextFrame(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
3146 return CreateXFrame
<text::XTextFrame
, SwXTextFrame
>(rDoc
, pFrameFormat
);
3149 void SAL_CALL
SwXTextFrame::acquire( )throw()
3151 SwXFrame::acquire();
3154 void SAL_CALL
SwXTextFrame::release( )throw()
3156 SwXFrame::release();
3159 ::uno::Any SAL_CALL
SwXTextFrame::queryInterface( const uno::Type
& aType
)
3160 throw (uno::RuntimeException
, std::exception
)
3162 ::uno::Any aRet
= SwXFrame::queryInterface(aType
);
3163 if(aRet
.getValueType() == cppu::UnoType
<void>::get())
3164 aRet
= SwXText::queryInterface(aType
);
3165 if(aRet
.getValueType() == cppu::UnoType
<void>::get())
3166 aRet
= SwXTextFrameBaseClass::queryInterface(aType
);
3170 uno::Sequence
< uno::Type
> SAL_CALL
SwXTextFrame::getTypes( ) throw(uno::RuntimeException
, std::exception
)
3172 uno::Sequence
< uno::Type
> aTextFrameTypes
= SwXTextFrameBaseClass::getTypes();
3173 uno::Sequence
< uno::Type
> aFrameTypes
= SwXFrame::getTypes();
3174 uno::Sequence
< uno::Type
> aTextTypes
= SwXText::getTypes();
3176 long nIndex
= aTextFrameTypes
.getLength();
3177 aTextFrameTypes
.realloc(
3178 aTextFrameTypes
.getLength() +
3179 aFrameTypes
.getLength() +
3180 aTextTypes
.getLength());
3182 uno::Type
* pTextFrameTypes
= aTextFrameTypes
.getArray();
3183 const uno::Type
* pFrameTypes
= aFrameTypes
.getConstArray();
3185 for(nPos
= 0; nPos
<aFrameTypes
.getLength(); nPos
++)
3186 pTextFrameTypes
[nIndex
++] = pFrameTypes
[nPos
];
3188 const uno::Type
* pTextTypes
= aTextTypes
.getConstArray();
3189 for(nPos
= 0; nPos
<aTextTypes
.getLength(); nPos
++)
3190 pTextFrameTypes
[nIndex
++] = pTextTypes
[nPos
];
3192 return aTextFrameTypes
;
3195 uno::Sequence
< sal_Int8
> SAL_CALL
SwXTextFrame::getImplementationId( ) throw(uno::RuntimeException
, std::exception
)
3197 return css::uno::Sequence
<sal_Int8
>();
3200 uno::Reference
< text::XText
> SwXTextFrame::getText() throw( uno::RuntimeException
, std::exception
)
3205 const SwStartNode
*SwXTextFrame::GetStartNode() const
3207 const SwStartNode
*pSttNd
= nullptr;
3209 const SwFrameFormat
* pFormat
= GetFrameFormat();
3212 const SwFormatContent
& rFlyContent
= pFormat
->GetContent();
3213 if( rFlyContent
.GetContentIdx() )
3214 pSttNd
= rFlyContent
.GetContentIdx()->GetNode().GetStartNode();
3220 uno::Reference
< text::XTextCursor
>
3221 SwXTextFrame::CreateCursor() throw (uno::RuntimeException
)
3223 return createTextCursor();
3226 uno::Reference
< text::XTextCursor
> SwXTextFrame::createTextCursor() throw( uno::RuntimeException
, std::exception
)
3228 SolarMutexGuard aGuard
;
3229 uno::Reference
< text::XTextCursor
> aRef
;
3230 SwFrameFormat
* pFormat
= GetFrameFormat();
3233 //save current start node to be able to check if there is content after the table -
3234 //otherwise the cursor would be in the body text!
3235 const SwNode
& rNode
= pFormat
->GetContent().GetContentIdx()->GetNode();
3236 const SwStartNode
* pOwnStartNode
= rNode
.FindSttNodeByType(SwFlyStartNode
);
3239 aPam
.Move(fnMoveForward
, fnGoNode
);
3240 SwTableNode
* pTableNode
= aPam
.GetNode().FindTableNode();
3241 SwContentNode
* pCont
= nullptr;
3244 aPam
.GetPoint()->nNode
= *pTableNode
->EndOfSectionNode();
3245 pCont
= GetDoc()->GetNodes().GoNext(&aPam
.GetPoint()->nNode
);
3246 pTableNode
= pCont
->FindTableNode();
3249 aPam
.GetPoint()->nContent
.Assign(pCont
, 0);
3251 const SwStartNode
* pNewStartNode
=
3252 aPam
.GetNode().FindSttNodeByType(SwFlyStartNode
);
3253 if(!pNewStartNode
|| pNewStartNode
!= pOwnStartNode
)
3255 uno::RuntimeException aExcept
;
3256 aExcept
.Message
= "no text available";
3260 SwXTextCursor
*const pXCursor
= new SwXTextCursor(
3261 *pFormat
->GetDoc(), this, CURSOR_FRAME
, *aPam
.GetPoint());
3262 aRef
= static_cast<text::XWordCursor
*>(pXCursor
);
3265 throw uno::RuntimeException();
3269 uno::Reference
< text::XTextCursor
> SwXTextFrame::createTextCursorByRange(const uno::Reference
< text::XTextRange
> & aTextPosition
) throw( uno::RuntimeException
, std::exception
)
3271 SolarMutexGuard aGuard
;
3272 uno::Reference
< text::XTextCursor
> aRef
;
3273 SwFrameFormat
* pFormat
= GetFrameFormat();
3274 SwUnoInternalPaM
aPam(*GetDoc());
3275 if (pFormat
&& ::sw::XTextRangeToSwPaM(aPam
, aTextPosition
))
3277 SwNode
& rNode
= pFormat
->GetContent().GetContentIdx()->GetNode();
3278 if(aPam
.GetNode().FindFlyStartNode() == rNode
.FindFlyStartNode())
3280 aRef
= static_cast<text::XWordCursor
*>(
3281 new SwXTextCursor(*pFormat
->GetDoc(), this, CURSOR_FRAME
,
3282 *aPam
.GetPoint(), aPam
.GetMark()));
3286 throw uno::RuntimeException();
3290 uno::Reference
< container::XEnumeration
> SwXTextFrame::createEnumeration() throw( uno::RuntimeException
, std::exception
)
3292 SolarMutexGuard aGuard
;
3293 SwFrameFormat
* pFormat
= GetFrameFormat();
3296 SwPosition
aPos(pFormat
->GetContent().GetContentIdx()->GetNode());
3297 auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos
));
3298 pUnoCursor
->Move(fnMoveForward
, fnGoNode
);
3299 return SwXParagraphEnumeration::Create(this, pUnoCursor
, CURSOR_FRAME
);
3302 uno::Type
SwXTextFrame::getElementType() throw( uno::RuntimeException
, std::exception
)
3304 return cppu::UnoType
<text::XTextRange
>::get();
3307 sal_Bool
SwXTextFrame::hasElements() throw( uno::RuntimeException
, std::exception
)
3312 void SwXTextFrame::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
3313 throw( lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
3315 SwXFrame::attach(xTextRange
);
3318 uno::Reference
< text::XTextRange
> SwXTextFrame::getAnchor() throw( uno::RuntimeException
, std::exception
)
3320 SolarMutexGuard aGuard
;
3321 return SwXFrame::getAnchor();
3324 void SwXTextFrame::dispose() throw( uno::RuntimeException
, std::exception
)
3326 SolarMutexGuard aGuard
;
3327 SwXFrame::dispose();
3330 void SwXTextFrame::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
, std::exception
)
3332 SwXFrame::addEventListener(aListener
);
3335 void SwXTextFrame::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
, std::exception
)
3337 SwXFrame::removeEventListener(aListener
);
3340 OUString
SwXTextFrame::getImplementationName() throw( uno::RuntimeException
, std::exception
)
3342 return OUString("SwXTextFrame");
3345 sal_Bool
SwXTextFrame::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
, std::exception
)
3347 return cppu::supportsService(this, rServiceName
);
3350 uno::Sequence
< OUString
> SwXTextFrame::getSupportedServiceNames() throw( uno::RuntimeException
, std::exception
)
3352 uno::Sequence
< OUString
> aRet
= SwXFrame::getSupportedServiceNames();
3353 aRet
.realloc(aRet
.getLength() + 2);
3354 OUString
* pArray
= aRet
.getArray();
3355 pArray
[aRet
.getLength() - 2] = "com.sun.star.text.TextFrame";
3356 pArray
[aRet
.getLength() - 1] = "com.sun.star.text.Text";
3360 void * SAL_CALL
SwXTextFrame::operator new( size_t t
) throw()
3362 return SwXTextFrameBaseClass::operator new( t
);
3365 void SAL_CALL
SwXTextFrame::operator delete( void * p
) throw()
3367 SwXTextFrameBaseClass::operator delete(p
);
3370 uno::Reference
<container::XNameReplace
> SAL_CALL
SwXTextFrame::getEvents()
3371 throw(uno::RuntimeException
, std::exception
)
3373 return new SwFrameEventDescriptor( *this );
3376 sal_Int64 SAL_CALL
SwXTextFrame::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
3377 throw(uno::RuntimeException
, std::exception
)
3379 sal_Int64 nRet
= SwXFrame::getSomething( rId
);
3381 nRet
= SwXText::getSomething( rId
);
3386 ::uno::Any
SwXTextFrame::getPropertyValue(const OUString
& rPropertyName
)
3387 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
3389 SolarMutexGuard aGuard
;
3391 if(rPropertyName
== UNO_NAME_START_REDLINE
||
3392 rPropertyName
== UNO_NAME_END_REDLINE
)
3394 //redline can only be returned if it's a living object
3396 aRet
= SwXText::getPropertyValue(rPropertyName
);
3399 aRet
= SwXFrame::getPropertyValue(rPropertyName
);
3403 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc
*pDoc
) :
3404 SwXFrame(FLYCNTTYPE_GRF
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC
), pDoc
)
3408 SwXTextGraphicObject::SwXTextGraphicObject(SwFrameFormat
& rFormat
) :
3409 SwXFrame(rFormat
, FLYCNTTYPE_GRF
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC
))
3414 SwXTextGraphicObject::~SwXTextGraphicObject()
3419 uno::Reference
<text::XTextContent
>
3420 SwXTextGraphicObject::CreateXTextGraphicObject(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
3422 return CreateXFrame
<text::XTextContent
, SwXTextGraphicObject
>(rDoc
, pFrameFormat
);
3425 void SAL_CALL
SwXTextGraphicObject::acquire( )throw()
3427 SwXFrame::acquire();
3430 void SAL_CALL
SwXTextGraphicObject::release( )throw()
3432 SwXFrame::release();
3435 ::uno::Any SAL_CALL
SwXTextGraphicObject::queryInterface( const uno::Type
& aType
)
3436 throw(uno::RuntimeException
, std::exception
)
3438 ::uno::Any aRet
= SwXFrame::queryInterface(aType
);
3439 if(aRet
.getValueType() == cppu::UnoType
<void>::get())
3440 aRet
= SwXTextGraphicObjectBaseClass::queryInterface(aType
);
3444 uno::Sequence
< uno::Type
> SAL_CALL
3445 SwXTextGraphicObject::getTypes( ) throw(uno::RuntimeException
, std::exception
)
3447 uno::Sequence
< uno::Type
> aGraphicTypes
= SwXTextGraphicObjectBaseClass::getTypes();
3448 uno::Sequence
< uno::Type
> aFrameTypes
= SwXFrame::getTypes();
3450 long nIndex
= aGraphicTypes
.getLength();
3451 aGraphicTypes
.realloc(
3452 aGraphicTypes
.getLength() +
3453 aFrameTypes
.getLength());
3455 uno::Type
* pGraphicTypes
= aGraphicTypes
.getArray();
3456 const uno::Type
* pFrameTypes
= aFrameTypes
.getConstArray();
3458 for(nPos
= 0; nPos
<aFrameTypes
.getLength(); nPos
++)
3459 pGraphicTypes
[nIndex
++] = pFrameTypes
[nPos
];
3461 return aGraphicTypes
;
3464 uno::Sequence
< sal_Int8
> SAL_CALL
SwXTextGraphicObject::getImplementationId( ) throw(uno::RuntimeException
, std::exception
)
3466 return css::uno::Sequence
<sal_Int8
>();
3469 void SwXTextGraphicObject::attach(const uno::Reference
< text::XTextRange
> & xTextRange
) throw( lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
3471 SwXFrame::attach(xTextRange
);
3474 uno::Reference
< text::XTextRange
> SwXTextGraphicObject::getAnchor() throw( uno::RuntimeException
, std::exception
)
3476 SolarMutexGuard aGuard
;
3477 return SwXFrame::getAnchor();
3480 void SwXTextGraphicObject::dispose() throw( uno::RuntimeException
, std::exception
)
3482 SolarMutexGuard aGuard
;
3483 SwXFrame::dispose();
3486 void SwXTextGraphicObject::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
3487 throw( uno::RuntimeException
, std::exception
)
3489 SwXFrame::addEventListener(aListener
);
3492 void SwXTextGraphicObject::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
3493 throw( uno::RuntimeException
, std::exception
)
3495 SwXFrame::removeEventListener(aListener
);
3498 OUString
SwXTextGraphicObject::getImplementationName() throw( uno::RuntimeException
, std::exception
)
3500 return OUString("SwXTextGraphicObject");
3503 sal_Bool
SwXTextGraphicObject::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
, std::exception
)
3505 return cppu::supportsService(this, rServiceName
);
3508 uno::Sequence
< OUString
> SwXTextGraphicObject::getSupportedServiceNames()
3509 throw( uno::RuntimeException
, std::exception
)
3511 uno::Sequence
< OUString
> aRet
= SwXFrame::getSupportedServiceNames();
3512 aRet
.realloc(aRet
.getLength() + 1);
3513 OUString
* pArray
= aRet
.getArray();
3514 pArray
[aRet
.getLength() - 1] = "com.sun.star.text.TextGraphicObject";
3518 void * SAL_CALL
SwXTextGraphicObject::operator new( size_t t
) throw()
3520 return SwXTextGraphicObjectBaseClass::operator new(t
);
3523 void SAL_CALL
SwXTextGraphicObject::operator delete( void * p
) throw()
3525 SwXTextGraphicObjectBaseClass::operator delete(p
);
3528 uno::Reference
<container::XNameReplace
> SAL_CALL
3529 SwXTextGraphicObject::getEvents()
3530 throw(uno::RuntimeException
, std::exception
)
3532 return new SwFrameEventDescriptor( *this );
3535 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc
*pDoc
)
3536 : SwXFrame(FLYCNTTYPE_OLE
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT
), pDoc
)
3537 , m_xOLEListener(nullptr)
3540 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrameFormat
& rFormat
) :
3541 SwXFrame(rFormat
, FLYCNTTYPE_OLE
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT
))
3546 SwXTextEmbeddedObject::~SwXTextEmbeddedObject()
3551 uno::Reference
<text::XTextContent
>
3552 SwXTextEmbeddedObject::CreateXTextEmbeddedObject(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
3554 return CreateXFrame
<text::XTextContent
, SwXTextEmbeddedObject
>(rDoc
, pFrameFormat
);
3557 void SAL_CALL
SwXTextEmbeddedObject::acquire()throw()
3559 SwXFrame::acquire();
3562 void SAL_CALL
SwXTextEmbeddedObject::release()throw()
3564 SwXFrame::release();
3567 ::uno::Any SAL_CALL
SwXTextEmbeddedObject::queryInterface( const uno::Type
& aType
)
3568 throw( uno::RuntimeException
, std::exception
)
3570 ::uno::Any aRet
= SwXFrame::queryInterface(aType
);
3571 if(aRet
.getValueType() == cppu::UnoType
<void>::get())
3572 aRet
= SwXTextEmbeddedObjectBaseClass::queryInterface(aType
);
3576 uno::Sequence
< uno::Type
> SAL_CALL
SwXTextEmbeddedObject::getTypes( ) throw(uno::RuntimeException
, std::exception
)
3578 uno::Sequence
< uno::Type
> aTextEmbeddedTypes
= SwXTextEmbeddedObjectBaseClass::getTypes();
3579 uno::Sequence
< uno::Type
> aFrameTypes
= SwXFrame::getTypes();
3581 long nIndex
= aTextEmbeddedTypes
.getLength();
3582 aTextEmbeddedTypes
.realloc(
3583 aTextEmbeddedTypes
.getLength() +
3584 aFrameTypes
.getLength());
3586 uno::Type
* pTextEmbeddedTypes
= aTextEmbeddedTypes
.getArray();
3588 const uno::Type
* pFrameTypes
= aFrameTypes
.getConstArray();
3590 for(nPos
= 0; nPos
<aFrameTypes
.getLength(); nPos
++)
3591 pTextEmbeddedTypes
[nIndex
++] = pFrameTypes
[nPos
];
3593 return aTextEmbeddedTypes
;
3596 uno::Sequence
< sal_Int8
> SAL_CALL
SwXTextEmbeddedObject::getImplementationId( ) throw(uno::RuntimeException
, std::exception
)
3598 return css::uno::Sequence
<sal_Int8
>();
3601 void SwXTextEmbeddedObject::attach(const uno::Reference
< text::XTextRange
> & xTextRange
) throw( lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
3603 SwXFrame::attach(xTextRange
);
3606 uno::Reference
< text::XTextRange
> SwXTextEmbeddedObject::getAnchor() throw( uno::RuntimeException
, std::exception
)
3608 SolarMutexGuard aGuard
;
3609 return SwXFrame::getAnchor();
3612 void SwXTextEmbeddedObject::dispose() throw( uno::RuntimeException
, std::exception
)
3614 SolarMutexGuard aGuard
;
3615 SwXFrame::dispose();
3618 void SwXTextEmbeddedObject::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
, std::exception
)
3620 SwXFrame::addEventListener(aListener
);
3623 void SwXTextEmbeddedObject::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
, std::exception
)
3625 SwXFrame::removeEventListener(aListener
);
3628 uno::Reference
< lang::XComponent
> SwXTextEmbeddedObject::getEmbeddedObject() throw( uno::RuntimeException
, std::exception
)
3630 uno::Reference
<embed::XEmbeddedObject
> xObj(getExtendedControlOverEmbeddedObject());
3631 return xObj
.is() ? uno::Reference
<lang::XComponent
>(xObj
->getComponent(), uno::UNO_QUERY
) : nullptr;
3634 uno::Reference
< embed::XEmbeddedObject
> SAL_CALL
SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject()
3635 throw( uno::RuntimeException
, std::exception
)
3637 uno::Reference
< embed::XEmbeddedObject
> xResult
;
3638 SwFrameFormat
* pFormat
= GetFrameFormat();
3641 SwDoc
* pDoc
= pFormat
->GetDoc();
3642 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3643 OSL_ENSURE( pCnt
->GetContentIdx() &&
3644 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3645 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3647 SwOLENode
* pOleNode
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()
3648 ->GetIndex() + 1 ]->GetOLENode();
3649 xResult
= pOleNode
->GetOLEObj().GetOleRef();
3650 if ( svt::EmbeddedObjectRef::TryRunningState( xResult
) )
3652 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3653 if ( pDoc
->GetDocShell() )
3654 pDoc
->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult
, embed::Aspects::MSOLE_CONTENT
) );
3656 uno::Reference
< lang::XComponent
> xComp( xResult
->getComponent(), uno::UNO_QUERY
);
3657 uno::Reference
< util::XModifyBroadcaster
> xBrdcst( xComp
, uno::UNO_QUERY
);
3658 uno::Reference
< frame::XModel
> xModel( xComp
, uno::UNO_QUERY
);
3659 if(xBrdcst
.is() && xModel
.is() && !m_xOLEListener
.is())
3661 m_xOLEListener
= new SwXOLEListener(*pFormat
, xModel
);
3662 xBrdcst
->addModifyListener( m_xOLEListener
);
3669 sal_Int64 SAL_CALL
SwXTextEmbeddedObject::getAspect() throw (uno::RuntimeException
, std::exception
)
3671 SwFrameFormat
* pFormat
= GetFrameFormat();
3674 SwDoc
* pDoc
= pFormat
->GetDoc();
3675 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3676 OSL_ENSURE( pCnt
->GetContentIdx() &&
3677 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3678 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3680 return pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect();
3683 return embed::Aspects::MSOLE_CONTENT
; // return the default value
3686 void SAL_CALL
SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect
) throw (uno::RuntimeException
, std::exception
)
3688 SwFrameFormat
* pFormat
= GetFrameFormat();
3691 SwDoc
* pDoc
= pFormat
->GetDoc();
3692 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3693 OSL_ENSURE( pCnt
->GetContentIdx() &&
3694 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3695 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3697 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect
);
3701 uno::Reference
< graphic::XGraphic
> SAL_CALL
SwXTextEmbeddedObject::getReplacementGraphic() throw (uno::RuntimeException
, std::exception
)
3703 SwFrameFormat
* pFormat
= GetFrameFormat();
3706 SwDoc
* pDoc
= pFormat
->GetDoc();
3707 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3708 OSL_ENSURE( pCnt
->GetContentIdx() &&
3709 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3710 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3712 const Graphic
* pGraphic
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic();
3714 return pGraphic
->GetXGraphic();
3717 return uno::Reference
< graphic::XGraphic
>();
3720 OUString
SwXTextEmbeddedObject::getImplementationName() throw( uno::RuntimeException
, std::exception
)
3722 return OUString("SwXTextEmbeddedObject");
3725 sal_Bool
SwXTextEmbeddedObject::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
, std::exception
)
3727 return cppu::supportsService(this, rServiceName
);
3730 uno::Sequence
< OUString
> SwXTextEmbeddedObject::getSupportedServiceNames()
3731 throw( uno::RuntimeException
, std::exception
)
3733 uno::Sequence
< OUString
> aRet
= SwXFrame::getSupportedServiceNames();
3734 aRet
.realloc(aRet
.getLength() + 1);
3735 OUString
* pArray
= aRet
.getArray();
3736 pArray
[aRet
.getLength() - 1] = "com.sun.star.text.TextEmbeddedObject";
3740 void * SAL_CALL
SwXTextEmbeddedObject::operator new( size_t t
) throw()
3742 return SwXTextEmbeddedObjectBaseClass::operator new(t
);
3745 void SAL_CALL
SwXTextEmbeddedObject::operator delete( void * p
) throw()
3747 SwXTextEmbeddedObjectBaseClass::operator delete(p
);
3750 uno::Reference
<container::XNameReplace
> SAL_CALL
3751 SwXTextEmbeddedObject::getEvents()
3752 throw(uno::RuntimeException
, std::exception
)
3754 return new SwFrameEventDescriptor( *this );
3758 SwXOLEListener::SwXOLEListener( SwFormat
& rOLEFormat
, uno::Reference
< XModel
> xOLE
) :
3759 SwClient(&rOLEFormat
),
3764 SwXOLEListener::~SwXOLEListener()
3767 void SwXOLEListener::modified( const lang::EventObject
& /*rEvent*/ )
3768 throw( uno::RuntimeException
, std::exception
)
3770 SolarMutexGuard aGuard
;
3772 SwOLENode
* pNd
= nullptr;
3773 SwFormat
* pFormat
= GetFormat();
3775 {const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
3778 SwNodeIndex
aIdx(*pIdx
, 1);
3779 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
3780 pNd
= pNoText
->GetOLENode();
3784 throw uno::RuntimeException();
3786 uno::Reference
< embed::XEmbeddedObject
> xIP
= pNd
->GetOLEObj().GetOleRef();
3789 sal_Int32 nState
= xIP
->getCurrentState();
3790 if ( nState
== embed::EmbedStates::INPLACE_ACTIVE
|| nState
== embed::EmbedStates::UI_ACTIVE
)
3794 // if the OLE-Node is UI-Active do nothing
3795 pNd
->SetOLESizeInvalid(true);
3796 pNd
->GetDoc()->SetOLEObjModified();
3799 void SwXOLEListener::disposing( const lang::EventObject
& rEvent
)
3800 throw( uno::RuntimeException
, std::exception
)
3802 SolarMutexGuard aGuard
;
3804 uno::Reference
< util::XModifyListener
> xListener( this );
3806 uno::Reference
< frame::XModel
> xModel( rEvent
.Source
, uno::UNO_QUERY
);
3807 uno::Reference
< util::XModifyBroadcaster
> xBrdcst(xModel
, uno::UNO_QUERY
);
3812 xBrdcst
->removeModifyListener( xListener
);
3814 catch(uno::Exception
const &)
3816 OSL_FAIL("OLE Listener couldn't be removed");
3820 void SwXOLEListener::Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
* pNew
)
3822 ClientModify(this, pOld
, pNew
);
3823 if(!GetRegisteredIn())
3824 xOLEModel
= nullptr;
3827 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */