1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24
25 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
26 #include <com/sun/star/container/XChild.hpp>
27 #include <com/sun/star/embed/XClassifiedObject.hpp>
28 #include <com/sun/star/embed/XVisualObject.hpp>
29 #include <com/sun/star/embed/XComponentSupplier.hpp>
30 #include <com/sun/star/embed/EmbedStates.hpp>
31 #include <com/sun/star/embed/Aspects.hpp>
32 #include <com/sun/star/graphic/XGraphicProvider.hpp>
33 #include <com/sun/star/drawing/BitmapMode.hpp>
34 #include <svx/svxids.hrc>
35 #include <svx/xflclit.hxx>
36 #include <svx/xflhtit.hxx>
37 #include <svx/xfltrit.hxx>
38 #include <editeng/memberids.hrc>
39 #include <swtypes.hxx>
40 #include <cmdid.h>
41 #include <memory>
42 #include <hints.hxx>
43 #include <doc.hxx>
44 #include <IDocumentUndoRedo.hxx>
45 #include <docsh.hxx>
46 #include <editsh.hxx>
47 #include <swcli.hxx>
48 #include <ndindex.hxx>
49 #include <pam.hxx>
50 #include <ndnotxt.hxx>
51 #include <svx/unomid.hxx>
52 #include <unocrsr.hxx>
53 #include <unocrsrhelper.hxx>
54 #include <docstyle.hxx>
55 #include <dcontact.hxx>
56 #include <fmtcnct.hxx>
57 #include <ndole.hxx>
58 #include <frmfmt.hxx>
59 #include <frame.hxx>
60 #include <unotextrange.hxx>
61 #include <unotextcursor.hxx>
62 #include <unoparagraph.hxx>
63 #include <unomap.hxx>
64 #include <unoprnms.hxx>
65 #include <unoevent.hxx>
66 #include <com/sun/star/table/BorderLine.hpp>
67 #include <com/sun/star/util/XModifyBroadcaster.hpp>
68 #include <com/sun/star/table/ShadowFormat.hpp>
69 #include <com/sun/star/style/GraphicLocation.hpp>
70 #include <com/sun/star/text/GraphicCrop.hpp>
71 #include <com/sun/star/text/TextContentAnchorType.hpp>
72 #include <com/sun/star/text/XTextColumns.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 <com/sun/star/drawing/ColorMode.hpp>
78 #include <tools/poly.hxx>
79 #include <swundo.hxx>
80 #include <unostyle.hxx>
81 #include <svx/svdmodel.hxx>
82 #include <svx/svdpage.hxx>
83 #include <editeng/brshitem.hxx>
84 #include <editeng/protitem.hxx>
85 #include <fmtornt.hxx>
86 #include <fmturl.hxx>
87 #include <editeng/lrspitem.hxx>
88 #include <editeng/ulspitem.hxx>
89 #include <editeng/boxitem.hxx>
90 #include <editeng/opaqitem.hxx>
91 #include <editeng/prntitem.hxx>
92 #include <editeng/shaditem.hxx>
93 #include <fmtsrnd.hxx>
94 #include <fmtfsize.hxx>
95 #include <grfatr.hxx>
96 #include <unoframe.hxx>
97 #include <fmtanchr.hxx>
98 #include <fmtclds.hxx>
99 #include <fmtcntnt.hxx>
100 #include <frmatr.hxx>
101 #include <ndtxt.hxx>
102 #include <ndgrf.hxx>
103 #include <vos/mutex.hxx>
104 #include <vcl/svapp.hxx>
105 #include <sfx2/printer.hxx>
106 #include <sfx2/docfile.hxx>
107 #include <sfx2/docfilt.hxx>
108 #include <SwStyleNameMapper.hxx>
109 #include <xmloff/xmlcnitm.hxx>
110 #include <poolfmt.hxx>
111 #include <pagedesc.hxx>
112 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
113 #include <tools/urlobj.hxx>
114 #include <editeng/frmdiritem.hxx>
115 #include <fmtfollowtextflow.hxx>
116 #include <fmtwrapinfluenceonobjpos.hxx>
117 #include <toolkit/helper/vclunohelper.hxx>
118 #include <switerator.hxx>
119 #include <svx/unobrushitemhelper.hxx>
120 #include <svx/xfillit0.hxx>
121 #include <svx/xbtmpit.hxx>
122 #include <svx/xgrscit.hxx>
123 #include <svx/xflbmtit.hxx>
124 #include <svx/xflbmpit.hxx>
125 #include <svx/xflbmsxy.hxx>
126 #include <svx/xflbmsxy.hxx>
127 #include <svx/xflftrit.hxx>
128 #include <svx/xsflclit.hxx>
129 #include <svx/xflbmsli.hxx>
130 #include <svx/xflbtoxy.hxx>
131 #include <svx/xflbstit.hxx>
132 #include <svx/xflboxy.hxx>
133 #include <svx/xflbckit.hxx>
134 #include <svx/unoshape.hxx>
135 #include <swunohelper.hxx>
136 #include <drawdoc.hxx>
137
138 // from fefly1.cxx
139 extern sal_Bool lcl_ChkAndSetNewAnchor( SwEditShell& rEditShell, const SwFlyFrm& rFly, SfxItemSet& rSet );
140
141 using namespace ::com::sun::star;
142 using ::rtl::OUString;
143
144 using ::com::sun::star::frame::XModel;
145 using ::com::sun::star::container::XNameAccess;
146 using ::com::sun::star::style::XStyleFamiliesSupplier;
147
148 const sal_Char __FAR_DATA sPackageProtocol[] = "vnd.sun.star.Package:";
149 const sal_Char __FAR_DATA sGraphicObjectProtocol[] = "vnd.sun.star.GraphicObject:";
150
151 /****************************************************************************
152 Rahmenbeschreibung
153 ****************************************************************************/
154 class BaseFrameProperties_Impl
155 {
156 SwUnoCursorHelper::SwAnyMapHelper aAnyMap;
157
158 public:
159 virtual ~BaseFrameProperties_Impl();
160
161 void SetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any& rVal);
162 sal_Bool GetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any*& pAny );
163 // void GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
164
165 // const SfxItemPropertyMap* GetMap() const {return _pMap;}
166 //Begin Bug 119922:Graphic in header and footer can not be displayed correctly.
167 //Set default value for "Follow text flow" to false if a previous version didn't support "Follow text flow".
168 sal_Bool FillBaseProperties(SfxItemSet& rToSet,
169 const SfxItemSet &rFromSet,
170 sal_Bool& rSizeFound,
171 const sal_Bool bOasis = sal_False );
172 //End Bug 119922
173
174 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound) = 0;
175 };
176
~BaseFrameProperties_Impl()177 BaseFrameProperties_Impl::~BaseFrameProperties_Impl()
178 {
179 }
180
SetProperty(sal_uInt16 nWID,sal_uInt8 nMemberId,const uno::Any & rVal)181 void BaseFrameProperties_Impl::SetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any& rVal)
182 {
183 aAnyMap.SetValue( nWID, nMemberId, rVal );
184 }
185
GetProperty(sal_uInt16 nWID,sal_uInt8 nMemberId,const uno::Any * & rpAny)186 sal_Bool BaseFrameProperties_Impl::GetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any*& rpAny)
187 {
188 return aAnyMap.FillValue( nWID, nMemberId, rpAny );
189 }
190
191 //Begin Bug 119922:Graphic in header and footer can not be displayed correctly.
192 //Set default value for "Follow text flow" to false if a previous version didn't support "Follow text flow".
FillBaseProperties(SfxItemSet & rToSet,const SfxItemSet & rFromSet,sal_Bool & rSizeFound,const sal_Bool bOasis)193 sal_Bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet,
194 const SfxItemSet& rFromSet,
195 sal_Bool& rSizeFound,
196 const sal_Bool bOasis /*sal_False*/ )
197 //End Bug 119922
198 {
199 //UUUU assert when the target SfxItemSet has no parent. It *should* have the pDfltFrmFmt
200 // from SwDoc set as parent (or similar) to have the necessary XFILL_NONE in the ItemSet
201 if(!rToSet.GetParent())
202 {
203 OSL_ENSURE(false, "OOps, target SfxItemSet *should* have a parent which contains XFILL_NONE as XFillStyleItem (!)");
204 }
205
206 sal_Bool bRet = sal_True;
207 //Anker kommt auf jeden Fall in den Set
208 SwFmtAnchor aAnchor ( static_cast < const SwFmtAnchor & > ( rFromSet.Get ( RES_ANCHOR ) ) );
209 {
210 const ::uno::Any* pAnchorPgNo;
211 if(GetProperty(RES_ANCHOR, MID_ANCHOR_PAGENUM, pAnchorPgNo))
212 bRet &= ((SfxPoolItem&)aAnchor).PutValue(*pAnchorPgNo, MID_ANCHOR_PAGENUM);
213 const ::uno::Any* pAnchorType;
214 if(GetProperty(RES_ANCHOR, MID_ANCHOR_ANCHORTYPE, pAnchorType))
215 bRet &= ((SfxPoolItem&)aAnchor).PutValue(*pAnchorType, MID_ANCHOR_ANCHORTYPE);
216 }
217
218 rToSet.Put(aAnchor);
219
220 //UUUU check for SvxBrushItem (RES_BACKGROUND) properties
221 const ::uno::Any* pCol = 0; GetProperty(RES_BACKGROUND, MID_BACK_COLOR, pCol );
222 const ::uno::Any* pRGBCol = 0; GetProperty(RES_BACKGROUND, MID_BACK_COLOR_R_G_B, pRGBCol );
223 const ::uno::Any* pColTrans = 0; GetProperty(RES_BACKGROUND, MID_BACK_COLOR_TRANSPARENCY, pColTrans);
224 const ::uno::Any* pTrans = 0; GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENT, pTrans );
225 const ::uno::Any* pGrLoc = 0; GetProperty(RES_BACKGROUND, MID_GRAPHIC_POSITION, pGrLoc );
226 const ::uno::Any* pGrURL = 0; GetProperty(RES_BACKGROUND, MID_GRAPHIC_URL, pGrURL );
227 const ::uno::Any* pGrFilter = 0; GetProperty(RES_BACKGROUND, MID_GRAPHIC_FILTER, pGrFilter );
228 const ::uno::Any* pGrTranparency = 0; GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENCY, pGrTranparency );
229 const bool bSvxBrushItemPropertiesUsed(
230 pCol ||
231 pTrans ||
232 pGrURL ||
233 pGrFilter ||
234 pGrLoc ||
235 pGrTranparency ||
236 pColTrans ||
237 pRGBCol);
238
239 //UUUU check for FillStyle properties in the range XATTR_FILL_FIRST, XATTR_FILL_LAST
240 const uno::Any* pXFillStyleItem = 0; GetProperty(XATTR_FILLSTYLE, 0, pXFillStyleItem);
241 const uno::Any* pXFillColorItem = 0; GetProperty(XATTR_FILLCOLOR, 0, pXFillColorItem);
242
243 // XFillGradientItem: two possible slots supported in UNO API
244 const uno::Any* pXFillGradientItem = 0; GetProperty(XATTR_FILLGRADIENT, MID_FILLGRADIENT, pXFillGradientItem);
245 const uno::Any* pXFillGradientNameItem = 0; GetProperty(XATTR_FILLGRADIENT, MID_NAME, pXFillGradientNameItem);
246
247 // XFillHatchItem: two possible slots supported in UNO API
248 const uno::Any* pXFillHatchItem = 0; GetProperty(XATTR_FILLHATCH, MID_FILLHATCH, pXFillHatchItem);
249 const uno::Any* pXFillHatchNameItem = 0; GetProperty(XATTR_FILLHATCH, MID_NAME, pXFillHatchNameItem);
250
251 // XFillBitmapItem: three possible slots supported in UNO API
252 const uno::Any* pXFillBitmapItem = 0; GetProperty(XATTR_FILLBITMAP, MID_BITMAP, pXFillBitmapItem);
253 const uno::Any* pXFillBitmapNameItem = 0; GetProperty(XATTR_FILLBITMAP, MID_NAME, pXFillBitmapNameItem);
254 const uno::Any* pXFillBitmapURLItem = 0; GetProperty(XATTR_FILLBITMAP, MID_GRAFURL, pXFillBitmapURLItem);
255
256 const uno::Any* pXFillTransparenceItem = 0; GetProperty(XATTR_FILLTRANSPARENCE, 0, pXFillTransparenceItem);
257 const uno::Any* pXGradientStepCountItem = 0; GetProperty(XATTR_GRADIENTSTEPCOUNT, 0, pXGradientStepCountItem);
258 const uno::Any* pXFillBmpPosItem = 0; GetProperty(XATTR_FILLBMP_POS, 0, pXFillBmpPosItem);
259 const uno::Any* pXFillBmpSizeXItem = 0; GetProperty(XATTR_FILLBMP_SIZEX, 0, pXFillBmpSizeXItem);
260 const uno::Any* pXFillBmpSizeYItem = 0; GetProperty(XATTR_FILLBMP_SIZEY, 0, pXFillBmpSizeYItem);
261
262 // XFillFloatTransparenceItem: two possible slots supported in UNO API
263 const uno::Any* pXFillFloatTransparenceItem = 0; GetProperty(XATTR_FILLFLOATTRANSPARENCE, MID_FILLGRADIENT, pXFillFloatTransparenceItem);
264 const uno::Any* pXFillFloatTransparenceNameItem = 0; GetProperty(XATTR_FILLFLOATTRANSPARENCE, MID_NAME, pXFillFloatTransparenceNameItem);
265
266 const uno::Any* pXSecondaryFillColorItem = 0; GetProperty(XATTR_SECONDARYFILLCOLOR, 0, pXSecondaryFillColorItem);
267 const uno::Any* pXFillBmpSizeLogItem = 0; GetProperty(XATTR_FILLBMP_SIZELOG, 0, pXFillBmpSizeLogItem);
268 const uno::Any* pXFillBmpTileOffsetXItem = 0; GetProperty(XATTR_FILLBMP_TILEOFFSETX, 0, pXFillBmpTileOffsetXItem);
269 const uno::Any* pXFillBmpTileOffsetYItem = 0; GetProperty(XATTR_FILLBMP_TILEOFFSETY, 0, pXFillBmpTileOffsetYItem);
270 const uno::Any* pXFillBmpPosOffsetXItem = 0; GetProperty(XATTR_FILLBMP_POSOFFSETX, 0, pXFillBmpPosOffsetXItem);
271 const uno::Any* pXFillBmpPosOffsetYItem = 0; GetProperty(XATTR_FILLBMP_POSOFFSETY, 0, pXFillBmpPosOffsetYItem);
272 const uno::Any* pXFillBackgroundItem = 0; GetProperty(XATTR_FILLBACKGROUND, 0, pXFillBackgroundItem);
273 const uno::Any* pOwnAttrFillBmpItem = 0; GetProperty(OWN_ATTR_FILLBMP_MODE, 0, pOwnAttrFillBmpItem);
274
275 const bool bXFillStyleItemUsed(
276 pXFillStyleItem ||
277 pXFillColorItem ||
278 pXFillGradientItem || pXFillGradientNameItem ||
279 pXFillHatchItem || pXFillHatchNameItem ||
280 pXFillBitmapItem || pXFillBitmapNameItem || pXFillBitmapURLItem ||
281 pXFillTransparenceItem ||
282 pXGradientStepCountItem ||
283 pXFillBmpPosItem ||
284 pXFillBmpSizeXItem ||
285 pXFillBmpSizeYItem ||
286 pXFillFloatTransparenceItem || pXFillFloatTransparenceNameItem ||
287 pXSecondaryFillColorItem ||
288 pXFillBmpSizeLogItem ||
289 pXFillBmpTileOffsetXItem ||
290 pXFillBmpTileOffsetYItem ||
291 pXFillBmpPosOffsetXItem ||
292 pXFillBmpPosOffsetYItem ||
293 pXFillBackgroundItem ||
294 pOwnAttrFillBmpItem);
295
296 // use brush items, but *only* if no FillStyle properties are used; if both are used and when applying both
297 // in the obvious order some attributes may be wrong since they are set by the 1st set, but not
298 // redefined as needed by the 2nd set when they are default (and thus no tset) in the 2nd set. If
299 // it is necessary for any reason to set both (it should not) a in-between step will be needed
300 // that resets the items for FillAttributes in rToSet to default.
301 // Note: There are other mechanisms in XMLOFF to pre-sort this relationship already, but this version
302 // was used initially, is tested and works. Keep it to be able to react when another feed adds attributes
303 // from both sets.
304 if(bSvxBrushItemPropertiesUsed && !bXFillStyleItemUsed)
305 {
306 //UUUU create a temporary SvxBrushItem, fill the attributes to it and use it to set
307 // the corresponding FillAttributes
308 SvxBrushItem aBrush(RES_BACKGROUND);
309
310 if(pCol)
311 {
312 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pCol,MID_BACK_COLOR );
313 }
314
315 if(pColTrans)
316 {
317 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pColTrans, MID_BACK_COLOR_TRANSPARENCY);
318 }
319
320 if(pRGBCol)
321 {
322 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pRGBCol, MID_BACK_COLOR_R_G_B);
323 }
324
325 if(pTrans)
326 {
327 // don't overwrite transparency with a non-transparence flag
328 if(!pColTrans || Any2Bool( *pTrans ))
329 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pTrans, MID_GRAPHIC_TRANSPARENT);
330 }
331
332 if(pGrURL)
333 {
334 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrURL, MID_GRAPHIC_URL);
335 }
336
337 if(pGrFilter)
338 {
339 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrFilter, MID_GRAPHIC_FILTER);
340 }
341
342 if(pGrLoc)
343 {
344 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrLoc, MID_GRAPHIC_POSITION);
345 }
346
347 if(pGrTranparency)
348 {
349 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrTranparency, MID_GRAPHIC_TRANSPARENCY);
350 }
351
352 setSvxBrushItemAsFillAttributesToTargetSet(aBrush, rToSet);
353 }
354
355 if(bXFillStyleItemUsed)
356 {
357 if(pXFillStyleItem)
358 {
359 XFillStyleItem aXFillStyleItem;
360
361 aXFillStyleItem.PutValue(*pXFillStyleItem);
362 rToSet.Put(aXFillStyleItem);
363 }
364
365 if(pXFillColorItem)
366 {
367 const XubString aNullStr;
368 const Color aNullCol(COL_DEFAULT_SHAPE_FILLING);
369 XFillColorItem aXFillColorItem(aNullStr, aNullCol);
370
371 aXFillColorItem.PutValue(*pXFillColorItem);
372 rToSet.Put(aXFillColorItem);
373 }
374
375 if(pXFillGradientItem || pXFillGradientNameItem)
376 {
377 if(pXFillGradientItem)
378 {
379 const XGradient aNullGrad(RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
380 XFillGradientItem aXFillGradientItem(rToSet.GetPool(), aNullGrad);
381
382 aXFillGradientItem.PutValue(*pXFillGradientItem, MID_FILLGRADIENT);
383 rToSet.Put(aXFillGradientItem);
384 }
385
386 if(pXFillGradientNameItem)
387 {
388 OUString aTempName;
389
390 if(!(*pXFillGradientNameItem >>= aTempName ))
391 {
392 throw lang::IllegalArgumentException();
393 }
394
395 bRet &= SvxShape::SetFillAttribute(XATTR_FILLGRADIENT, aTempName, rToSet);
396 }
397 }
398
399 if(pXFillHatchItem || pXFillHatchNameItem)
400 {
401 if(pXFillHatchItem)
402 {
403 const Color aNullCol(COL_DEFAULT_SHAPE_STROKE);
404 const XHatch aNullHatch(aNullCol);
405 XFillHatchItem aXFillHatchItem(rToSet.GetPool(), aNullHatch);
406
407 aXFillHatchItem.PutValue(*pXFillHatchItem, MID_FILLHATCH);
408 rToSet.Put(aXFillHatchItem);
409 }
410
411 if(pXFillHatchNameItem)
412 {
413 OUString aTempName;
414
415 if(!(*pXFillHatchNameItem >>= aTempName ))
416 {
417 throw lang::IllegalArgumentException();
418 }
419
420 bRet &= SvxShape::SetFillAttribute(XATTR_FILLHATCH, aTempName, rToSet);
421 }
422 }
423
424 if(pXFillBitmapItem || pXFillBitmapNameItem || pXFillBitmapURLItem)
425 {
426 if(pXFillBitmapItem)
427 {
428 const Graphic aNullGraphic;
429 XFillBitmapItem aXFillBitmapItem(rToSet.GetPool(), aNullGraphic);
430
431 aXFillBitmapItem.PutValue(*pXFillBitmapItem, MID_BITMAP);
432 rToSet.Put(aXFillBitmapItem);
433 }
434
435 if(pXFillBitmapNameItem)
436 {
437 OUString aTempName;
438
439 if(!(*pXFillBitmapNameItem >>= aTempName ))
440 {
441 throw lang::IllegalArgumentException();
442 }
443
444 bRet &= SvxShape::SetFillAttribute(XATTR_FILLBITMAP, aTempName, rToSet);
445 }
446
447 if(pXFillBitmapURLItem)
448 {
449 const Graphic aNullGraphic;
450 XFillBitmapItem aXFillBitmapItem(rToSet.GetPool(), aNullGraphic);
451
452 aXFillBitmapItem.PutValue(*pXFillBitmapURLItem, MID_GRAFURL);
453 rToSet.Put(aXFillBitmapItem);
454 }
455 }
456
457 if(pXFillTransparenceItem)
458 {
459 const XGradient aNullGrad(RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
460 XFillTransparenceItem aXFillTransparenceItem;
461
462 aXFillTransparenceItem.PutValue(*pXFillTransparenceItem);
463 rToSet.Put(aXFillTransparenceItem);
464 }
465
466 if(pXGradientStepCountItem)
467 {
468 XGradientStepCountItem aXGradientStepCountItem;
469
470 aXGradientStepCountItem.PutValue(*pXGradientStepCountItem);
471 rToSet.Put(aXGradientStepCountItem);
472 }
473
474 if(pXFillBmpPosItem)
475 {
476 XFillBmpPosItem aXFillBmpPosItem;
477
478 aXFillBmpPosItem.PutValue(*pXFillBmpPosItem);
479 rToSet.Put(aXFillBmpPosItem);
480 }
481
482 if(pXFillBmpSizeXItem)
483 {
484 XFillBmpSizeXItem aXFillBmpSizeXItem;
485
486 aXFillBmpSizeXItem.PutValue(*pXFillBmpSizeXItem);
487 rToSet.Put(aXFillBmpSizeXItem);
488 }
489
490 if(pXFillBmpSizeYItem)
491 {
492 XFillBmpSizeYItem aXFillBmpSizeYItem;
493
494 aXFillBmpSizeYItem.PutValue(*pXFillBmpSizeYItem);
495 rToSet.Put(aXFillBmpSizeYItem);
496 }
497
498 if(pXFillFloatTransparenceItem || pXFillFloatTransparenceNameItem)
499 {
500 if(pXFillFloatTransparenceItem)
501 {
502 const XGradient aNullGrad(RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
503 XFillFloatTransparenceItem aXFillFloatTransparenceItem(rToSet.GetPool(), aNullGrad, false);
504
505 aXFillFloatTransparenceItem.PutValue(*pXFillFloatTransparenceItem, MID_FILLGRADIENT);
506 rToSet.Put(aXFillFloatTransparenceItem);
507 }
508
509 if(pXFillFloatTransparenceNameItem)
510 {
511 OUString aTempName;
512
513 if(!(*pXFillFloatTransparenceNameItem >>= aTempName ))
514 {
515 throw lang::IllegalArgumentException();
516 }
517
518 bRet &= SvxShape::SetFillAttribute(XATTR_FILLFLOATTRANSPARENCE, aTempName, rToSet);
519 }
520 }
521
522 if(pXSecondaryFillColorItem)
523 {
524 const XubString aNullStr;
525 const Color aNullCol(COL_DEFAULT_SHAPE_FILLING);
526 XSecondaryFillColorItem aXSecondaryFillColorItem(aNullStr, aNullCol);
527
528 aXSecondaryFillColorItem.PutValue(*pXSecondaryFillColorItem);
529 rToSet.Put(aXSecondaryFillColorItem);
530 }
531
532 if(pXFillBmpSizeLogItem)
533 {
534 XFillBmpSizeLogItem aXFillBmpSizeLogItem;
535
536 aXFillBmpSizeLogItem.PutValue(*pXFillBmpSizeLogItem);
537 rToSet.Put(aXFillBmpSizeLogItem);
538 }
539
540 if(pXFillBmpTileOffsetXItem)
541 {
542 XFillBmpTileOffsetXItem aXFillBmpTileOffsetXItem;
543
544 aXFillBmpTileOffsetXItem.PutValue(*pXFillBmpTileOffsetXItem);
545 rToSet.Put(aXFillBmpTileOffsetXItem);
546 }
547
548 if(pXFillBmpTileOffsetYItem)
549 {
550 XFillBmpTileOffsetYItem aXFillBmpTileOffsetYItem;
551
552 aXFillBmpTileOffsetYItem.PutValue(*pXFillBmpTileOffsetYItem);
553 rToSet.Put(aXFillBmpTileOffsetYItem);
554 }
555
556 if(pXFillBmpPosOffsetXItem)
557 {
558 XFillBmpPosOffsetXItem aXFillBmpPosOffsetXItem;
559
560 aXFillBmpPosOffsetXItem.PutValue(*pXFillBmpPosOffsetXItem);
561 rToSet.Put(aXFillBmpPosOffsetXItem);
562 }
563
564 if(pXFillBmpPosOffsetYItem)
565 {
566 XFillBmpPosOffsetYItem aXFillBmpPosOffsetYItem;
567
568 aXFillBmpPosOffsetYItem.PutValue(*pXFillBmpPosOffsetYItem);
569 rToSet.Put(aXFillBmpPosOffsetYItem);
570 }
571
572 if(pXFillBackgroundItem)
573 {
574 XFillBackgroundItem aXFillBackgroundItem;
575
576 aXFillBackgroundItem.PutValue(*pXFillBackgroundItem);
577 rToSet.Put(aXFillBackgroundItem);
578 }
579
580 if(pOwnAttrFillBmpItem)
581 {
582 drawing::BitmapMode eMode;
583
584 if(!(*pOwnAttrFillBmpItem >>= eMode))
585 {
586 sal_Int32 nMode = 0;
587
588 if(!(*pOwnAttrFillBmpItem >>= nMode))
589 {
590 throw lang::IllegalArgumentException();
591 }
592
593 eMode = (drawing::BitmapMode)nMode;
594 }
595
596 rToSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
597 rToSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
598 }
599 }
600 {
601 const ::uno::Any* pCont = 0;
602 GetProperty(RES_PROTECT, MID_PROTECT_CONTENT, pCont );
603 const ::uno::Any* pPos = 0;
604 GetProperty(RES_PROTECT,MID_PROTECT_POSITION, pPos );
605 const ::uno::Any* pName = 0;
606 GetProperty(RES_PROTECT, MID_PROTECT_SIZE, pName );
607 if(pCont||pPos||pName)
608 {
609 SvxProtectItem aProt ( static_cast < const :: SvxProtectItem & > ( rFromSet.Get ( RES_PROTECT ) ) );
610 if(pCont)
611 bRet &= ((SfxPoolItem&)aProt).PutValue(*pCont, MID_PROTECT_CONTENT);
612 if(pPos )
613 bRet &= ((SfxPoolItem&)aProt).PutValue(*pPos, MID_PROTECT_POSITION);
614 if(pName)
615 bRet &= ((SfxPoolItem&)aProt).PutValue(*pName, MID_PROTECT_SIZE);
616 rToSet.Put(aProt);
617 }
618 }
619 {
620 const ::uno::Any* pHori = 0;
621 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHori );
622 const ::uno::Any* pHoriP = 0;
623 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_POSITION|CONVERT_TWIPS, pHoriP );
624 const ::uno::Any* pHoriR = 0;
625 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_RELATION, pHoriR );
626 const ::uno::Any* pPageT = 0;
627 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_PAGETOGGLE, pPageT);
628 if(pHori||pHoriP||pHoriR||pPageT)
629 {
630 SwFmtHoriOrient aOrient ( static_cast < const :: SwFmtHoriOrient & > ( rFromSet.Get ( RES_HORI_ORIENT ) ) );
631 if(pHori )
632 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pHori, MID_HORIORIENT_ORIENT);
633 if(pHoriP)
634 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pHoriP, MID_HORIORIENT_POSITION|CONVERT_TWIPS);
635 if(pHoriR)
636 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pHoriR, MID_HORIORIENT_RELATION);
637 if(pPageT)
638 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pPageT, MID_HORIORIENT_PAGETOGGLE);
639 rToSet.Put(aOrient);
640 }
641 }
642
643 {
644 const ::uno::Any* pVert = 0;
645 GetProperty(RES_VERT_ORIENT, MID_VERTORIENT_ORIENT, pVert);
646 const ::uno::Any* pVertP = 0;
647 GetProperty(RES_VERT_ORIENT, MID_VERTORIENT_POSITION|CONVERT_TWIPS, pVertP );
648 const ::uno::Any* pVertR = 0;
649 GetProperty(RES_VERT_ORIENT, MID_VERTORIENT_RELATION, pVertR );
650 if(pVert||pVertP||pVertR)
651 {
652 SwFmtVertOrient aOrient ( static_cast < const :: SwFmtVertOrient & > ( rFromSet.Get ( RES_VERT_ORIENT ) ) );
653 if(pVert )
654 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pVert, MID_VERTORIENT_ORIENT);
655 if(pVertP)
656 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pVertP, MID_VERTORIENT_POSITION|CONVERT_TWIPS);
657 if(pVertR)
658 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pVertR, MID_VERTORIENT_RELATION);
659 rToSet.Put(aOrient);
660 }
661 }
662 {
663 const ::uno::Any* pURL = 0;
664 GetProperty(RES_URL, MID_URL_URL, pURL );
665 const ::uno::Any* pTarget = 0;
666 GetProperty(RES_URL, MID_URL_TARGET, pTarget );
667 const ::uno::Any* pHyLNm = 0;
668 GetProperty(RES_URL, MID_URL_HYPERLINKNAME, pHyLNm );
669 const ::uno::Any* pHySMp = 0;
670 GetProperty(RES_URL, MID_URL_SERVERMAP, pHySMp );
671 if(pURL||pTarget||pHyLNm||pHySMp)
672 {
673 SwFmtURL aURL ( static_cast < const :: SwFmtURL & > ( rFromSet.Get ( RES_URL ) ) );
674 if(pURL)
675 bRet &= ((SfxPoolItem&)aURL).PutValue(*pURL, MID_URL_URL);
676 if(pTarget)
677 bRet &= ((SfxPoolItem&)aURL).PutValue(*pTarget, MID_URL_TARGET);
678 if(pHyLNm)
679 bRet &= ((SfxPoolItem&)aURL).PutValue(*pHyLNm, MID_URL_HYPERLINKNAME );
680 if(pHySMp)
681 bRet &= ((SfxPoolItem&)aURL).PutValue(*pHySMp, MID_URL_SERVERMAP);
682 rToSet.Put(aURL);
683 }
684 }
685 const ::uno::Any* pL = 0;
686 GetProperty(RES_LR_SPACE, MID_L_MARGIN|CONVERT_TWIPS, pL );
687 const ::uno::Any* pR = 0;
688 GetProperty(RES_LR_SPACE, MID_R_MARGIN|CONVERT_TWIPS, pR );
689 if(pL||pR)
690 {
691 SvxLRSpaceItem aLR ( static_cast < const :: SvxLRSpaceItem & > ( rFromSet.Get ( RES_LR_SPACE ) ) );
692 if(pL)
693 bRet &= ((SfxPoolItem&)aLR).PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS);
694 if(pR)
695 bRet &= ((SfxPoolItem&)aLR).PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS);
696 rToSet.Put(aLR);
697 }
698 const ::uno::Any* pT = 0;
699 GetProperty(RES_UL_SPACE, MID_UP_MARGIN|CONVERT_TWIPS, pT );
700 const ::uno::Any* pB = 0;
701 GetProperty(RES_UL_SPACE, MID_LO_MARGIN|CONVERT_TWIPS, pB );
702 if(pT||pB)
703 {
704 SvxULSpaceItem aTB ( static_cast < const :: SvxULSpaceItem &> ( rFromSet.Get ( RES_UL_SPACE ) ) );
705 if(pT)
706 bRet &= ((SfxPoolItem&)aTB).PutValue(*pT, MID_UP_MARGIN|CONVERT_TWIPS);
707 if(pB)
708 bRet &= ((SfxPoolItem&)aTB).PutValue(*pB, MID_LO_MARGIN|CONVERT_TWIPS);
709 rToSet.Put(aTB);
710 }
711 const ::uno::Any* pOp;
712 if(GetProperty(RES_OPAQUE, 0, pOp))
713 {
714 SvxOpaqueItem aOp ( static_cast < const :: SvxOpaqueItem& > ( rFromSet.Get ( RES_OPAQUE ) ) );
715 bRet &= ((SfxPoolItem&)aOp).PutValue(*pOp, 0);
716 rToSet.Put(aOp);
717 }
718 const ::uno::Any* pPrt;
719 if(GetProperty(RES_PRINT, 0, pPrt))
720 {
721 SvxPrintItem aPrt ( static_cast < const :: SvxPrintItem & > ( rFromSet.Get ( RES_PRINT ) ) );
722 bRet &= ((SfxPoolItem&)aPrt).PutValue(*pPrt, 0);
723 rToSet.Put(aPrt);
724 }
725 const ::uno::Any* pSh;
726 if(GetProperty(RES_SHADOW, CONVERT_TWIPS, pSh))
727 {
728 SvxShadowItem aSh ( static_cast < const :: SvxShadowItem& > ( rFromSet.Get ( RES_SHADOW ) ) );
729 bRet &= ((SfxPoolItem&)aSh).PutValue(*pSh, CONVERT_TWIPS);
730 rToSet.Put(aSh);
731 }
732 const ::uno::Any* pSur = 0;
733 GetProperty(RES_SURROUND, MID_SURROUND_SURROUNDTYPE, pSur);
734 const ::uno::Any* pSurAnch = 0;
735 GetProperty(RES_SURROUND, MID_SURROUND_ANCHORONLY, pSurAnch);
736 if(pSur || pSurAnch)
737 {
738 SwFmtSurround aSrnd ( static_cast < const :: SwFmtSurround & > ( rFromSet.Get ( RES_SURROUND ) ) );
739 if(pSur)
740 bRet &= ((SfxPoolItem&)aSrnd).PutValue(*pSur, MID_SURROUND_SURROUNDTYPE );
741 if(pSurAnch)
742 bRet &= ((SfxPoolItem&)aSrnd).PutValue(*pSurAnch, MID_SURROUND_ANCHORONLY);
743 rToSet.Put(aSrnd);
744 }
745 const ::uno::Any* pLeft = 0;
746 GetProperty(RES_BOX, LEFT_BORDER |CONVERT_TWIPS, pLeft );
747 const ::uno::Any* pRight = 0;
748 GetProperty(RES_BOX, CONVERT_TWIPS|RIGHT_BORDER , pRight );
749 const ::uno::Any* pTop = 0;
750 GetProperty(RES_BOX, CONVERT_TWIPS|TOP_BORDER , pTop );
751 const ::uno::Any* pBottom = 0;
752 GetProperty(RES_BOX, CONVERT_TWIPS|BOTTOM_BORDER, pBottom);
753 const ::uno::Any* pDistance = 0;
754 GetProperty(RES_BOX, CONVERT_TWIPS|BORDER_DISTANCE, pDistance);
755 const ::uno::Any* pLeftDistance = 0;
756 GetProperty(RES_BOX, CONVERT_TWIPS|LEFT_BORDER_DISTANCE, pLeftDistance);
757 const ::uno::Any* pRightDistance = 0;
758 GetProperty(RES_BOX, CONVERT_TWIPS|RIGHT_BORDER_DISTANCE, pRightDistance);
759 const ::uno::Any* pTopDistance = 0;
760 GetProperty(RES_BOX, CONVERT_TWIPS|TOP_BORDER_DISTANCE, pTopDistance);
761 const ::uno::Any* pBottomDistance = 0;
762 GetProperty(RES_BOX, CONVERT_TWIPS|BOTTOM_BORDER_DISTANCE, pBottomDistance);
763 if( pLeft || pRight || pTop || pBottom || pDistance ||
764 pLeftDistance || pRightDistance || pTopDistance || pBottomDistance )
765 {
766 SvxBoxItem aBox ( static_cast < const :: SvxBoxItem & > ( rFromSet.Get ( RES_BOX ) ) );
767 if( pLeft )
768 bRet &= ((SfxPoolItem&)aBox).PutValue(*pLeft, CONVERT_TWIPS|LEFT_BORDER );
769 if( pRight )
770 bRet &= ((SfxPoolItem&)aBox).PutValue(*pRight, CONVERT_TWIPS|RIGHT_BORDER );
771 if( pTop )
772 bRet &= ((SfxPoolItem&)aBox).PutValue(*pTop, CONVERT_TWIPS|TOP_BORDER);
773 if( pBottom )
774 bRet &= ((SfxPoolItem&)aBox).PutValue(*pBottom, CONVERT_TWIPS|BOTTOM_BORDER);
775 if( pDistance )
776 bRet &= ((SfxPoolItem&)aBox).PutValue(*pDistance, CONVERT_TWIPS|BORDER_DISTANCE);
777 if( pLeftDistance )
778 bRet &= ((SfxPoolItem&)aBox).PutValue(*pLeftDistance, CONVERT_TWIPS|LEFT_BORDER_DISTANCE);
779 if( pRightDistance )
780 bRet &= ((SfxPoolItem&)aBox).PutValue(*pRightDistance, CONVERT_TWIPS|RIGHT_BORDER_DISTANCE);
781 if( pTopDistance )
782 bRet &= ((SfxPoolItem&)aBox).PutValue(*pTopDistance, CONVERT_TWIPS|TOP_BORDER_DISTANCE);
783 if( pBottomDistance )
784 bRet &= ((SfxPoolItem&)aBox).PutValue(*pBottomDistance, CONVERT_TWIPS|BOTTOM_BORDER_DISTANCE);
785 rToSet.Put(aBox);
786 }
787 {
788 const ::uno::Any* pRelH = 0;
789 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_REL_HEIGHT, pRelH);
790 const ::uno::Any* pRelW = 0;
791 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_REL_WIDTH, pRelW);
792 const ::uno::Any* pSyncWidth = 0;
793 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT, pSyncWidth);
794 const ::uno::Any* pSyncHeight = 0;
795 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH, pSyncHeight);
796 const ::uno::Any* pWidth = 0;
797 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_WIDTH|CONVERT_TWIPS, pWidth);
798 const ::uno::Any* pHeight = 0;
799 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_HEIGHT|CONVERT_TWIPS, pHeight);
800 const ::uno::Any* pSize = 0;
801 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_SIZE|CONVERT_TWIPS, pSize);
802 const ::uno::Any* pSizeType = 0;
803 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_SIZE_TYPE, pSizeType);
804 const ::uno::Any* pWidthType = 0;
805 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_WIDTH_TYPE, pWidthType);
806 if( pWidth || pHeight ||pRelH || pRelW || pSize ||pSizeType ||
807 pWidthType ||pSyncWidth || pSyncHeight )
808 {
809 rSizeFound = sal_True;
810 SwFmtFrmSize aFrmSz ( static_cast < const :: SwFmtFrmSize& > ( rFromSet.Get ( RES_FRM_SIZE ) ) );
811 if(pWidth)
812 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pWidth, MID_FRMSIZE_WIDTH|CONVERT_TWIPS);
813 if(pHeight)
814 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pHeight, MID_FRMSIZE_HEIGHT|CONVERT_TWIPS);
815 if(pRelH )
816 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pRelH, MID_FRMSIZE_REL_HEIGHT);
817 if(pRelW )
818 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pRelW, MID_FRMSIZE_REL_WIDTH);
819 if(pSyncWidth)
820 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSyncWidth, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT);
821 if(pSyncHeight)
822 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSyncHeight, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH);
823 if(pSize)
824 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSize, MID_FRMSIZE_SIZE|CONVERT_TWIPS);
825 if(pSizeType)
826 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSizeType, MID_FRMSIZE_SIZE_TYPE);
827 if(pWidthType)
828 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pWidthType, MID_FRMSIZE_WIDTH_TYPE);
829 if(!aFrmSz.GetWidth())
830 aFrmSz.SetWidth(MINFLY);
831 if(!aFrmSz.GetHeight())
832 aFrmSz.SetHeight(MINFLY);
833 rToSet.Put(aFrmSz);
834 }
835 else
836 {
837 rSizeFound = sal_False;
838 SwFmtFrmSize aFrmSz;
839 awt::Size aSize;
840 aSize.Width = 2 * MM50;
841 aSize.Height = 2 * MM50;
842 ::uno::Any aSizeVal;
843 aSizeVal <<= aSize;
844 ((SfxPoolItem&)aFrmSz).PutValue(aSizeVal, MID_FRMSIZE_SIZE|CONVERT_TWIPS);
845 rToSet.Put(aFrmSz);
846 }
847 }
848 const ::uno::Any* pFrameDirection = 0;
849 GetProperty(RES_FRAMEDIR, 0, pFrameDirection);
850 if(pFrameDirection)
851 {
852 SvxFrameDirectionItem aAttr(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR);
853 aAttr.PutValue(*pFrameDirection, 0);
854 rToSet.Put(aAttr);
855 }
856 const ::uno::Any* pUnknown = 0;
857 GetProperty(RES_UNKNOWNATR_CONTAINER, 0, pUnknown);
858 if(pUnknown)
859 {
860 SvXMLAttrContainerItem aAttr(RES_UNKNOWNATR_CONTAINER);
861 aAttr.PutValue(*pUnknown, 0);
862 rToSet.Put(aAttr);
863 }
864
865 // DVO, OD 01.10.2003 #i18732#
866 const ::uno::Any* pFollowTextFlow = 0;
867 GetProperty(RES_FOLLOW_TEXT_FLOW, 0, pFollowTextFlow);
868 if ( pFollowTextFlow )
869 {
870 SwFmtFollowTextFlow aFmtFollowTextFlow;
871 aFmtFollowTextFlow.PutValue(*pFollowTextFlow, 0);
872 rToSet.Put(aFmtFollowTextFlow);
873 }
874 //Begin Bug 119922
875 else if ( bOasis )
876 rToSet.Put( SwFmtFollowTextFlow() );
877 //End Bug 119922
878
879 // OD 2004-05-04 #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS
880 const ::uno::Any* pWrapInfluenceOnObjPos = 0;
881 GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS, MID_WRAP_INFLUENCE, pWrapInfluenceOnObjPos);
882 if ( pWrapInfluenceOnObjPos )
883 {
884 SwFmtWrapInfluenceOnObjPos aFmtWrapInfluenceOnObjPos;
885 aFmtWrapInfluenceOnObjPos.PutValue( *pWrapInfluenceOnObjPos, MID_WRAP_INFLUENCE );
886 rToSet.Put(aFmtWrapInfluenceOnObjPos);
887 }
888
889 return bRet;
890 }
891
892 class SwFrameProperties_Impl : public BaseFrameProperties_Impl
893 {
894 public:
895 SwFrameProperties_Impl();
~SwFrameProperties_Impl()896 virtual ~SwFrameProperties_Impl(){}
897
898 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound);
899 };
900
SwFrameProperties_Impl()901 SwFrameProperties_Impl::SwFrameProperties_Impl():
902 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_FRAME)*/ )
903 {
904 }
905
lcl_FillCol(SfxItemSet & rToSet,const::SfxItemSet & rFromSet,const::uno::Any * pAny)906 inline void lcl_FillCol ( SfxItemSet &rToSet, const :: SfxItemSet &rFromSet, const :: uno::Any *pAny)
907 {
908 if ( pAny )
909 {
910 SwFmtCol aCol ( static_cast < const :: SwFmtCol & > ( rFromSet.Get ( RES_COL ) ) );
911 ((SfxPoolItem&)aCol).PutValue( *pAny, MID_COLUMNS);
912 rToSet.Put(aCol);
913 }
914 }
AnyToItemSet(SwDoc * pDoc,SfxItemSet & rSet,SfxItemSet &,sal_Bool & rSizeFound)915 sal_Bool SwFrameProperties_Impl::AnyToItemSet(
916 SwDoc *pDoc,
917 SfxItemSet& rSet,
918 SfxItemSet&,
919 sal_Bool& rSizeFound )
920 {
921 sal_Bool bRet = sal_False;
922
923 SwDocStyleSheet* pStyle = NULL;
924 const ::uno::Any *pStyleName;
925 if ( GetProperty( FN_UNO_FRAME_STYLE_NAME, 0, pStyleName ) )
926 {
927 OUString sTmpStylename;
928 *pStyleName >>= sTmpStylename;
929 String sStylename;
930 SwStyleNameMapper::FillUIName( String(sTmpStylename), sStylename, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, sal_True );
931 pStyle =
932 (SwDocStyleSheet*) pDoc->GetDocShell()->GetStyleSheetPool()->Find( sStylename, SFX_STYLE_FAMILY_FRAME );
933 }
934
935 const ::uno::Any* pColumns = NULL;
936 GetProperty( RES_COL, MID_COLUMNS, pColumns );
937 if ( pStyle != NULL )
938 {
939 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *pStyle ) );
940 const ::SfxItemSet *pItemSet = &xStyle->GetItemSet();
941 bRet = FillBaseProperties( rSet, *pItemSet, rSizeFound );
942 lcl_FillCol( rSet, *pItemSet, pColumns );
943 }
944 else
945 {
946 const ::SfxItemSet *pItemSet = &pDoc->GetFrmFmtFromPool( RES_POOLFRM_FRAME )->GetAttrSet();
947 bRet = FillBaseProperties( rSet, *pItemSet, rSizeFound );
948 lcl_FillCol( rSet, *pItemSet, pColumns );
949 }
950
951 const ::uno::Any* pEdit;
952 if ( GetProperty( RES_EDIT_IN_READONLY, 0, pEdit ) )
953 {
954 SfxBoolItem aBool( RES_EDIT_IN_READONLY );
955 ( (SfxPoolItem&) aBool ).PutValue( *pEdit, 0 );
956 rSet.Put( aBool );
957 }
958
959 return bRet;
960 }
961 /****************************************************************************
962 Grafik-Descriptor
963 ****************************************************************************/
964 class SwGraphicProperties_Impl : public BaseFrameProperties_Impl
965 {
966 public:
967 SwGraphicProperties_Impl();
~SwGraphicProperties_Impl()968 virtual ~SwGraphicProperties_Impl(){}
969
970 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound);
971 };
972
SwGraphicProperties_Impl()973 SwGraphicProperties_Impl::SwGraphicProperties_Impl( ) :
974 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_GRAPHIC)*/ )
975 {
976 }
977
978
lcl_FillMirror(SfxItemSet & rToSet,const::SfxItemSet & rFromSet,const::uno::Any * pHEvenMirror,const::uno::Any * pHOddMirror,const::uno::Any * pVMirror,sal_Bool & rRet)979 inline void lcl_FillMirror ( SfxItemSet &rToSet, const :: SfxItemSet &rFromSet, const ::uno::Any *pHEvenMirror, const ::uno::Any *pHOddMirror, const ::uno::Any *pVMirror, sal_Bool &rRet )
980 {
981 if(pHEvenMirror || pHOddMirror || pVMirror )
982 {
983 SwMirrorGrf aMirror ( static_cast < const :: SwMirrorGrf& > ( rFromSet.Get ( RES_GRFATR_MIRRORGRF ) ) );
984 if(pHEvenMirror)
985 rRet &= ((SfxPoolItem&)aMirror).PutValue(*pHEvenMirror, MID_MIRROR_HORZ_EVEN_PAGES);
986 if(pHOddMirror)
987 rRet &= ((SfxPoolItem&)aMirror).PutValue(*pHOddMirror, MID_MIRROR_HORZ_ODD_PAGES);
988 if(pVMirror)
989 rRet &= ((SfxPoolItem&)aMirror).PutValue(*pVMirror, MID_MIRROR_VERT);
990 rToSet.Put(aMirror);
991 }
992 }
993
AnyToItemSet(SwDoc * pDoc,SfxItemSet & rFrmSet,SfxItemSet & rGrSet,sal_Bool & rSizeFound)994 sal_Bool SwGraphicProperties_Impl::AnyToItemSet(
995 SwDoc* pDoc,
996 SfxItemSet& rFrmSet,
997 SfxItemSet& rGrSet,
998 sal_Bool& rSizeFound )
999 {
1000 sal_Bool bRet = sal_False;
1001
1002 SwDocStyleSheet* pStyle = NULL;
1003 const ::uno::Any *pStyleName;
1004 if ( GetProperty( FN_UNO_FRAME_STYLE_NAME, 0, pStyleName ) )
1005 {
1006 OUString sTmpStylename;
1007 *pStyleName >>= sTmpStylename;
1008 String sStylename;
1009 SwStyleNameMapper::FillUIName( String(sTmpStylename), sStylename, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, sal_True );
1010 pStyle =
1011 (SwDocStyleSheet*) pDoc->GetDocShell()->GetStyleSheetPool()->Find( sStylename, SFX_STYLE_FAMILY_FRAME );
1012 }
1013
1014 const ::uno::Any* pHEvenMirror = 0;
1015 const ::uno::Any* pHOddMirror = 0;
1016 const ::uno::Any* pVMirror = 0;
1017 GetProperty(RES_GRFATR_MIRRORGRF, MID_MIRROR_HORZ_EVEN_PAGES, pHEvenMirror);
1018 GetProperty(RES_GRFATR_MIRRORGRF, MID_MIRROR_HORZ_ODD_PAGES, pHOddMirror);
1019 GetProperty(RES_GRFATR_MIRRORGRF, MID_MIRROR_VERT, pVMirror);
1020
1021 if ( pStyle != NULL )
1022 {
1023 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet(*pStyle) );
1024 const :: SfxItemSet *pItemSet = &xStyle->GetItemSet();
1025 sal_Bool bOasis = sal_False;
1026 {
1027 const SfxMedium* pMedium = pDoc->GetDocShell()->GetMedium();
1028 const SfxFilter * pFilter = pMedium != NULL
1029 ? pMedium->GetFilter()
1030 : NULL;
1031 if ( pFilter != NULL )
1032 {
1033 bOasis = pFilter->GetVersion() > SOFFICE_FILEFORMAT_60;
1034 }
1035 }
1036 bRet = FillBaseProperties( rFrmSet, *pItemSet, rSizeFound, bOasis );
1037 lcl_FillMirror ( rGrSet, *pItemSet, pHEvenMirror, pHOddMirror, pVMirror, bRet );
1038 }
1039 else
1040 {
1041 const :: SfxItemSet *pItemSet = &pDoc->GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC )->GetAttrSet();
1042 bRet = FillBaseProperties(rFrmSet, *pItemSet, rSizeFound);
1043 lcl_FillMirror ( rGrSet, *pItemSet, pHEvenMirror, pHOddMirror, pVMirror, bRet );
1044 }
1045
1046 static const ::sal_uInt16 nIDs[] =
1047 {
1048 RES_GRFATR_CROPGRF,
1049 RES_GRFATR_ROTATION,
1050 RES_GRFATR_LUMINANCE,
1051 RES_GRFATR_CONTRAST,
1052 RES_GRFATR_CHANNELR,
1053 RES_GRFATR_CHANNELG,
1054 RES_GRFATR_CHANNELB,
1055 RES_GRFATR_GAMMA,
1056 RES_GRFATR_INVERT,
1057 RES_GRFATR_TRANSPARENCY,
1058 RES_GRFATR_DRAWMODE,
1059 0
1060 };
1061 const ::uno::Any* pAny;
1062 for ( sal_Int16 nIndex = 0; nIDs[nIndex]; nIndex++ )
1063 {
1064 const sal_uInt8 nMId = RES_GRFATR_CROPGRF == nIDs[nIndex] ? CONVERT_TWIPS : 0;
1065 if ( GetProperty( nIDs[nIndex], nMId, pAny ) )
1066 {
1067 SfxPoolItem* pItem = ::GetDfltAttr( nIDs[nIndex] )->Clone();
1068 bRet &= pItem->PutValue( *pAny, nMId );
1069 rGrSet.Put( *pItem );
1070 delete pItem;
1071 }
1072 }
1073
1074 return bRet;
1075 }
1076
1077
1078 class SwOLEProperties_Impl : public SwFrameProperties_Impl
1079 {
1080 public:
SwOLEProperties_Impl()1081 SwOLEProperties_Impl() :
1082 SwFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_EMBEDDED_OBJECT)*/ ){}
~SwOLEProperties_Impl()1083 virtual ~SwOLEProperties_Impl(){}
1084
1085 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound);
1086 };
1087
1088
AnyToItemSet(SwDoc * pDoc,SfxItemSet & rFrmSet,SfxItemSet & rSet,sal_Bool & rSizeFound)1089 sal_Bool SwOLEProperties_Impl::AnyToItemSet(
1090 SwDoc* pDoc,
1091 SfxItemSet& rFrmSet,
1092 SfxItemSet& rSet,
1093 sal_Bool& rSizeFound )
1094 {
1095 const ::uno::Any* pTemp;
1096 if ( !GetProperty( FN_UNO_CLSID, 0, pTemp ) && !GetProperty( FN_UNO_STREAM_NAME, 0, pTemp ) )
1097 return sal_False;
1098 SwFrameProperties_Impl::AnyToItemSet( pDoc, rFrmSet, rSet, rSizeFound );
1099
1100 return sal_True;
1101 }
1102
1103
1104 /******************************************************************
1105 * SwXFrame
1106 ******************************************************************/
1107
getUnoTunnelId()1108 const :: uno::Sequence< sal_Int8 > & SwXFrame::getUnoTunnelId()
1109 {
1110 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
1111 return aSeq;
1112 }
1113
getSomething(const::uno::Sequence<sal_Int8> & rId)1114 sal_Int64 SAL_CALL SwXFrame::getSomething( const :: uno::Sequence< sal_Int8 >& rId )
1115 {
1116 if( rId.getLength() == 16
1117 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1118 rId.getConstArray(), 16 ) )
1119 {
1120 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1121 }
1122 return 0;
1123 }
1124
1125 TYPEINIT1(SwXFrame, SwClient);
1126
getImplementationName(void)1127 OUString SwXFrame::getImplementationName(void)
1128 {
1129 return C2U("SwXFrame");
1130 }
1131
supportsService(const::OUString & rServiceName)1132 sal_Bool SwXFrame::supportsService(const :: OUString& rServiceName)
1133 {
1134 return !rServiceName.compareToAscii("com.sun.star.text.BaseFrame")||
1135 !rServiceName.compareToAscii("com.sun.star.text.TextContent") ||
1136 !rServiceName.compareToAscii("com.sun.star.document.LinkTarget");
1137 }
1138
getSupportedServiceNames(void)1139 uno::Sequence< OUString > SwXFrame::getSupportedServiceNames(void)
1140 {
1141 uno::Sequence< OUString > aRet(3);
1142 OUString* pArray = aRet.getArray();
1143 pArray[0] = C2U("com.sun.star.text.BaseFrame");
1144 pArray[1] = C2U("com.sun.star.text.TextContent");
1145 pArray[2] = C2U("com.sun.star.document.LinkTarget");
1146 return aRet;
1147 }
1148
1149
SwXFrame(FlyCntType eSet,const::SfxItemPropertySet * pSet,SwDoc * pDoc)1150 SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc) :
1151 aLstnrCntnr( (container::XNamed*)this),
1152 m_pPropSet(pSet),
1153 m_pDoc ( pDoc ),
1154 eType(eSet),
1155 bIsDescriptor(sal_True),
1156 m_pCopySource( 0 )
1157 {
1158 // Register ourselves as a listener to the document (via the page descriptor)
1159 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1160 // get the property set for the default style data
1161 // First get the model
1162 uno::Reference < XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1163 // Ask the model for it's family supplier interface
1164 uno::Reference < XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1165 // Get the style families
1166 uno::Reference < XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1167 // Get the Frame family (and keep it for later)
1168 const ::uno::Any aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "FrameStyles" ) ) );
1169 aAny >>= mxStyleFamily;
1170 // In the derived class, we'll ask mxStyleFamily for the relevant default style
1171 // mxStyleFamily is initialised in the SwXFrame constructor
1172 switch(eType)
1173 {
1174 case FLYCNTTYPE_FRM:
1175 {
1176 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Frame" ) ) );
1177 aAny2 >>= mxStyleData;
1178 pProps = new SwFrameProperties_Impl( );
1179 }
1180 break;
1181 case FLYCNTTYPE_GRF:
1182 {
1183 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Graphics" ) ) );
1184 aAny2 >>= mxStyleData;
1185 pProps = new SwGraphicProperties_Impl( );
1186 }
1187 break;
1188 case FLYCNTTYPE_OLE:
1189 {
1190 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "OLE" ) ) );
1191 aAny2 >>= mxStyleData;
1192 pProps = new SwOLEProperties_Impl( );
1193 }
1194 break;
1195
1196 default:
1197 ;
1198 }
1199 }
1200
1201
SwXFrame(SwFrmFmt & rFrmFmt,FlyCntType eSet,const::SfxItemPropertySet * pSet)1202 SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet) :
1203 SwClient( &rFrmFmt ),
1204 aLstnrCntnr( (container::XNamed*)this),
1205 m_pPropSet(pSet),
1206 m_pDoc( 0 ),
1207 eType(eSet),
1208 pProps(0),
1209 bIsDescriptor(sal_False),
1210 m_pCopySource(0)
1211 {
1212
1213 }
1214
~SwXFrame()1215 SwXFrame::~SwXFrame()
1216 {
1217 delete m_pCopySource;
1218 delete pProps;
1219 }
1220
getName(void)1221 OUString SwXFrame::getName(void)
1222 {
1223 vos::OGuard aGuard(Application::GetSolarMutex());
1224 String sRet;
1225 SwFrmFmt* pFmt = GetFrmFmt();
1226 if(pFmt)
1227 sRet = pFmt->GetName();
1228 else if(bIsDescriptor)
1229 sRet = sName;
1230 else
1231 throw uno::RuntimeException();
1232 return sRet;
1233 }
1234
setName(const::OUString & rName)1235 void SwXFrame::setName(const :: OUString& rName)
1236 {
1237 vos::OGuard aGuard(Application::GetSolarMutex());
1238 SwFrmFmt* pFmt = GetFrmFmt();
1239 String sTmpName(rName);
1240 if(pFmt)
1241 {
1242 pFmt->GetDoc()->SetFlyName((SwFlyFrmFmt&)*pFmt, sTmpName);
1243 if(pFmt->GetName() != sTmpName)
1244 {
1245 throw uno::RuntimeException();
1246 }
1247 }
1248 else if(bIsDescriptor)
1249 sName = sTmpName;
1250 else
1251 throw uno::RuntimeException();
1252 }
1253
getPropertySetInfo(void)1254 uno::Reference< beans::XPropertySetInfo > SwXFrame::getPropertySetInfo(void)
1255 {
1256 uno::Reference< beans::XPropertySetInfo > xRef;
1257 static uno::Reference< beans::XPropertySetInfo > xFrmRef;
1258 static uno::Reference< beans::XPropertySetInfo > xGrfRef;
1259 static uno::Reference< beans::XPropertySetInfo > xOLERef;
1260 switch(eType)
1261 {
1262 case FLYCNTTYPE_FRM:
1263 if( !xFrmRef.is() )
1264 xFrmRef = m_pPropSet->getPropertySetInfo();
1265 xRef = xFrmRef;
1266 break;
1267 case FLYCNTTYPE_GRF:
1268 if( !xGrfRef.is() )
1269 xGrfRef = m_pPropSet->getPropertySetInfo();
1270 xRef = xGrfRef;
1271 break;
1272 case FLYCNTTYPE_OLE:
1273 if( !xOLERef.is() )
1274 xOLERef = m_pPropSet->getPropertySetInfo();
1275 xRef = xOLERef;
1276 break;
1277 default:
1278 ;
1279 }
1280 return xRef;
1281 }
1282
SetSelection(SwPaM & rCopySource)1283 void SwXFrame::SetSelection(SwPaM& rCopySource)
1284 {
1285 if(m_pCopySource)
1286 delete m_pCopySource;
1287 m_pCopySource = new SwPaM( *rCopySource.Start() );
1288 m_pCopySource->SetMark();
1289 *m_pCopySource->GetMark() = *rCopySource.End();
1290 }
1291
GetOrCreateSdrObject(SwFlyFrmFmt * pFmt)1292 SdrObject *SwXFrame::GetOrCreateSdrObject( SwFlyFrmFmt *pFmt )
1293 {
1294 SdrObject* pObject = pFmt->FindSdrObject();
1295 if( !pObject )
1296 {
1297 SwDoc *pDoc = pFmt->GetDoc();
1298 // --> OD 2005-08-08 #i52858# - method name changed
1299 SwDrawModel* pDrawModel = pDoc->GetOrCreateDrawModel();
1300 // <--
1301 SwFlyDrawContact* pContactObject
1302 = new SwFlyDrawContact( pFmt, pDrawModel );
1303 pObject = pContactObject->GetMaster();
1304
1305 const :: SwFmtSurround& rSurround = pFmt->GetSurround();
1306 pObject->SetLayer(
1307 ( SURROUND_THROUGHT == rSurround.GetSurround() &&
1308 !pFmt->GetOpaque().GetValue() ) ? pDoc->GetHellId()
1309 : pDoc->GetHeavenId() );
1310
1311 pDrawModel->GetPage(0)->InsertObject( pObject );
1312 }
1313
1314 return pObject;
1315 }
1316
lcl_GetFrmFmt(const::uno::Any & rValue,SwDoc * pDoc)1317 SwFrmFmt *lcl_GetFrmFmt( const :: uno::Any& rValue, SwDoc *pDoc )
1318 {
1319 SwFrmFmt *pRet = 0;
1320 SwDocShell* pDocSh = pDoc->GetDocShell();
1321 if(pDocSh)
1322 {
1323 OUString uTemp;
1324 rValue >>= uTemp;
1325 String sStyle;
1326 SwStyleNameMapper::FillUIName(String (uTemp), sStyle, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, sal_True );
1327 SwDocStyleSheet* pStyle =
1328 (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle,
1329 SFX_STYLE_FAMILY_FRAME);
1330 if(pStyle)
1331 pRet = pStyle->GetFrmFmt();
1332 }
1333
1334 return pRet;
1335 }
1336
setPropertyValue(const::OUString & rPropertyName,const::uno::Any & _rValue)1337 void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::Any& _rValue)
1338 {
1339 vos::OGuard aGuard(Application::GetSolarMutex());
1340 SwFrmFmt* pFmt = GetFrmFmt();
1341 const :: SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1342
1343 if (!pEntry)
1344 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1345
1346 //UUUU
1347 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
1348 uno::Any aValue(_rValue);
1349
1350 //UUUU check for needed metric translation
1351 if(pEntry->nMemberId & SFX_METRIC_ITEM)
1352 {
1353 bool bDoIt(true);
1354
1355 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
1356 {
1357 // exception: If these ItemTypes are used, do not convert when these are negative
1358 // since this means they are intended as percent values
1359 sal_Int32 nValue = 0;
1360
1361 if(aValue >>= nValue)
1362 {
1363 bDoIt = nValue > 0;
1364 }
1365 }
1366
1367 if(bDoIt)
1368 {
1369 const SwDoc* pDoc = (IsDescriptor() ? m_pDoc : GetFrmFmt()->GetDoc());
1370 const SfxItemPool& rPool = pDoc->GetAttrPool();
1371 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
1372
1373 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1374 {
1375 SvxUnoConvertFromMM(eMapUnit, aValue);
1376 }
1377 }
1378 }
1379
1380 if(pFmt)
1381 {
1382 sal_Bool bNextFrame = sal_False;
1383 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1384 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1385
1386 SwDoc* pDoc = pFmt->GetDoc();
1387 if ((eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) ||
1388 (FN_PARAM_COUNTOUR_PP == pEntry->nWID) ||
1389 (FN_UNO_IS_AUTOMATIC_CONTOUR == pEntry->nWID) ||
1390 (FN_UNO_IS_PIXEL_CONTOUR == pEntry->nWID) )
1391 {
1392 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1393 if(pIdx)
1394 {
1395 SwNodeIndex aIdx(*pIdx, 1);
1396 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1397 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP)
1398 {
1399 drawing::PointSequenceSequence aParam;
1400 if(!aValue.hasValue())
1401 pNoTxt->SetContour(0);
1402 else if(aValue >>= aParam)
1403 {
1404 PolyPolygon aPoly((sal_uInt16)aParam.getLength());
1405 for(sal_Int32 i = 0; i < aParam.getLength(); i++)
1406 {
1407 const :: drawing::PointSequence* pPointSeq = aParam.getConstArray();
1408 sal_Int32 nPoints = pPointSeq[i].getLength();
1409 const :: awt::Point* pPoints = pPointSeq[i].getConstArray();
1410 Polygon aSet( (sal_uInt16)nPoints );
1411 for(sal_Int32 j = 0; j < nPoints; j++)
1412 {
1413 Point aPoint(pPoints[j].X, pPoints[j].Y);
1414 aSet.SetPoint(aPoint, (sal_uInt16)j);
1415 }
1416 // Close polygon if it isn't closed already.
1417 aSet.Optimize( POLY_OPTIMIZE_CLOSE );
1418 aPoly.Insert( aSet );
1419 }
1420 pNoTxt->SetContourAPI( &aPoly );
1421 }
1422 else
1423 throw lang::IllegalArgumentException();
1424 }
1425 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR )
1426 {
1427 pNoTxt->SetAutomaticContour( *(sal_Bool *)aValue.getValue() );
1428 }
1429 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )
1430 {
1431 // The IsPixelContour property can only be set if there
1432 // is no contour, or if the contour has been set by the
1433 // API itself (or in other words, if the contour isn't
1434 // used already).
1435 if( !pNoTxt->_HasContour() ||
1436 !pNoTxt->IsContourMapModeValid() )
1437 pNoTxt->SetPixelContour( *(sal_Bool *)aValue.getValue() );
1438 else
1439 throw lang::IllegalArgumentException();
1440 }
1441 else
1442 {
1443 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
1444 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1445 pNoTxt->SetAttr(aSet);
1446 }
1447 }
1448 }
1449 // New attribute Title
1450 else if( FN_UNO_TITLE == pEntry->nWID )
1451 {
1452 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1453 ASSERT( pFmt,
1454 "unexpected type of <pFmt> --> crash" );
1455 OUString uTemp;
1456 aValue >>= uTemp;
1457 const String sTitle(uTemp);
1458 // assure that <SdrObject> instance exists.
1459 GetOrCreateSdrObject( pFlyFmt );
1460 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), sTitle );
1461 }
1462 // New attribute Description
1463 else if( FN_UNO_DESCRIPTION == pEntry->nWID )
1464 {
1465 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1466 ASSERT( pFmt,
1467 "unexpected type of <pFmt> --> crash" );
1468 OUString uTemp;
1469 aValue >>= uTemp;
1470 const String sDescription(uTemp);
1471 // assure that <SdrObject> instance exists.
1472 GetOrCreateSdrObject( pFlyFmt );
1473 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), sDescription );
1474 }
1475 else if( FN_UNO_DECORATIVE == pEntry->nWID )
1476 {
1477 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1478 ASSERT( pFmt,
1479 "unexpected type of <pFmt> --> crash" );
1480 sal_Bool bDecorative = sal_False;
1481 aValue >>= bDecorative;
1482 // assure that <SdrObject> instance exists.
1483 GetOrCreateSdrObject( pFlyFmt );
1484 if ( pFlyFmt->IsObjDecorative() != ( bDecorative != sal_False ) )
1485 {
1486 pFlyFmt->SetObjDecorative( bDecorative );
1487 pFlyFmt->GetDoc()->SetModified();
1488 }
1489 }
1490 // <--
1491 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID)
1492 {
1493 SwFrmFmt *pFrmFmt = lcl_GetFrmFmt( aValue, pFmt->GetDoc() );
1494 if( pFrmFmt )
1495 {
1496 UnoActionContext aAction(pFmt->GetDoc());
1497
1498 SfxItemSet* pSet = 0;
1499 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of
1500 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ),
1501 // if document is currently in reading mode.
1502 if ( !pFmt->GetDoc()->IsInReading() )
1503 {
1504 // see SwFEShell::SetFrmFmt( SwFrmFmt *pNewFmt, sal_Bool bKeepOrient, Point* pDocPos )
1505 SwFlyFrm *pFly = 0;
1506 {
1507 const :: SwFrmFmt* pFmtXX = pFmt;
1508 if (PTR_CAST(SwFlyFrmFmt, pFmtXX))
1509 pFly = ((SwFlyFrmFmt*)pFmtXX)->GetFrm();
1510 }
1511 if ( pFly )
1512 {
1513 const :: SfxPoolItem* pItem;
1514 if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_ANCHOR, sal_False, &pItem ))
1515 {
1516 pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrmFmtSetRange );
1517 pSet->Put( *pItem );
1518 if ( pFmt->GetDoc()->GetEditShell() != NULL
1519 && !::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, *pSet ) )
1520 delete pSet, pSet = 0;
1521 }
1522 }
1523 }
1524 // <--
1525
1526 pFmt->GetDoc()->SetFrmFmtToFly( *pFmt, *pFrmFmt, pSet, sal_False );
1527 delete pSet;
1528 }
1529 else
1530 throw lang::IllegalArgumentException();
1531 }
1532 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID ||
1533 FN_UNO_GRAPHIC_FILTER == pEntry->nWID)
1534 {
1535 String sGrfName, sFltName;
1536 GraphicObject *pGrfObj = 0;
1537 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, &sGrfName, &sFltName );
1538 OUString uTemp;
1539 aValue >>= uTemp;
1540 String sTmp(uTemp);
1541 UnoActionContext aAction(pFmt->GetDoc());
1542 if(FN_UNO_GRAPHIC_U_R_L == pEntry->nWID)
1543 {
1544 if( sTmp.EqualsAscii( sPackageProtocol,
1545 0, sizeof( sPackageProtocol )-1 ) )
1546 {
1547 pGrfObj = new GraphicObject;
1548 pGrfObj->SetUserData( sTmp );
1549 pGrfObj->SetSwapState();
1550 sGrfName.Erase();
1551 }
1552 else if( sTmp.EqualsAscii( sGraphicObjectProtocol,
1553 0, sizeof(sGraphicObjectProtocol)-1 ) )
1554 {
1555 ByteString sId( sTmp.Copy(sizeof(sGraphicObjectProtocol)-1),
1556 RTL_TEXTENCODING_ASCII_US );
1557 pGrfObj = new GraphicObject( sId );
1558 sGrfName.Erase();
1559 }
1560 else
1561 {
1562 sGrfName = sTmp;
1563 }
1564 }
1565 else
1566 {
1567 sFltName = sTmp;
1568 }
1569
1570 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1571 if(pIdx)
1572 {
1573 SwNodeIndex aIdx(*pIdx, 1);
1574 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1575 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
1576 if(!pGrfNode)
1577 {
1578 delete pGrfObj;
1579 throw uno::RuntimeException();
1580 }
1581 SwPaM aGrfPaM(*pGrfNode);
1582 pFmt->GetDoc()->ReRead( aGrfPaM, sGrfName, sFltName, 0,
1583 pGrfObj );
1584 }
1585 delete pGrfObj;
1586 }
1587 else if( FN_UNO_GRAPHIC == pEntry->nWID )
1588 {
1589 uno::Reference< graphic::XGraphic > xGraphic;
1590 aValue >>= xGraphic;
1591 if(xGraphic.is())
1592 {
1593 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1594 if(pIdx)
1595 {
1596 SwNodeIndex aIdx(*pIdx, 1);
1597 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
1598 if(!pGrfNode)
1599 {
1600 throw uno::RuntimeException();
1601 }
1602 SwPaM aGrfPaM(*pGrfNode);
1603 Graphic aGraphic( xGraphic );
1604 pFmt->GetDoc()->ReRead( aGrfPaM, String(), String(), &aGraphic, 0 );
1605 }
1606 }
1607 }
1608 else if( FN_UNO_REPLACEMENT_GRAPHIC_URL == pEntry->nWID || FN_UNO_REPLACEMENT_GRAPHIC == pEntry->nWID )
1609 {
1610 bool bURL = FN_UNO_REPLACEMENT_GRAPHIC_URL == pEntry->nWID;
1611 bool bApply = false;
1612 Graphic aGraphic;
1613 if( bURL )
1614 {
1615 GraphicObject *pGrfObj = 0;
1616 OUString aGrfUrl;
1617 aValue >>= aGrfUrl;
1618
1619 // the package URL based graphics are handled in different way currently
1620 // TODO/LATER: actually this is the correct place to handle them
1621 ::rtl::OUString aGraphicProtocol( RTL_CONSTASCII_USTRINGPARAM( sGraphicObjectProtocol ) );
1622 if( aGrfUrl.compareTo( aGraphicProtocol, aGraphicProtocol.getLength() ) == 0 )
1623 {
1624 ByteString sId( aGrfUrl.copy(sizeof(sGraphicObjectProtocol)-1).getStr(), RTL_TEXTENCODING_ASCII_US );
1625 pGrfObj = new GraphicObject( sId );
1626 aGraphic = pGrfObj->GetGraphic();
1627 bApply = true;
1628 }
1629 }
1630 else
1631 {
1632 uno::Reference< graphic::XGraphic > xGraphic;
1633 aValue >>= xGraphic;
1634 if( xGraphic.is() )
1635 {
1636 aGraphic = Graphic( xGraphic );
1637 bApply = true;
1638 }
1639 }
1640
1641 if ( bApply )
1642 {
1643 const :: SwFmtCntnt* pCnt = &pFmt->GetCntnt();
1644 if ( pCnt->GetCntntIdx() && pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ] )
1645 {
1646 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode();
1647
1648 if ( pOleNode )
1649 {
1650 svt::EmbeddedObjectRef xObj = pOleNode->GetOLEObj().GetObject();
1651
1652 ::rtl::OUString aMediaType;
1653 xObj.SetGraphic( aGraphic, aMediaType );
1654 }
1655 }
1656 }
1657 }
1658 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME))))
1659 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME)))
1660 {
1661 OUString uTemp;
1662 aValue >>= uTemp;
1663 String sChainName(uTemp);
1664 if(!sChainName.Len())
1665 {
1666 if(bNextFrame)
1667 pDoc->Unchain(*pFmt);
1668 else
1669 {
1670 SwFmtChain aChain( pFmt->GetChain() );
1671 SwFrmFmt *pPrev = aChain.GetPrev();
1672 if(pPrev)
1673 pDoc->Unchain(*pPrev);
1674 }
1675 }
1676 else
1677 {
1678 sal_uInt16 nCount = pDoc->GetFlyCount(FLYCNTTYPE_FRM);
1679
1680 SwFrmFmt* pChain = 0;
1681 for( sal_uInt16 i = 0; i < nCount; i++)
1682 {
1683 SwFrmFmt* pFmt2 = pDoc->GetFlyNum(i, FLYCNTTYPE_FRM);
1684 if(sChainName == pFmt2->GetName() )
1685 {
1686 pChain = pFmt2;
1687 break;
1688 }
1689 }
1690 if(pChain)
1691 {
1692 SwFrmFmt* pSource = bNextFrame ? pFmt : pChain;
1693 SwFrmFmt* pDest = bNextFrame ? pChain: pFmt;
1694 pDoc->Chain(*pSource, *pDest);
1695 }
1696 }
1697 }
1698 else if(FN_UNO_Z_ORDER == pEntry->nWID)
1699 {
1700 sal_Int32 nZOrder = - 1;
1701 aValue >>= nZOrder;
1702 if( nZOrder >= 0)
1703 {
1704 SdrObject* pObject =
1705 GetOrCreateSdrObject( (SwFlyFrmFmt*)pFmt );
1706 SwDrawModel* pDrawModel = pDoc->GetDrawModel();
1707 pDrawModel->GetPage(0)->
1708 SetObjectOrdNum(pObject->GetOrdNum(), nZOrder);
1709 }
1710 }
1711 else if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == nMemberId)
1712 {
1713 sal_Bool bDone = sal_False;
1714 uno::Reference<text::XTextFrame> xFrame;
1715 if(aValue >>= xFrame)
1716 {
1717 uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
1718 SwXFrame* pFrame = xTunnel.is() ?
1719 reinterpret_cast< SwXFrame * >( sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
1720 : 0;
1721 if(pFrame && this != pFrame && pFrame->GetFrmFmt() && pFrame->GetFrmFmt()->GetDoc() == pDoc)
1722 {
1723 SfxItemSet aSet( pDoc->GetAttrPool(),
1724 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
1725 aSet.SetParent(&pFmt->GetAttrSet());
1726 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID);
1727
1728
1729 SwPosition aPos(*pFrame->GetFrmFmt()->GetCntnt().GetCntntIdx());
1730 aAnchor.SetAnchor(&aPos);
1731 aAnchor.SetType(FLY_AT_FLY);
1732 aSet.Put(aAnchor);
1733 pDoc->SetFlyFrmAttr( *pFmt, aSet );
1734 bDone = sal_True;
1735 }
1736 }
1737 if(!bDone)
1738 throw lang::IllegalArgumentException();
1739 }
1740 else
1741 { //UUUU
1742 // standard UNO API write attributes
1743 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
1744 SfxItemSet aSet( pDoc->GetAttrPool(),
1745 RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
1746 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
1747
1748 //UUUU FillAttribute support
1749 XATTR_FILL_FIRST, XATTR_FILL_LAST,
1750
1751 0L);
1752 bool bDone(false);
1753
1754 aSet.SetParent(&pFmt->GetAttrSet());
1755
1756 if(RES_BACKGROUND == pEntry->nWID)
1757 {
1758 const SwAttrSet& rSet = pFmt->GetAttrSet();
1759 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
1760 SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
1761
1762 aChangedBrushItem.PutValue(aValue, nMemberId);
1763
1764 if(!(aChangedBrushItem == aOriginalBrushItem))
1765 {
1766 setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet);
1767 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
1768 }
1769
1770 bDone = true;
1771 }
1772 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
1773 {
1774 //UUUU
1775 drawing::BitmapMode eMode;
1776
1777 if(!(aValue >>= eMode))
1778 {
1779 sal_Int32 nMode = 0;
1780
1781 if(!(aValue >>= nMode))
1782 {
1783 throw lang::IllegalArgumentException();
1784 }
1785
1786 eMode = (drawing::BitmapMode)nMode;
1787 }
1788
1789 aSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
1790 aSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
1791 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
1792 bDone = true;
1793 }
1794
1795 switch(nMemberId)
1796 {
1797 case MID_NAME:
1798 {
1799 //UUUU when named items get set, replace these with the NameOrIndex items
1800 // which exist already in the pool
1801 switch(pEntry->nWID)
1802 {
1803 case XATTR_FILLGRADIENT:
1804 case XATTR_FILLHATCH:
1805 case XATTR_FILLBITMAP:
1806 case XATTR_FILLFLOATTRANSPARENCE:
1807 {
1808 OUString aTempName;
1809
1810 if(!(aValue >>= aTempName ))
1811 {
1812 throw lang::IllegalArgumentException();
1813 }
1814
1815 bDone = SvxShape::SetFillAttribute(pEntry->nWID, aTempName, aSet);
1816 break;
1817 }
1818 default:
1819 {
1820 break;
1821 }
1822 }
1823 break;
1824 }
1825 case MID_GRAFURL:
1826 {
1827 //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
1828 switch(pEntry->nWID)
1829 {
1830 case XATTR_FILLBITMAP:
1831 {
1832 const Graphic aNullGraphic;
1833 XFillBitmapItem aXFillBitmapItem(aSet.GetPool(), aNullGraphic);
1834
1835 aXFillBitmapItem.PutValue(aValue, nMemberId);
1836 aSet.Put(aXFillBitmapItem);
1837 bDone = true;
1838 break;
1839 }
1840 default:
1841 {
1842 break;
1843 }
1844 }
1845 break;
1846 }
1847 default:
1848 {
1849 break;
1850 }
1851 }
1852
1853 if(!bDone)
1854 {
1855 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1856 }
1857
1858 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == nMemberId)
1859 {
1860 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID);
1861 if(aAnchor.GetAnchorId() == FLY_AT_FLY)
1862 {
1863 const :: SwPosition* pPosition = aAnchor.GetCntntAnchor();
1864 SwFrmFmt* pFlyFmt = pPosition ? pPosition->nNode.GetNode().GetFlyFmt() : 0;
1865 if(!pFlyFmt || pFlyFmt->Which() == RES_DRAWFRMFMT)
1866 {
1867 lang::IllegalArgumentException aExcept;
1868 aExcept.Message = C2U("Anchor to frame: no frame found");
1869 throw aExcept;
1870 }
1871 else
1872 {
1873 SwPosition aPos = *pPosition;
1874 aPos.nNode = *pFlyFmt->GetCntnt().GetCntntIdx();
1875 aAnchor.SetAnchor(&aPos);
1876 aSet.Put(aAnchor);
1877 }
1878 }
1879 else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) &&
1880 !aAnchor.GetCntntAnchor())
1881 {
1882 SwNode& rNode = pDoc->GetNodes().GetEndOfContent();
1883 SwPaM aPam(rNode);
1884 aPam.Move( fnMoveBackward, fnGoDoc );
1885 aAnchor.SetAnchor( aPam.Start() );
1886 aSet.Put(aAnchor);
1887 }
1888
1889 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of
1890 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ),
1891 // if document is currently in reading mode.
1892 if ( !pFmt->GetDoc()->IsInReading() )
1893 {
1894 // see SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet )
1895 SwFlyFrm *pFly = 0;
1896 if (PTR_CAST(SwFlyFrmFmt, pFmt))
1897 pFly = ((SwFlyFrmFmt*)pFmt)->GetFrm();
1898 if (pFly)
1899 {
1900 const :: SfxPoolItem* pItem;
1901 if( SFX_ITEM_SET == aSet.GetItemState( RES_ANCHOR, sal_False, &pItem ))
1902 {
1903 aSet.Put( *pItem );
1904 if ( pFmt->GetDoc()->GetEditShell() != NULL )
1905 {
1906 ::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, aSet );
1907 }
1908 }
1909 }
1910 }
1911 // <--
1912
1913 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
1914 }
1915 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_STREAM_NAME == pEntry->nWID)
1916 {
1917 throw lang::IllegalArgumentException();
1918 }
1919 else
1920 {
1921 pFmt->SetFmtAttr(aSet);
1922 }
1923 }
1924 }
1925 else if(IsDescriptor())
1926 {
1927 pProps->SetProperty(pEntry->nWID, nMemberId, aValue);
1928 if( FN_UNO_FRAME_STYLE_NAME == pEntry->nWID )
1929 {
1930 OUString sStyleName;
1931 aValue >>= sStyleName;
1932 try
1933 {
1934 uno::Any aAny = mxStyleFamily->getByName ( sStyleName );
1935 aAny >>= mxStyleData;
1936 }
1937 catch ( container::NoSuchElementException const & )
1938 {
1939 }
1940 catch ( lang::WrappedTargetException const & )
1941 {
1942 }
1943 catch ( uno::RuntimeException const & )
1944 {
1945 }
1946 }
1947 }
1948 else
1949 throw uno::RuntimeException();
1950 }
1951
getPropertyValue(const OUString & rPropertyName)1952 uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
1953 {
1954 vos::OGuard aGuard(Application::GetSolarMutex());
1955 uno::Any aAny;
1956 SwFrmFmt* pFmt = GetFrmFmt();
1957 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1958 if (!pEntry)
1959 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1960
1961 //UUUU
1962 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
1963
1964 if(FN_UNO_ANCHOR_TYPES == pEntry->nWID)
1965 {
1966 uno::Sequence<text::TextContentAnchorType> aTypes(5);
1967 text::TextContentAnchorType* pArray = aTypes.getArray();
1968 pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
1969 pArray[1] = text::TextContentAnchorType_AS_CHARACTER;
1970 pArray[2] = text::TextContentAnchorType_AT_PAGE;
1971 pArray[3] = text::TextContentAnchorType_AT_FRAME;
1972 pArray[4] = text::TextContentAnchorType_AT_CHARACTER;
1973 aAny.setValue(&aTypes, ::getCppuType(static_cast<uno::Sequence<text::TextContentAnchorType>*>(0)));
1974 }
1975 else if(pFmt)
1976 {
1977 if( ((eType == FLYCNTTYPE_GRF) || (eType == FLYCNTTYPE_OLE)) &&
1978 pEntry &&
1979 (isGRFATR(pEntry->nWID) ||
1980 pEntry->nWID == FN_PARAM_COUNTOUR_PP ||
1981 pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR ||
1982 pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ))
1983 {
1984 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1985 if(pIdx)
1986 {
1987 SwNodeIndex aIdx(*pIdx, 1);
1988 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1989 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP)
1990 {
1991 PolyPolygon aContour;
1992 if( pNoTxt->GetContourAPI( aContour ) )
1993 {
1994 drawing::PointSequenceSequence aPtSeq(aContour.Count());
1995 drawing::PointSequence* pPSeq = aPtSeq.getArray();
1996 for(sal_uInt16 i = 0; i < aContour.Count(); i++)
1997 {
1998 const Polygon& rPoly = aContour.GetObject(i);
1999 pPSeq[i].realloc(rPoly.GetSize());
2000 awt::Point* pPoints = pPSeq[i].getArray();
2001 for(sal_uInt16 j = 0; j < rPoly.GetSize(); j++)
2002 {
2003 const Point& rPoint = rPoly.GetPoint(j);
2004 pPoints[j].X = rPoint.X();
2005 pPoints[j].Y = rPoint.Y();
2006 }
2007 }
2008 aAny <<= aPtSeq;
2009 }
2010 }
2011 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR )
2012 {
2013 sal_Bool bValue = pNoTxt->HasAutomaticContour();
2014 aAny.setValue( &bValue, ::getBooleanCppuType() );
2015 }
2016 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )
2017 {
2018 sal_Bool bValue = pNoTxt->IsPixelContour();
2019 aAny.setValue( &bValue, ::getBooleanCppuType() );
2020 }
2021 else
2022 {
2023 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
2024 m_pPropSet->getPropertyValue(*pEntry, aSet, aAny);
2025 }
2026 }
2027 }
2028 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID)
2029 {
2030 String sGrfName;
2031 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2032 if ( pIdx )
2033 {
2034 SwNodeIndex aIdx( *pIdx, 1 );
2035 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
2036 if ( !pGrfNode )
2037 throw uno::RuntimeException();
2038 if ( pGrfNode->IsGrfLink() )
2039 {
2040 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*) pFmt, &sGrfName, 0 );
2041 }
2042 else
2043 {
2044 String sPrefix( RTL_CONSTASCII_STRINGPARAM( sGraphicObjectProtocol ) );
2045 String sId( pGrfNode->GetGrfObj().GetUniqueID(),
2046 RTL_TEXTENCODING_ASCII_US );
2047 ( sGrfName = sPrefix ) += sId;
2048 }
2049 }
2050 aAny <<= OUString( sGrfName );
2051 }
2052 else if( FN_UNO_REPLACEMENT_GRAPHIC_U_R_L == pEntry->nWID)
2053 {
2054 String sGrfName;
2055 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2056
2057 if(pIdx)
2058 {
2059 SwNodeIndex aIdx(*pIdx, 1);
2060 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
2061 if(!pGrfNode)
2062 throw uno::RuntimeException();
2063
2064 const GraphicObject* pGraphicObject = pGrfNode->GetReplacementGrfObj();
2065
2066 if(pGraphicObject)
2067 {
2068 String sPrefix( RTL_CONSTASCII_STRINGPARAM(sGraphicObjectProtocol) );
2069 String sId( pGraphicObject->GetUniqueID(), RTL_TEXTENCODING_ASCII_US );
2070 (sGrfName = sPrefix) += sId;
2071 }
2072 }
2073
2074 aAny <<= OUString(sGrfName);
2075 }
2076 else if( FN_UNO_GRAPHIC_FILTER == pEntry->nWID )
2077 {
2078 String sFltName;
2079 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, 0, &sFltName );
2080 aAny <<= OUString(sFltName);
2081 }
2082 else if( FN_UNO_GRAPHIC == pEntry->nWID )
2083 {
2084 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2085 if(pIdx)
2086 {
2087 SwNodeIndex aIdx(*pIdx, 1);
2088 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
2089 if(!pGrfNode)
2090 throw uno::RuntimeException();
2091 aAny <<= pGrfNode->GetGrf().GetXGraphic();
2092 }
2093 }
2094 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID)
2095 {
2096 aAny <<= OUString(SwStyleNameMapper::GetProgName(pFmt->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ) );
2097 }
2098 // --> OD 2009-07-13 #i73249#
2099 // Attribute AlternativeText was never published.
2100 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances
2101 // else if(eType != FLYCNTTYPE_FRM &&
2102 // FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
2103 // {
2104 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2105 // if(pIdx)
2106 // {
2107 // SwNodeIndex aIdx(*pIdx, 1);
2108 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2109 // aAny <<= OUString(pNoTxt->GetAlternateText());
2110 // }
2111 // }
2112 else if( FN_UNO_TITLE == pEntry->nWID )
2113 {
2114 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2115 ASSERT( pFmt,
2116 "unexpected type of <pFmt> --> crash" );
2117 // assure that <SdrObject> instance exists.
2118 GetOrCreateSdrObject( pFlyFmt );
2119 aAny <<= OUString(pFlyFmt->GetObjTitle());
2120 }
2121 // New attribute Description
2122 else if( FN_UNO_DESCRIPTION == pEntry->nWID )
2123 {
2124 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2125 ASSERT( pFmt,
2126 "unexpected type of <pFmt> --> crash" );
2127 // assure that <SdrObject> instance exists.
2128 GetOrCreateSdrObject( pFlyFmt );
2129 aAny <<= OUString(pFlyFmt->GetObjDescription());
2130 }
2131 else if( FN_UNO_DECORATIVE == pEntry->nWID )
2132 {
2133 const SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2134 aAny <<= static_cast<sal_Bool>( pFlyFmt && pFlyFmt->IsObjDecorative() );
2135 }
2136 // <--
2137 else if(eType == FLYCNTTYPE_GRF &&
2138 (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ACTUAL_SIZE))))
2139 {
2140 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2141 if(pIdx)
2142 {
2143 SwNodeIndex aIdx(*pIdx, 1);
2144 // --> OD #i85105#
2145 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2146 // Size aActSize = ((SwGrfNode*)pNoTxt)->GetTwipSize();
2147 Size aActSize;
2148 {
2149 SwGrfNode* pGrfNode = dynamic_cast<SwGrfNode*>(aIdx.GetNode().GetNoTxtNode());
2150 if ( pGrfNode )
2151 {
2152 aActSize = pGrfNode->GetTwipSize();
2153 if ( aActSize.Width() == 0 && aActSize.Height() == 0 &&
2154 pGrfNode->IsLinkedFile() )
2155 {
2156 pGrfNode->SwapIn( sal_True );
2157 aActSize = pGrfNode->GetTwipSize();
2158 }
2159 }
2160 }
2161 // <--
2162 awt::Size aTmp;
2163 aTmp.Width = TWIP_TO_MM100(aActSize.Width());
2164 aTmp.Height = TWIP_TO_MM100(aActSize.Height());
2165 aAny.setValue(&aTmp, ::getCppuType(static_cast<const awt::Size*>(0)));
2166 }
2167 }
2168 else if(FN_PARAM_LINK_DISPLAY_NAME == pEntry->nWID)
2169 {
2170 aAny <<= OUString(pFmt->GetName());
2171 }
2172 else if(FN_UNO_Z_ORDER == pEntry->nWID)
2173 {
2174 const SdrObject* pObj = pFmt->FindRealSdrObject();
2175 if( pObj )
2176 {
2177 aAny <<= (sal_Int32)pObj->GetOrdNum();
2178 }
2179 }
2180 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_MODEL == pEntry->nWID||
2181 FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID||
2182 FN_EMBEDDED_OBJECT == pEntry->nWID)
2183 {
2184 SwDoc* pDoc = pFmt->GetDoc();
2185 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
2186 DBG_ASSERT( pCnt->GetCntntIdx() &&
2187 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
2188 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
2189
2190 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()
2191 ->GetIndex() + 1 ]->GetOLENode();
2192 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
2193 OUString aHexCLSID;
2194 {
2195 SvGlobalName aClassName( xIP->getClassID() );
2196 aHexCLSID = aClassName.GetHexName();
2197 if(FN_UNO_CLSID != pEntry->nWID)
2198 {
2199 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
2200 {
2201 uno::Reference < lang::XComponent > xComp( xIP->getComponent(), uno::UNO_QUERY );
2202 uno::Reference < frame::XModel > xModel( xComp, uno::UNO_QUERY );
2203 if ( FN_EMBEDDED_OBJECT == pEntry->nWID )
2204 {
2205 // ensure the
2206 ASSERT( pDoc->GetDocShell(), "no doc shell => no client site" );
2207 if ( pDoc->GetDocShell() )
2208 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
2209 aAny <<= xIP;
2210 }
2211 else if ( xModel.is() )
2212 aAny <<= xModel;
2213 else if ( FN_UNO_COMPONENT == pEntry->nWID )
2214 aAny <<= xComp;
2215 }
2216 }
2217 }
2218
2219 if(FN_UNO_CLSID == pEntry->nWID)
2220 aAny <<= aHexCLSID;
2221 else if(FN_UNO_STREAM_NAME == pEntry->nWID)
2222 {
2223 aAny <<= ::rtl::OUString(pOleNode->GetOLEObj().GetCurrentPersistName());
2224 }
2225 }
2226 else if(WID_LAYOUT_SIZE == pEntry->nWID)
2227 {
2228 // format document completely in order to get correct value
2229 pFmt->GetDoc()->GetEditShell()->CalcLayout();
2230
2231 SwFrm* pTmpFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt );
2232 if ( pTmpFrm )
2233 {
2234 DBG_ASSERT( pTmpFrm->IsValid(), "frame not valid" );
2235 const SwRect &rRect = pTmpFrm->Frm();
2236 Size aMM100Size = OutputDevice::LogicToLogic(
2237 Size( rRect.Width(), rRect.Height() ),
2238 MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ));
2239 aAny <<= awt::Size( aMM100Size.Width(), aMM100Size.Height() );
2240 }
2241 }
2242 else
2243 { //UUUU
2244 // standard UNO API read attributes
2245 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
2246 const SwAttrSet& rSet = pFmt->GetAttrSet();
2247 bool bDone(false);
2248
2249 if(RES_BACKGROUND == pEntry->nWID)
2250 {
2251 //UUUU
2252 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
2253
2254 if(!aOriginalBrushItem.QueryValue(aAny, nMemberId))
2255 {
2256 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
2257 }
2258
2259 bDone = true;
2260 }
2261 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2262 {
2263 //UUUU
2264 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
2265 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
2266
2267 if( pTileItem && pTileItem->GetValue() )
2268 {
2269 aAny <<= drawing::BitmapMode_REPEAT;
2270 }
2271 else if( pStretchItem && pStretchItem->GetValue() )
2272 {
2273 aAny <<= drawing::BitmapMode_STRETCH;
2274 }
2275 else
2276 {
2277 aAny <<= drawing::BitmapMode_NO_REPEAT;
2278 }
2279
2280 bDone = true;
2281 }
2282
2283 if(!bDone)
2284 {
2285 m_pPropSet->getPropertyValue(*pEntry, rSet, aAny);
2286 }
2287 }
2288 }
2289 else if(IsDescriptor())
2290 {
2291 if ( ! m_pDoc )
2292 throw uno::RuntimeException();
2293 if(WID_LAYOUT_SIZE != pEntry->nWID) // there is no LayoutSize in a descriptor
2294 {
2295 const uno::Any* pAny = 0;
2296 if( !pProps->GetProperty( pEntry->nWID, nMemberId, pAny ) )
2297 aAny = mxStyleData->getPropertyValue( rPropertyName );
2298 else if ( pAny )
2299 aAny = *pAny;
2300 }
2301 }
2302 else
2303 throw uno::RuntimeException();
2304
2305 //UUUU
2306 if(pEntry && pEntry->pType && *(pEntry->pType) == ::getCppuType((const sal_Int16*)0) && *(pEntry->pType) != aAny.getValueType())
2307 {
2308 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2309 sal_Int32 nValue = 0;
2310 aAny >>= nValue;
2311 aAny <<= (sal_Int16)nValue;
2312 }
2313
2314 //UUUU check for needed metric translation
2315 if(pEntry->nMemberId & SFX_METRIC_ITEM)
2316 {
2317 bool bDoIt(true);
2318
2319 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
2320 {
2321 // exception: If these ItemTypes are used, do not convert when these are negative
2322 // since this means they are intended as percent values
2323 sal_Int32 nValue = 0;
2324
2325 if(aAny >>= nValue)
2326 {
2327 bDoIt = nValue > 0;
2328 }
2329 }
2330
2331 if(bDoIt)
2332 {
2333 const SwDoc* pDoc = (IsDescriptor() ? m_pDoc : GetFrmFmt()->GetDoc());
2334 const SfxItemPool& rPool = pDoc->GetAttrPool();
2335 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
2336
2337 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
2338 {
2339 SvxUnoConvertToMM(eMapUnit, aAny);
2340 }
2341 }
2342 }
2343
2344 return aAny;
2345 }
2346
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)2347 void SwXFrame::addPropertyChangeListener(const OUString& /*PropertyName*/,
2348 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2349 {
2350 DBG_WARNING("not implemented");
2351 }
2352
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)2353 void SwXFrame::removePropertyChangeListener(const OUString& /*PropertyName*/,
2354 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2355 {
2356 DBG_WARNING("not implemented");
2357 }
2358
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)2359 void SwXFrame::addVetoableChangeListener(const OUString& /*PropertyName*/,
2360 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2361 {
2362 DBG_WARNING("not implemented");
2363 }
2364
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)2365 void SwXFrame::removeVetoableChangeListener(
2366 const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2367 {
2368 DBG_WARNING("not implemented");
2369 }
2370
getPropertyState(const OUString & rPropertyName)2371 beans::PropertyState SwXFrame::getPropertyState( const OUString& rPropertyName )
2372 {
2373 vos::OGuard aGuard(Application::GetSolarMutex());
2374 uno::Sequence< OUString > aPropertyNames(1);
2375 OUString* pNames = aPropertyNames.getArray();
2376 pNames[0] = rPropertyName;
2377 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aPropertyNames);
2378 return aStates.getConstArray()[0];
2379 }
2380
getPropertyStates(const uno::Sequence<OUString> & aPropertyNames)2381 uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates(
2382 const uno::Sequence< OUString >& aPropertyNames )
2383 {
2384 vos::OGuard aGuard(Application::GetSolarMutex());
2385 uno::Sequence< beans::PropertyState > aStates(aPropertyNames.getLength());
2386 beans::PropertyState* pStates = aStates.getArray();
2387 SwFrmFmt* pFmt = GetFrmFmt();
2388 if(pFmt)
2389 {
2390 const OUString* pNames = aPropertyNames.getConstArray();
2391 const SwAttrSet& rFmtSet = pFmt->GetAttrSet();
2392 for(int i = 0; i < aPropertyNames.getLength(); i++)
2393 {
2394 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(pNames[i]);
2395 if (!pEntry)
2396 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
2397
2398 if(pEntry->nWID == FN_UNO_ANCHOR_TYPES||
2399 pEntry->nWID == FN_PARAM_LINK_DISPLAY_NAME||
2400 FN_UNO_FRAME_STYLE_NAME == pEntry->nWID||
2401 FN_UNO_GRAPHIC_U_R_L == pEntry->nWID||
2402 FN_UNO_GRAPHIC_FILTER == pEntry->nWID||
2403 FN_UNO_ACTUAL_SIZE == pEntry->nWID||
2404 FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
2405 {
2406 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2407 }
2408 else if(FN_UNO_DECORATIVE == pEntry->nWID)
2409 {
2410 // no item behind it: a default of false must not be exported
2411 const SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2412 pStates[i] = ( pFlyFmt && pFlyFmt->IsObjDecorative() )
2413 ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_DEFAULT_VALUE;
2414 }
2415 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2416 {
2417 //UUUU
2418 if(SFX_ITEM_SET == rFmtSet.GetItemState(XATTR_FILLBMP_STRETCH, false)
2419 || SFX_ITEM_SET == rFmtSet.GetItemState(XATTR_FILLBMP_TILE, false))
2420 {
2421 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2422 }
2423 else
2424 {
2425 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2426 }
2427 }
2428 //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND
2429 // as beans::PropertyState_DIRECT_VALUE to let users of this property call
2430 // getPropertyValue where the member properties will be mapped from the
2431 // fill attributes to the according SvxBrushItem entries
2432 else if(RES_BACKGROUND == pEntry->nWID && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFmtSet))
2433 {
2434 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2435 }
2436 else
2437 {
2438 if ((eType == FLYCNTTYPE_GRF) &&
2439 pEntry && isGRFATR(pEntry->nWID))
2440 {
2441 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2442 if(pIdx)
2443 {
2444 SwNodeIndex aIdx(*pIdx, 1);
2445 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2446 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
2447 aSet.GetItemState(pEntry->nWID);
2448 if(SFX_ITEM_SET == aSet.GetItemState( pEntry->nWID, sal_False ))
2449 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2450 }
2451 }
2452 else
2453 {
2454 if(SFX_ITEM_SET == rFmtSet.GetItemState( pEntry->nWID, sal_False ))
2455 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2456 else
2457 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2458 }
2459 }
2460 }
2461 }
2462 else if(IsDescriptor())
2463 {
2464 for(int i = 0; i < aPropertyNames.getLength(); i++)
2465 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2466 }
2467 else
2468 throw uno::RuntimeException();
2469 return aStates;
2470 }
2471
setPropertyToDefault(const OUString & rPropertyName)2472 void SwXFrame::setPropertyToDefault( const OUString& rPropertyName )
2473 {
2474 vos::OGuard aGuard(Application::GetSolarMutex());
2475 SwFrmFmt* pFmt = GetFrmFmt();
2476 if(pFmt)
2477 {
2478 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
2479 if (!pEntry)
2480 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2481 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2482 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2483
2484 sal_Bool bNextFrame;
2485
2486 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2487 {
2488 //UUUU
2489 SwDoc* pDoc = pFmt->GetDoc();
2490 SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
2491 aSet.SetParent(&pFmt->GetAttrSet());
2492
2493 aSet.ClearItem(XATTR_FILLBMP_STRETCH);
2494 aSet.ClearItem(XATTR_FILLBMP_TILE);
2495
2496 pFmt->SetFmtAttr(aSet);
2497 }
2498 else if( pEntry->nWID &&
2499 pEntry->nWID != FN_UNO_ANCHOR_TYPES &&
2500 pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME)
2501 {
2502 if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) )
2503 {
2504 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2505 if(pIdx)
2506 {
2507 SwNodeIndex aIdx(*pIdx, 1);
2508 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2509 {
2510 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
2511 aSet.ClearItem(pEntry->nWID);
2512 pNoTxt->SetAttr(aSet);
2513 }
2514 }
2515 }
2516 // --> OD 2009-07-13 #i73249#
2517 // Attribute AlternativeText was never published.
2518 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances
2519 // else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID )
2520 // {
2521 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2522 // if(pIdx)
2523 // {
2524 // SwNodeIndex aIdx(*pIdx, 1);
2525 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2526 // pNoTxt->SetAlternateText(aEmptyStr);
2527 // }
2528 // }
2529 // New attribute Title
2530 else if( FN_UNO_TITLE == pEntry->nWID )
2531 {
2532 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2533 ASSERT( pFmt,
2534 "unexpected type of <pFmt> --> crash" );
2535 // assure that <SdrObject> instance exists.
2536 GetOrCreateSdrObject( pFlyFmt );
2537 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), aEmptyStr );
2538 }
2539 // New attribute Description
2540 else if( FN_UNO_DESCRIPTION == pEntry->nWID )
2541 {
2542 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2543 ASSERT( pFmt,
2544 "unexpected type of <pFmt> --> crash" );
2545 // assure that <SdrObject> instance exists.
2546 GetOrCreateSdrObject( pFlyFmt );
2547 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), aEmptyStr );
2548 }
2549 else if( FN_UNO_DECORATIVE == pEntry->nWID )
2550 {
2551 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2552 if ( pFlyFmt && pFlyFmt->IsObjDecorative() )
2553 {
2554 pFlyFmt->SetObjDecorative( false );
2555 pFlyFmt->GetDoc()->SetModified();
2556 }
2557 }
2558 // <--
2559 else
2560 {
2561 SwDoc* pDoc = pFmt->GetDoc();
2562 SfxItemSet aSet( pDoc->GetAttrPool(),
2563 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
2564 aSet.SetParent(&pFmt->GetAttrSet());
2565 aSet.ClearItem(pEntry->nWID);
2566 if(!rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)))
2567 pFmt->SetFmtAttr(aSet);
2568 }
2569 }
2570 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME))))
2571 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME)))
2572 {
2573 SwDoc* pDoc = pFmt->GetDoc();
2574 if(bNextFrame)
2575 pDoc->Unchain(*pFmt);
2576 else
2577 {
2578 SwFmtChain aChain( pFmt->GetChain() );
2579 SwFrmFmt *pPrev = aChain.GetPrev();
2580 if(pPrev)
2581 pDoc->Unchain(*pPrev);
2582 }
2583 }
2584 }
2585 else if(!IsDescriptor())
2586 throw uno::RuntimeException();
2587
2588 }
2589
getPropertyDefault(const OUString & rPropertyName)2590 uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName )
2591 {
2592 vos::OGuard aGuard(Application::GetSolarMutex());
2593 uno::Any aRet;
2594 SwFrmFmt* pFmt = GetFrmFmt();
2595 if(pFmt)
2596 {
2597 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
2598 if(pEntry)
2599 {
2600 if ( pEntry->nWID < RES_FRMATR_END )
2601 {
2602 const SfxPoolItem& rDefItem =
2603 pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
2604 //UUUU
2605 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
2606
2607 rDefItem.QueryValue(aRet, nMemberId);
2608 }
2609 }
2610 else
2611 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2612 }
2613 else if(!IsDescriptor())
2614 throw uno::RuntimeException();
2615 return aRet;
2616 }
2617
addEventListener(const uno::Reference<lang::XEventListener> & aListener)2618 void SwXFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
2619 {
2620 if(!GetRegisteredIn())
2621 throw uno::RuntimeException();
2622 aLstnrCntnr.AddListener(aListener);
2623 }
2624
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)2625 void SwXFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
2626 {
2627 if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener))
2628 throw uno::RuntimeException();
2629 }
2630
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)2631 void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
2632 {
2633 ClientModify(this, pOld, pNew);
2634 if(!GetRegisteredIn())
2635 {
2636 mxStyleData.clear();
2637 mxStyleFamily.clear();
2638 m_pDoc = 0;
2639 aLstnrCntnr.Disposing();
2640 }
2641 }
2642
2643
dispose(void)2644 void SwXFrame::dispose(void)
2645 {
2646 vos::OGuard aGuard(Application::GetSolarMutex());
2647 SwFrmFmt* pFmt = GetFrmFmt();
2648 if ( pFmt )
2649 {
2650 SdrObject* pObj = pFmt->FindSdrObject();
2651 // OD 11.09.2003 #112039# - add condition to perform delete of
2652 // format/anchor sign, not only if the object is inserted, but also
2653 // if a contact object is registered, which isn't in the destruction.
2654 if ( pObj &&
2655 ( pObj->IsInserted() ||
2656 ( pObj->GetUserCall() &&
2657 !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) )
2658 {
2659 if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
2660 {
2661 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
2662 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
2663 const xub_StrLen nIdx = rPos.nContent.GetIndex();
2664 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
2665 }
2666 else
2667 pFmt->GetDoc()->DelLayoutFmt(pFmt);
2668 }
2669 }
2670
2671 }
2672
getAnchor(void)2673 uno::Reference< text::XTextRange > SwXFrame::getAnchor(void)
2674 {
2675 vos::OGuard aGuard(Application::GetSolarMutex());
2676 uno::Reference< text::XTextRange > aRef;
2677 SwFrmFmt* pFmt = GetFrmFmt();
2678 if(pFmt)
2679 {
2680 const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
2681 // return an anchor for non-page bound frames
2682 // and for page bound frames that have a page no == NULL and a content position
2683 if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
2684 (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
2685 {
2686 const SwPosition &rPos = *(rAnchor.GetCntntAnchor());
2687 aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
2688 }
2689 }
2690 else
2691 throw uno::RuntimeException();
2692 return aRef;
2693 }
2694
ResetDescriptor()2695 void SwXFrame::ResetDescriptor()
2696 {
2697 bIsDescriptor = sal_False;
2698 mxStyleData.clear();
2699 mxStyleFamily.clear();
2700 DELETEZ(pProps);
2701 }
2702
attachToRange(const uno::Reference<text::XTextRange> & xTextRange)2703 void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
2704 {
2705 vos::OGuard aGuard(Application::GetSolarMutex());
2706 if(!IsDescriptor())
2707 throw uno::RuntimeException();
2708 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2709 SwXTextRange* pRange = 0;
2710 OTextCursorHelper* pCursor = 0;
2711 if(xRangeTunnel.is())
2712 {
2713 pRange = reinterpret_cast< SwXTextRange * >(
2714 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2715 pCursor = reinterpret_cast< OTextCursorHelper * >(
2716 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2717 }
2718
2719 SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
2720 if(pDoc)
2721 {
2722 SwUnoInternalPaM aIntPam(*pDoc);
2723 //das muss jetzt sal_True liefern
2724 ::sw::XTextRangeToSwPaM(aIntPam, xTextRange);
2725
2726 SwNode& rNode = pDoc->GetNodes().GetEndOfContent();
2727 SwPaM aPam(rNode);
2728 aPam.Move( fnMoveBackward, fnGoDoc );
2729 static sal_uInt16 __READONLY_DATA aFrmAttrRange[] =
2730 {
2731 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
2732 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
2733
2734 //UUUU FillAttribute support
2735 XATTR_FILL_FIRST, XATTR_FILL_LAST,
2736
2737 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
2738 0
2739 };
2740 static sal_uInt16 __READONLY_DATA aGrAttrRange[] =
2741 {
2742 RES_GRFATR_BEGIN, RES_GRFATR_END-1,
2743 0
2744 };
2745 SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange );
2746
2747 SfxItemSet aFrmSet(pDoc->GetAttrPool(), aFrmAttrRange );
2748
2749 //UUUU set correct parent to get the XFILL_NONE FillStyle as needed
2750 aFrmSet.SetParent(&pDoc->GetDfltFrmFmt()->GetAttrSet());
2751
2752 //jetzt muessen die passenden Items in den Set
2753 sal_Bool bSizeFound;
2754 if(!pProps->AnyToItemSet( pDoc, aFrmSet, aGrSet, bSizeFound))
2755 throw lang::IllegalArgumentException();
2756 //der TextRange wird einzeln behandelt
2757 *aPam.GetPoint() = *aIntPam.GetPoint();
2758 if(aIntPam.HasMark())
2759 {
2760 aPam.SetMark();
2761 *aPam.GetMark() = *aIntPam.GetMark();
2762 }
2763
2764 const SfxPoolItem* pItem;
2765 RndStdIds eAnchorId = FLY_AT_PARA;
2766 if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) )
2767 {
2768 eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId();
2769 if( FLY_AT_FLY == eAnchorId &&
2770 !aPam.GetNode()->FindFlyStartNode())
2771 {
2772 //rahmengebunden geht nur dort, wo ein Rahmen ist!
2773 SwFmtAnchor aAnchor(FLY_AT_PARA);
2774 aFrmSet.Put(aAnchor);
2775 }
2776 else if ((FLY_AT_PAGE == eAnchorId) &&
2777 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() )
2778 {
2779 SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) );
2780 aAnchor.SetAnchor( aPam.GetPoint() );
2781 aFrmSet.Put(aAnchor);
2782 }
2783 }
2784
2785 const ::uno::Any* pStyle;
2786 SwFrmFmt *pParentFrmFmt = 0;
2787 if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle))
2788 pParentFrmFmt = lcl_GetFrmFmt( *pStyle, pDoc );
2789
2790 SwFlyFrmFmt* pFmt = 0;
2791 if( eType == FLYCNTTYPE_FRM)
2792 {
2793 UnoActionContext aCont(pDoc);
2794 if(m_pCopySource)
2795 {
2796 SwFmtAnchor* pAnchorItem = 0;
2797 // the frame is inserted bound to page
2798 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text
2799 if (eAnchorId != FLY_AT_PAGE)
2800 {
2801 pAnchorItem = static_cast<SwFmtAnchor*>(aFrmSet.Get(RES_ANCHOR).Clone());
2802 aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 ));
2803 }
2804
2805 aPam.DeleteMark(); // mark position node will be deleted!
2806 aIntPam.DeleteMark(); // mark position node will be deleted!
2807 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet,
2808 0,
2809 pParentFrmFmt );
2810 if(pAnchorItem && pFmt)
2811 {
2812 pFmt->DelFrms();
2813 pAnchorItem->SetAnchor( m_pCopySource->Start() );
2814 SfxItemSet aAnchorSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR );
2815 aAnchorSet.Put( *pAnchorItem );
2816 pDoc->SetFlyFrmAttr( *pFmt, aAnchorSet );
2817 delete pAnchorItem;
2818 }
2819 DELETEZ( m_pCopySource );
2820 }
2821 else
2822 {
2823 pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(),
2824 &aFrmSet, pParentFrmFmt );
2825 }
2826 if(pFmt)
2827 {
2828 pFmt->Add(this);
2829 if(sName.Len())
2830 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName);
2831 }
2832 //den SwXText wecken
2833 ((SwXTextFrame*)this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrmFmt()->GetDoc() );
2834 }
2835 else if( eType == FLYCNTTYPE_GRF)
2836 {
2837 UnoActionContext aCont(pDoc);
2838 const ::uno::Any* pGraphicURL;
2839 String sGraphicURL;
2840 GraphicObject *pGrfObj = 0;
2841 if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL))
2842 {
2843 OUString uTemp;
2844 (*pGraphicURL) >>= uTemp;
2845 sGraphicURL = String(uTemp);
2846 if( sGraphicURL.EqualsAscii( sPackageProtocol,
2847 0, sizeof( sPackageProtocol )-1 ) )
2848 {
2849 pGrfObj = new GraphicObject;
2850 pGrfObj->SetUserData( sGraphicURL );
2851 pGrfObj->SetSwapState();
2852 sGraphicURL.Erase();
2853 }
2854 else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol,
2855 0, sizeof(sGraphicObjectProtocol)-1 ) )
2856 {
2857 ByteString sId( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ),
2858 RTL_TEXTENCODING_ASCII_US );
2859 pGrfObj = new GraphicObject( sId );
2860 sGraphicURL.Erase();
2861 }
2862 }
2863 Graphic aGraphic;
2864 const ::uno::Any* pGraphic;
2865 if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic ))
2866 {
2867 uno::Reference< graphic::XGraphic > xGraphic;
2868 (*pGraphic) >>= xGraphic;
2869 aGraphic = Graphic( xGraphic );
2870 }
2871
2872 String sFltName;
2873 const ::uno::Any* pFilter;
2874 if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter))
2875 {
2876 OUString uTemp;
2877 (*pFilter) >>= uTemp;
2878 sFltName = String(uTemp);
2879 }
2880
2881 pFmt =
2882 pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet,
2883 pParentFrmFmt )
2884 : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic,
2885 &aFrmSet, &aGrSet, pParentFrmFmt );
2886 delete pGrfObj;
2887 if(pFmt)
2888 {
2889 SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFmt->GetCntnt().GetCntntIdx()
2890 ->GetIndex()+1 ]->GetGrfNode();
2891 pGrfNd->SetChgTwipSize( !bSizeFound );
2892 pFmt->Add(this);
2893 if(sName.Len())
2894 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName);
2895
2896 }
2897 const ::uno::Any* pSurroundContour;
2898 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour))
2899 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SURROUND_CONTOUR)), *pSurroundContour);
2900 const ::uno::Any* pContourOutside;
2901 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside))
2902 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_OUTSIDE)), *pContourOutside);
2903 const ::uno::Any* pContourPoly;
2904 if(pProps->GetProperty(FN_PARAM_COUNTOUR_PP, 0, pContourPoly))
2905 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_POLY_POLYGON)), *pContourPoly);
2906 const ::uno::Any* pPixelContour;
2907 if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour))
2908 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_PIXEL_CONTOUR)), *pPixelContour);
2909 const ::uno::Any* pAutoContour;
2910 if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour))
2911 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_AUTOMATIC_CONTOUR)), *pAutoContour);
2912 // const ::uno::Any* pAltText;
2913 // if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText))
2914 // setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText);
2915 }
2916 else
2917 {
2918 const ::uno::Any* pCLSID = 0;
2919 const ::uno::Any* pStreamName = 0;
2920 if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName ))
2921 throw uno::RuntimeException();
2922 if(pCLSID)
2923 {
2924 OUString aCLSID;
2925 SvGlobalName aClassName;
2926 uno::Reference < embed::XEmbeddedObject > xIPObj;
2927 std::unique_ptr < comphelper::EmbeddedObjectContainer > pCnt;
2928 if( (*pCLSID) >>= aCLSID )
2929 {
2930 if( !aClassName.MakeId( aCLSID ) )
2931 {
2932 lang::IllegalArgumentException aExcept;
2933 aExcept.Message = OUString::createFromAscii("CLSID invalid");
2934 throw aExcept;
2935 }
2936
2937 pCnt.reset( new comphelper::EmbeddedObjectContainer );
2938 ::rtl::OUString aName;
2939 xIPObj = pCnt->CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
2940 }
2941 if ( xIPObj.is() )
2942 {
2943 //TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE
2944 //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xIPObj->GetMiscStatus() && pDoc->getPrinter( false ) )
2945 // xIPObj->OnDocumentPrinterChanged( pDoc->getPrinter( false ) );
2946
2947 UnoActionContext aAction(pDoc);
2948 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
2949 if(!bSizeFound)
2950 {
2951 //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode?
2952 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
2953
2954 // TODO/LEAN: VisualArea still needs running state
2955 svt::EmbeddedObjectRef::TryRunningState( xIPObj );
2956
2957 // set parent to get correct VisArea(in case of object needing parent printer)
2958 uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY );
2959 if ( xChild.is() )
2960 xChild->setParent( pDoc->GetDocShell()->GetModel() );
2961
2962 //The Size should be suggested by the OLE server if not manually set
2963 MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) );
2964 awt::Size aSize;
2965 try
2966 {
2967 aSize = xIPObj->getVisualAreaSize( nAspect );
2968 }
2969 catch ( embed::NoVisualAreaSizeException& )
2970 {
2971 // the default size will be set later
2972 }
2973
2974 Size aSz( aSize.Width, aSize.Height );
2975 if ( !aSz.Width() || !aSz.Height() )
2976 {
2977 aSz.Width() = aSz.Height() = 5000;
2978 aSz = OutputDevice::LogicToLogic
2979 ( aSz, MapMode( MAP_100TH_MM ), aRefMap );
2980 }
2981 MapMode aMyMap( MAP_TWIP );
2982 aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap );
2983 SwFmtFrmSize aFrmSz;
2984 aFrmSz.SetSize(aSz);
2985 aFrmSet.Put(aFrmSz);
2986 }
2987 SwFlyFrmFmt* pFmt2 = 0;
2988
2989 // TODO/LATER: Is it the only possible aspect here?
2990 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
2991 ::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect );
2992 pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL );
2993 ASSERT( pFmt2, "Doc->Insert(notxt) failed." );
2994
2995 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
2996 pFmt2->Add(this);
2997 if(sName.Len())
2998 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName);
2999 }
3000 }
3001 else if( pStreamName )
3002 {
3003 ::rtl::OUString sStreamName;
3004 (*pStreamName) >>= sStreamName;
3005 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
3006
3007 SwFlyFrmFmt* pFrmFmt = 0;
3008 pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL );
3009 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
3010 pFrmFmt->Add(this);
3011 if(sName.Len())
3012 pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName);
3013 }
3014 }
3015 if( pFmt && pDoc->GetDrawModel() )
3016 GetOrCreateSdrObject( pFmt );
3017 const ::uno::Any* pOrder;
3018 if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) )
3019 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_Z_ORDER)), *pOrder);
3020 const ::uno::Any* pReplacement;
3021 if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) )
3022 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_GRAPHIC)), *pReplacement);
3023 // --> OD 2009-07-13 #i73249#
3024 // new attribute Title
3025 const ::uno::Any* pTitle;
3026 if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) )
3027 {
3028 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_TITLE)), *pTitle);
3029 }
3030 // new attribute Description
3031 const ::uno::Any* pDescription;
3032 if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) )
3033 {
3034 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DESCRIPTION)), *pDescription);
3035 }
3036 const ::uno::Any* pDecorative;
3037 if ( pProps->GetProperty(FN_UNO_DECORATIVE, 0, pDecorative) )
3038 {
3039 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DECORATIVE)), *pDecorative);
3040 }
3041 // <--
3042 }
3043 else
3044 throw lang::IllegalArgumentException();
3045 //setzt das Flag zurueck und loescht den Descriptor-Pointer
3046 ResetDescriptor();
3047 }
3048
attach(const uno::Reference<text::XTextRange> & xTextRange)3049 void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
3050 {
3051 SwFrmFmt* pFmt;
3052 if(IsDescriptor())
3053 attachToRange(xTextRange);
3054 else if(0 != (pFmt = GetFrmFmt()))
3055 {
3056 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
3057 SwXTextRange* pRange = 0;
3058 OTextCursorHelper* pCursor = 0;
3059 if(xRangeTunnel.is())
3060 {
3061 pRange = reinterpret_cast< SwXTextRange * >(
3062 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
3063 pCursor = reinterpret_cast< OTextCursorHelper * >(
3064 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
3065 }
3066 SwDoc* pDoc = pFmt->GetDoc();
3067 SwUnoInternalPaM aIntPam(*pDoc);
3068 if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange))
3069 {
3070 SfxItemSet aSet( pDoc->GetAttrPool(),
3071 RES_ANCHOR, RES_ANCHOR );
3072 aSet.SetParent(&pFmt->GetAttrSet());
3073 SwFmtAnchor aAnchor = (const SwFmtAnchor&)aSet.Get(RES_ANCHOR);
3074 aAnchor.SetAnchor( aIntPam.Start() );
3075 aSet.Put(aAnchor);
3076 pDoc->SetFlyFrmAttr( *pFmt, aSet );
3077 }
3078 else
3079 throw lang::IllegalArgumentException();
3080 }
3081 }
3082
getPosition(void)3083 awt::Point SwXFrame::getPosition(void)
3084 {
3085 vos::OGuard aGuard(Application::GetSolarMutex());
3086 uno::RuntimeException aRuntime;
3087 aRuntime.Message = C2U("position cannot be determined with this method");
3088 throw aRuntime;
3089 }
3090
setPosition(const awt::Point &)3091 void SwXFrame::setPosition(const awt::Point& /*aPosition*/)
3092 {
3093 vos::OGuard aGuard(Application::GetSolarMutex());
3094 uno::RuntimeException aRuntime;
3095 aRuntime.Message = C2U("position cannot be changed with this method");
3096 throw aRuntime;
3097 }
3098
getSize(void)3099 awt::Size SwXFrame::getSize(void)
3100 {
3101 const ::uno::Any aVal = getPropertyValue(C2U("Size"));
3102 awt::Size* pRet = (awt::Size*)aVal.getValue();
3103 return *pRet;
3104 }
3105
setSize(const awt::Size & aSize)3106 void SwXFrame::setSize(const awt::Size& aSize)
3107 {
3108 const ::uno::Any aVal(&aSize, ::getCppuType(static_cast<const awt::Size*>(0)));
3109 setPropertyValue(C2U("Size"), aVal);
3110 }
3111
getShapeType(void)3112 OUString SwXFrame::getShapeType(void)
3113 {
3114 return C2U("FrameShape");
3115 }
3116
3117
3118 /******************************************************************
3119 * SwXTextFrame
3120 ******************************************************************/
3121
SwXTextFrame(SwDoc * _pDoc)3122 SwXTextFrame::SwXTextFrame( SwDoc *_pDoc ) :
3123 SwXText(0, CURSOR_FRAME),
3124 SwXFrame(FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME), _pDoc )
3125 {
3126 }
3127
SwXTextFrame(SwFrmFmt & rFmt)3128 SwXTextFrame::SwXTextFrame(SwFrmFmt& rFmt) :
3129 SwXText(rFmt.GetDoc(), CURSOR_FRAME),
3130 SwXFrame(rFmt, FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME))
3131 {
3132
3133 }
3134
~SwXTextFrame()3135 SwXTextFrame::~SwXTextFrame()
3136 {
3137 }
3138
acquire()3139 void SAL_CALL SwXTextFrame::acquire( )throw()
3140 {
3141 SwXFrame::acquire();
3142 }
3143
release()3144 void SAL_CALL SwXTextFrame::release( )throw()
3145 {
3146 SwXFrame::release();
3147 }
3148
queryInterface(const uno::Type & aType)3149 ::uno::Any SAL_CALL SwXTextFrame::queryInterface( const uno::Type& aType )
3150 {
3151 ::uno::Any aRet = SwXFrame::queryInterface(aType);
3152 if(aRet.getValueType() == ::getCppuVoidType())
3153 aRet = SwXText::queryInterface(aType);
3154 if(aRet.getValueType() == ::getCppuVoidType())
3155 aRet = SwXTextFrameBaseClass::queryInterface(aType);
3156 return aRet;
3157 }
3158
getTypes()3159 uno::Sequence< uno::Type > SAL_CALL SwXTextFrame::getTypes( )
3160 {
3161 uno::Sequence< uno::Type > aTextFrameTypes = SwXTextFrameBaseClass::getTypes();
3162 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
3163 uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
3164
3165 long nIndex = aTextFrameTypes.getLength();
3166 aTextFrameTypes.realloc(
3167 aTextFrameTypes.getLength() +
3168 aFrameTypes.getLength() +
3169 aTextTypes.getLength());
3170
3171 uno::Type* pTextFrameTypes = aTextFrameTypes.getArray();
3172 const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
3173 long nPos;
3174 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
3175 pTextFrameTypes[nIndex++] = pFrameTypes[nPos];
3176
3177 const uno::Type* pTextTypes = aTextTypes.getConstArray();
3178 for(nPos = 0; nPos <aTextTypes.getLength(); nPos++)
3179 pTextFrameTypes[nIndex++] = pTextTypes[nPos];
3180
3181 return aTextFrameTypes;
3182 }
3183
getImplementationId()3184 uno::Sequence< sal_Int8 > SAL_CALL SwXTextFrame::getImplementationId( )
3185 {
3186 vos::OGuard aGuard(Application::GetSolarMutex());
3187 static uno::Sequence< sal_Int8 > aId( 16 );
3188 static sal_Bool bInit = sal_False;
3189 if(!bInit)
3190 {
3191 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
3192 bInit = sal_True;
3193 }
3194 return aId;
3195 }
3196
getText(void)3197 uno::Reference< text::XText > SwXTextFrame::getText(void)
3198 {
3199 return this;
3200 }
3201
GetStartNode() const3202 const SwStartNode *SwXTextFrame::GetStartNode() const
3203 {
3204 const SwStartNode *pSttNd = 0;
3205
3206 SwFrmFmt* pFmt = GetFrmFmt();
3207 if(pFmt)
3208 {
3209 const SwFmtCntnt& rFlyCntnt = pFmt->GetCntnt();
3210 if( rFlyCntnt.GetCntntIdx() )
3211 pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode();
3212 }
3213
3214 return pSttNd;
3215 }
3216
3217 uno::Reference< text::XTextCursor >
CreateCursor()3218 SwXTextFrame::CreateCursor()
3219 {
3220 return createTextCursor();
3221 }
3222
createTextCursor(void)3223 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void)
3224 {
3225 vos::OGuard aGuard(Application::GetSolarMutex());
3226 uno::Reference< text::XTextCursor > aRef;
3227 SwFrmFmt* pFmt = GetFrmFmt();
3228 if(pFmt)
3229 {
3230 //save current start node to be able to check if there is content after the table -
3231 //otherwise the cursor would be in the body text!
3232 const SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode();
3233 const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode);
3234
3235 SwPaM aPam(rNode);
3236 aPam.Move(fnMoveForward, fnGoNode);
3237 SwTableNode* pTblNode = aPam.GetNode()->FindTableNode();
3238 SwCntntNode* pCont = 0;
3239 while( pTblNode )
3240 {
3241 aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode();
3242 pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode);
3243 pTblNode = pCont->FindTableNode();
3244 }
3245 if(pCont)
3246 aPam.GetPoint()->nContent.Assign(pCont, 0);
3247
3248 const SwStartNode* pNewStartNode =
3249 aPam.GetNode()->FindSttNodeByType(SwFlyStartNode);
3250 if(!pNewStartNode || pNewStartNode != pOwnStartNode)
3251 {
3252 uno::RuntimeException aExcept;
3253 aExcept.Message = C2U("no text available");
3254 throw aExcept;
3255 }
3256
3257 SwXTextCursor *const pXCursor = new SwXTextCursor(
3258 *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint());
3259 aRef = static_cast<text::XWordCursor*>(pXCursor);
3260 #if OSL_DEBUG_LEVEL > 1
3261 SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
3262 (void) pUnoCrsr;
3263 #endif
3264 }
3265 else
3266 throw uno::RuntimeException();
3267 return aRef;
3268 }
3269
createTextCursorByRange(const uno::Reference<text::XTextRange> & aTextPosition)3270 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextRange > & aTextPosition)
3271 {
3272 vos::OGuard aGuard(Application::GetSolarMutex());
3273 uno::Reference< text::XTextCursor > aRef;
3274 SwFrmFmt* pFmt = GetFrmFmt();
3275 SwUnoInternalPaM aPam(*GetDoc());
3276 if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition))
3277 {
3278 SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode();
3279 #if OSL_DEBUG_LEVEL > 1
3280 const SwStartNode* p1 = aPam.GetNode()->FindFlyStartNode();
3281 const SwStartNode* p2 = rNode.FindFlyStartNode();
3282 (void)p1;
3283 (void)p2;
3284 #endif
3285 if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode())
3286 {
3287 aRef = static_cast<text::XWordCursor*>(
3288 new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME,
3289 *aPam.GetPoint(), aPam.GetMark()));
3290 }
3291 }
3292 else
3293 throw uno::RuntimeException();
3294 return aRef;
3295 }
3296
createEnumeration(void)3297 uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void)
3298 {
3299 vos::OGuard aGuard(Application::GetSolarMutex());
3300 uno::Reference< container::XEnumeration > aRef;
3301 SwFrmFmt* pFmt = GetFrmFmt();
3302 if(pFmt)
3303 {
3304 SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode());
3305 ::std::unique_ptr<SwUnoCrsr> pUnoCursor(
3306 GetDoc()->CreateUnoCrsr(aPos, sal_False));
3307 pUnoCursor->Move(fnMoveForward, fnGoNode);
3308 // // no Cursor in protected sections
3309 // SwCrsrSaveState aSave( *pUnoCrsr );
3310 // if(pUnoCrsr->IsInProtectTable( sal_True ) ||
3311 // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS ))
3312 // throw uno::RuntimeException() );
3313 aRef = new SwXParagraphEnumeration(this, std::move(pUnoCursor), CURSOR_FRAME);
3314 }
3315 return aRef;
3316 }
3317
getElementType(void)3318 uno::Type SwXTextFrame::getElementType(void)
3319 {
3320 return ::getCppuType(static_cast<uno::Reference<text::XTextRange>*>(0));
3321 }
3322
hasElements(void)3323 sal_Bool SwXTextFrame::hasElements(void)
3324 {
3325 return sal_True;
3326 }
3327
attach(const uno::Reference<text::XTextRange> & xTextRange)3328 void SwXTextFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
3329 {
3330 SwXFrame::attach(xTextRange);
3331 }
3332
getAnchor(void)3333 uno::Reference< text::XTextRange > SwXTextFrame::getAnchor(void)
3334 {
3335 vos::OGuard aGuard(Application::GetSolarMutex());
3336 return SwXFrame::getAnchor();
3337 }
3338
dispose(void)3339 void SwXTextFrame::dispose(void)
3340 {
3341 vos::OGuard aGuard(Application::GetSolarMutex());
3342 SwXFrame::dispose();
3343 }
3344
addEventListener(const uno::Reference<lang::XEventListener> & aListener)3345 void SwXTextFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
3346 {
3347 SwXFrame::addEventListener(aListener);
3348 }
3349
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)3350 void SwXTextFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
3351 {
3352 SwXFrame::removeEventListener(aListener);
3353 }
3354
getImplementationName(void)3355 OUString SwXTextFrame::getImplementationName(void)
3356 {
3357 return C2U("SwXTextFrame");
3358 }
3359
supportsService(const OUString & rServiceName)3360 sal_Bool SwXTextFrame::supportsService(const OUString& rServiceName)
3361 {
3362 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.Text")||
3363 COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextFrame")||
3364 SwXFrame::supportsService(rServiceName);
3365 }
3366
getSupportedServiceNames(void)3367 uno::Sequence< OUString > SwXTextFrame::getSupportedServiceNames(void)
3368 {
3369 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3370 aRet.realloc(aRet.getLength() + 2);
3371 OUString* pArray = aRet.getArray();
3372 pArray[aRet.getLength() - 2] = C2U("com.sun.star.text.TextFrame");
3373 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.Text");
3374 return aRet;
3375 }
3376
operator new(size_t t)3377 void * SAL_CALL SwXTextFrame::operator new( size_t t) throw()
3378 {
3379 return SwXTextFrameBaseClass::operator new( t);
3380 }
3381
operator delete(void * p)3382 void SAL_CALL SwXTextFrame::operator delete( void * p) throw()
3383 {
3384 SwXTextFrameBaseClass::operator delete(p);
3385 }
3386
getEvents()3387 uno::Reference<container::XNameReplace > SAL_CALL SwXTextFrame::getEvents()
3388 {
3389 return new SwFrameEventDescriptor( *this );
3390 }
3391
getSomething(const uno::Sequence<sal_Int8> & rId)3392 sal_Int64 SAL_CALL SwXTextFrame::getSomething( const uno::Sequence< sal_Int8 >& rId )
3393 {
3394 sal_Int64 nRet = SwXFrame::getSomething( rId );
3395 if( !nRet )
3396 nRet = SwXText::getSomething( rId );
3397
3398 return nRet;
3399 }
3400
getPropertyValue(const OUString & rPropertyName)3401 ::uno::Any SwXTextFrame::getPropertyValue(const OUString& rPropertyName)
3402 {
3403 vos::OGuard aGuard(Application::GetSolarMutex());
3404 ::uno::Any aRet;
3405 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))||
3406 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE)))
3407 {
3408 //redline can only be returned if it's a living object
3409 if(!IsDescriptor())
3410 aRet = SwXText::getPropertyValue(rPropertyName);
3411 }
3412 else
3413 aRet = SwXFrame::getPropertyValue(rPropertyName);
3414 return aRet;
3415 }
3416 /******************************************************************
3417 * SwXTextGraphicObject
3418 ******************************************************************/
3419
SwXTextGraphicObject(SwDoc * pDoc)3420 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc *pDoc ) :
3421 SwXFrame(FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC), pDoc)
3422 {
3423 }
3424
SwXTextGraphicObject(SwFrmFmt & rFmt)3425 SwXTextGraphicObject::SwXTextGraphicObject(SwFrmFmt& rFmt) :
3426 SwXFrame(rFmt, FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC))
3427 {
3428
3429 }
3430
~SwXTextGraphicObject()3431 SwXTextGraphicObject::~SwXTextGraphicObject()
3432 {
3433
3434 }
3435
acquire()3436 void SAL_CALL SwXTextGraphicObject::acquire( )throw()
3437 {
3438 SwXFrame::acquire();
3439 }
3440
release()3441 void SAL_CALL SwXTextGraphicObject::release( )throw()
3442 {
3443 SwXFrame::release();
3444 }
3445
queryInterface(const uno::Type & aType)3446 ::uno::Any SAL_CALL SwXTextGraphicObject::queryInterface( const uno::Type& aType )
3447 {
3448 ::uno::Any aRet = SwXFrame::queryInterface(aType);
3449 if(aRet.getValueType() == ::getCppuVoidType())
3450 aRet = SwXTextGraphicObjectBaseClass::queryInterface(aType);
3451 return aRet;
3452 }
3453
3454 uno::Sequence< uno::Type > SAL_CALL
getTypes()3455 SwXTextGraphicObject::getTypes( )
3456 {
3457 uno::Sequence< uno::Type > aGraphicTypes = SwXTextGraphicObjectBaseClass::getTypes();
3458 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
3459
3460 long nIndex = aGraphicTypes.getLength();
3461 aGraphicTypes.realloc(
3462 aGraphicTypes.getLength() +
3463 aFrameTypes.getLength());
3464
3465 uno::Type* pGraphicTypes = aGraphicTypes.getArray();
3466 const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
3467 long nPos;
3468 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
3469 pGraphicTypes[nIndex++] = pFrameTypes[nPos];
3470
3471 return aGraphicTypes;
3472 }
3473
getImplementationId()3474 uno::Sequence< sal_Int8 > SAL_CALL SwXTextGraphicObject::getImplementationId( )
3475 {
3476 vos::OGuard aGuard(Application::GetSolarMutex());
3477 static uno::Sequence< sal_Int8 > aId( 16 );
3478 static sal_Bool bInit = sal_False;
3479 if(!bInit)
3480 {
3481 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
3482 bInit = sal_True;
3483 }
3484 return aId;
3485 }
3486
attach(const uno::Reference<text::XTextRange> & xTextRange)3487 void SwXTextGraphicObject::attach(const uno::Reference< text::XTextRange > & xTextRange)
3488 {
3489 SwXFrame::attach(xTextRange);
3490 }
3491
getAnchor(void)3492 uno::Reference< text::XTextRange > SwXTextGraphicObject::getAnchor(void)
3493 {
3494 vos::OGuard aGuard(Application::GetSolarMutex());
3495 return SwXFrame::getAnchor();
3496 }
3497
dispose(void)3498 void SwXTextGraphicObject::dispose(void)
3499 {
3500 vos::OGuard aGuard(Application::GetSolarMutex());
3501 SwXFrame::dispose();
3502 }
3503
addEventListener(const uno::Reference<lang::XEventListener> & aListener)3504 void SwXTextGraphicObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
3505 {
3506 SwXFrame::addEventListener(aListener);
3507 }
3508
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)3509 void SwXTextGraphicObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
3510 {
3511 SwXFrame::removeEventListener(aListener);
3512 }
3513
getImplementationName(void)3514 OUString SwXTextGraphicObject::getImplementationName(void)
3515 {
3516 return C2U("SwXTextGraphicObject");
3517 }
3518
supportsService(const OUString & rServiceName)3519 sal_Bool SwXTextGraphicObject::supportsService(const OUString& rServiceName)
3520 {
3521 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextGraphicObject") ||
3522 SwXFrame::supportsService(rServiceName);
3523 }
3524
getSupportedServiceNames(void)3525 uno::Sequence< OUString > SwXTextGraphicObject::getSupportedServiceNames(void)
3526 {
3527 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3528 aRet.realloc(aRet.getLength() + 1);
3529 OUString* pArray = aRet.getArray();
3530 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextGraphicObject");
3531 return aRet;
3532 }
3533
operator new(size_t t)3534 void * SAL_CALL SwXTextGraphicObject::operator new( size_t t) throw()
3535 {
3536 return SwXTextGraphicObjectBaseClass::operator new(t);
3537 }
3538
operator delete(void * p)3539 void SAL_CALL SwXTextGraphicObject::operator delete( void * p) throw()
3540 {
3541 SwXTextGraphicObjectBaseClass::operator delete(p);
3542 }
3543
3544 uno::Reference<container::XNameReplace> SAL_CALL
getEvents()3545 SwXTextGraphicObject::getEvents()
3546 {
3547 return new SwFrameEventDescriptor( *this );
3548 }
3549
3550 /******************************************************************
3551 *
3552 ******************************************************************/
3553
SwXTextEmbeddedObject(SwDoc * pDoc)3554 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc *pDoc ) :
3555 SwXFrame(FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT), pDoc)
3556 {
3557 }
3558
SwXTextEmbeddedObject(SwFrmFmt & rFmt)3559 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrmFmt& rFmt) :
3560 SwXFrame(rFmt, FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT))
3561 {
3562
3563 }
3564
~SwXTextEmbeddedObject()3565 SwXTextEmbeddedObject::~SwXTextEmbeddedObject()
3566 {
3567
3568 }
3569
acquire()3570 void SAL_CALL SwXTextEmbeddedObject::acquire()throw()
3571 {
3572 SwXFrame::acquire();
3573 }
3574
release()3575 void SAL_CALL SwXTextEmbeddedObject::release()throw()
3576 {
3577 SwXFrame::release();
3578 }
3579
queryInterface(const uno::Type & aType)3580 ::uno::Any SAL_CALL SwXTextEmbeddedObject::queryInterface( const uno::Type& aType )
3581 {
3582 ::uno::Any aRet = SwXFrame::queryInterface(aType);
3583 if(aRet.getValueType() == ::getCppuVoidType())
3584 aRet = SwXTextEmbeddedObjectBaseClass::queryInterface(aType);
3585 return aRet;
3586 }
3587
getTypes()3588 uno::Sequence< uno::Type > SAL_CALL SwXTextEmbeddedObject::getTypes( )
3589 {
3590 uno::Sequence< uno::Type > aTextEmbeddedTypes = SwXTextEmbeddedObjectBaseClass::getTypes();
3591 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
3592
3593 long nIndex = aTextEmbeddedTypes.getLength();
3594 aTextEmbeddedTypes.realloc(
3595 aTextEmbeddedTypes.getLength() +
3596 aFrameTypes.getLength());
3597
3598 uno::Type* pTextEmbeddedTypes = aTextEmbeddedTypes.getArray();
3599
3600 const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
3601 long nPos;
3602 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
3603 pTextEmbeddedTypes[nIndex++] = pFrameTypes[nPos];
3604
3605 return aTextEmbeddedTypes;
3606 }
3607
getImplementationId()3608 uno::Sequence< sal_Int8 > SAL_CALL SwXTextEmbeddedObject::getImplementationId( )
3609 {
3610 vos::OGuard aGuard(Application::GetSolarMutex());
3611 static uno::Sequence< sal_Int8 > aId( 16 );
3612 static sal_Bool bInit = sal_False;
3613 if(!bInit)
3614 {
3615 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
3616 bInit = sal_True;
3617 }
3618 return aId;
3619 }
3620
attach(const uno::Reference<text::XTextRange> & xTextRange)3621 void SwXTextEmbeddedObject::attach(const uno::Reference< text::XTextRange > & xTextRange)
3622 {
3623 SwXFrame::attach(xTextRange);
3624 }
3625
getAnchor(void)3626 uno::Reference< text::XTextRange > SwXTextEmbeddedObject::getAnchor(void)
3627 {
3628 vos::OGuard aGuard(Application::GetSolarMutex());
3629 return SwXFrame::getAnchor();
3630 }
3631
dispose(void)3632 void SwXTextEmbeddedObject::dispose(void)
3633 {
3634 vos::OGuard aGuard(Application::GetSolarMutex());
3635 SwXFrame::dispose();
3636 }
3637
addEventListener(const uno::Reference<lang::XEventListener> & aListener)3638 void SwXTextEmbeddedObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
3639 {
3640 SwXFrame::addEventListener(aListener);
3641 }
3642
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)3643 void SwXTextEmbeddedObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
3644 {
3645 SwXFrame::removeEventListener(aListener);
3646 }
3647
getEmbeddedObject(void)3648 uno::Reference< lang::XComponent > SwXTextEmbeddedObject::getEmbeddedObject(void)
3649 {
3650 uno::Reference< lang::XComponent > xRet;
3651 SwFrmFmt* pFmt = GetFrmFmt();
3652 if(pFmt)
3653 {
3654 SwDoc* pDoc = pFmt->GetDoc();
3655 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3656 DBG_ASSERT( pCnt->GetCntntIdx() &&
3657 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3658 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3659
3660 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()
3661 ->GetIndex() + 1 ]->GetOLENode();
3662 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
3663 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
3664 {
3665 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3666 if ( pDoc->GetDocShell() )
3667 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
3668
3669 xRet = uno::Reference < lang::XComponent >( xIP->getComponent(), uno::UNO_QUERY );
3670 uno::Reference< util::XModifyBroadcaster > xBrdcst( xRet, uno::UNO_QUERY);
3671 uno::Reference< frame::XModel > xModel( xRet, uno::UNO_QUERY);
3672 if( xBrdcst.is() && xModel.is() )
3673 {
3674 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt );
3675 //create a new one if the OLE object doesn't have one already
3676 if( !pListener )
3677 {
3678 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
3679 xBrdcst->addModifyListener( xOLEListener );
3680 }
3681 }
3682 }
3683 }
3684 return xRet;
3685 }
3686
getExtendedControlOverEmbeddedObject()3687 uno::Reference< embed::XEmbeddedObject > SAL_CALL SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject()
3688 {
3689 uno::Reference< embed::XEmbeddedObject > xResult;
3690 SwFrmFmt* pFmt = GetFrmFmt();
3691 if(pFmt)
3692 {
3693 SwDoc* pDoc = pFmt->GetDoc();
3694 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3695 DBG_ASSERT( pCnt->GetCntntIdx() &&
3696 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3697 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3698
3699 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()
3700 ->GetIndex() + 1 ]->GetOLENode();
3701 xResult = pOleNode->GetOLEObj().GetOleRef();
3702 if ( svt::EmbeddedObjectRef::TryRunningState( xResult ) )
3703 {
3704 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3705 if ( pDoc->GetDocShell() )
3706 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult, embed::Aspects::MSOLE_CONTENT ) );
3707
3708 uno::Reference < lang::XComponent > xComp( xResult->getComponent(), uno::UNO_QUERY );
3709 uno::Reference< util::XModifyBroadcaster > xBrdcst( xComp, uno::UNO_QUERY);
3710 uno::Reference< frame::XModel > xModel( xComp, uno::UNO_QUERY);
3711 if( xBrdcst.is() && xModel.is() )
3712 {
3713 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt );
3714 //create a new one if the OLE object doesn't have one already
3715 if( !pListener )
3716 {
3717 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
3718 xBrdcst->addModifyListener( xOLEListener );
3719 }
3720 }
3721 }
3722 }
3723 return xResult;
3724 }
3725
getAspect()3726 sal_Int64 SAL_CALL SwXTextEmbeddedObject::getAspect()
3727 {
3728 SwFrmFmt* pFmt = GetFrmFmt();
3729 if(pFmt)
3730 {
3731 SwDoc* pDoc = pFmt->GetDoc();
3732 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3733 DBG_ASSERT( pCnt->GetCntntIdx() &&
3734 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3735 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3736
3737 return pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect();
3738 }
3739
3740 return embed::Aspects::MSOLE_CONTENT; // return the default value
3741 }
3742
setAspect(sal_Int64 nAspect)3743 void SAL_CALL SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect )
3744 {
3745 SwFrmFmt* pFmt = GetFrmFmt();
3746 if(pFmt)
3747 {
3748 SwDoc* pDoc = pFmt->GetDoc();
3749 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3750 DBG_ASSERT( pCnt->GetCntntIdx() &&
3751 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3752 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3753
3754 pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect );
3755 }
3756 }
3757
getReplacementGraphic()3758 uno::Reference< graphic::XGraphic > SAL_CALL SwXTextEmbeddedObject::getReplacementGraphic()
3759 {
3760 SwFrmFmt* pFmt = GetFrmFmt();
3761 if(pFmt)
3762 {
3763 SwDoc* pDoc = pFmt->GetDoc();
3764 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3765 DBG_ASSERT( pCnt->GetCntntIdx() &&
3766 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3767 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3768
3769 Graphic* pGraphic = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic();
3770 if ( pGraphic )
3771 return pGraphic->GetXGraphic();
3772 }
3773
3774 return uno::Reference< graphic::XGraphic >();
3775 }
3776
3777
getImplementationName(void)3778 OUString SwXTextEmbeddedObject::getImplementationName(void)
3779
3780 {
3781 return C2U("SwXTextEmbeddedObject");
3782 }
3783
supportsService(const OUString & rServiceName)3784 sal_Bool SwXTextEmbeddedObject::supportsService(const OUString& rServiceName)
3785 {
3786 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextEmbeddedObject")||
3787 SwXFrame::supportsService(rServiceName);
3788 }
3789
getSupportedServiceNames(void)3790 uno::Sequence< OUString > SwXTextEmbeddedObject::getSupportedServiceNames(void)
3791 {
3792 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3793 aRet.realloc(aRet.getLength() + 1);
3794 OUString* pArray = aRet.getArray();
3795 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextEmbeddedObject");
3796 return aRet;
3797 }
3798
operator new(size_t t)3799 void * SAL_CALL SwXTextEmbeddedObject::operator new( size_t t) throw()
3800 {
3801 return SwXTextEmbeddedObjectBaseClass::operator new(t);
3802 }
3803
operator delete(void * p)3804 void SAL_CALL SwXTextEmbeddedObject::operator delete( void * p) throw()
3805 {
3806 SwXTextEmbeddedObjectBaseClass::operator delete(p);
3807 }
3808
3809 uno::Reference<container::XNameReplace> SAL_CALL
getEvents()3810 SwXTextEmbeddedObject::getEvents()
3811 {
3812 return new SwFrameEventDescriptor( *this );
3813 }
3814
3815
3816 /******************************************************************
3817 *
3818 ******************************************************************/
3819 TYPEINIT1(SwXOLEListener, SwClient);
3820
SwXOLEListener(SwFmt & rOLEFmt,uno::Reference<XModel> xOLE)3821 SwXOLEListener::SwXOLEListener( SwFmt& rOLEFmt, uno::Reference< XModel > xOLE) :
3822 SwClient(&rOLEFmt),
3823 xOLEModel(xOLE)
3824 {
3825 }
3826
~SwXOLEListener()3827 SwXOLEListener::~SwXOLEListener()
3828 {}
3829
modified(const lang::EventObject &)3830 void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
3831 {
3832 vos::OGuard aGuard(Application::GetSolarMutex());
3833
3834 SwOLENode* pNd = 0;
3835 SwFmt* pFmt = GetFmt();
3836 if(pFmt)
3837 {const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
3838 if(pIdx)
3839 {
3840 SwNodeIndex aIdx(*pIdx, 1);
3841 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
3842 pNd = pNoTxt->GetOLENode();
3843 }
3844 }
3845 if(!pNd)
3846 throw uno::RuntimeException();
3847
3848 uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef();
3849 if ( xIP.is() )
3850 {
3851 sal_Int32 nState = xIP->getCurrentState();
3852 if ( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE )
3853 return;
3854 }
3855
3856 // if the OLE-Node is UI-Active do nothing
3857 pNd->SetOLESizeInvalid( sal_True );
3858 pNd->GetDoc()->SetOLEObjModified();
3859 }
3860
3861 /* ---------------------------------------------------------------------------
3862
3863 ---------------------------------------------------------------------------*/
disposing(const lang::EventObject & rEvent)3864 void SwXOLEListener::disposing( const lang::EventObject& rEvent )
3865 {
3866 vos::OGuard aGuard(Application::GetSolarMutex());
3867
3868 uno::Reference< util::XModifyListener > xListener( this );
3869
3870
3871 uno::Reference< frame::XModel > xModel( rEvent.Source, uno::UNO_QUERY );
3872 uno::Reference< util::XModifyBroadcaster > xBrdcst(xModel, uno::UNO_QUERY);
3873
3874 try
3875 {
3876 if( xBrdcst.is() )
3877 xBrdcst->removeModifyListener( xListener );
3878 }
3879 catch(uno::Exception const &)
3880 {
3881 DBG_ERROR("OLE Listener couldn't be removed");
3882 }
3883 }
3884 /* ---------------------------------------------------------------------------
3885
3886 ---------------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)3887 void SwXOLEListener::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
3888 {
3889 ClientModify(this, pOld, pNew);
3890 if(!GetRegisteredIn())
3891 xOLEModel = 0;
3892 }
3893