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/awt/XBitmap.hpp>
21 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
22 #include <com/sun/star/container/XChild.hpp>
23 #include <com/sun/star/drawing/BitmapMode.hpp>
24 #include <com/sun/star/drawing/FillStyle.hpp>
25 #include <com/sun/star/embed/EmbedStates.hpp>
26 #include <com/sun/star/embed/Aspects.hpp>
27 #include <com/sun/star/frame/XTitle.hpp>
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <o3tl/any.hxx>
30 #include <svx/xfillit0.hxx>
31 #include <svx/xflgrit.hxx>
32 #include <svx/sdtaitm.hxx>
33 #include <svx/xflclit.hxx>
34 #include <tools/globname.hxx>
35 #include <tools/UnitConversion.hxx>
36 #include <editeng/memberids.h>
37 #include <swtypes.hxx>
44 #include <drawdoc.hxx>
45 #include <IDocumentUndoRedo.hxx>
46 #include <IDocumentDrawModelAccess.hxx>
47 #include <IDocumentLayoutAccess.hxx>
48 #include <IDocumentStylePoolAccess.hxx>
49 #include <UndoAttribute.hxx>
52 #include <ndindex.hxx>
54 #include <ndnotxt.hxx>
55 #include <svx/unomid.hxx>
56 #include <unocrsr.hxx>
57 #include <unocrsrhelper.hxx>
58 #include <docstyle.hxx>
59 #include <dcontact.hxx>
60 #include <fmtcnct.hxx>
64 #include <textboxhelper.hxx>
65 #include <unotextrange.hxx>
66 #include <unotextcursor.hxx>
67 #include <unoparagraph.hxx>
69 #include <unoprnms.hxx>
70 #include <unoevent.hxx>
71 #include <com/sun/star/util/XModifyBroadcaster.hpp>
72 #include <com/sun/star/text/TextContentAnchorType.hpp>
73 #include <com/sun/star/text/WrapTextMode.hpp>
74 #include <com/sun/star/beans/PropertyAttribute.hpp>
75 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
76 #include <com/sun/star/drawing/PointSequence.hpp>
77 #include <tools/poly.hxx>
79 #include <svx/svdpage.hxx>
80 #include <editeng/brushitem.hxx>
81 #include <editeng/protitem.hxx>
82 #include <fmtornt.hxx>
83 #include <fmteiro.hxx>
85 #include <editeng/lrspitem.hxx>
86 #include <editeng/ulspitem.hxx>
87 #include <editeng/boxitem.hxx>
88 #include <editeng/opaqitem.hxx>
89 #include <editeng/prntitem.hxx>
90 #include <editeng/shaditem.hxx>
91 #include <fmtsrnd.hxx>
92 #include <fmtfsize.hxx>
94 #include <unoframe.hxx>
95 #include <fmtanchr.hxx>
96 #include <fmtclds.hxx>
97 #include <fmtcntnt.hxx>
102 #include <vcl/svapp.hxx>
103 #include <vcl/GraphicLoader.hxx>
104 #include <SwStyleNameMapper.hxx>
105 #include <editeng/xmlcnitm.hxx>
106 #include <poolfmt.hxx>
107 #include <pagedesc.hxx>
108 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
109 #include <editeng/frmdiritem.hxx>
110 #include <fmtfollowtextflow.hxx>
111 #include <fmtwrapinfluenceonobjpos.hxx>
112 #include <toolkit/helper/vclunohelper.hxx>
113 #include <comphelper/interfacecontainer4.hxx>
114 #include <comphelper/servicehelper.hxx>
115 #include <cppuhelper/supportsservice.hxx>
116 #include <sal/log.hxx>
117 #include <vcl/errinf.hxx>
119 #include <svx/unobrushitemhelper.hxx>
120 #include <svx/xbtmpit.hxx>
121 #include <svx/xgrscit.hxx>
122 #include <svx/xflbmtit.hxx>
123 #include <svx/xflbmpit.hxx>
124 #include <svx/xflbmsxy.hxx>
125 #include <svx/xflftrit.hxx>
126 #include <svx/xsflclit.hxx>
127 #include <svx/xflbmsli.hxx>
128 #include <svx/xflbtoxy.hxx>
129 #include <svx/xflbstit.hxx>
130 #include <svx/xflboxy.hxx>
131 #include <svx/xflbckit.hxx>
132 #include <svx/unoshape.hxx>
133 #include <svx/xflhtit.hxx>
134 #include <svx/xfltrit.hxx>
135 #include <swunohelper.hxx>
137 #include <formatflysplit.hxx>
139 using namespace ::com::sun::star
;
141 using ::com::sun::star::frame::XModel
;
142 using ::com::sun::star::container::XNameAccess
;
143 using ::com::sun::star::style::XStyleFamiliesSupplier
;
145 class BaseFrameProperties_Impl
147 SwUnoCursorHelper::SwAnyMapHelper m_aAnyMap
;
150 virtual ~BaseFrameProperties_Impl();
152 void SetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
& rVal
);
153 bool GetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
*& pAny
);
154 bool FillBaseProperties(SfxItemSet
& rToSet
, const SfxItemSet
&rFromSet
, bool& rSizeFound
);
156 virtual bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) = 0;
159 BaseFrameProperties_Impl::~BaseFrameProperties_Impl()
163 void BaseFrameProperties_Impl::SetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
& rVal
)
165 m_aAnyMap
.SetValue( nWID
, nMemberId
, rVal
);
168 bool BaseFrameProperties_Impl::GetProperty(sal_uInt16 nWID
, sal_uInt8 nMemberId
, const uno::Any
*& rpAny
)
170 return m_aAnyMap
.FillValue( nWID
, nMemberId
, rpAny
);
173 bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet
& rToSet
, const SfxItemSet
& rFromSet
, bool& rSizeFound
)
175 // assert when the target SfxItemSet has no parent. It *should* have the pDfltFrameFormat
176 // from SwDoc set as parent (or similar) to have the necessary XFILL_NONE in the ItemSet
177 if(!rToSet
.GetParent())
179 OSL_ENSURE(false, "OOps, target SfxItemSet *should* have a parent which contains XFILL_NONE as XFillStyleItem (!)");
183 // always add an anchor to the set
184 SwFormatAnchor
aAnchor ( rFromSet
.Get ( RES_ANCHOR
) );
186 const ::uno::Any
* pAnchorType
;
187 if(GetProperty(RES_ANCHOR
, MID_ANCHOR_ANCHORTYPE
, pAnchorType
))
188 bRet
&= static_cast<SfxPoolItem
&>(aAnchor
).PutValue(*pAnchorType
, MID_ANCHOR_ANCHORTYPE
);
189 const ::uno::Any
* pAnchorPgNo
;
190 if(GetProperty(RES_ANCHOR
, MID_ANCHOR_PAGENUM
, pAnchorPgNo
))
191 bRet
&= static_cast<SfxPoolItem
&>(aAnchor
).PutValue(*pAnchorPgNo
, MID_ANCHOR_PAGENUM
);
196 // check for SvxBrushItem (RES_BACKGROUND) properties
197 const ::uno::Any
* pCol
= nullptr; GetProperty(RES_BACKGROUND
, MID_BACK_COLOR
, pCol
);
198 const ::uno::Any
* pRGBCol
= nullptr; GetProperty(RES_BACKGROUND
, MID_BACK_COLOR_R_G_B
, pRGBCol
);
199 const ::uno::Any
* pColTrans
= nullptr; GetProperty(RES_BACKGROUND
, MID_BACK_COLOR_TRANSPARENCY
, pColTrans
);
200 const ::uno::Any
* pTrans
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_TRANSPARENT
, pTrans
);
201 const ::uno::Any
* pGrLoc
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_POSITION
, pGrLoc
);
202 const ::uno::Any
* pGraphic
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC
, pGraphic
);
203 const ::uno::Any
* pGrFilter
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_FILTER
, pGrFilter
);
204 const ::uno::Any
* pGraphicURL
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_URL
, pGraphicURL
);
205 const ::uno::Any
* pGrTransparency
= nullptr; GetProperty(RES_BACKGROUND
, MID_GRAPHIC_TRANSPARENCY
, pGrTransparency
);
206 const bool bSvxBrushItemPropertiesUsed(
217 // check for FillStyle properties in the range XATTR_FILL_FIRST, XATTR_FILL_LAST
218 const uno::Any
* pXFillStyleItem
= nullptr; GetProperty(XATTR_FILLSTYLE
, 0, pXFillStyleItem
);
219 const uno::Any
* pXFillColorItem
= nullptr; GetProperty(XATTR_FILLCOLOR
, 0, pXFillColorItem
);
221 // XFillGradientItem: two possible slots supported in UNO API
222 const uno::Any
* pXFillGradientItem
= nullptr; GetProperty(XATTR_FILLGRADIENT
, MID_FILLGRADIENT
, pXFillGradientItem
);
223 const uno::Any
* pXFillGradientNameItem
= nullptr; GetProperty(XATTR_FILLGRADIENT
, MID_NAME
, pXFillGradientNameItem
);
225 // XFillHatchItem: two possible slots supported in UNO API
226 const uno::Any
* pXFillHatchItem
= nullptr; GetProperty(XATTR_FILLHATCH
, MID_FILLHATCH
, pXFillHatchItem
);
227 const uno::Any
* pXFillHatchNameItem
= nullptr; GetProperty(XATTR_FILLHATCH
, MID_NAME
, pXFillHatchNameItem
);
229 // XFillBitmapItem: three possible slots supported in UNO API
230 const uno::Any
* pXFillBitmapItem
= nullptr; GetProperty(XATTR_FILLBITMAP
, MID_BITMAP
, pXFillBitmapItem
);
231 const uno::Any
* pXFillBitmapNameItem
= nullptr; GetProperty(XATTR_FILLBITMAP
, MID_NAME
, pXFillBitmapNameItem
);
233 const uno::Any
* pXFillTransparenceItem
= nullptr; GetProperty(XATTR_FILLTRANSPARENCE
, 0, pXFillTransparenceItem
);
234 const uno::Any
* pXGradientStepCountItem
= nullptr; GetProperty(XATTR_GRADIENTSTEPCOUNT
, 0, pXGradientStepCountItem
);
235 const uno::Any
* pXFillBmpPosItem
= nullptr; GetProperty(XATTR_FILLBMP_POS
, 0, pXFillBmpPosItem
);
236 const uno::Any
* pXFillBmpSizeXItem
= nullptr; GetProperty(XATTR_FILLBMP_SIZEX
, 0, pXFillBmpSizeXItem
);
237 const uno::Any
* pXFillBmpSizeYItem
= nullptr; GetProperty(XATTR_FILLBMP_SIZEY
, 0, pXFillBmpSizeYItem
);
239 // XFillFloatTransparenceItem: two possible slots supported in UNO API
240 const uno::Any
* pXFillFloatTransparenceItem
= nullptr; GetProperty(XATTR_FILLFLOATTRANSPARENCE
, MID_FILLGRADIENT
, pXFillFloatTransparenceItem
);
241 const uno::Any
* pXFillFloatTransparenceNameItem
= nullptr; GetProperty(XATTR_FILLFLOATTRANSPARENCE
, MID_NAME
, pXFillFloatTransparenceNameItem
);
243 const uno::Any
* pXSecondaryFillColorItem
= nullptr; GetProperty(XATTR_SECONDARYFILLCOLOR
, 0, pXSecondaryFillColorItem
);
244 const uno::Any
* pXFillBmpSizeLogItem
= nullptr; GetProperty(XATTR_FILLBMP_SIZELOG
, 0, pXFillBmpSizeLogItem
);
245 const uno::Any
* pXFillBmpTileOffsetXItem
= nullptr; GetProperty(XATTR_FILLBMP_TILEOFFSETX
, 0, pXFillBmpTileOffsetXItem
);
246 const uno::Any
* pXFillBmpTileOffsetYItem
= nullptr; GetProperty(XATTR_FILLBMP_TILEOFFSETY
, 0, pXFillBmpTileOffsetYItem
);
247 const uno::Any
* pXFillBmpPosOffsetXItem
= nullptr; GetProperty(XATTR_FILLBMP_POSOFFSETX
, 0, pXFillBmpPosOffsetXItem
);
248 const uno::Any
* pXFillBmpPosOffsetYItem
= nullptr; GetProperty(XATTR_FILLBMP_POSOFFSETY
, 0, pXFillBmpPosOffsetYItem
);
249 const uno::Any
* pXFillBackgroundItem
= nullptr; GetProperty(XATTR_FILLBACKGROUND
, 0, pXFillBackgroundItem
);
250 const uno::Any
* pOwnAttrFillBmpItem
= nullptr; GetProperty(OWN_ATTR_FILLBMP_MODE
, 0, pOwnAttrFillBmpItem
);
252 // tdf#91140: ignore SOLID fill style for determining if fill style is used
253 // but there is a Graphic
254 const bool bFillStyleUsed(pXFillStyleItem
&& pXFillStyleItem
->hasValue() &&
255 (pXFillStyleItem
->get
<drawing::FillStyle
>() != drawing::FillStyle_SOLID
|| (!pGraphic
|| !pGraphicURL
) ));
256 SAL_INFO_IF(pXFillStyleItem
&& pXFillStyleItem
->hasValue() && !bFillStyleUsed
,
257 "sw.uno", "FillBaseProperties: ignoring invalid FillStyle");
258 const bool bXFillStyleItemUsed(
261 pXFillGradientItem
|| pXFillGradientNameItem
||
262 pXFillHatchItem
|| pXFillHatchNameItem
||
263 pXFillBitmapItem
|| pXFillBitmapNameItem
||
264 pXFillTransparenceItem
||
265 pXGradientStepCountItem
||
267 pXFillBmpSizeXItem
||
268 pXFillBmpSizeYItem
||
269 pXFillFloatTransparenceItem
|| pXFillFloatTransparenceNameItem
||
270 pXSecondaryFillColorItem
||
271 pXFillBmpSizeLogItem
||
272 pXFillBmpTileOffsetXItem
||
273 pXFillBmpTileOffsetYItem
||
274 pXFillBmpPosOffsetXItem
||
275 pXFillBmpPosOffsetYItem
||
276 pXFillBackgroundItem
||
277 pOwnAttrFillBmpItem
);
279 // use brush items, but *only* if no FillStyle properties are used; if both are used and when applying both
280 // in the obvious order some attributes may be wrong since they are set by the 1st set, but not
281 // redefined as needed by the 2nd set when they are default (and thus no tset) in the 2nd set. If
282 // it is necessary for any reason to set both (it should not) an in-between step will be needed
283 // that resets the items for FillAttributes in rToSet to default.
284 // Note: There are other mechanisms in XMLOFF to pre-sort this relationship already, but this version
285 // was used initially, is tested and works. Keep it to be able to react when another feed adds attributes
287 if(bSvxBrushItemPropertiesUsed
&& !bXFillStyleItemUsed
)
289 // create a temporary SvxBrushItem, fill the attributes to it and use it to set
290 // the corresponding FillAttributes
291 SvxBrushItem
aBrush(RES_BACKGROUND
);
295 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pCol
,MID_BACK_COLOR
);
300 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pColTrans
, MID_BACK_COLOR_TRANSPARENCY
);
305 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pRGBCol
, MID_BACK_COLOR_R_G_B
);
310 // don't overwrite transparency with a non-transparence flag
311 if(!pColTrans
|| Any2Bool( *pTrans
))
312 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pTrans
, MID_GRAPHIC_TRANSPARENT
);
317 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pGraphic
, MID_GRAPHIC
);
322 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pGraphicURL
, MID_GRAPHIC_URL
);
327 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pGrFilter
, MID_GRAPHIC_FILTER
);
332 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pGrLoc
, MID_GRAPHIC_POSITION
);
337 bRet
&= static_cast<SfxPoolItem
&>(aBrush
).PutValue(*pGrTransparency
, MID_GRAPHIC_TRANSPARENCY
);
340 setSvxBrushItemAsFillAttributesToTargetSet(aBrush
, rToSet
);
343 if(bXFillStyleItemUsed
)
345 XFillStyleItem aXFillStyleItem
;
346 std::unique_ptr
<SvxBrushItem
> aBrush(std::make_unique
<SvxBrushItem
>(RES_BACKGROUND
));
350 aXFillStyleItem
.PutValue(*pXFillStyleItem
, 0);
351 rToSet
.Put(aXFillStyleItem
);
356 const Color
aNullCol(COL_DEFAULT_SHAPE_FILLING
);
357 XFillColorItem
aXFillColorItem(OUString(), aNullCol
);
359 aXFillColorItem
.PutValue(*pXFillColorItem
, 0);
360 rToSet
.Put(aXFillColorItem
);
361 //set old-school brush color if we later encounter the
362 //MID_BACK_COLOR_TRANSPARENCY case below
363 aBrush
= getSvxBrushItemFromSourceSet(rToSet
, RES_BACKGROUND
, false);
365 else if (aXFillStyleItem
.GetValue() == drawing::FillStyle_SOLID
&& (pCol
|| pRGBCol
))
367 // Fill style is set to solid, but no fill color is given.
368 // On the other hand, we have a BackColor, so use that.
370 aBrush
->PutValue(*pCol
, MID_BACK_COLOR
);
372 aBrush
->PutValue(*pRGBCol
, MID_BACK_COLOR_R_G_B
);
373 setSvxBrushItemAsFillAttributesToTargetSet(*aBrush
, rToSet
);
376 if(pXFillGradientItem
|| pXFillGradientNameItem
)
378 if(pXFillGradientItem
)
380 // basegfx::BGradient() default already creates [COL_BLACK, COL_WHITE] as defaults
381 const basegfx::BGradient aNullGrad
;
382 XFillGradientItem
aXFillGradientItem(aNullGrad
);
384 aXFillGradientItem
.PutValue(*pXFillGradientItem
, MID_FILLGRADIENT
);
385 rToSet
.Put(aXFillGradientItem
);
388 if(pXFillGradientNameItem
)
392 if(!(*pXFillGradientNameItem
>>= aTempName
))
394 throw lang::IllegalArgumentException();
397 bool const bSuccess
= SvxShape::SetFillAttribute(
398 XATTR_FILLGRADIENT
, aTempName
, rToSet
);
399 if (aXFillStyleItem
.GetValue() == drawing::FillStyle_GRADIENT
)
400 { // tdf#90946 ignore invalid gradient-name if SOLID
405 SAL_INFO_IF(!bSuccess
, "sw.uno",
406 "FillBaseProperties: ignoring invalid FillGradientName");
411 if(pXFillHatchItem
|| pXFillHatchNameItem
)
415 const Color
aNullCol(COL_DEFAULT_SHAPE_STROKE
);
416 const XHatch
aNullHatch(aNullCol
);
417 XFillHatchItem
aXFillHatchItem(aNullHatch
);
419 aXFillHatchItem
.PutValue(*pXFillHatchItem
, MID_FILLHATCH
);
420 rToSet
.Put(aXFillHatchItem
);
423 if(pXFillHatchNameItem
)
427 if(!(*pXFillHatchNameItem
>>= aTempName
))
429 throw lang::IllegalArgumentException();
432 bRet
&= SvxShape::SetFillAttribute(XATTR_FILLHATCH
, aTempName
, rToSet
);
436 if (pXFillBitmapItem
|| pXFillBitmapNameItem
)
440 Graphic aNullGraphic
;
441 XFillBitmapItem
aXFillBitmapItem(std::move(aNullGraphic
));
443 aXFillBitmapItem
.PutValue(*pXFillBitmapItem
, MID_BITMAP
);
444 rToSet
.Put(aXFillBitmapItem
);
447 if(pXFillBitmapNameItem
)
451 if(!(*pXFillBitmapNameItem
>>= aTempName
))
453 throw lang::IllegalArgumentException();
456 bRet
&= SvxShape::SetFillAttribute(XATTR_FILLBITMAP
, aTempName
, rToSet
);
460 if (pXFillTransparenceItem
)
462 XFillTransparenceItem aXFillTransparenceItem
;
463 aXFillTransparenceItem
.PutValue(*pXFillTransparenceItem
, 0);
464 rToSet
.Put(aXFillTransparenceItem
);
466 else if (pColTrans
&&
467 !pXFillFloatTransparenceItem
&& !pXFillFloatTransparenceNameItem
)
469 // No fill transparency is given. On the other hand, we have a
470 // BackColorTransparency, so use that.
471 // tdf#90640 tdf#90130: this is necessary for LO 4.4.0 - 4.4.2
472 // that forgot to write draw:opacity into documents
473 // but: the value was *always* wrong for bitmaps! => ignore it
474 sal_Int8
nGraphicTransparency(0);
475 *pColTrans
>>= nGraphicTransparency
;
476 if (aXFillStyleItem
.GetValue() != drawing::FillStyle_BITMAP
)
478 rToSet
.Put(XFillTransparenceItem(nGraphicTransparency
));
480 if (aXFillStyleItem
.GetValue() == drawing::FillStyle_SOLID
)
482 aBrush
->PutValue(*pColTrans
, MID_BACK_COLOR_TRANSPARENCY
);
483 setSvxBrushItemAsFillAttributesToTargetSet(*aBrush
, rToSet
);
487 if(pXGradientStepCountItem
)
489 XGradientStepCountItem aXGradientStepCountItem
;
491 aXGradientStepCountItem
.PutValue(*pXGradientStepCountItem
, 0);
492 rToSet
.Put(aXGradientStepCountItem
);
497 XFillBmpPosItem aXFillBmpPosItem
;
499 aXFillBmpPosItem
.PutValue(*pXFillBmpPosItem
, 0);
500 rToSet
.Put(aXFillBmpPosItem
);
503 if(pXFillBmpSizeXItem
)
505 XFillBmpSizeXItem aXFillBmpSizeXItem
;
507 aXFillBmpSizeXItem
.PutValue(*pXFillBmpSizeXItem
, 0);
508 rToSet
.Put(aXFillBmpSizeXItem
);
511 if(pXFillBmpSizeYItem
)
513 XFillBmpSizeYItem aXFillBmpSizeYItem
;
515 aXFillBmpSizeYItem
.PutValue(*pXFillBmpSizeYItem
, 0);
516 rToSet
.Put(aXFillBmpSizeYItem
);
519 if(pXFillFloatTransparenceItem
|| pXFillFloatTransparenceNameItem
)
521 if(pXFillFloatTransparenceItem
)
523 // basegfx::BGradient() default already creates [COL_BLACK, COL_WHITE] as defaults
524 const basegfx::BGradient aNullGrad
;
525 XFillFloatTransparenceItem
aXFillFloatTransparenceItem(aNullGrad
, false);
527 aXFillFloatTransparenceItem
.PutValue(*pXFillFloatTransparenceItem
, MID_FILLGRADIENT
);
528 rToSet
.Put(aXFillFloatTransparenceItem
);
531 if(pXFillFloatTransparenceNameItem
)
535 if(!(*pXFillFloatTransparenceNameItem
>>= aTempName
))
537 throw lang::IllegalArgumentException();
540 bRet
&= SvxShape::SetFillAttribute(XATTR_FILLFLOATTRANSPARENCE
, aTempName
, rToSet
);
544 if(pXSecondaryFillColorItem
)
546 const Color
aNullCol(COL_DEFAULT_SHAPE_FILLING
);
547 XSecondaryFillColorItem
aXSecondaryFillColorItem(OUString(), aNullCol
);
549 aXSecondaryFillColorItem
.PutValue(*pXSecondaryFillColorItem
, 0);
550 rToSet
.Put(aXSecondaryFillColorItem
);
553 if(pXFillBmpSizeLogItem
)
555 XFillBmpSizeLogItem aXFillBmpSizeLogItem
;
557 aXFillBmpSizeLogItem
.PutValue(*pXFillBmpSizeLogItem
, 0);
558 rToSet
.Put(aXFillBmpSizeLogItem
);
561 if(pXFillBmpTileOffsetXItem
)
563 XFillBmpTileOffsetXItem aXFillBmpTileOffsetXItem
;
565 aXFillBmpTileOffsetXItem
.PutValue(*pXFillBmpTileOffsetXItem
, 0);
566 rToSet
.Put(aXFillBmpTileOffsetXItem
);
569 if(pXFillBmpTileOffsetYItem
)
571 XFillBmpTileOffsetYItem aXFillBmpTileOffsetYItem
;
573 aXFillBmpTileOffsetYItem
.PutValue(*pXFillBmpTileOffsetYItem
, 0);
574 rToSet
.Put(aXFillBmpTileOffsetYItem
);
577 if(pXFillBmpPosOffsetXItem
)
579 XFillBmpPosOffsetXItem aXFillBmpPosOffsetXItem
;
581 aXFillBmpPosOffsetXItem
.PutValue(*pXFillBmpPosOffsetXItem
, 0);
582 rToSet
.Put(aXFillBmpPosOffsetXItem
);
585 if(pXFillBmpPosOffsetYItem
)
587 XFillBmpPosOffsetYItem aXFillBmpPosOffsetYItem
;
589 aXFillBmpPosOffsetYItem
.PutValue(*pXFillBmpPosOffsetYItem
, 0);
590 rToSet
.Put(aXFillBmpPosOffsetYItem
);
593 if(pXFillBackgroundItem
)
595 XFillBackgroundItem aXFillBackgroundItem
;
597 aXFillBackgroundItem
.PutValue(*pXFillBackgroundItem
, 0);
598 rToSet
.Put(aXFillBackgroundItem
);
601 if(pOwnAttrFillBmpItem
)
603 drawing::BitmapMode eMode
;
605 if(!(*pOwnAttrFillBmpItem
>>= eMode
))
609 if(!(*pOwnAttrFillBmpItem
>>= nMode
))
611 throw lang::IllegalArgumentException();
614 eMode
= static_cast<drawing::BitmapMode
>(nMode
);
617 rToSet
.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH
== eMode
));
618 rToSet
.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT
== eMode
));
622 const ::uno::Any
* pCont
= nullptr;
623 GetProperty(RES_PROTECT
, MID_PROTECT_CONTENT
, pCont
);
624 const ::uno::Any
* pPos
= nullptr;
625 GetProperty(RES_PROTECT
,MID_PROTECT_POSITION
, pPos
);
626 const ::uno::Any
* pName
= nullptr;
627 GetProperty(RES_PROTECT
, MID_PROTECT_SIZE
, pName
);
628 if(pCont
||pPos
||pName
)
630 SvxProtectItem
aProt ( rFromSet
.Get ( RES_PROTECT
) );
632 bRet
&= static_cast<SfxPoolItem
&>(aProt
).PutValue(*pCont
, MID_PROTECT_CONTENT
);
634 bRet
&= static_cast<SfxPoolItem
&>(aProt
).PutValue(*pPos
, MID_PROTECT_POSITION
);
636 bRet
&= static_cast<SfxPoolItem
&>(aProt
).PutValue(*pName
, MID_PROTECT_SIZE
);
641 const ::uno::Any
* pHori
= nullptr;
642 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_ORIENT
, pHori
);
643 const ::uno::Any
* pHoriP
= nullptr;
644 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_POSITION
|CONVERT_TWIPS
, pHoriP
);
645 const ::uno::Any
* pHoriR
= nullptr;
646 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_RELATION
, pHoriR
);
647 const ::uno::Any
* pPageT
= nullptr;
648 GetProperty(RES_HORI_ORIENT
, MID_HORIORIENT_PAGETOGGLE
, pPageT
);
649 if(pHori
||pHoriP
||pHoriR
||pPageT
)
651 SwFormatHoriOrient
aOrient ( rFromSet
.Get ( RES_HORI_ORIENT
) );
653 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pHori
, MID_HORIORIENT_ORIENT
);
655 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pHoriP
, MID_HORIORIENT_POSITION
|CONVERT_TWIPS
);
657 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pHoriR
, MID_HORIORIENT_RELATION
);
659 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pPageT
, MID_HORIORIENT_PAGETOGGLE
);
665 const ::uno::Any
* pVert
= nullptr;
666 GetProperty(RES_VERT_ORIENT
, MID_VERTORIENT_ORIENT
, pVert
);
667 const ::uno::Any
* pVertP
= nullptr;
668 GetProperty(RES_VERT_ORIENT
, MID_VERTORIENT_POSITION
|CONVERT_TWIPS
, pVertP
);
669 const ::uno::Any
* pVertR
= nullptr;
670 GetProperty(RES_VERT_ORIENT
, MID_VERTORIENT_RELATION
, pVertR
);
671 if(pVert
||pVertP
||pVertR
)
673 SwFormatVertOrient
aOrient ( rFromSet
.Get ( RES_VERT_ORIENT
) );
675 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pVert
, MID_VERTORIENT_ORIENT
);
677 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pVertP
, MID_VERTORIENT_POSITION
|CONVERT_TWIPS
);
679 bRet
&= static_cast<SfxPoolItem
&>(aOrient
).PutValue(*pVertR
, MID_VERTORIENT_RELATION
);
684 const ::uno::Any
* pURL
= nullptr;
685 GetProperty(RES_URL
, MID_URL_URL
, pURL
);
686 const ::uno::Any
* pTarget
= nullptr;
687 GetProperty(RES_URL
, MID_URL_TARGET
, pTarget
);
688 const ::uno::Any
* pHyLNm
= nullptr;
689 GetProperty(RES_URL
, MID_URL_HYPERLINKNAME
, pHyLNm
);
690 const ::uno::Any
* pHySMp
= nullptr;
691 GetProperty(RES_URL
, MID_URL_SERVERMAP
, pHySMp
);
692 if(pURL
||pTarget
||pHyLNm
||pHySMp
)
694 SwFormatURL
aURL ( rFromSet
.Get ( RES_URL
) );
696 bRet
&= static_cast<SfxPoolItem
&>(aURL
).PutValue(*pURL
, MID_URL_URL
);
698 bRet
&= static_cast<SfxPoolItem
&>(aURL
).PutValue(*pTarget
, MID_URL_TARGET
);
700 bRet
&= static_cast<SfxPoolItem
&>(aURL
).PutValue(*pHyLNm
, MID_URL_HYPERLINKNAME
);
702 bRet
&= static_cast<SfxPoolItem
&>(aURL
).PutValue(*pHySMp
, MID_URL_SERVERMAP
);
706 const ::uno::Any
* pL
= nullptr;
707 GetProperty(RES_LR_SPACE
, MID_L_MARGIN
|CONVERT_TWIPS
, pL
);
708 const ::uno::Any
* pR
= nullptr;
709 GetProperty(RES_LR_SPACE
, MID_R_MARGIN
|CONVERT_TWIPS
, pR
);
712 SvxLRSpaceItem
aLR ( rFromSet
.Get ( RES_LR_SPACE
) );
714 bRet
&= static_cast<SfxPoolItem
&>(aLR
).PutValue(*pL
, MID_L_MARGIN
|CONVERT_TWIPS
);
716 bRet
&= static_cast<SfxPoolItem
&>(aLR
).PutValue(*pR
, MID_R_MARGIN
|CONVERT_TWIPS
);
719 const ::uno::Any
* pT
= nullptr;
720 GetProperty(RES_UL_SPACE
, MID_UP_MARGIN
|CONVERT_TWIPS
, pT
);
721 const ::uno::Any
* pB
= nullptr;
722 GetProperty(RES_UL_SPACE
, MID_LO_MARGIN
|CONVERT_TWIPS
, pB
);
725 SvxULSpaceItem
aTB ( rFromSet
.Get ( RES_UL_SPACE
) );
727 bRet
&= static_cast<SfxPoolItem
&>(aTB
).PutValue(*pT
, MID_UP_MARGIN
|CONVERT_TWIPS
);
729 bRet
&= static_cast<SfxPoolItem
&>(aTB
).PutValue(*pB
, MID_LO_MARGIN
|CONVERT_TWIPS
);
732 const ::uno::Any
* pOp
;
733 if(GetProperty(RES_OPAQUE
, 0, pOp
))
735 SvxOpaqueItem
aOp ( rFromSet
.Get ( RES_OPAQUE
) );
736 bRet
&= static_cast<SfxPoolItem
&>(aOp
).PutValue(*pOp
, 0);
739 const ::uno::Any
* pPrt
;
740 if(GetProperty(RES_PRINT
, 0, pPrt
))
742 SvxPrintItem
aPrt ( rFromSet
.Get ( RES_PRINT
) );
743 bRet
&= static_cast<SfxPoolItem
&>(aPrt
).PutValue(*pPrt
, 0);
746 const ::uno::Any
* pSh
;
747 if(GetProperty(RES_SHADOW
, CONVERT_TWIPS
, pSh
))
749 SvxShadowItem
aSh ( rFromSet
.Get ( RES_SHADOW
) );
750 bRet
&= static_cast<SfxPoolItem
&>(aSh
).PutValue(*pSh
, CONVERT_TWIPS
);
753 const ::uno::Any
* pShTr
;
754 if(GetProperty(RES_SHADOW
, MID_SHADOW_TRANSPARENCE
, pShTr
) && rToSet
.HasItem(RES_SHADOW
))
756 SvxShadowItem
aSh(rToSet
.Get(RES_SHADOW
));
757 bRet
&= aSh
.PutValue(*pShTr
, MID_SHADOW_TRANSPARENCE
);
760 const ::uno::Any
* pSur
= nullptr;
761 GetProperty(RES_SURROUND
, MID_SURROUND_SURROUNDTYPE
, pSur
);
762 const ::uno::Any
* pSurCont
= nullptr;
763 GetProperty(RES_SURROUND
, MID_SURROUND_CONTOUR
, pSurCont
);
764 const ::uno::Any
* pSurAnch
= nullptr;
765 GetProperty(RES_SURROUND
, MID_SURROUND_ANCHORONLY
, pSurAnch
);
768 SwFormatSurround
aSrnd ( rFromSet
.Get ( RES_SURROUND
) );
770 bRet
&= static_cast<SfxPoolItem
&>(aSrnd
).PutValue(*pSur
, MID_SURROUND_SURROUNDTYPE
);
772 bRet
&= static_cast<SfxPoolItem
&>(aSrnd
).PutValue(*pSurCont
, MID_SURROUND_CONTOUR
);
774 bRet
&= static_cast<SfxPoolItem
&>(aSrnd
).PutValue(*pSurAnch
, MID_SURROUND_ANCHORONLY
);
777 const ::uno::Any
* pLeft
= nullptr;
778 GetProperty(RES_BOX
, LEFT_BORDER
|CONVERT_TWIPS
, pLeft
);
779 const ::uno::Any
* pRight
= nullptr;
780 GetProperty(RES_BOX
, CONVERT_TWIPS
|RIGHT_BORDER
, pRight
);
781 const ::uno::Any
* pTop
= nullptr;
782 GetProperty(RES_BOX
, CONVERT_TWIPS
|TOP_BORDER
, pTop
);
783 const ::uno::Any
* pBottom
= nullptr;
784 GetProperty(RES_BOX
, CONVERT_TWIPS
|BOTTOM_BORDER
, pBottom
);
785 const ::uno::Any
* pDistance
= nullptr;
786 GetProperty(RES_BOX
, CONVERT_TWIPS
|BORDER_DISTANCE
, pDistance
);
787 const ::uno::Any
* pLeftDistance
= nullptr;
788 GetProperty(RES_BOX
, CONVERT_TWIPS
|LEFT_BORDER_DISTANCE
, pLeftDistance
);
789 const ::uno::Any
* pRightDistance
= nullptr;
790 GetProperty(RES_BOX
, CONVERT_TWIPS
|RIGHT_BORDER_DISTANCE
, pRightDistance
);
791 const ::uno::Any
* pTopDistance
= nullptr;
792 GetProperty(RES_BOX
, CONVERT_TWIPS
|TOP_BORDER_DISTANCE
, pTopDistance
);
793 const ::uno::Any
* pBottomDistance
= nullptr;
794 GetProperty(RES_BOX
, CONVERT_TWIPS
|BOTTOM_BORDER_DISTANCE
, pBottomDistance
);
795 const ::uno::Any
* pLineStyle
= nullptr;
796 GetProperty(RES_BOX
, LINE_STYLE
, pLineStyle
);
797 const ::uno::Any
* pLineWidth
= nullptr;
798 GetProperty(RES_BOX
, LINE_WIDTH
, pLineWidth
);
799 if( pLeft
|| pRight
|| pTop
|| pBottom
|| pDistance
||
800 pLeftDistance
|| pRightDistance
|| pTopDistance
|| pBottomDistance
||
801 pLineStyle
|| pLineWidth
)
803 SvxBoxItem
aBox ( rFromSet
.Get ( RES_BOX
) );
805 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pLeft
, CONVERT_TWIPS
|LEFT_BORDER
);
807 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pRight
, CONVERT_TWIPS
|RIGHT_BORDER
);
809 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pTop
, CONVERT_TWIPS
|TOP_BORDER
);
811 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pBottom
, CONVERT_TWIPS
|BOTTOM_BORDER
);
813 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pDistance
, CONVERT_TWIPS
|BORDER_DISTANCE
);
815 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pLeftDistance
, CONVERT_TWIPS
|LEFT_BORDER_DISTANCE
);
817 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pRightDistance
, CONVERT_TWIPS
|RIGHT_BORDER_DISTANCE
);
819 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pTopDistance
, CONVERT_TWIPS
|TOP_BORDER_DISTANCE
);
820 if( pBottomDistance
)
821 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pBottomDistance
, CONVERT_TWIPS
|BOTTOM_BORDER_DISTANCE
);
823 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pLineStyle
, LINE_STYLE
);
825 bRet
&= static_cast<SfxPoolItem
&>(aBox
).PutValue(*pLineWidth
, LINE_WIDTH
|CONVERT_TWIPS
);
829 const ::uno::Any
* pRelH
= nullptr;
830 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_HEIGHT
, pRelH
);
831 const ::uno::Any
* pRelHRelation
= nullptr;
832 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_HEIGHT_RELATION
, pRelHRelation
);
833 const ::uno::Any
* pRelW
= nullptr;
834 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_WIDTH
, pRelW
);
835 const ::uno::Any
* pRelWRelation
= nullptr;
836 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_REL_WIDTH_RELATION
, pRelWRelation
);
837 const ::uno::Any
* pSyncWidth
= nullptr;
838 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT
, pSyncWidth
);
839 const ::uno::Any
* pSyncHeight
= nullptr;
840 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH
, pSyncHeight
);
841 const ::uno::Any
* pWidth
= nullptr;
842 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_WIDTH
|CONVERT_TWIPS
, pWidth
);
843 const ::uno::Any
* pHeight
= nullptr;
844 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_HEIGHT
|CONVERT_TWIPS
, pHeight
);
845 const ::uno::Any
* pSize
= nullptr;
846 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_SIZE
|CONVERT_TWIPS
, pSize
);
847 const ::uno::Any
* pSizeType
= nullptr;
848 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_SIZE_TYPE
, pSizeType
);
849 const ::uno::Any
* pWidthType
= nullptr;
850 GetProperty(RES_FRM_SIZE
, MID_FRMSIZE_WIDTH_TYPE
, pWidthType
);
851 if( pWidth
|| pHeight
||pRelH
|| pRelHRelation
|| pRelW
|| pRelWRelation
|| pSize
||pSizeType
||
852 pWidthType
||pSyncWidth
|| pSyncHeight
)
855 SwFormatFrameSize
aFrameSz ( rFromSet
.Get ( RES_FRM_SIZE
) );
857 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pWidth
, MID_FRMSIZE_WIDTH
|CONVERT_TWIPS
);
859 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pHeight
, MID_FRMSIZE_HEIGHT
|CONVERT_TWIPS
);
861 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pRelH
, MID_FRMSIZE_REL_HEIGHT
);
863 bRet
&= aFrameSz
.PutValue(*pRelHRelation
, MID_FRMSIZE_REL_HEIGHT_RELATION
);
865 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pRelW
, MID_FRMSIZE_REL_WIDTH
);
867 bRet
&= aFrameSz
.PutValue(*pRelWRelation
, MID_FRMSIZE_REL_WIDTH_RELATION
);
869 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pSyncWidth
, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT
);
871 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pSyncHeight
, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH
);
873 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pSize
, MID_FRMSIZE_SIZE
|CONVERT_TWIPS
);
875 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pSizeType
, MID_FRMSIZE_SIZE_TYPE
);
877 bRet
&= static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(*pWidthType
, MID_FRMSIZE_WIDTH_TYPE
);
878 if(!aFrameSz
.GetWidth())
879 aFrameSz
.SetWidth(MINFLY
);
880 if(!aFrameSz
.GetHeight())
881 aFrameSz
.SetHeight(MINFLY
);
882 rToSet
.Put(aFrameSz
);
887 SwFormatFrameSize aFrameSz
;
888 constexpr sal_Int32 constTwips_1cm
= o3tl::toTwips(1, o3tl::Length::cm
);
890 aSize
.Width
= constTwips_1cm
;
891 aSize
.Height
= constTwips_1cm
;
894 static_cast<SfxPoolItem
&>(aFrameSz
).PutValue(aSizeVal
, MID_FRMSIZE_SIZE
|CONVERT_TWIPS
);
895 rToSet
.Put(aFrameSz
);
898 const ::uno::Any
* pFrameDirection
= nullptr;
899 GetProperty(RES_FRAMEDIR
, 0, pFrameDirection
);
902 SvxFrameDirectionItem
aAttr(SvxFrameDirection::Horizontal_LR_TB
, RES_FRAMEDIR
);
903 aAttr
.PutValue(*pFrameDirection
, 0);
906 const ::uno::Any
* pUnknown
= nullptr;
907 GetProperty(RES_UNKNOWNATR_CONTAINER
, 0, pUnknown
);
910 SvXMLAttrContainerItem
aAttr(RES_UNKNOWNATR_CONTAINER
);
911 aAttr
.PutValue(*pUnknown
, 0);
916 const ::uno::Any
* pFollowTextFlow
= nullptr;
917 GetProperty(RES_FOLLOW_TEXT_FLOW
, MID_FOLLOW_TEXT_FLOW
, pFollowTextFlow
);
921 SwFormatFollowTextFlow aFormatFollowTextFlow
;
922 if( pFollowTextFlow
)
924 aFormatFollowTextFlow
.PutValue(*pFollowTextFlow
, MID_FOLLOW_TEXT_FLOW
);
927 rToSet
.Put(aFormatFollowTextFlow
);
930 // #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS
931 const ::uno::Any
* pWrapInfluenceOnObjPos
= nullptr;
932 GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS
, MID_WRAP_INFLUENCE
, pWrapInfluenceOnObjPos
);
933 const ::uno::Any
* pAllowOverlap
= nullptr;
934 GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS
, MID_ALLOW_OVERLAP
, pAllowOverlap
);
935 if ( pWrapInfluenceOnObjPos
|| pAllowOverlap
)
937 SwFormatWrapInfluenceOnObjPos aFormatWrapInfluenceOnObjPos
;
938 if (pWrapInfluenceOnObjPos
)
939 aFormatWrapInfluenceOnObjPos
.PutValue( *pWrapInfluenceOnObjPos
, MID_WRAP_INFLUENCE
);
941 aFormatWrapInfluenceOnObjPos
.PutValue( *pAllowOverlap
, MID_ALLOW_OVERLAP
);
942 rToSet
.Put(aFormatWrapInfluenceOnObjPos
);
946 const ::uno::Any
* pTextVertAdjust
= nullptr;
947 GetProperty(RES_TEXT_VERT_ADJUST
, 0, pTextVertAdjust
);
948 if ( pTextVertAdjust
)
950 SdrTextVertAdjustItem
aTextVertAdjust( rFromSet
.Get ( RES_TEXT_VERT_ADJUST
) );
951 bRet
&= static_cast<SfxPoolItem
&>(aTextVertAdjust
).PutValue(*pTextVertAdjust
, 0);
952 rToSet
.Put(aTextVertAdjust
);
956 const ::uno::Any
* pDecorative
= nullptr;
957 GetProperty(RES_DECORATIVE
, 0, pDecorative
);
960 SfxBoolItem
item(RES_DECORATIVE
);
961 bRet
&= item
.PutValue(*pDecorative
, 0);
965 const ::uno::Any
* pFlySplit
= nullptr;
966 GetProperty(RES_FLY_SPLIT
, 0, pFlySplit
);
969 SwFormatFlySplit
aSplit(true);
970 bRet
&= aSplit
.PutValue(*pFlySplit
, 0);
979 class SwFrameProperties_Impl
: public BaseFrameProperties_Impl
982 SwFrameProperties_Impl();
984 bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) override
;
989 SwFrameProperties_Impl::SwFrameProperties_Impl():
990 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_FRAME)*/ )
994 static void lcl_FillCol ( SfxItemSet
&rToSet
, const ::SfxItemSet
&rFromSet
, const ::uno::Any
*pAny
)
998 SwFormatCol
aCol ( rFromSet
.Get ( RES_COL
) );
999 static_cast<SfxPoolItem
&>(aCol
).PutValue( *pAny
, MID_COLUMNS
);
1004 bool SwFrameProperties_Impl::AnyToItemSet(SwDoc
*pDoc
, SfxItemSet
& rSet
, SfxItemSet
&, bool& rSizeFound
)
1006 // Properties for all frames
1007 const ::uno::Any
*pStyleName
;
1008 SwDocStyleSheet
* pStyle
= nullptr;
1011 if ( GetProperty ( FN_UNO_FRAME_STYLE_NAME
, 0, pStyleName
) )
1014 *pStyleName
>>= sStyle
;
1015 SwStyleNameMapper::FillUIName(sStyle
, sStyle
, SwGetPoolIdFromName::FrmFmt
);
1016 pStyle
= static_cast<SwDocStyleSheet
*>(pDoc
->GetDocShell()->GetStyleSheetPool()->Find(sStyle
,
1017 SfxStyleFamily::Frame
));
1020 const ::uno::Any
* pColumns
= nullptr;
1021 GetProperty (RES_COL
, MID_COLUMNS
, pColumns
);
1024 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet( *pStyle
) );
1025 const ::SfxItemSet
*pItemSet
= &xStyle
->GetItemSet();
1026 bRet
= FillBaseProperties( rSet
, *pItemSet
, rSizeFound
);
1027 lcl_FillCol ( rSet
, *pItemSet
, pColumns
);
1031 const ::SfxItemSet
*pItemSet
= &pDoc
->getIDocumentStylePoolAccess().GetFrameFormatFromPool( RES_POOLFRM_FRAME
)->GetAttrSet();
1032 bRet
= FillBaseProperties( rSet
, *pItemSet
, rSizeFound
);
1033 lcl_FillCol ( rSet
, *pItemSet
, pColumns
);
1035 const ::uno::Any
* pEdit
;
1036 if(GetProperty(RES_EDIT_IN_READONLY
, 0, pEdit
))
1038 SwFormatEditInReadonly
item(RES_EDIT_IN_READONLY
);
1039 item
.PutValue(*pEdit
, 0);
1047 class SwGraphicProperties_Impl
: public BaseFrameProperties_Impl
1050 SwGraphicProperties_Impl();
1052 virtual bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) override
;
1057 SwGraphicProperties_Impl::SwGraphicProperties_Impl( ) :
1058 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_GRAPHIC)*/ )
1062 static void lcl_FillMirror ( SfxItemSet
&rToSet
, const ::SfxItemSet
&rFromSet
, const ::uno::Any
*pHEvenMirror
, const ::uno::Any
*pHOddMirror
, const ::uno::Any
*pVMirror
, bool &rRet
)
1064 if(pHEvenMirror
|| pHOddMirror
|| pVMirror
)
1066 SwMirrorGrf
aMirror ( rFromSet
.Get ( RES_GRFATR_MIRRORGRF
) );
1068 rRet
&= static_cast<SfxPoolItem
&>(aMirror
).PutValue(*pHEvenMirror
, MID_MIRROR_HORZ_EVEN_PAGES
);
1070 rRet
&= static_cast<SfxPoolItem
&>(aMirror
).PutValue(*pHOddMirror
, MID_MIRROR_HORZ_ODD_PAGES
);
1072 rRet
&= static_cast<SfxPoolItem
&>(aMirror
).PutValue(*pVMirror
, MID_MIRROR_VERT
);
1073 rToSet
.Put(aMirror
);
1077 bool SwGraphicProperties_Impl::AnyToItemSet(
1079 SfxItemSet
& rFrameSet
,
1083 // Properties for all frames
1085 const ::uno::Any
*pStyleName
;
1086 SwDocStyleSheet
* pStyle
= nullptr;
1088 if ( GetProperty ( FN_UNO_FRAME_STYLE_NAME
, 0, pStyleName
) )
1091 *pStyleName
>>= sStyle
;
1092 SwStyleNameMapper::FillUIName(sStyle
, sStyle
, SwGetPoolIdFromName::FrmFmt
);
1093 pStyle
= static_cast<SwDocStyleSheet
*>(pDoc
->GetDocShell()->GetStyleSheetPool()->Find(sStyle
,
1094 SfxStyleFamily::Frame
));
1097 const ::uno::Any
* pHEvenMirror
= nullptr;
1098 const ::uno::Any
* pHOddMirror
= nullptr;
1099 const ::uno::Any
* pVMirror
= nullptr;
1100 GetProperty(RES_GRFATR_MIRRORGRF
, MID_MIRROR_HORZ_EVEN_PAGES
, pHEvenMirror
);
1101 GetProperty(RES_GRFATR_MIRRORGRF
, MID_MIRROR_HORZ_ODD_PAGES
, pHOddMirror
);
1102 GetProperty(RES_GRFATR_MIRRORGRF
, MID_MIRROR_VERT
, pVMirror
);
1106 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet(*pStyle
) );
1107 const ::SfxItemSet
*pItemSet
= &xStyle
->GetItemSet();
1108 bRet
= FillBaseProperties(rFrameSet
, *pItemSet
, rSizeFound
);
1109 lcl_FillMirror ( rGrSet
, *pItemSet
, pHEvenMirror
, pHOddMirror
, pVMirror
, bRet
);
1113 const ::SfxItemSet
*pItemSet
= &pDoc
->getIDocumentStylePoolAccess().GetFrameFormatFromPool( RES_POOLFRM_GRAPHIC
)->GetAttrSet();
1114 bRet
= FillBaseProperties(rFrameSet
, *pItemSet
, rSizeFound
);
1115 lcl_FillMirror ( rGrSet
, *pItemSet
, pHEvenMirror
, pHOddMirror
, pVMirror
, bRet
);
1118 static const ::sal_uInt16 nIDs
[] =
1121 RES_GRFATR_ROTATION
,
1122 RES_GRFATR_LUMINANCE
,
1123 RES_GRFATR_CONTRAST
,
1124 RES_GRFATR_CHANNELR
,
1125 RES_GRFATR_CHANNELG
,
1126 RES_GRFATR_CHANNELB
,
1129 RES_GRFATR_TRANSPARENCY
,
1130 RES_GRFATR_DRAWMODE
,
1133 const ::uno::Any
* pAny
;
1134 for(sal_Int16 nIndex
= 0; nIDs
[nIndex
]; nIndex
++)
1136 sal_uInt8 nMId
= RES_GRFATR_CROPGRF
== nIDs
[nIndex
] ? CONVERT_TWIPS
: 0;
1137 if(GetProperty(nIDs
[nIndex
], nMId
, pAny
))
1139 std::unique_ptr
<SfxPoolItem
> pItem(::GetDfltAttr( nIDs
[nIndex
] )->Clone());
1140 bRet
&= pItem
->PutValue(*pAny
, nMId
);
1141 rGrSet
.Put(std::move(pItem
));
1150 class SwOLEProperties_Impl
: public SwFrameProperties_Impl
1153 SwOLEProperties_Impl() {}
1155 virtual bool AnyToItemSet( SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
) override
;
1160 bool SwOLEProperties_Impl::AnyToItemSet(
1161 SwDoc
* pDoc
, SfxItemSet
& rFrameSet
, SfxItemSet
& rSet
, bool& rSizeFound
)
1163 const ::uno::Any
* pTemp
;
1164 if(!GetProperty(FN_UNO_CLSID
, 0, pTemp
) && !GetProperty(FN_UNO_STREAM_NAME
, 0, pTemp
)
1165 && !GetProperty(FN_EMBEDDED_OBJECT
, 0, pTemp
)
1166 && !GetProperty(FN_UNO_VISIBLE_AREA_WIDTH
, 0, pTemp
)
1167 && !GetProperty(FN_UNO_VISIBLE_AREA_HEIGHT
, 0, pTemp
) )
1169 SwFrameProperties_Impl::AnyToItemSet( pDoc
, rFrameSet
, rSet
, rSizeFound
);
1174 class SwXFrame::Impl
1177 uno::WeakReference
<uno::XInterface
> m_wThis
;
1178 std::mutex m_Mutex
; // just for OInterfaceContainerHelper4
1179 ::comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> m_EventListeners
;
1182 OUString
SwXFrame::getImplementationName()
1187 sal_Bool
SwXFrame::supportsService(const OUString
& rServiceName
)
1189 return cppu::supportsService(this, rServiceName
);
1192 uno::Sequence
< OUString
> SwXFrame::getSupportedServiceNames()
1194 return { "com.sun.star.text.BaseFrame", "com.sun.star.text.TextContent", "com.sun.star.document.LinkTarget" };
1197 SwXFrame::SwXFrame(FlyCntType eSet
, const ::SfxItemPropertySet
* pSet
, SwDoc
*pDoc
)
1199 , m_pFrameFormat(nullptr)
1203 , m_bIsDescriptor(true)
1204 , m_nDrawAspect(embed::Aspects::MSOLE_CONTENT
)
1205 , m_nVisibleAreaWidth(0)
1206 , m_nVisibleAreaHeight(0)
1208 // Register ourselves as a listener to the document (via the page descriptor)
1209 StartListening(pDoc
->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD
)->GetNotifier());
1210 // get the property set for the default style data
1211 // First get the model
1212 uno::Reference
< XModel
> xModel
= pDoc
->GetDocShell()->GetBaseModel();
1213 // Ask the model for its family supplier interface
1214 uno::Reference
< XStyleFamiliesSupplier
> xFamilySupplier ( xModel
, uno::UNO_QUERY
);
1215 // Get the style families
1216 uno::Reference
< XNameAccess
> xFamilies
= xFamilySupplier
->getStyleFamilies();
1217 // Get the Frame family (and keep it for later)
1218 const ::uno::Any aAny
= xFamilies
->getByName ("FrameStyles");
1219 aAny
>>= mxStyleFamily
;
1220 // In the derived class, we'll ask mxStyleFamily for the relevant default style
1221 // mxStyleFamily is initialised in the SwXFrame constructor
1224 case FLYCNTTYPE_FRM
:
1226 uno::Any aAny2
= mxStyleFamily
->getByName ("Frame");
1227 aAny2
>>= mxStyleData
;
1228 m_pProps
.reset(new SwFrameProperties_Impl
);
1231 case FLYCNTTYPE_GRF
:
1233 uno::Any aAny2
= mxStyleFamily
->getByName ("Graphics");
1234 aAny2
>>= mxStyleData
;
1235 m_pProps
.reset(new SwGraphicProperties_Impl
);
1238 case FLYCNTTYPE_OLE
:
1240 uno::Any aAny2
= mxStyleFamily
->getByName ("OLE");
1241 aAny2
>>= mxStyleData
;
1242 m_pProps
.reset(new SwOLEProperties_Impl
);
1252 SwXFrame::SwXFrame(SwFrameFormat
& rFrameFormat
, FlyCntType eSet
, const ::SfxItemPropertySet
* pSet
)
1254 , m_pFrameFormat(&rFrameFormat
)
1258 , m_bIsDescriptor(false)
1259 , m_nDrawAspect(embed::Aspects::MSOLE_CONTENT
)
1260 , m_nVisibleAreaWidth(0)
1261 , m_nVisibleAreaHeight(0)
1263 StartListening(rFrameFormat
.GetNotifier());
1266 SwXFrame::~SwXFrame()
1268 SolarMutexGuard aGuard
;
1273 template<class NameLookupIsHard
>
1274 rtl::Reference
<NameLookupIsHard
>
1275 SwXFrame::CreateXFrame(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
1277 assert(!pFrameFormat
|| &rDoc
== pFrameFormat
->GetDoc());
1278 rtl::Reference
<NameLookupIsHard
> xFrame
;
1281 xFrame
= dynamic_cast<NameLookupIsHard
*>(pFrameFormat
->GetXObject().get().get()); // cached?
1285 xFrame
= pFrameFormat
1286 ? new NameLookupIsHard(*pFrameFormat
)
1287 : new NameLookupIsHard(&rDoc
);
1290 pFrameFormat
->SetXObject(static_cast<cppu::OWeakObject
*>(xFrame
.get()));
1292 // need a permanent Reference to initialize m_wThis
1293 xFrame
->SwXFrame::m_pImpl
->m_wThis
= uno::Reference
<XWeak
>(xFrame
.get());
1298 OUString
SwXFrame::getName()
1300 SolarMutexGuard aGuard
;
1301 SwFrameFormat
* pFormat
= GetFrameFormat();
1303 return pFormat
->GetName();
1304 if(!m_bIsDescriptor
)
1305 throw uno::RuntimeException();
1309 void SwXFrame::setName(const OUString
& rName
)
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("SwXFrame::setName(): Illegal object name. Duplicate name?");
1321 else if(m_bIsDescriptor
)
1324 throw uno::RuntimeException();
1327 uno::Reference
< beans::XPropertySetInfo
> SwXFrame::getPropertySetInfo()
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 SdrObject
*SwXFrame::GetOrCreateSdrObject(SwFlyFrameFormat
&rFormat
)
1358 SdrObject
* pObject
= rFormat
.FindSdrObject();
1361 SwDoc
*pDoc
= rFormat
.GetDoc();
1362 // #i52858# - method name changed
1363 SwFlyDrawContact
* pContactObject(rFormat
.GetOrCreateContact());
1364 pObject
= pContactObject
->GetMaster();
1366 const ::SwFormatSurround
& rSurround
= rFormat
.GetSurround();
1368 ( css::text::WrapTextMode_THROUGH
== rSurround
.GetSurround() &&
1369 !rFormat
.GetOpaque().GetValue() ) ? pDoc
->getIDocumentDrawModelAccess().GetHellId()
1370 : pDoc
->getIDocumentDrawModelAccess().GetHeavenId() );
1371 SwDrawModel
* pDrawModel
= pDoc
->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
1372 pDrawModel
->GetPage(0)->InsertObject( pObject
);
1378 static SwFrameFormat
*lcl_GetFrameFormat( const ::uno::Any
& rValue
, SwDoc
*pDoc
)
1380 SwFrameFormat
*pRet
= nullptr;
1381 SwDocShell
* pDocSh
= pDoc
->GetDocShell();
1387 SwStyleNameMapper::FillUIName(uTemp
, sStyle
,
1388 SwGetPoolIdFromName::FrmFmt
);
1389 SwDocStyleSheet
* pStyle
=
1390 static_cast<SwDocStyleSheet
*>(pDocSh
->GetStyleSheetPool()->Find(sStyle
,
1391 SfxStyleFamily::Frame
));
1393 pRet
= pStyle
->GetFrameFormat();
1399 void SwXFrame::setPropertyValue(const OUString
& rPropertyName
, const ::uno::Any
& _rValue
)
1401 SolarMutexGuard aGuard
;
1402 SwFrameFormat
* pFormat
= GetFrameFormat();
1403 if (!pFormat
&& !IsDescriptor())
1404 throw uno::RuntimeException();
1406 // Hack to support hidden property to transfer textDirection
1407 if(rPropertyName
== "FRMDirection")
1411 SwDocModifyAndUndoGuard
guard(*pFormat
);
1412 SvxFrameDirectionItem
aItem(SvxFrameDirection::Environment
, RES_FRAMEDIR
);
1413 aItem
.PutValue(_rValue
, 0);
1414 pFormat
->SetFormatAttr(aItem
);
1416 else // if(IsDescriptor())
1418 m_pProps
->SetProperty(o3tl::narrowing
<sal_uInt16
>(RES_FRAMEDIR
), 0, _rValue
);
1423 const ::SfxItemPropertyMapEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
1427 // Hack to skip the dummy CursorNotIgnoreTables property
1428 if (rPropertyName
!= "CursorNotIgnoreTables")
1429 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast <cppu::OWeakObject
*> (this));
1433 const sal_uInt8
nMemberId(pEntry
->nMemberId
);
1434 uno::Any
aValue(_rValue
);
1436 // check for needed metric translation
1437 if(pEntry
->nMoreFlags
& PropertyMoreFlags::METRIC_ITEM
)
1441 if(XATTR_FILLBMP_SIZEX
== pEntry
->nWID
|| XATTR_FILLBMP_SIZEY
== pEntry
->nWID
)
1443 // exception: If these ItemTypes are used, do not convert when these are negative
1444 // since this means they are intended as percent values
1445 sal_Int32 nValue
= 0;
1447 if(aValue
>>= nValue
)
1455 const SwDoc
* pDoc
= (IsDescriptor() ? m_pDoc
: pFormat
->GetDoc());
1456 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
1457 const MapUnit
eMapUnit(rPool
.GetMetric(pEntry
->nWID
));
1459 if(eMapUnit
!= MapUnit::Map100thMM
)
1461 SvxUnoConvertFromMM(eMapUnit
, aValue
);
1468 bool bNextFrame
= false;
1469 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
1470 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1472 SwDoc
* pDoc
= pFormat
->GetDoc();
1473 if ( ((m_eType
== FLYCNTTYPE_GRF
) && isGRFATR(pEntry
->nWID
)) ||
1474 (FN_PARAM_CONTOUR_PP
== pEntry
->nWID
) ||
1475 (FN_UNO_IS_AUTOMATIC_CONTOUR
== pEntry
->nWID
) ||
1476 (FN_UNO_IS_PIXEL_CONTOUR
== pEntry
->nWID
) )
1478 const ::SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1481 SwNodeIndex
aIdx(*pIdx
, 1);
1482 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
1483 if(pEntry
->nWID
== FN_PARAM_CONTOUR_PP
)
1485 drawing::PointSequenceSequence aParam
;
1486 if(!aValue
.hasValue())
1487 pNoText
->SetContour(nullptr);
1488 else if(aValue
>>= aParam
)
1490 tools::PolyPolygon
aPoly(o3tl::narrowing
<sal_uInt16
>(aParam
.getLength()));
1491 for(const ::drawing::PointSequence
& rPointSeq
: std::as_const(aParam
))
1493 sal_Int32 nPoints
= rPointSeq
.getLength();
1494 const ::awt::Point
* pPoints
= rPointSeq
.getConstArray();
1495 tools::Polygon
aSet( o3tl::narrowing
<sal_uInt16
>(nPoints
) );
1496 for(sal_Int32 j
= 0; j
< nPoints
; j
++)
1498 Point
aPoint(pPoints
[j
].X
, pPoints
[j
].Y
);
1499 aSet
.SetPoint(aPoint
, o3tl::narrowing
<sal_uInt16
>(j
));
1501 // Close polygon if it isn't closed already.
1502 aSet
.Optimize( PolyOptimizeFlags::CLOSE
);
1503 aPoly
.Insert( aSet
);
1505 pNoText
->SetContourAPI( &aPoly
);
1508 throw lang::IllegalArgumentException();
1510 else if(pEntry
->nWID
== FN_UNO_IS_AUTOMATIC_CONTOUR
)
1512 pNoText
->SetAutomaticContour( *o3tl::doAccess
<bool>(aValue
) );
1514 else if(pEntry
->nWID
== FN_UNO_IS_PIXEL_CONTOUR
)
1516 // The IsPixelContour property can only be set if there
1517 // is no contour, or if the contour has been set by the
1518 // API itself (or in other words, if the contour isn't
1520 if( pNoText
->HasContour_() && pNoText
->IsContourMapModeValid() )
1521 throw lang::IllegalArgumentException();
1523 pNoText
->SetPixelContour( *o3tl::doAccess
<bool>(aValue
) );
1528 SfxItemSet
aSet(pNoText
->GetSwAttrSet());
1529 m_pPropSet
->setPropertyValue(*pEntry
, aValue
, aSet
);
1530 pNoText
->SetAttr(aSet
);
1534 // New attribute Title
1535 else if( FN_UNO_TITLE
== pEntry
->nWID
)
1537 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
1540 // assure that <SdrObject> instance exists.
1541 GetOrCreateSdrObject(rFlyFormat
);
1542 rFlyFormat
.GetDoc()->SetFlyFrameTitle(rFlyFormat
, sTitle
);
1544 else if (pEntry
->nWID
== FN_UNO_TOOLTIP
)
1546 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
1548 aValue
>>= sTooltip
;
1549 rFlyFormat
.SetObjTooltip(sTooltip
);
1551 // New attribute Description
1552 else if( FN_UNO_DESCRIPTION
== pEntry
->nWID
)
1554 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
1555 OUString sDescription
;
1556 aValue
>>= sDescription
;
1557 // assure that <SdrObject> instance exists.
1558 GetOrCreateSdrObject(rFlyFormat
);
1559 rFlyFormat
.GetDoc()->SetFlyFrameDescription(rFlyFormat
, sDescription
);
1561 else if(FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
)
1563 SwFrameFormat
*pFrameFormat
= lcl_GetFrameFormat( aValue
, pFormat
->GetDoc() );
1565 throw lang::IllegalArgumentException();
1567 UnoActionContext
aAction(pFormat
->GetDoc());
1569 std::optional
<SfxItemSet
> pSet
;
1570 // #i31771#, #i25798# - No adjustment of
1571 // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ),
1572 // if document is currently in reading mode.
1573 if ( !pFormat
->GetDoc()->IsInReading() )
1575 // see SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point* pDocPos )
1576 SwFlyFrame
*pFly
= nullptr;
1577 if (auto pFlyFrameFormat
= dynamic_cast<const SwFlyFrameFormat
*>(pFormat
) )
1578 pFly
= pFlyFrameFormat
->GetFrame();
1581 if( const SwFormatAnchor
* pItem
= pFrameFormat
->GetItemIfSet( RES_ANCHOR
, false ))
1583 pSet
.emplace( pDoc
->GetAttrPool(), aFrameFormatSetRange
);
1584 pSet
->Put( *pItem
);
1585 if ( pFormat
->GetDoc()->GetEditShell() != nullptr
1586 && !sw_ChkAndSetNewAnchor( *pFly
, *pSet
) )
1594 pFormat
->GetDoc()->SetFrameFormatToFly( *pFormat
, *pFrameFormat
, pSet
? &*pSet
: nullptr );
1596 else if (FN_UNO_GRAPHIC_FILTER
== pEntry
->nWID
)
1600 SwDoc::GetGrfNms( *static_cast<SwFlyFrameFormat
*>(pFormat
), &sGrfName
, &sFltName
);
1601 aValue
>>= sFltName
;
1602 UnoActionContext
aAction(pFormat
->GetDoc());
1603 const ::SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1606 SwNodeIndex
aIdx(*pIdx
, 1);
1607 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
1610 throw uno::RuntimeException();
1612 SwPaM
aGrfPaM(*pGrfNode
);
1613 pFormat
->GetDoc()->getIDocumentContentOperations().ReRead(aGrfPaM
, sGrfName
, sFltName
, nullptr);
1616 else if (FN_UNO_GRAPHIC
== pEntry
->nWID
|| FN_UNO_GRAPHIC_URL
== pEntry
->nWID
)
1619 if (aValue
.has
<OUString
>())
1621 OUString aURL
= aValue
.get
<OUString
>();
1622 if (!aURL
.isEmpty())
1624 aGraphic
= vcl::graphic::loadFromURL(aURL
);
1627 else if (aValue
.has
<uno::Reference
<graphic::XGraphic
>>())
1629 uno::Reference
<graphic::XGraphic
> xGraphic
= aValue
.get
<uno::Reference
<graphic::XGraphic
>>();
1632 aGraphic
= Graphic(xGraphic
);
1636 if (!aGraphic
.IsNone())
1638 const ::SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1641 SwNodeIndex
aIdx(*pIdx
, 1);
1642 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
1645 throw uno::RuntimeException();
1647 SwPaM
aGrfPaM(*pGrfNode
);
1648 pFormat
->GetDoc()->getIDocumentContentOperations().ReRead(aGrfPaM
, OUString(), OUString(), &aGraphic
);
1652 else if (FN_UNO_REPLACEMENT_GRAPHIC
== pEntry
->nWID
|| FN_UNO_REPLACEMENT_GRAPHIC_URL
== pEntry
->nWID
)
1655 if (aValue
.has
<OUString
>())
1657 OUString aURL
= aValue
.get
<OUString
>();
1658 if (!aURL
.isEmpty())
1660 aGraphic
= vcl::graphic::loadFromURL(aURL
);
1663 else if (aValue
.has
<uno::Reference
<graphic::XGraphic
>>())
1665 uno::Reference
<graphic::XGraphic
> xGraphic
= aValue
.get
<uno::Reference
<graphic::XGraphic
>>();
1668 aGraphic
= Graphic(xGraphic
);
1672 if (!aGraphic
.IsNone())
1674 const ::SwFormatContent
* pCnt
= &pFormat
->GetContent();
1675 if ( pCnt
->GetContentIdx() && pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ] )
1677 SwOLENode
* pOleNode
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode();
1681 svt::EmbeddedObjectRef
&rEmbeddedObject
= pOleNode
->GetOLEObj().GetObject();
1682 rEmbeddedObject
.SetGraphic(aGraphic
, OUString() );
1687 else if((bNextFrame
= (rPropertyName
== UNO_NAME_CHAIN_NEXT_NAME
))
1688 || rPropertyName
== UNO_NAME_CHAIN_PREV_NAME
)
1690 OUString sChainName
;
1691 aValue
>>= sChainName
;
1692 if (sChainName
.isEmpty())
1695 pDoc
->Unchain(*pFormat
);
1698 const SwFormatChain
& aChain( pFormat
->GetChain() );
1699 SwFrameFormat
*pPrev
= aChain
.GetPrev();
1701 pDoc
->Unchain(*pPrev
);
1706 const size_t nCount
= pDoc
->GetFlyCount(FLYCNTTYPE_FRM
);
1708 SwFrameFormat
* pChain
= nullptr;
1709 for( size_t i
= 0; i
< nCount
; ++i
)
1711 SwFrameFormat
* pFormat2
= pDoc
->GetFlyNum(i
, FLYCNTTYPE_FRM
);
1712 if(sChainName
== pFormat2
->GetName() )
1720 SwFrameFormat
* pSource
= bNextFrame
? pFormat
: pChain
;
1721 SwFrameFormat
* pDest
= bNextFrame
? pChain
: pFormat
;
1722 pDoc
->Chain(*pSource
, *pDest
);
1726 else if(FN_UNO_Z_ORDER
== pEntry
->nWID
)
1728 sal_Int32 nZOrder
= - 1;
1731 // Don't set an explicit ZOrder on TextBoxes.
1732 if( nZOrder
>= 0 && !SwTextBoxHelper::isTextBox(pFormat
, RES_FLYFRMFMT
) )
1734 SdrObject
* pObject
=
1735 GetOrCreateSdrObject( static_cast<SwFlyFrameFormat
&>(*pFormat
) );
1736 SwDrawModel
*pDrawModel
= pDoc
->getIDocumentDrawModelAccess().GetDrawModel();
1737 pDrawModel
->GetPage(0)->
1738 SetObjectOrdNum(pObject
->GetOrdNum(), nZOrder
);
1741 else if(RES_ANCHOR
== pEntry
->nWID
&& MID_ANCHOR_ANCHORFRAME
== nMemberId
)
1744 uno::Reference
<text::XTextFrame
> xFrame
;
1745 if(aValue
>>= xFrame
)
1747 SwXFrame
* pFrame
= dynamic_cast<SwXFrame
*>(xFrame
.get());
1748 if(pFrame
&& this != pFrame
&& pFrame
->GetFrameFormat() && pFrame
->GetFrameFormat()->GetDoc() == pDoc
)
1750 SfxItemSetFixed
<RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1> aSet( pDoc
->GetAttrPool() );
1751 aSet
.SetParent(&pFormat
->GetAttrSet());
1752 SwFormatAnchor aAnchor
= static_cast<const SwFormatAnchor
&>(aSet
.Get(pEntry
->nWID
));
1754 SwPosition
aPos(*pFrame
->GetFrameFormat()->GetContent().GetContentIdx());
1755 aAnchor
.SetAnchor(&aPos
);
1756 aAnchor
.SetType(RndStdIds::FLY_AT_FLY
);
1758 pDoc
->SetFlyFrameAttr( *pFormat
, aSet
);
1763 throw lang::IllegalArgumentException();
1767 // standard UNO API write attributes
1768 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
1770 <RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1,
1771 RES_UNKNOWNATR_CONTAINER
, RES_UNKNOWNATR_CONTAINER
,
1773 // FillAttribute support
1774 XATTR_FILL_FIRST
, XATTR_FILL_LAST
>
1775 aSet( pDoc
->GetAttrPool());
1778 aSet
.SetParent(&pFormat
->GetAttrSet());
1780 if(RES_BACKGROUND
== pEntry
->nWID
)
1782 const SwAttrSet
& rSet
= pFormat
->GetAttrSet();
1783 const std::unique_ptr
<SvxBrushItem
> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet
, RES_BACKGROUND
, true, pDoc
->IsInXMLImport()));
1784 std::unique_ptr
<SvxBrushItem
> aChangedBrushItem(aOriginalBrushItem
->Clone());
1786 aChangedBrushItem
->PutValue(aValue
, nMemberId
);
1788 if(*aChangedBrushItem
!= *aOriginalBrushItem
)
1790 setSvxBrushItemAsFillAttributesToTargetSet(*aChangedBrushItem
, aSet
);
1791 pFormat
->GetDoc()->SetFlyFrameAttr( *pFormat
, aSet
);
1796 else if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
1798 drawing::BitmapMode eMode
;
1800 if(!(aValue
>>= eMode
))
1802 sal_Int32 nMode
= 0;
1804 if(!(aValue
>>= nMode
))
1806 throw lang::IllegalArgumentException();
1809 eMode
= static_cast<drawing::BitmapMode
>(nMode
);
1812 aSet
.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH
== eMode
));
1813 aSet
.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT
== eMode
));
1814 pFormat
->GetDoc()->SetFlyFrameAttr( *pFormat
, aSet
);
1822 // when named items get set, replace these with the NameOrIndex items
1823 // which exist already in the pool
1824 switch(pEntry
->nWID
)
1826 case XATTR_FILLGRADIENT
:
1827 case XATTR_FILLHATCH
:
1828 case XATTR_FILLBITMAP
:
1829 case XATTR_FILLFLOATTRANSPARENCE
:
1833 if(!(aValue
>>= aTempName
))
1835 throw lang::IllegalArgumentException();
1838 bDone
= SvxShape::SetFillAttribute(pEntry
->nWID
, aTempName
, aSet
);
1850 switch(pEntry
->nWID
)
1852 case XATTR_FILLBITMAP
:
1854 Graphic aNullGraphic
;
1855 XFillBitmapItem
aXFillBitmapItem(std::move(aNullGraphic
));
1857 aXFillBitmapItem
.PutValue(aValue
, nMemberId
);
1858 aSet
.Put(aXFillBitmapItem
);
1877 m_pPropSet
->setPropertyValue(*pEntry
, aValue
, aSet
);
1880 if(RES_ANCHOR
== pEntry
->nWID
&& MID_ANCHOR_ANCHORTYPE
== nMemberId
)
1882 SwFormatAnchor aAnchor
= static_cast<const SwFormatAnchor
&>(aSet
.Get(pEntry
->nWID
));
1883 if(aAnchor
.GetAnchorId() == RndStdIds::FLY_AT_FLY
)
1885 const ::SwNode
* pAnchorNode
= aAnchor
.GetAnchorNode();
1886 SwFrameFormat
* pFlyFormat
= pAnchorNode
? pAnchorNode
->GetFlyFormat() : nullptr;
1887 if(!pFlyFormat
|| pFlyFormat
->Which() == RES_DRAWFRMFMT
)
1889 lang::IllegalArgumentException aExcept
;
1890 aExcept
.Message
= "Anchor to frame: no frame found";
1895 SwPosition aPos
= *aAnchor
.GetContentAnchor();
1896 aPos
.Assign( *pFlyFormat
->GetContent().GetContentIdx() );
1897 aAnchor
.SetAnchor(&aPos
);
1901 else if ((aAnchor
.GetAnchorId() != RndStdIds::FLY_AT_PAGE
) &&
1902 !aAnchor
.GetAnchorNode())
1904 SwNode
& rNode
= pDoc
->GetNodes().GetEndOfContent();
1906 aPam
.Move( fnMoveBackward
, GoInDoc
);
1907 aAnchor
.SetAnchor( aPam
.Start() );
1911 // #i31771#, #i25798# - No adjustment of
1912 // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ),
1913 // if document is currently in reading mode.
1914 if ( !pFormat
->GetDoc()->IsInReading() )
1916 // see SwFEShell::SetFlyFrameAttr( SfxItemSet& rSet )
1917 SwFlyFrame
*pFly
= nullptr;
1918 if (auto pFrameFormat
= dynamic_cast<SwFlyFrameFormat
*>( pFormat
) )
1919 pFly
= pFrameFormat
->GetFrame();
1922 if( const SwFormatAnchor
* pItem
= aSet
.GetItemIfSet( RES_ANCHOR
, false ))
1925 if ( pFormat
->GetDoc()->GetEditShell() != nullptr )
1927 sw_ChkAndSetNewAnchor( *pFly
, aSet
);
1933 pFormat
->GetDoc()->SetFlyFrameAttr( *pFormat
, aSet
);
1935 else if(FN_UNO_CLSID
== pEntry
->nWID
|| FN_UNO_STREAM_NAME
== pEntry
->nWID
|| FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
1937 throw lang::IllegalArgumentException();
1941 SwDocModifyAndUndoGuard
guard(*pFormat
);
1942 pFormat
->SetFormatAttr(aSet
);
1946 else // if(IsDescriptor())
1948 m_pProps
->SetProperty(pEntry
->nWID
, nMemberId
, aValue
);
1949 if( FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
)
1951 OUString sStyleName
;
1952 aValue
>>= sStyleName
;
1955 uno::Any aAny
= mxStyleFamily
->getByName ( sStyleName
);
1956 aAny
>>= mxStyleData
;
1958 catch ( container::NoSuchElementException
const & )
1961 catch ( lang::WrappedTargetException
const & )
1964 catch ( uno::RuntimeException
const & )
1968 else if (FN_UNO_DRAW_ASPECT
== pEntry
->nWID
)
1970 OUString sAspect
= "";
1973 if (sAspect
== "Icon")
1974 m_nDrawAspect
= embed::Aspects::MSOLE_ICON
;
1975 else if (sAspect
== "Content")
1976 m_nDrawAspect
= embed::Aspects::MSOLE_CONTENT
;
1978 else if (FN_UNO_VISIBLE_AREA_WIDTH
== pEntry
->nWID
)
1980 OUString sAspect
= "";
1982 m_nVisibleAreaWidth
= sAspect
.toInt64();
1984 else if (FN_UNO_VISIBLE_AREA_HEIGHT
== pEntry
->nWID
)
1986 OUString sAspect
= "";
1988 m_nVisibleAreaHeight
= sAspect
.toInt64();
1995 /// Redirect error popups to developer warnings for the duration of the UNO API call.
1996 class DisplayLockGuard
2003 m_bLock
= ErrorRegistry::GetLock();
2004 ErrorRegistry::SetLock(true);
2007 ~DisplayLockGuard() { ErrorRegistry::SetLock(m_bLock
); }
2011 uno::Any
SwXFrame::getPropertyValue(const OUString
& rPropertyName
)
2013 SolarMutexGuard aGuard
;
2014 DisplayLockGuard aDisplayGuard
;
2016 SwFrameFormat
* pFormat
= GetFrameFormat();
2017 const SfxItemPropertyMapEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
2019 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2021 const sal_uInt8
nMemberId(pEntry
->nMemberId
);
2023 if(FN_UNO_ANCHOR_TYPES
== pEntry
->nWID
)
2025 uno::Sequence
<text::TextContentAnchorType
> aTypes
2027 text::TextContentAnchorType_AT_PARAGRAPH
,
2028 text::TextContentAnchorType_AS_CHARACTER
,
2029 text::TextContentAnchorType_AT_PAGE
,
2030 text::TextContentAnchorType_AT_FRAME
,
2031 text::TextContentAnchorType_AT_CHARACTER
2037 if( ((m_eType
== FLYCNTTYPE_GRF
) || (m_eType
== FLYCNTTYPE_OLE
)) &&
2038 (isGRFATR(pEntry
->nWID
) ||
2039 pEntry
->nWID
== FN_PARAM_CONTOUR_PP
||
2040 pEntry
->nWID
== FN_UNO_IS_AUTOMATIC_CONTOUR
||
2041 pEntry
->nWID
== FN_UNO_IS_PIXEL_CONTOUR
))
2043 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2046 SwNodeIndex
aIdx(*pIdx
, 1);
2047 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
2048 if(pEntry
->nWID
== FN_PARAM_CONTOUR_PP
)
2050 tools::PolyPolygon aContour
;
2051 if( pNoText
->GetContourAPI( aContour
) )
2053 drawing::PointSequenceSequence
aPtSeq(aContour
.Count());
2054 drawing::PointSequence
* pPSeq
= aPtSeq
.getArray();
2055 for(sal_uInt16 i
= 0; i
< aContour
.Count(); i
++)
2057 const tools::Polygon
& rPoly
= aContour
.GetObject(i
);
2058 pPSeq
[i
].realloc(rPoly
.GetSize());
2059 awt::Point
* pPoints
= pPSeq
[i
].getArray();
2060 for(sal_uInt16 j
= 0; j
< rPoly
.GetSize(); j
++)
2062 const Point
& rPoint
= rPoly
.GetPoint(j
);
2063 pPoints
[j
].X
= rPoint
.X();
2064 pPoints
[j
].Y
= rPoint
.Y();
2070 else if(pEntry
->nWID
== FN_UNO_IS_AUTOMATIC_CONTOUR
)
2072 aAny
<<= pNoText
->HasAutomaticContour();
2074 else if(pEntry
->nWID
== FN_UNO_IS_PIXEL_CONTOUR
)
2076 aAny
<<= pNoText
->IsPixelContour();
2080 const SfxItemSet
& aSet(pNoText
->GetSwAttrSet());
2081 m_pPropSet
->getPropertyValue(*pEntry
, aSet
, aAny
);
2085 else if (FN_UNO_REPLACEMENT_GRAPHIC
== pEntry
->nWID
)
2087 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2088 uno::Reference
<graphic::XGraphic
> xGraphic
;
2092 SwNodeIndex
aIdx(*pIdx
, 1);
2093 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
2095 throw uno::RuntimeException();
2097 const GraphicObject
* pGraphicObject
= pGrfNode
->GetReplacementGrfObj();
2101 xGraphic
= pGraphicObject
->GetGraphic().GetXGraphic();
2106 else if( FN_UNO_GRAPHIC_FILTER
== pEntry
->nWID
)
2109 SwDoc::GetGrfNms( *static_cast<SwFlyFrameFormat
*>(pFormat
), nullptr, &sFltName
);
2112 else if( FN_UNO_GRAPHIC_URL
== pEntry
->nWID
)
2114 throw uno::RuntimeException("Getting from this property is not supported");
2116 else if( FN_UNO_GRAPHIC
== pEntry
->nWID
)
2118 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2121 SwNodeIndex
aIdx(*pIdx
, 1);
2122 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
2124 throw uno::RuntimeException();
2125 aAny
<<= pGrfNode
->GetGrf().GetXGraphic();
2128 else if( FN_UNO_TRANSFORMED_GRAPHIC
== pEntry
->nWID
2129 || FN_UNO_GRAPHIC_PREVIEW
== pEntry
->nWID
)
2131 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2134 SwNodeIndex
aIdx(*pIdx
, 1);
2135 SwGrfNode
* pGrfNode
= aIdx
.GetNode().GetGrfNode();
2137 throw uno::RuntimeException();
2139 SwDoc
* pDoc
= pFormat
->GetDoc();
2142 if (const SwEditShell
* pEditShell
= pDoc
->GetEditShell())
2144 SwFrame
* pCurrFrame
= pEditShell
->GetCurrFrame(false);
2145 GraphicAttr aGraphicAttr
;
2146 pGrfNode
->GetGraphicAttr( aGraphicAttr
, pCurrFrame
);
2147 const GraphicObject aGraphicObj
= pGrfNode
->GetGrfObj();
2149 awt::Size aFrameSize
= getSize();
2150 Size
aSize100thmm(aFrameSize
.Width
, aFrameSize
.Height
);
2151 Size aSize
= OutputDevice::LogicToLogic(aSize100thmm
, MapMode(MapUnit::Map100thMM
), aGraphicObj
.GetPrefMapMode());
2153 if (FN_UNO_GRAPHIC_PREVIEW
== pEntry
->nWID
)
2155 double fX
= static_cast<double>(aSize
.getWidth()) / 1280;
2156 double fY
= static_cast<double>(aSize
.getHeight()) / 720;
2157 double fFactor
= fX
> fY
? fX
: fY
;
2160 aSize
.setWidth(aSize
.getWidth() / fFactor
);
2161 aSize
.setHeight(aSize
.getHeight() / fFactor
);
2165 Graphic aGraphic
= aGraphicObj
.GetTransformedGraphic(aSize
, aGraphicObj
.GetPrefMapMode(), aGraphicAttr
);
2166 aAny
<<= aGraphic
.GetXGraphic();
2171 else if(FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
)
2173 aAny
<<= SwStyleNameMapper::GetProgName(pFormat
->DerivedFrom()->GetName(), SwGetPoolIdFromName::FrmFmt
);
2176 else if( FN_UNO_TITLE
== pEntry
->nWID
)
2178 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2179 // assure that <SdrObject> instance exists.
2180 GetOrCreateSdrObject(rFlyFormat
);
2181 aAny
<<= rFlyFormat
.GetObjTitle();
2183 else if (pEntry
->nWID
== FN_UNO_TOOLTIP
)
2185 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2186 aAny
<<= rFlyFormat
.GetObjTooltip();
2188 // New attribute Description
2189 else if( FN_UNO_DESCRIPTION
== pEntry
->nWID
)
2191 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2192 // assure that <SdrObject> instance exists.
2193 GetOrCreateSdrObject(rFlyFormat
);
2194 aAny
<<= rFlyFormat
.GetObjDescription();
2196 else if(m_eType
== FLYCNTTYPE_GRF
&&
2197 (rPropertyName
== UNO_NAME_ACTUAL_SIZE
))
2199 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2202 SwNodeIndex
aIdx(*pIdx
, 1);
2203 Size aActSize
= aIdx
.GetNode().GetNoTextNode()->GetTwipSize();
2205 aTmp
.Width
= convertTwipToMm100(aActSize
.Width());
2206 aTmp
.Height
= convertTwipToMm100(aActSize
.Height());
2210 else if(FN_PARAM_LINK_DISPLAY_NAME
== pEntry
->nWID
)
2212 aAny
<<= pFormat
->GetName();
2214 else if(FN_UNO_Z_ORDER
== pEntry
->nWID
)
2216 const SdrObject
* pObj
= pFormat
->FindRealSdrObject();
2217 if( pObj
== nullptr )
2218 pObj
= pFormat
->FindSdrObject();
2221 aAny
<<= static_cast<sal_Int32
>(pObj
->GetOrdNum());
2224 else if(FN_UNO_CLSID
== pEntry
->nWID
|| FN_UNO_MODEL
== pEntry
->nWID
||
2225 FN_UNO_COMPONENT
== pEntry
->nWID
||FN_UNO_STREAM_NAME
== pEntry
->nWID
||
2226 FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
2228 SwDoc
* pDoc
= pFormat
->GetDoc();
2229 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
2230 OSL_ENSURE( pCnt
->GetContentIdx() &&
2231 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
2232 GetIndex() + 1 ]->GetOLENode(), "no OLE-Node?");
2234 SwOLENode
* pOleNode
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()
2235 ->GetIndex() + 1 ]->GetOLENode();
2236 uno::Reference
< embed::XEmbeddedObject
> xIP
= pOleNode
->GetOLEObj().GetOleRef();
2239 SvGlobalName
aClassName( xIP
->getClassID() );
2240 aHexCLSID
= aClassName
.GetHexName();
2241 if(FN_UNO_CLSID
!= pEntry
->nWID
)
2243 if ( svt::EmbeddedObjectRef::TryRunningState( xIP
) )
2245 uno::Reference
< lang::XComponent
> xComp( xIP
->getComponent(), uno::UNO_QUERY
);
2246 uno::Reference
< frame::XModel
> xModel( xComp
, uno::UNO_QUERY
);
2247 if ( FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
2249 // when exposing the EmbeddedObject, ensure it has a client site
2250 OSL_ENSURE( pDoc
->GetDocShell(), "no doc shell => no client site" );
2251 if ( pDoc
->GetDocShell() )
2252 pDoc
->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP
, embed::Aspects::MSOLE_CONTENT
) );
2255 else if ( xModel
.is() )
2257 else if ( FN_UNO_COMPONENT
== pEntry
->nWID
)
2263 if(FN_UNO_CLSID
== pEntry
->nWID
)
2265 else if(FN_UNO_STREAM_NAME
== pEntry
->nWID
)
2267 aAny
<<= pOleNode
->GetOLEObj().GetCurrentPersistName();
2269 else if(FN_EMBEDDED_OBJECT
== pEntry
->nWID
)
2271 aAny
<<= pOleNode
->GetOLEObj().GetOleRef();
2274 else if(WID_LAYOUT_SIZE
== pEntry
->nWID
)
2276 // format document completely in order to get correct value (no EditShell for ole embedded case)
2277 if (SwEditShell
* pEditShell
= pFormat
->GetDoc()->GetEditShell())
2278 pEditShell
->CalcLayout();
2280 SwFrame
* pTmpFrame
= SwIterator
<SwFrame
,SwFormat
>( *pFormat
).First();
2283 OSL_ENSURE( pTmpFrame
->isFrameAreaDefinitionValid(), "frame not valid" );
2284 const SwRect
&rRect
= pTmpFrame
->getFrameArea();
2285 Size aMM100Size
= o3tl::convert(
2286 Size( rRect
.Width(), rRect
.Height() ),
2287 o3tl::Length::twip
, o3tl::Length::mm100
);
2288 aAny
<<= awt::Size( aMM100Size
.Width(), aMM100Size
.Height() );
2291 else if(pEntry
->nWID
== FN_UNO_PARENT_TEXT
)
2293 if (!m_xParentText
.is())
2295 const SwFormatAnchor
& rFormatAnchor
= pFormat
->GetAnchor();
2296 if (rFormatAnchor
.GetAnchorNode())
2298 m_xParentText
= sw::CreateParentXText(*pFormat
->GetDoc(), *rFormatAnchor
.GetContentAnchor());
2301 aAny
<<= m_xParentText
;
2305 // standard UNO API read attributes
2306 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
2307 const SwAttrSet
& rSet
= pFormat
->GetAttrSet();
2310 if(RES_BACKGROUND
== pEntry
->nWID
)
2312 const std::unique_ptr
<SvxBrushItem
> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet
, RES_BACKGROUND
));
2314 if(!aOriginalBrushItem
->QueryValue(aAny
, nMemberId
))
2316 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
2321 else if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
2323 if (rSet
.Get(XATTR_FILLBMP_TILE
).GetValue())
2325 aAny
<<= drawing::BitmapMode_REPEAT
;
2327 else if (rSet
.Get(XATTR_FILLBMP_STRETCH
).GetValue())
2329 aAny
<<= drawing::BitmapMode_STRETCH
;
2333 aAny
<<= drawing::BitmapMode_NO_REPEAT
;
2341 m_pPropSet
->getPropertyValue(*pEntry
, rSet
, aAny
);
2345 else if(IsDescriptor())
2348 throw uno::RuntimeException();
2349 if(WID_LAYOUT_SIZE
!= pEntry
->nWID
) // there is no LayoutSize in a descriptor
2351 const uno::Any
* pAny
= nullptr;
2352 if (!m_pProps
->GetProperty(pEntry
->nWID
, nMemberId
, pAny
))
2353 aAny
= mxStyleData
->getPropertyValue( rPropertyName
);
2359 throw uno::RuntimeException();
2361 if (pEntry
->aType
== ::cppu::UnoType
<sal_Int16
>::get() && pEntry
->aType
!= aAny
.getValueType())
2363 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2364 sal_Int32 nValue
= 0;
2366 aAny
<<= static_cast<sal_Int16
>(nValue
);
2369 // check for needed metric translation
2370 if(pEntry
->nMoreFlags
& PropertyMoreFlags::METRIC_ITEM
)
2374 if(XATTR_FILLBMP_SIZEX
== pEntry
->nWID
|| XATTR_FILLBMP_SIZEY
== pEntry
->nWID
)
2376 // exception: If these ItemTypes are used, do not convert when these are negative
2377 // since this means they are intended as percent values
2378 sal_Int32 nValue
= 0;
2388 const SwDoc
* pDoc
= (IsDescriptor() ? m_pDoc
: GetFrameFormat()->GetDoc());
2389 const SfxItemPool
& rPool
= pDoc
->GetAttrPool();
2390 const MapUnit
eMapUnit(rPool
.GetMetric(pEntry
->nWID
));
2392 if(eMapUnit
!= MapUnit::Map100thMM
)
2394 SvxUnoConvertToMM(eMapUnit
, aAny
);
2402 void SwXFrame::addPropertyChangeListener(const OUString
& /*PropertyName*/,
2403 const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/)
2405 OSL_FAIL("not implemented");
2408 void SwXFrame::removePropertyChangeListener(const OUString
& /*PropertyName*/,
2409 const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/)
2411 OSL_FAIL("not implemented");
2414 void SwXFrame::addVetoableChangeListener(const OUString
& /*PropertyName*/,
2415 const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/)
2417 OSL_FAIL("not implemented");
2420 void SwXFrame::removeVetoableChangeListener(
2421 const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/)
2423 OSL_FAIL("not implemented");
2426 beans::PropertyState
SwXFrame::getPropertyState( const OUString
& rPropertyName
)
2428 SolarMutexGuard aGuard
;
2429 uno::Sequence
< OUString
> aPropertyNames
{ rPropertyName
};
2430 uno::Sequence
< beans::PropertyState
> aStates
= getPropertyStates(aPropertyNames
);
2431 return aStates
.getConstArray()[0];
2434 uno::Sequence
< beans::PropertyState
> SwXFrame::getPropertyStates(
2435 const uno::Sequence
< OUString
>& aPropertyNames
)
2437 SolarMutexGuard aGuard
;
2438 uno::Sequence
< beans::PropertyState
> aStates(aPropertyNames
.getLength());
2439 auto [pStates
, end
] = asNonConstRange(aStates
);
2440 SwFrameFormat
* pFormat
= GetFrameFormat();
2443 const OUString
* pNames
= aPropertyNames
.getConstArray();
2444 const SwAttrSet
& rFormatSet
= pFormat
->GetAttrSet();
2445 for(int i
= 0; i
< aPropertyNames
.getLength(); i
++)
2447 const SfxItemPropertyMapEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(pNames
[i
]);
2449 throw beans::UnknownPropertyException("Unknown property: " + pNames
[i
], static_cast < cppu::OWeakObject
* > ( this ) );
2451 if(pEntry
->nWID
== FN_UNO_ANCHOR_TYPES
||
2452 pEntry
->nWID
== FN_PARAM_LINK_DISPLAY_NAME
||
2453 FN_UNO_FRAME_STYLE_NAME
== pEntry
->nWID
||
2454 FN_UNO_GRAPHIC
== pEntry
->nWID
||
2455 FN_UNO_GRAPHIC_URL
== pEntry
->nWID
||
2456 FN_UNO_GRAPHIC_FILTER
== pEntry
->nWID
||
2457 FN_UNO_ACTUAL_SIZE
== pEntry
->nWID
||
2458 FN_UNO_ALTERNATIVE_TEXT
== pEntry
->nWID
)
2460 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2462 else if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
2464 if(SfxItemState::SET
== rFormatSet
.GetItemState(XATTR_FILLBMP_STRETCH
, false)
2465 || SfxItemState::SET
== rFormatSet
.GetItemState(XATTR_FILLBMP_TILE
, false))
2467 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2471 pStates
[i
] = beans::PropertyState_AMBIGUOUS_VALUE
;
2474 // for FlyFrames we need to mark the used properties from type RES_BACKGROUND
2475 // as beans::PropertyState_DIRECT_VALUE to let users of this property call
2476 // getPropertyValue where the member properties will be mapped from the
2477 // fill attributes to the according SvxBrushItem entries
2478 else if (RES_BACKGROUND
== pEntry
->nWID
)
2480 if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFormatSet
, pEntry
->nMemberId
))
2481 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2483 pStates
[i
] = beans::PropertyState_DEFAULT_VALUE
;
2487 if ((m_eType
== FLYCNTTYPE_GRF
) && isGRFATR(pEntry
->nWID
))
2489 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2492 SwNodeIndex
aIdx(*pIdx
, 1);
2493 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
2494 const SfxItemSet
& aSet(pNoText
->GetSwAttrSet());
2495 aSet
.GetItemState(pEntry
->nWID
);
2496 if(SfxItemState::SET
== aSet
.GetItemState( pEntry
->nWID
, false ))
2497 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2502 if(SfxItemState::SET
== rFormatSet
.GetItemState( pEntry
->nWID
, false ))
2503 pStates
[i
] = beans::PropertyState_DIRECT_VALUE
;
2505 pStates
[i
] = beans::PropertyState_DEFAULT_VALUE
;
2510 else if(IsDescriptor())
2512 std::fill(pStates
, end
, beans::PropertyState_DIRECT_VALUE
);
2515 throw uno::RuntimeException();
2519 void SwXFrame::setPropertyToDefault( const OUString
& rPropertyName
)
2521 SolarMutexGuard aGuard
;
2522 SwFrameFormat
* pFormat
= GetFrameFormat();
2525 const SfxItemPropertyMapEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
2527 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2528 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
2529 throw uno::RuntimeException("setPropertyToDefault: property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2531 if(OWN_ATTR_FILLBMP_MODE
== pEntry
->nWID
)
2533 SwDoc
* pDoc
= pFormat
->GetDoc();
2534 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aSet(pDoc
->GetAttrPool());
2535 aSet
.SetParent(&pFormat
->GetAttrSet());
2537 aSet
.ClearItem(XATTR_FILLBMP_STRETCH
);
2538 aSet
.ClearItem(XATTR_FILLBMP_TILE
);
2540 SwDocModifyAndUndoGuard
guard(*pFormat
);
2541 pFormat
->SetFormatAttr(aSet
);
2543 else if( pEntry
->nWID
&&
2544 pEntry
->nWID
!= FN_UNO_ANCHOR_TYPES
&&
2545 pEntry
->nWID
!= FN_PARAM_LINK_DISPLAY_NAME
)
2547 if ( (m_eType
== FLYCNTTYPE_GRF
) && isGRFATR(pEntry
->nWID
) )
2549 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
2552 SwNodeIndex
aIdx(*pIdx
, 1);
2553 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
2555 SfxItemSet
aSet(pNoText
->GetSwAttrSet());
2556 aSet
.ClearItem(pEntry
->nWID
);
2557 pNoText
->SetAttr(aSet
);
2562 else if( FN_UNO_TITLE
== pEntry
->nWID
)
2564 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2565 // assure that <SdrObject> instance exists.
2566 GetOrCreateSdrObject(rFlyFormat
);
2567 rFlyFormat
.GetDoc()->SetFlyFrameTitle(rFlyFormat
, OUString());
2569 // New attribute Description
2570 else if( FN_UNO_DESCRIPTION
== pEntry
->nWID
)
2572 SwFlyFrameFormat
& rFlyFormat
= dynamic_cast<SwFlyFrameFormat
&>(*pFormat
);
2573 // assure that <SdrObject> instance exists.
2574 GetOrCreateSdrObject(rFlyFormat
);
2575 rFlyFormat
.GetDoc()->SetFlyFrameDescription(rFlyFormat
, OUString());
2577 else if (rPropertyName
!= UNO_NAME_ANCHOR_TYPE
)
2579 SwDoc
* pDoc
= pFormat
->GetDoc();
2580 SfxItemSetFixed
<RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1> aSet( pDoc
->GetAttrPool() );
2581 aSet
.SetParent(&pFormat
->GetAttrSet());
2582 aSet
.ClearItem(pEntry
->nWID
);
2583 SwDocModifyAndUndoGuard
guard(*pFormat
);
2584 pFormat
->SetFormatAttr(aSet
);
2589 bool bNextFrame
= rPropertyName
== UNO_NAME_CHAIN_NEXT_NAME
;
2590 if( bNextFrame
|| rPropertyName
== UNO_NAME_CHAIN_PREV_NAME
)
2592 SwDoc
* pDoc
= pFormat
->GetDoc();
2594 pDoc
->Unchain(*pFormat
);
2597 const SwFormatChain
& aChain( pFormat
->GetChain() );
2598 SwFrameFormat
*pPrev
= aChain
.GetPrev();
2600 pDoc
->Unchain(*pPrev
);
2605 else if(!IsDescriptor())
2606 throw uno::RuntimeException();
2610 uno::Any
SwXFrame::getPropertyDefault( const OUString
& rPropertyName
)
2612 SolarMutexGuard aGuard
;
2614 SwFrameFormat
* pFormat
= GetFrameFormat();
2617 const SfxItemPropertyMapEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName(rPropertyName
);
2619 throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2621 if ( pEntry
->nWID
< RES_FRMATR_END
)
2623 const SfxPoolItem
& rDefItem
=
2624 pFormat
->GetDoc()->GetAttrPool().GetDefaultItem(pEntry
->nWID
);
2625 rDefItem
.QueryValue(aRet
, pEntry
->nMemberId
);
2629 else if(!IsDescriptor())
2630 throw uno::RuntimeException();
2634 void SAL_CALL
SwXFrame::addEventListener(
2635 const uno::Reference
<lang::XEventListener
> & xListener
)
2637 std::unique_lock
aGuard(m_pImpl
->m_Mutex
);
2638 m_pImpl
->m_EventListeners
.addInterface(aGuard
, xListener
);
2641 void SAL_CALL
SwXFrame::removeEventListener(
2642 const uno::Reference
<lang::XEventListener
> & xListener
)
2644 std::unique_lock
aGuard(m_pImpl
->m_Mutex
);
2645 m_pImpl
->m_EventListeners
.removeInterface(aGuard
, xListener
);
2648 void SwXFrame::DisposeInternal()
2650 mxStyleData
.clear();
2651 mxStyleFamily
.clear();
2653 uno::Reference
<uno::XInterface
> const xThis(m_pImpl
->m_wThis
);
2655 { // fdo#72695: if UNO object is already dead, don't revive it with event
2659 lang::EventObject
const ev(xThis
);
2660 std::unique_lock
aGuard(m_pImpl
->m_Mutex
);
2661 m_pImpl
->m_EventListeners
.disposeAndClear(aGuard
, ev
);
2663 m_pFrameFormat
= nullptr;
2666 void SwXFrame::Notify(const SfxHint
& rHint
)
2668 if(rHint
.GetId() == SfxHintId::Dying
)
2672 void SwXFrame::dispose()
2674 SolarMutexGuard aGuard
;
2675 SwFrameFormat
* pFormat
= GetFrameFormat();
2680 SdrObject
* pObj
= pFormat
->FindSdrObject();
2681 // OD 11.09.2003 #112039# - add condition to perform delete of
2682 // format/anchor sign, not only if the object is inserted, but also
2683 // if a contact object is registered, which isn't in the destruction.
2685 ( pObj
->IsInserted() ||
2686 ( pObj
->GetUserCall() &&
2687 !static_cast<SwContact
*>(pObj
->GetUserCall())->IsInDTOR() ) ) )
2689 const SwFormatAnchor
& rFormatAnchor
= pFormat
->GetAnchor();
2690 if (rFormatAnchor
.GetAnchorId() == RndStdIds::FLY_AS_CHAR
)
2692 SwTextNode
*pTextNode
= rFormatAnchor
.GetAnchorNode()->GetTextNode();
2693 const sal_Int32 nIdx
= rFormatAnchor
.GetAnchorContentOffset();
2694 pTextNode
->DeleteAttributes( RES_TXTATR_FLYCNT
, nIdx
, nIdx
);
2697 pFormat
->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(pFormat
);
2702 uno::Reference
< text::XTextRange
> SwXFrame::getAnchor()
2704 SolarMutexGuard aGuard
;
2705 rtl::Reference
<SwXTextRange
> aRef
;
2706 SwFrameFormat
* pFormat
= GetFrameFormat();
2708 throw uno::RuntimeException();
2710 const SwFormatAnchor
& rAnchor
= pFormat
->GetAnchor();
2711 // return an anchor for non-page bound frames
2712 // and for page bound frames that have a page no == NULL and a content position
2713 if ((rAnchor
.GetAnchorId() != RndStdIds::FLY_AT_PAGE
) ||
2714 (rAnchor
.GetAnchorNode() && !rAnchor
.GetPageNum()))
2716 if (rAnchor
.GetAnchorId() == RndStdIds::FLY_AT_PARA
)
2717 { // ensure that SwXTextRange has SwContentIndex
2718 aRef
= SwXTextRange::CreateXTextRange(*pFormat
->GetDoc(), SwPosition(*rAnchor
.GetAnchorNode()), nullptr);
2722 aRef
= SwXTextRange::CreateXTextRange(*pFormat
->GetDoc(), *rAnchor
.GetContentAnchor(), nullptr);
2729 void SwXFrame::ResetDescriptor()
2731 m_bIsDescriptor
= false;
2732 mxStyleData
.clear();
2733 mxStyleFamily
.clear();
2737 void SwXFrame::attachToRange(uno::Reference
<text::XTextRange
> const& xTextRange
,
2738 SwPaM
const*const pCopySource
)
2740 SolarMutexGuard aGuard
;
2742 throw uno::RuntimeException();
2743 SwXTextRange
* pRange
= dynamic_cast<SwXTextRange
*>(xTextRange
.get());
2744 OTextCursorHelper
* pCursor
= dynamic_cast<OTextCursorHelper
*>(xTextRange
.get());
2746 SwDoc
* pDoc
= pRange
? &pRange
->GetDoc() : pCursor
? pCursor
->GetDoc() : nullptr;
2748 throw lang::IllegalArgumentException();
2750 SwUnoInternalPaM
aIntPam(*pDoc
);
2751 // this now needs to return TRUE
2752 ::sw::XTextRangeToSwPaM(aIntPam
, xTextRange
);
2754 SwNode
& rNode
= pDoc
->GetNodes().GetEndOfContent();
2756 aPam
.Move( fnMoveBackward
, GoInDoc
);
2758 SfxItemSetFixed
<RES_GRFATR_BEGIN
, RES_GRFATR_END
-1> aGrSet(pDoc
->GetAttrPool());
2761 RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
2762 RES_UNKNOWNATR_CONTAINER
, RES_UNKNOWNATR_CONTAINER
,
2764 // FillAttribute support
2765 XATTR_FILL_FIRST
, XATTR_FILL_LAST
,
2767 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
>
2768 aFrameSet(pDoc
->GetAttrPool() );
2770 // set correct parent to get the XFILL_NONE FillStyle as needed
2771 aFrameSet
.SetParent(&pDoc
->GetDfltFrameFormat()->GetAttrSet());
2773 // no the related items need to be added to the set
2775 if (!m_pProps
->AnyToItemSet(pDoc
, aFrameSet
, aGrSet
, bSizeFound
))
2776 throw lang::IllegalArgumentException();
2777 // a TextRange is handled separately
2778 *aPam
.GetPoint() = *aIntPam
.GetPoint();
2779 if(aIntPam
.HasMark())
2782 *aPam
.GetMark() = *aIntPam
.GetMark();
2785 RndStdIds eAnchorId
= RndStdIds::FLY_AT_PARA
;
2786 if(const SwFormatAnchor
* pItem
= aFrameSet
.GetItemIfSet(RES_ANCHOR
, false) )
2788 eAnchorId
= pItem
->GetAnchorId();
2789 if( RndStdIds::FLY_AT_FLY
== eAnchorId
&&
2790 !aPam
.GetPointNode().FindFlyStartNode())
2792 // framebound only where a frame exists
2793 SwFormatAnchor
aAnchor(RndStdIds::FLY_AT_PARA
);
2794 aFrameSet
.Put(aAnchor
);
2796 else if ((RndStdIds::FLY_AT_PAGE
== eAnchorId
) &&
2797 0 == pItem
->GetPageNum() )
2799 SwFormatAnchor
aAnchor( *pItem
);
2800 aAnchor
.SetType(RndStdIds::FLY_AT_CHAR
); // convert invalid at-page
2801 aAnchor
.SetAnchor( aPam
.GetPoint() );
2802 aFrameSet
.Put(aAnchor
);
2805 if (eAnchorId
== RndStdIds::FLY_AT_PAGE
)
2807 sal_Int16
nRelOrient(aFrameSet
.Get(RES_HORI_ORIENT
).GetRelationOrient());
2808 if (sw::GetAtPageRelOrientation(nRelOrient
, true))
2810 SAL_WARN("sw.core", "SwXFrame: fixing invalid horizontal RelOrientation for at-page anchor");
2812 SwFormatHoriOrient
item(aFrameSet
.Get(RES_HORI_ORIENT
));
2813 item
.SetRelationOrient(nRelOrient
);
2814 aFrameSet
.Put(item
);
2819 const ::uno::Any
* pStyle
;
2820 SwFrameFormat
*pParentFrameFormat
= nullptr;
2821 if (m_pProps
->GetProperty(FN_UNO_FRAME_STYLE_NAME
, 0, pStyle
))
2822 pParentFrameFormat
= lcl_GetFrameFormat( *pStyle
, pDoc
);
2824 SwFlyFrameFormat
* pFormat
= nullptr;
2825 if( m_eType
== FLYCNTTYPE_FRM
)
2827 UnoActionContext
aCont(pDoc
);
2830 std::unique_ptr
<SwFormatAnchor
> pAnchorItem
;
2831 // the frame is inserted bound to page
2832 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text
2833 if (eAnchorId
!= RndStdIds::FLY_AT_PAGE
)
2835 pAnchorItem
.reset(aFrameSet
.Get(RES_ANCHOR
).Clone());
2836 aFrameSet
.Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE
, 1 ));
2839 // park these no longer needed PaMs somewhere safe so MakeFlyAndMove
2840 // can delete what it likes without any assert these are pointing to
2843 aIntPam
.DeleteMark();
2844 aIntPam
.GetPoint()->Assign(*pDoc
->GetNodes()[SwNodeOffset(0)]);
2845 *aPam
.GetPoint() = *aIntPam
.GetPoint();
2847 pFormat
= pDoc
->MakeFlyAndMove( *pCopySource
, aFrameSet
,
2849 pParentFrameFormat
);
2850 if(pAnchorItem
&& pFormat
)
2852 pFormat
->DelFrames();
2853 pAnchorItem
->SetAnchor( pCopySource
->Start() );
2854 SfxItemSetFixed
<RES_ANCHOR
, RES_ANCHOR
> aAnchorSet( pDoc
->GetAttrPool() );
2855 aAnchorSet
.Put( std::move(pAnchorItem
) );
2856 pDoc
->SetFlyFrameAttr( *pFormat
, aAnchorSet
);
2861 pFormat
= pDoc
->MakeFlySection( RndStdIds::FLY_AT_PARA
, aPam
.GetPoint(),
2862 &aFrameSet
, pParentFrameFormat
);
2867 m_pFrameFormat
= pFormat
;
2868 StartListening(pFormat
->GetNotifier());
2869 if(!m_sName
.isEmpty())
2870 pDoc
->SetFlyName(*pFormat
, m_sName
);
2872 // wake up the SwXTextFrame
2873 static_cast<SwXTextFrame
*>(this)->SetDoc( m_bIsDescriptor
? m_pDoc
: GetFrameFormat()->GetDoc() );
2875 else if( m_eType
== FLYCNTTYPE_GRF
)
2877 UnoActionContext
aActionContext(pDoc
);
2880 // Read graphic URL from the descriptor, if it has any.
2881 const ::uno::Any
* pGraphicURL
;
2882 if (m_pProps
->GetProperty(FN_UNO_GRAPHIC_URL
, 0, pGraphicURL
))
2884 OUString sGraphicURL
;
2885 uno::Reference
<awt::XBitmap
> xBitmap
;
2886 if (((*pGraphicURL
) >>= sGraphicURL
) && !sGraphicURL
.isEmpty())
2887 aGraphic
= vcl::graphic::loadFromURL(sGraphicURL
);
2888 else if ((*pGraphicURL
) >>= xBitmap
)
2890 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
2892 aGraphic
= xGraphic
;
2896 const ::uno::Any
* pGraphicAny
;
2897 const bool bHasGraphic
= m_pProps
->GetProperty(FN_UNO_GRAPHIC
, 0, pGraphicAny
);
2900 uno::Reference
<graphic::XGraphic
> xGraphic
;
2901 (*pGraphicAny
) >>= xGraphic
;
2902 aGraphic
= Graphic(xGraphic
);
2905 OUString sFilterName
;
2906 const uno::Any
* pFilterAny
;
2907 if (m_pProps
->GetProperty(FN_UNO_GRAPHIC_FILTER
, 0, pFilterAny
))
2909 (*pFilterAny
) >>= sFilterName
;
2912 pFormat
= pDoc
->getIDocumentContentOperations().InsertGraphic(
2913 aPam
, OUString(), sFilterName
, &aGraphic
, &aFrameSet
, &aGrSet
, pParentFrameFormat
);
2916 SwGrfNode
*pGrfNd
= pDoc
->GetNodes()[ pFormat
->GetContent().GetContentIdx()
2917 ->GetIndex()+1 ]->GetGrfNode();
2919 pGrfNd
->SetChgTwipSize( !bSizeFound
);
2920 m_pFrameFormat
= pFormat
;
2922 StartListening(m_pFrameFormat
->GetNotifier());
2923 if(!m_sName
.isEmpty())
2924 pDoc
->SetFlyName(*pFormat
, m_sName
);
2927 const ::uno::Any
* pSurroundContour
;
2928 if (m_pProps
->GetProperty(RES_SURROUND
, MID_SURROUND_CONTOUR
, pSurroundContour
))
2929 setPropertyValue(UNO_NAME_SURROUND_CONTOUR
, *pSurroundContour
);
2930 const ::uno::Any
* pContourOutside
;
2931 if (m_pProps
->GetProperty(RES_SURROUND
, MID_SURROUND_CONTOUROUTSIDE
, pContourOutside
))
2932 setPropertyValue(UNO_NAME_CONTOUR_OUTSIDE
, *pContourOutside
);
2933 const ::uno::Any
* pContourPoly
;
2934 if (m_pProps
->GetProperty(FN_PARAM_CONTOUR_PP
, 0, pContourPoly
))
2935 setPropertyValue(UNO_NAME_CONTOUR_POLY_POLYGON
, *pContourPoly
);
2936 const ::uno::Any
* pPixelContour
;
2937 if (m_pProps
->GetProperty(FN_UNO_IS_PIXEL_CONTOUR
, 0, pPixelContour
))
2938 setPropertyValue(UNO_NAME_IS_PIXEL_CONTOUR
, *pPixelContour
);
2939 const ::uno::Any
* pAutoContour
;
2940 if (m_pProps
->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR
, 0, pAutoContour
))
2941 setPropertyValue(UNO_NAME_IS_AUTOMATIC_CONTOUR
, *pAutoContour
);
2945 const ::uno::Any
* pCLSID
= nullptr;
2946 const ::uno::Any
* pStreamName
= nullptr;
2947 const ::uno::Any
* pEmbeddedObject
= nullptr;
2948 if (!m_pProps
->GetProperty(FN_UNO_CLSID
, 0, pCLSID
)
2949 && !m_pProps
->GetProperty(FN_UNO_STREAM_NAME
, 0, pStreamName
)
2950 && !m_pProps
->GetProperty(FN_EMBEDDED_OBJECT
, 0, pEmbeddedObject
))
2952 throw uno::RuntimeException();
2957 SvGlobalName aClassName
;
2958 uno::Reference
< embed::XEmbeddedObject
> xIPObj
;
2959 std::unique_ptr
< comphelper::EmbeddedObjectContainer
> pCnt
;
2960 if( (*pCLSID
) >>= aCLSID
)
2962 if( !aClassName
.MakeId( aCLSID
) )
2964 lang::IllegalArgumentException aExcept
;
2965 aExcept
.Message
= "CLSID invalid";
2969 pCnt
.reset( new comphelper::EmbeddedObjectContainer
);
2972 OUString sDocumentBaseURL
= pDoc
->GetPersist()->getDocumentBaseURL();
2973 xIPObj
= pCnt
->CreateEmbeddedObject(aClassName
.GetByteSequence(), aName
,
2978 UnoActionContext
aAction(pDoc
);
2979 pDoc
->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT
, nullptr);
2981 // tdf#99631 set imported VisibleArea settings of embedded XLSX OLE objects
2982 if ( m_nDrawAspect
== embed::Aspects::MSOLE_CONTENT
2983 && m_nVisibleAreaWidth
&& m_nVisibleAreaHeight
)
2985 sal_Int64 nAspect
= m_nDrawAspect
;
2986 MapUnit aUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj
->getMapUnit( nAspect
) );
2987 Size
aSize( OutputDevice::LogicToLogic(Size( m_nVisibleAreaWidth
, m_nVisibleAreaHeight
),
2988 MapMode(MapUnit::MapTwip
), MapMode(aUnit
)));
2990 aSz
.Width
= aSize
.Width();
2991 aSz
.Height
= aSize
.Height();
2992 xIPObj
->setVisualAreaSize(m_nDrawAspect
, aSz
);
2997 //TODO/LATER: how do I transport it to the OLENode?
2998 sal_Int64 nAspect
= m_nDrawAspect
;
3000 // TODO/LEAN: VisualArea still needs running state
3001 svt::EmbeddedObjectRef::TryRunningState( xIPObj
);
3003 // set parent to get correct VisArea(in case of object needing parent printer)
3004 uno::Reference
< container::XChild
> xChild( xIPObj
, uno::UNO_QUERY
);
3006 xChild
->setParent( pDoc
->GetDocShell()->GetModel() );
3008 //The Size should be suggested by the OLE server if not manually set
3009 MapUnit aRefMap
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj
->getMapUnit( nAspect
) );
3013 aSize
= xIPObj
->getVisualAreaSize( nAspect
);
3015 catch ( embed::NoVisualAreaSizeException
& )
3017 // the default size will be set later
3020 Size
aSz( aSize
.Width
, aSize
.Height
);
3021 if ( !aSz
.Width() || !aSz
.Height() )
3024 aSz
.setHeight(5000);
3025 aSz
= OutputDevice::LogicToLogic(aSz
,
3026 MapMode(MapUnit::Map100thMM
), MapMode(aRefMap
));
3028 MapMode
aMyMap( MapUnit::MapTwip
);
3029 aSz
= OutputDevice::LogicToLogic(aSz
, MapMode(aRefMap
), aMyMap
);
3030 SwFormatFrameSize aFrameSz
;
3031 aFrameSz
.SetSize(aSz
);
3032 aFrameSet
.Put(aFrameSz
);
3034 SwFlyFrameFormat
* pFormat2
= nullptr;
3036 ::svt::EmbeddedObjectRef
xObjRef( xIPObj
, m_nDrawAspect
);
3037 pFormat2
= pDoc
->getIDocumentContentOperations().InsertEmbObject(
3038 aPam
, xObjRef
, &aFrameSet
);
3040 // store main document name to show in the title bar
3041 uno::Reference
< frame::XTitle
> xModelTitle( pDoc
->GetDocShell()->GetModel(), css::uno::UNO_QUERY
);
3042 if( xModelTitle
.is() )
3043 xIPObj
->setContainerName( xModelTitle
->getTitle() );
3045 assert(pFormat2
&& "Doc->Insert(notxt) failed.");
3047 pDoc
->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT
, nullptr);
3048 m_pFrameFormat
= pFormat2
;
3050 StartListening(m_pFrameFormat
->GetNotifier());
3051 if(!m_sName
.isEmpty())
3052 pDoc
->SetFlyName(*pFormat2
, m_sName
);
3055 else if( pStreamName
)
3057 OUString sStreamName
;
3058 (*pStreamName
) >>= sStreamName
;
3059 pDoc
->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT
, nullptr);
3061 SwFlyFrameFormat
* pFrameFormat
= pDoc
->getIDocumentContentOperations().InsertOLE(
3062 aPam
, sStreamName
, m_nDrawAspect
, &aFrameSet
, nullptr);
3064 // store main document name to show in the title bar
3065 SwOLENode
* pNd
= nullptr;
3066 const SwNodeIndex
* pIdx
= pFrameFormat
->GetContent().GetContentIdx();
3069 SwNodeIndex
aIdx( *pIdx
, 1 );
3070 SwNoTextNode
* pNoText
= aIdx
.GetNode().GetNoTextNode();
3071 pNd
= pNoText
->GetOLENode();
3075 uno::Reference
< embed::XEmbeddedObject
> xObj
= pNd
->GetOLEObj().GetOleRef();
3078 uno::Reference
< frame::XTitle
> xModelTitle( pDoc
->GetDocShell()->GetModel(), css::uno::UNO_QUERY
);
3079 if( xModelTitle
.is() )
3080 xObj
->setContainerName( xModelTitle
->getTitle() );
3084 pDoc
->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT
, nullptr);
3085 m_pFrameFormat
= pFrameFormat
;
3087 StartListening(m_pFrameFormat
->GetNotifier());
3088 if(!m_sName
.isEmpty())
3089 pDoc
->SetFlyName(*pFrameFormat
, m_sName
);
3091 else if (pEmbeddedObject
)
3093 uno::Reference
< embed::XEmbeddedObject
> obj
;
3094 (*pEmbeddedObject
) >>= obj
;
3095 svt::EmbeddedObjectRef xObj
;
3096 xObj
.Assign( obj
, embed::Aspects::MSOLE_CONTENT
);
3098 pDoc
->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT
, nullptr);
3100 // Do not call here container::XChild(obj)->setParent() and
3101 // pDoc->GetPersist()->GetEmbeddedObjectContainer().InsertEmbeddedObject:
3102 // they are called indirectly by pDoc->getIDocumentContentOperations().InsertEmbObject
3103 // below. Calling them twice will add the same object twice to EmbeddedObjectContainer's
3104 // pImpl->maNameToObjectMap, and then it will misbehave in
3105 // EmbeddedObjectContainer::StoreAsChildren and SfxObjectShell::SaveCompletedChildren.
3107 SwFlyFrameFormat
* pFrameFormat
3108 = pDoc
->getIDocumentContentOperations().InsertEmbObject(aPam
, xObj
, &aFrameSet
);
3109 pDoc
->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT
, nullptr);
3110 m_pFrameFormat
= pFrameFormat
;
3112 StartListening(m_pFrameFormat
->GetNotifier());
3113 if(!m_sName
.isEmpty())
3114 pDoc
->SetFlyName(*pFrameFormat
, m_sName
);
3117 if( pFormat
&& pDoc
->getIDocumentDrawModelAccess().GetDrawModel() )
3118 GetOrCreateSdrObject(*pFormat
);
3119 const ::uno::Any
* pOrder
;
3120 if (m_pProps
->GetProperty(FN_UNO_Z_ORDER
, 0, pOrder
))
3121 setPropertyValue(UNO_NAME_Z_ORDER
, *pOrder
);
3122 const ::uno::Any
* pReplacement
;
3123 if (m_pProps
->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC
, 0, pReplacement
))
3124 setPropertyValue(UNO_NAME_GRAPHIC
, *pReplacement
);
3125 // new attribute Title
3126 const ::uno::Any
* pTitle
;
3127 if (m_pProps
->GetProperty(FN_UNO_TITLE
, 0, pTitle
))
3129 setPropertyValue(UNO_NAME_TITLE
, *pTitle
);
3131 // new attribute Description
3132 const ::uno::Any
* pDescription
;
3133 if (m_pProps
->GetProperty(FN_UNO_DESCRIPTION
, 0, pDescription
))
3135 setPropertyValue(UNO_NAME_DESCRIPTION
, *pDescription
);
3139 const uno::Any
* pFrameIntropgrabbagItem
;
3140 if (m_pProps
->GetProperty(RES_FRMATR_GRABBAG
, 0, pFrameIntropgrabbagItem
))
3142 setPropertyValue(UNO_NAME_FRAME_INTEROP_GRAB_BAG
, *pFrameIntropgrabbagItem
);
3145 // reset the flag and delete Descriptor pointer
3149 void SwXFrame::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
3155 attachToRange(xTextRange
);
3159 SwFrameFormat
* pFormat
= GetFrameFormat();
3163 SwDoc
* pDoc
= pFormat
->GetDoc();
3164 SwUnoInternalPaM
aIntPam(*pDoc
);
3165 if (!::sw::XTextRangeToSwPaM(aIntPam
, xTextRange
))
3166 throw lang::IllegalArgumentException();
3168 SfxItemSetFixed
<RES_ANCHOR
, RES_ANCHOR
> aSet( pDoc
->GetAttrPool() );
3169 aSet
.SetParent(&pFormat
->GetAttrSet());
3170 SwFormatAnchor aAnchor
= aSet
.Get(RES_ANCHOR
);
3172 if (aAnchor
.GetAnchorId() == RndStdIds::FLY_AS_CHAR
)
3174 throw lang::IllegalArgumentException(
3175 "SwXFrame::attach(): re-anchoring AS_CHAR not supported",
3179 aAnchor
.SetAnchor( aIntPam
.Start() );
3181 pDoc
->SetFlyFrameAttr( *pFormat
, aSet
);
3184 awt::Point
SwXFrame::getPosition()
3186 uno::RuntimeException aRuntime
;
3187 aRuntime
.Message
= "position cannot be determined with this method";
3191 void SwXFrame::setPosition(const awt::Point
& /*aPosition*/)
3193 uno::RuntimeException aRuntime
;
3194 aRuntime
.Message
= "position cannot be changed with this method";
3198 awt::Size
SwXFrame::getSize()
3200 const ::uno::Any aVal
= getPropertyValue("Size");
3201 awt::Size
const * pRet
= o3tl::doAccess
<awt::Size
>(aVal
);
3205 void SwXFrame::setSize(const awt::Size
& aSize
)
3207 const ::uno::Any
aVal(&aSize
, ::cppu::UnoType
<awt::Size
>::get());
3208 setPropertyValue("Size", aVal
);
3211 OUString
SwXFrame::getShapeType()
3213 return "FrameShape";
3216 SwXTextFrame::SwXTextFrame( SwDoc
*_pDoc
) :
3217 SwXTextFrameBaseClass(FLYCNTTYPE_FRM
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_FRAME
), _pDoc
),
3218 SwXText(nullptr, CursorType::Frame
)
3222 SwXTextFrame::SwXTextFrame(SwFrameFormat
& rFormat
) :
3223 SwXTextFrameBaseClass(rFormat
, FLYCNTTYPE_FRM
, aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_FRAME
)),
3224 SwXText(rFormat
.GetDoc(), CursorType::Frame
)
3229 SwXTextFrame::~SwXTextFrame()
3233 rtl::Reference
<SwXTextFrame
>
3234 SwXTextFrame::CreateXTextFrame(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
3236 return CreateXFrame
<SwXTextFrame
>(rDoc
, pFrameFormat
);
3239 void SAL_CALL
SwXTextFrame::acquire( )noexcept
3241 SwXFrame::acquire();
3244 void SAL_CALL
SwXTextFrame::release( )noexcept
3246 SwXFrame::release();
3249 ::uno::Any SAL_CALL
SwXTextFrame::queryInterface( const uno::Type
& aType
)
3251 ::uno::Any aRet
= SwXFrame::queryInterface(aType
);
3252 if(aRet
.getValueType() == cppu::UnoType
<void>::get())
3253 aRet
= SwXText::queryInterface(aType
);
3254 if(aRet
.getValueType() == cppu::UnoType
<void>::get())
3255 aRet
= SwXTextFrameBaseClass::queryInterface(aType
);
3259 uno::Sequence
< uno::Type
> SAL_CALL
SwXTextFrame::getTypes( )
3261 return comphelper::concatSequences(
3262 SwXTextFrameBaseClass::getTypes(),
3263 SwXFrame::getTypes(),
3268 uno::Sequence
< sal_Int8
> SAL_CALL
SwXTextFrame::getImplementationId( )
3270 return css::uno::Sequence
<sal_Int8
>();
3273 uno::Reference
< text::XText
> SwXTextFrame::getText()
3278 const SwStartNode
*SwXTextFrame::GetStartNode() const
3280 const SwStartNode
*pSttNd
= nullptr;
3282 const SwFrameFormat
* pFormat
= GetFrameFormat();
3285 const SwFormatContent
& rFlyContent
= pFormat
->GetContent();
3286 if( rFlyContent
.GetContentIdx() )
3287 pSttNd
= rFlyContent
.GetContentIdx()->GetNode().GetStartNode();
3293 rtl::Reference
<SwXTextCursor
> SwXTextFrame::createXTextCursor()
3295 SwFrameFormat
* pFormat
= GetFrameFormat();
3297 throw uno::RuntimeException();
3299 //save current start node to be able to check if there is content after the table -
3300 //otherwise the cursor would be in the body text!
3301 const SwNode
& rNode
= pFormat
->GetContent().GetContentIdx()->GetNode();
3302 const SwStartNode
* pOwnStartNode
= rNode
.FindSttNodeByType(SwFlyStartNode
);
3305 aPam
.Move(fnMoveForward
, GoInNode
);
3306 SwTableNode
* pTableNode
= aPam
.GetPointNode().FindTableNode();
3309 aPam
.GetPoint()->Assign( *pTableNode
->EndOfSectionNode() );
3310 SwContentNode
* pCont
= GetDoc()->GetNodes().GoNext(aPam
.GetPoint());
3311 pTableNode
= pCont
->FindTableNode();
3314 const SwStartNode
* pNewStartNode
=
3315 aPam
.GetPointNode().FindSttNodeByType(SwFlyStartNode
);
3316 if(!pNewStartNode
|| pNewStartNode
!= pOwnStartNode
)
3318 uno::RuntimeException aExcept
;
3319 aExcept
.Message
= "no text available";
3323 return new SwXTextCursor(
3324 *pFormat
->GetDoc(), this, CursorType::Frame
, *aPam
.GetPoint());
3327 rtl::Reference
< SwXTextCursor
> SwXTextFrame::createXTextCursorByRange(const uno::Reference
< text::XTextRange
> & aTextPosition
)
3329 SwFrameFormat
* pFormat
= GetFrameFormat();
3331 throw uno::RuntimeException();
3332 SwUnoInternalPaM
aPam(*GetDoc());
3333 if (!::sw::XTextRangeToSwPaM(aPam
, aTextPosition
))
3334 throw uno::RuntimeException();
3336 rtl::Reference
< SwXTextCursor
> aRef
;
3337 SwNode
& rNode
= pFormat
->GetContent().GetContentIdx()->GetNode();
3338 if(aPam
.GetPointNode().FindFlyStartNode() == rNode
.FindFlyStartNode())
3340 aRef
= new SwXTextCursor(*pFormat
->GetDoc(), this, CursorType::Frame
,
3341 *aPam
.GetPoint(), aPam
.GetMark());
3347 uno::Reference
< container::XEnumeration
> SwXTextFrame::createEnumeration()
3349 SolarMutexGuard aGuard
;
3350 SwFrameFormat
* pFormat
= GetFrameFormat();
3353 SwPosition
aPos(pFormat
->GetContent().GetContentIdx()->GetNode());
3354 auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos
));
3355 pUnoCursor
->Move(fnMoveForward
, GoInNode
);
3356 return SwXParagraphEnumeration::Create(this, pUnoCursor
, CursorType::Frame
);
3359 uno::Type
SwXTextFrame::getElementType()
3361 return cppu::UnoType
<text::XTextRange
>::get();
3364 sal_Bool
SwXTextFrame::hasElements()
3369 void SwXTextFrame::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
3371 SwXFrame::attach(xTextRange
);
3374 uno::Reference
< text::XTextRange
> SwXTextFrame::getAnchor()
3376 SolarMutexGuard aGuard
;
3377 return SwXFrame::getAnchor();
3380 void SwXTextFrame::dispose()
3382 SolarMutexGuard aGuard
;
3383 SwXFrame::dispose();
3386 void SwXTextFrame::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
3388 SwXFrame::addEventListener(aListener
);
3391 void SwXTextFrame::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
3393 SwXFrame::removeEventListener(aListener
);
3396 OUString
SwXTextFrame::getImplementationName()
3398 return "SwXTextFrame";
3401 sal_Bool
SwXTextFrame::supportsService(const OUString
& rServiceName
)
3403 return cppu::supportsService(this, rServiceName
);
3406 uno::Sequence
< OUString
> SwXTextFrame::getSupportedServiceNames()
3408 uno::Sequence
< OUString
> aRet
= SwXFrame::getSupportedServiceNames();
3409 aRet
.realloc(aRet
.getLength() + 2);
3410 OUString
* pArray
= aRet
.getArray();
3411 pArray
[aRet
.getLength() - 2] = "com.sun.star.text.TextFrame";
3412 pArray
[aRet
.getLength() - 1] = "com.sun.star.text.Text";
3416 uno::Reference
<container::XNameReplace
> SAL_CALL
SwXTextFrame::getEvents()
3418 return new SwFrameEventDescriptor( *this );
3421 ::uno::Any
SwXTextFrame::getPropertyValue(const OUString
& rPropertyName
)
3423 SolarMutexGuard aGuard
;
3425 if(rPropertyName
== UNO_NAME_START_REDLINE
||
3426 rPropertyName
== UNO_NAME_END_REDLINE
)
3428 //redline can only be returned if it's a living object
3430 aRet
= SwXText::getPropertyValue(rPropertyName
);
3433 aRet
= SwXFrame::getPropertyValue(rPropertyName
);
3437 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc
*pDoc
)
3438 : SwXTextGraphicObjectBaseClass(FLYCNTTYPE_GRF
,
3439 aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC
), pDoc
)
3443 SwXTextGraphicObject::SwXTextGraphicObject(SwFrameFormat
& rFormat
)
3444 : SwXTextGraphicObjectBaseClass(rFormat
, FLYCNTTYPE_GRF
,
3445 aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC
))
3449 SwXTextGraphicObject::~SwXTextGraphicObject()
3453 rtl::Reference
<SwXTextGraphicObject
>
3454 SwXTextGraphicObject::CreateXTextGraphicObject(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
3456 return CreateXFrame
<SwXTextGraphicObject
>(rDoc
, pFrameFormat
);
3459 OUString
SwXTextGraphicObject::getImplementationName()
3461 return "SwXTextGraphicObject";
3464 sal_Bool
SwXTextGraphicObject::supportsService(const OUString
& rServiceName
)
3466 return cppu::supportsService(this, rServiceName
);
3469 uno::Sequence
< OUString
> SwXTextGraphicObject::getSupportedServiceNames()
3471 uno::Sequence
< OUString
> aRet
= SwXFrame::getSupportedServiceNames();
3472 aRet
.realloc(aRet
.getLength() + 1);
3473 OUString
* pArray
= aRet
.getArray();
3474 pArray
[aRet
.getLength() - 1] = "com.sun.star.text.TextGraphicObject";
3478 uno::Reference
<container::XNameReplace
> SAL_CALL
3479 SwXTextGraphicObject::getEvents()
3481 return new SwFrameEventDescriptor( *this );
3484 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc
*pDoc
)
3485 : SwXTextEmbeddedObjectBaseClass(FLYCNTTYPE_OLE
,
3486 aSwMapProvider
.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT
), pDoc
)
3490 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrameFormat
& rFormat
)
3491 : SwXTextEmbeddedObjectBaseClass(rFormat
, FLYCNTTYPE_OLE
,
3492 aSwMapProvider
.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT
))
3496 SwXTextEmbeddedObject::~SwXTextEmbeddedObject()
3500 rtl::Reference
<SwXTextEmbeddedObject
>
3501 SwXTextEmbeddedObject::CreateXTextEmbeddedObject(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
)
3503 return CreateXFrame
<SwXTextEmbeddedObject
>(rDoc
, pFrameFormat
);
3506 uno::Reference
< lang::XComponent
> SwXTextEmbeddedObject::getEmbeddedObject()
3508 uno::Reference
<embed::XEmbeddedObject
> xObj(getExtendedControlOverEmbeddedObject());
3509 return xObj
.is() ? uno::Reference
<lang::XComponent
>(xObj
->getComponent(), uno::UNO_QUERY
) : nullptr;
3512 uno::Reference
< embed::XEmbeddedObject
> SAL_CALL
SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject()
3514 uno::Reference
< embed::XEmbeddedObject
> xResult
;
3515 SwFrameFormat
* pFormat
= GetFrameFormat();
3518 SwDoc
* pDoc
= pFormat
->GetDoc();
3519 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3520 OSL_ENSURE( pCnt
->GetContentIdx() &&
3521 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3522 GetIndex() + 1 ]->GetOLENode(), "no OLE-Node?");
3524 SwOLENode
* pOleNode
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()
3525 ->GetIndex() + 1 ]->GetOLENode();
3526 xResult
= pOleNode
->GetOLEObj().GetOleRef();
3527 if ( svt::EmbeddedObjectRef::TryRunningState( xResult
) )
3529 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3530 if ( pDoc
->GetDocShell() )
3531 pDoc
->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult
, embed::Aspects::MSOLE_CONTENT
) );
3533 uno::Reference
< lang::XComponent
> xComp( xResult
->getComponent(), uno::UNO_QUERY
);
3534 uno::Reference
< util::XModifyBroadcaster
> xBrdcst( xComp
, uno::UNO_QUERY
);
3535 uno::Reference
< frame::XModel
> xModel( xComp
, uno::UNO_QUERY
);
3536 if(xBrdcst
.is() && xModel
.is() && !m_xOLEListener
.is())
3538 m_xOLEListener
= new SwXOLEListener(*pFormat
, xModel
);
3539 xBrdcst
->addModifyListener( m_xOLEListener
);
3546 sal_Int64 SAL_CALL
SwXTextEmbeddedObject::getAspect()
3548 SwFrameFormat
* pFormat
= GetFrameFormat();
3551 SwDoc
* pDoc
= pFormat
->GetDoc();
3552 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3553 OSL_ENSURE( pCnt
->GetContentIdx() &&
3554 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3555 GetIndex() + 1 ]->GetOLENode(), "no OLE-Node?");
3557 return pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect();
3560 return embed::Aspects::MSOLE_CONTENT
; // return the default value
3563 void SAL_CALL
SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect
)
3565 SwFrameFormat
* pFormat
= GetFrameFormat();
3568 SwDoc
* pDoc
= pFormat
->GetDoc();
3569 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3570 OSL_ENSURE( pCnt
->GetContentIdx() &&
3571 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3572 GetIndex() + 1 ]->GetOLENode(), "no OLE-Node?");
3574 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect
);
3578 uno::Reference
< graphic::XGraphic
> SAL_CALL
SwXTextEmbeddedObject::getReplacementGraphic()
3580 SwFrameFormat
* pFormat
= GetFrameFormat();
3583 SwDoc
* pDoc
= pFormat
->GetDoc();
3584 const SwFormatContent
* pCnt
= &pFormat
->GetContent();
3585 OSL_ENSURE( pCnt
->GetContentIdx() &&
3586 pDoc
->GetNodes()[ pCnt
->GetContentIdx()->
3587 GetIndex() + 1 ]->GetOLENode(), "no OLE-Node?");
3589 const Graphic
* pGraphic
= pDoc
->GetNodes()[ pCnt
->GetContentIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic();
3591 return pGraphic
->GetXGraphic();
3594 return uno::Reference
< graphic::XGraphic
>();
3597 OUString
SwXTextEmbeddedObject::getImplementationName()
3599 return "SwXTextEmbeddedObject";
3602 sal_Bool
SwXTextEmbeddedObject::supportsService(const OUString
& rServiceName
)
3604 return cppu::supportsService(this, rServiceName
);
3607 uno::Sequence
< OUString
> SwXTextEmbeddedObject::getSupportedServiceNames()
3609 uno::Sequence
< OUString
> aRet
= SwXFrame::getSupportedServiceNames();
3610 aRet
.realloc(aRet
.getLength() + 1);
3611 OUString
* pArray
= aRet
.getArray();
3612 pArray
[aRet
.getLength() - 1] = "com.sun.star.text.TextEmbeddedObject";
3616 uno::Reference
<container::XNameReplace
> SAL_CALL
3617 SwXTextEmbeddedObject::getEvents()
3619 return new SwFrameEventDescriptor( *this );
3624 SwOLENode
* lcl_GetOLENode(const SwFormat
* pFormat
)
3628 const SwNodeIndex
* pIdx(pFormat
->GetContent().GetContentIdx());
3631 const SwNodeIndex
aIdx(*pIdx
, 1);
3632 return aIdx
.GetNode().GetNoTextNode()->GetOLENode();
3636 SwXOLEListener::SwXOLEListener( SwFormat
& rOLEFormat
, uno::Reference
< XModel
> xOLE
)
3637 : m_pOLEFormat(&rOLEFormat
)
3638 , m_xOLEModel(std::move(xOLE
))
3640 StartListening(m_pOLEFormat
->GetNotifier());
3643 SwXOLEListener::~SwXOLEListener()
3646 void SwXOLEListener::modified( const lang::EventObject
& /*rEvent*/ )
3648 SolarMutexGuard aGuard
;
3649 const auto pNd
= lcl_GetOLENode(m_pOLEFormat
);
3651 throw uno::RuntimeException();
3652 const auto xIP
= pNd
->GetOLEObj().GetOleRef();
3655 sal_Int32 nState
= xIP
->getCurrentState();
3656 if(nState
== embed::EmbedStates::INPLACE_ACTIVE
|| nState
== embed::EmbedStates::UI_ACTIVE
)
3657 // if the OLE-Node is UI-Active do nothing
3660 pNd
->SetOLESizeInvalid(true);
3661 pNd
->GetDoc().SetOLEObjModified();
3664 void SwXOLEListener::disposing( const lang::EventObject
& rEvent
)
3666 SolarMutexGuard aGuard
;
3667 uno::Reference
<util::XModifyListener
> xListener( this );
3668 uno::Reference
<frame::XModel
> xModel(rEvent
.Source
, uno::UNO_QUERY
);
3669 uno::Reference
<util::XModifyBroadcaster
> xBrdcst(xModel
, uno::UNO_QUERY
);
3674 xBrdcst
->removeModifyListener(xListener
);
3676 catch(uno::Exception
const &)
3678 OSL_FAIL("OLE Listener couldn't be removed");
3682 void SwXOLEListener::Notify( const SfxHint
& rHint
)
3684 if(rHint
.GetId() == SfxHintId::Dying
)
3686 m_xOLEModel
= nullptr;
3687 m_pOLEFormat
= nullptr;
3691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */