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 throw(uno::RuntimeException)
1116 {
1117 if( rId.getLength() == 16
1118 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1119 rId.getConstArray(), 16 ) )
1120 {
1121 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1122 }
1123 return 0;
1124 }
1125
1126 TYPEINIT1(SwXFrame, SwClient);
1127
getImplementationName(void)1128 OUString SwXFrame::getImplementationName(void) throw( uno::RuntimeException )
1129 {
1130 return C2U("SwXFrame");
1131 }
1132
supportsService(const::OUString & rServiceName)1133 sal_Bool SwXFrame::supportsService(const :: OUString& rServiceName) throw( uno::RuntimeException )
1134 {
1135 return !rServiceName.compareToAscii("com.sun.star.text.BaseFrame")||
1136 !rServiceName.compareToAscii("com.sun.star.text.TextContent") ||
1137 !rServiceName.compareToAscii("com.sun.star.document.LinkTarget");
1138 }
1139
getSupportedServiceNames(void)1140 uno::Sequence< OUString > SwXFrame::getSupportedServiceNames(void) throw( uno::RuntimeException )
1141 {
1142 uno::Sequence< OUString > aRet(3);
1143 OUString* pArray = aRet.getArray();
1144 pArray[0] = C2U("com.sun.star.text.BaseFrame");
1145 pArray[1] = C2U("com.sun.star.text.TextContent");
1146 pArray[2] = C2U("com.sun.star.document.LinkTarget");
1147 return aRet;
1148 }
1149
1150
SwXFrame(FlyCntType eSet,const::SfxItemPropertySet * pSet,SwDoc * pDoc)1151 SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc) :
1152 aLstnrCntnr( (container::XNamed*)this),
1153 m_pPropSet(pSet),
1154 m_pDoc ( pDoc ),
1155 eType(eSet),
1156 bIsDescriptor(sal_True),
1157 m_pCopySource( 0 )
1158 {
1159 // Register ourselves as a listener to the document (via the page descriptor)
1160 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1161 // get the property set for the default style data
1162 // First get the model
1163 uno::Reference < XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1164 // Ask the model for it's family supplier interface
1165 uno::Reference < XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1166 // Get the style families
1167 uno::Reference < XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1168 // Get the Frame family (and keep it for later)
1169 const ::uno::Any aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "FrameStyles" ) ) );
1170 aAny >>= mxStyleFamily;
1171 // In the derived class, we'll ask mxStyleFamily for the relevant default style
1172 // mxStyleFamily is initialised in the SwXFrame constructor
1173 switch(eType)
1174 {
1175 case FLYCNTTYPE_FRM:
1176 {
1177 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Frame" ) ) );
1178 aAny2 >>= mxStyleData;
1179 pProps = new SwFrameProperties_Impl( );
1180 }
1181 break;
1182 case FLYCNTTYPE_GRF:
1183 {
1184 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Graphics" ) ) );
1185 aAny2 >>= mxStyleData;
1186 pProps = new SwGraphicProperties_Impl( );
1187 }
1188 break;
1189 case FLYCNTTYPE_OLE:
1190 {
1191 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "OLE" ) ) );
1192 aAny2 >>= mxStyleData;
1193 pProps = new SwOLEProperties_Impl( );
1194 }
1195 break;
1196
1197 default:
1198 ;
1199 }
1200 }
1201
1202
SwXFrame(SwFrmFmt & rFrmFmt,FlyCntType eSet,const::SfxItemPropertySet * pSet)1203 SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet) :
1204 SwClient( &rFrmFmt ),
1205 aLstnrCntnr( (container::XNamed*)this),
1206 m_pPropSet(pSet),
1207 m_pDoc( 0 ),
1208 eType(eSet),
1209 pProps(0),
1210 bIsDescriptor(sal_False),
1211 m_pCopySource(0)
1212 {
1213
1214 }
1215
~SwXFrame()1216 SwXFrame::~SwXFrame()
1217 {
1218 delete m_pCopySource;
1219 delete pProps;
1220 }
1221
getName(void)1222 OUString SwXFrame::getName(void) throw( uno::RuntimeException )
1223 {
1224 vos::OGuard aGuard(Application::GetSolarMutex());
1225 String sRet;
1226 SwFrmFmt* pFmt = GetFrmFmt();
1227 if(pFmt)
1228 sRet = pFmt->GetName();
1229 else if(bIsDescriptor)
1230 sRet = sName;
1231 else
1232 throw uno::RuntimeException();
1233 return sRet;
1234 }
1235
setName(const::OUString & rName)1236 void SwXFrame::setName(const :: OUString& rName) throw( uno::RuntimeException )
1237 {
1238 vos::OGuard aGuard(Application::GetSolarMutex());
1239 SwFrmFmt* pFmt = GetFrmFmt();
1240 String sTmpName(rName);
1241 if(pFmt)
1242 {
1243 pFmt->GetDoc()->SetFlyName((SwFlyFrmFmt&)*pFmt, sTmpName);
1244 if(pFmt->GetName() != sTmpName)
1245 {
1246 throw uno::RuntimeException();
1247 }
1248 }
1249 else if(bIsDescriptor)
1250 sName = sTmpName;
1251 else
1252 throw uno::RuntimeException();
1253 }
1254
getPropertySetInfo(void)1255 uno::Reference< beans::XPropertySetInfo > SwXFrame::getPropertySetInfo(void) throw( uno::RuntimeException )
1256 {
1257 uno::Reference< beans::XPropertySetInfo > xRef;
1258 static uno::Reference< beans::XPropertySetInfo > xFrmRef;
1259 static uno::Reference< beans::XPropertySetInfo > xGrfRef;
1260 static uno::Reference< beans::XPropertySetInfo > xOLERef;
1261 switch(eType)
1262 {
1263 case FLYCNTTYPE_FRM:
1264 if( !xFrmRef.is() )
1265 xFrmRef = m_pPropSet->getPropertySetInfo();
1266 xRef = xFrmRef;
1267 break;
1268 case FLYCNTTYPE_GRF:
1269 if( !xGrfRef.is() )
1270 xGrfRef = m_pPropSet->getPropertySetInfo();
1271 xRef = xGrfRef;
1272 break;
1273 case FLYCNTTYPE_OLE:
1274 if( !xOLERef.is() )
1275 xOLERef = m_pPropSet->getPropertySetInfo();
1276 xRef = xOLERef;
1277 break;
1278 default:
1279 ;
1280 }
1281 return xRef;
1282 }
1283
SetSelection(SwPaM & rCopySource)1284 void SwXFrame::SetSelection(SwPaM& rCopySource)
1285 {
1286 if(m_pCopySource)
1287 delete m_pCopySource;
1288 m_pCopySource = new SwPaM( *rCopySource.Start() );
1289 m_pCopySource->SetMark();
1290 *m_pCopySource->GetMark() = *rCopySource.End();
1291 }
1292
GetOrCreateSdrObject(SwFlyFrmFmt * pFmt)1293 SdrObject *SwXFrame::GetOrCreateSdrObject( SwFlyFrmFmt *pFmt )
1294 {
1295 SdrObject* pObject = pFmt->FindSdrObject();
1296 if( !pObject )
1297 {
1298 SwDoc *pDoc = pFmt->GetDoc();
1299 // --> OD 2005-08-08 #i52858# - method name changed
1300 SwDrawModel* pDrawModel = pDoc->GetOrCreateDrawModel();
1301 // <--
1302 SwFlyDrawContact* pContactObject
1303 = new SwFlyDrawContact( pFmt, pDrawModel );
1304 pObject = pContactObject->GetMaster();
1305
1306 const :: SwFmtSurround& rSurround = pFmt->GetSurround();
1307 pObject->SetLayer(
1308 ( SURROUND_THROUGHT == rSurround.GetSurround() &&
1309 !pFmt->GetOpaque().GetValue() ) ? pDoc->GetHellId()
1310 : pDoc->GetHeavenId() );
1311
1312 pDrawModel->GetPage(0)->InsertObject( pObject );
1313 }
1314
1315 return pObject;
1316 }
1317
lcl_GetFrmFmt(const::uno::Any & rValue,SwDoc * pDoc)1318 SwFrmFmt *lcl_GetFrmFmt( const :: uno::Any& rValue, SwDoc *pDoc )
1319 {
1320 SwFrmFmt *pRet = 0;
1321 SwDocShell* pDocSh = pDoc->GetDocShell();
1322 if(pDocSh)
1323 {
1324 OUString uTemp;
1325 rValue >>= uTemp;
1326 String sStyle;
1327 SwStyleNameMapper::FillUIName(String (uTemp), sStyle, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, sal_True );
1328 SwDocStyleSheet* pStyle =
1329 (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle,
1330 SFX_STYLE_FAMILY_FRAME);
1331 if(pStyle)
1332 pRet = pStyle->GetFrmFmt();
1333 }
1334
1335 return pRet;
1336 }
1337
setPropertyValue(const::OUString & rPropertyName,const::uno::Any & _rValue)1338 void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::Any& _rValue)
1339 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
1340 {
1341 vos::OGuard aGuard(Application::GetSolarMutex());
1342 SwFrmFmt* pFmt = GetFrmFmt();
1343 const :: SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1344
1345 if (!pEntry)
1346 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1347
1348 //UUUU
1349 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
1350 uno::Any aValue(_rValue);
1351
1352 //UUUU check for needed metric translation
1353 if(pEntry->nMemberId & SFX_METRIC_ITEM)
1354 {
1355 bool bDoIt(true);
1356
1357 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
1358 {
1359 // exception: If these ItemTypes are used, do not convert when these are negative
1360 // since this means they are intended as percent values
1361 sal_Int32 nValue = 0;
1362
1363 if(aValue >>= nValue)
1364 {
1365 bDoIt = nValue > 0;
1366 }
1367 }
1368
1369 if(bDoIt)
1370 {
1371 const SwDoc* pDoc = (IsDescriptor() ? m_pDoc : GetFrmFmt()->GetDoc());
1372 const SfxItemPool& rPool = pDoc->GetAttrPool();
1373 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
1374
1375 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1376 {
1377 SvxUnoConvertFromMM(eMapUnit, aValue);
1378 }
1379 }
1380 }
1381
1382 if(pFmt)
1383 {
1384 sal_Bool bNextFrame = sal_False;
1385 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1386 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1387
1388 SwDoc* pDoc = pFmt->GetDoc();
1389 if ((eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) ||
1390 (FN_PARAM_COUNTOUR_PP == pEntry->nWID) ||
1391 (FN_UNO_IS_AUTOMATIC_CONTOUR == pEntry->nWID) ||
1392 (FN_UNO_IS_PIXEL_CONTOUR == pEntry->nWID) )
1393 {
1394 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1395 if(pIdx)
1396 {
1397 SwNodeIndex aIdx(*pIdx, 1);
1398 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1399 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP)
1400 {
1401 drawing::PointSequenceSequence aParam;
1402 if(!aValue.hasValue())
1403 pNoTxt->SetContour(0);
1404 else if(aValue >>= aParam)
1405 {
1406 PolyPolygon aPoly((sal_uInt16)aParam.getLength());
1407 for(sal_Int32 i = 0; i < aParam.getLength(); i++)
1408 {
1409 const :: drawing::PointSequence* pPointSeq = aParam.getConstArray();
1410 sal_Int32 nPoints = pPointSeq[i].getLength();
1411 const :: awt::Point* pPoints = pPointSeq[i].getConstArray();
1412 Polygon aSet( (sal_uInt16)nPoints );
1413 for(sal_Int32 j = 0; j < nPoints; j++)
1414 {
1415 Point aPoint(pPoints[j].X, pPoints[j].Y);
1416 aSet.SetPoint(aPoint, (sal_uInt16)j);
1417 }
1418 // Close polygon if it isn't closed already.
1419 aSet.Optimize( POLY_OPTIMIZE_CLOSE );
1420 aPoly.Insert( aSet );
1421 }
1422 pNoTxt->SetContourAPI( &aPoly );
1423 }
1424 else
1425 throw lang::IllegalArgumentException();
1426 }
1427 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR )
1428 {
1429 pNoTxt->SetAutomaticContour( *(sal_Bool *)aValue.getValue() );
1430 }
1431 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )
1432 {
1433 // The IsPixelContour property can only be set if there
1434 // is no contour, or if the contour has been set by the
1435 // API itself (or in other words, if the contour isn't
1436 // used already).
1437 if( !pNoTxt->_HasContour() ||
1438 !pNoTxt->IsContourMapModeValid() )
1439 pNoTxt->SetPixelContour( *(sal_Bool *)aValue.getValue() );
1440 else
1441 throw lang::IllegalArgumentException();
1442 }
1443 else
1444 {
1445 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
1446 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1447 pNoTxt->SetAttr(aSet);
1448 }
1449 }
1450 }
1451 // New attribute Title
1452 else if( FN_UNO_TITLE == pEntry->nWID )
1453 {
1454 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1455 ASSERT( pFmt,
1456 "unexpected type of <pFmt> --> crash" );
1457 OUString uTemp;
1458 aValue >>= uTemp;
1459 const String sTitle(uTemp);
1460 // assure that <SdrObject> instance exists.
1461 GetOrCreateSdrObject( pFlyFmt );
1462 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), sTitle );
1463 }
1464 // New attribute Description
1465 else if( FN_UNO_DESCRIPTION == pEntry->nWID )
1466 {
1467 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1468 ASSERT( pFmt,
1469 "unexpected type of <pFmt> --> crash" );
1470 OUString uTemp;
1471 aValue >>= uTemp;
1472 const String sDescription(uTemp);
1473 // assure that <SdrObject> instance exists.
1474 GetOrCreateSdrObject( pFlyFmt );
1475 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), sDescription );
1476 }
1477 // <--
1478 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID)
1479 {
1480 SwFrmFmt *pFrmFmt = lcl_GetFrmFmt( aValue, pFmt->GetDoc() );
1481 if( pFrmFmt )
1482 {
1483 UnoActionContext aAction(pFmt->GetDoc());
1484
1485 SfxItemSet* pSet = 0;
1486 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of
1487 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ),
1488 // if document is currently in reading mode.
1489 if ( !pFmt->GetDoc()->IsInReading() )
1490 {
1491 // see SwFEShell::SetFrmFmt( SwFrmFmt *pNewFmt, sal_Bool bKeepOrient, Point* pDocPos )
1492 SwFlyFrm *pFly = 0;
1493 {
1494 const :: SwFrmFmt* pFmtXX = pFmt;
1495 if (PTR_CAST(SwFlyFrmFmt, pFmtXX))
1496 pFly = ((SwFlyFrmFmt*)pFmtXX)->GetFrm();
1497 }
1498 if ( pFly )
1499 {
1500 const :: SfxPoolItem* pItem;
1501 if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_ANCHOR, sal_False, &pItem ))
1502 {
1503 pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrmFmtSetRange );
1504 pSet->Put( *pItem );
1505 if ( pFmt->GetDoc()->GetEditShell() != NULL
1506 && !::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, *pSet ) )
1507 delete pSet, pSet = 0;
1508 }
1509 }
1510 }
1511 // <--
1512
1513 pFmt->GetDoc()->SetFrmFmtToFly( *pFmt, *pFrmFmt, pSet, sal_False );
1514 delete pSet;
1515 }
1516 else
1517 throw lang::IllegalArgumentException();
1518 }
1519 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID ||
1520 FN_UNO_GRAPHIC_FILTER == pEntry->nWID)
1521 {
1522 String sGrfName, sFltName;
1523 GraphicObject *pGrfObj = 0;
1524 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, &sGrfName, &sFltName );
1525 OUString uTemp;
1526 aValue >>= uTemp;
1527 String sTmp(uTemp);
1528 UnoActionContext aAction(pFmt->GetDoc());
1529 if(FN_UNO_GRAPHIC_U_R_L == pEntry->nWID)
1530 {
1531 if( sTmp.EqualsAscii( sPackageProtocol,
1532 0, sizeof( sPackageProtocol )-1 ) )
1533 {
1534 pGrfObj = new GraphicObject;
1535 pGrfObj->SetUserData( sTmp );
1536 pGrfObj->SetSwapState();
1537 sGrfName.Erase();
1538 }
1539 else if( sTmp.EqualsAscii( sGraphicObjectProtocol,
1540 0, sizeof(sGraphicObjectProtocol)-1 ) )
1541 {
1542 ByteString sId( sTmp.Copy(sizeof(sGraphicObjectProtocol)-1),
1543 RTL_TEXTENCODING_ASCII_US );
1544 pGrfObj = new GraphicObject( sId );
1545 sGrfName.Erase();
1546 }
1547 else
1548 {
1549 sGrfName = sTmp;
1550 }
1551 }
1552 else
1553 {
1554 sFltName = sTmp;
1555 }
1556
1557 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1558 if(pIdx)
1559 {
1560 SwNodeIndex aIdx(*pIdx, 1);
1561 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1562 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
1563 if(!pGrfNode)
1564 {
1565 delete pGrfObj;
1566 throw uno::RuntimeException();
1567 }
1568 SwPaM aGrfPaM(*pGrfNode);
1569 pFmt->GetDoc()->ReRead( aGrfPaM, sGrfName, sFltName, 0,
1570 pGrfObj );
1571 }
1572 delete pGrfObj;
1573 }
1574 else if( FN_UNO_GRAPHIC == pEntry->nWID )
1575 {
1576 uno::Reference< graphic::XGraphic > xGraphic;
1577 aValue >>= xGraphic;
1578 if(xGraphic.is())
1579 {
1580 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1581 if(pIdx)
1582 {
1583 SwNodeIndex aIdx(*pIdx, 1);
1584 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
1585 if(!pGrfNode)
1586 {
1587 throw uno::RuntimeException();
1588 }
1589 SwPaM aGrfPaM(*pGrfNode);
1590 Graphic aGraphic( xGraphic );
1591 pFmt->GetDoc()->ReRead( aGrfPaM, String(), String(), &aGraphic, 0 );
1592 }
1593 }
1594 }
1595 else if( FN_UNO_REPLACEMENT_GRAPHIC_URL == pEntry->nWID || FN_UNO_REPLACEMENT_GRAPHIC == pEntry->nWID )
1596 {
1597 bool bURL = FN_UNO_REPLACEMENT_GRAPHIC_URL == pEntry->nWID;
1598 bool bApply = false;
1599 Graphic aGraphic;
1600 if( bURL )
1601 {
1602 GraphicObject *pGrfObj = 0;
1603 OUString aGrfUrl;
1604 aValue >>= aGrfUrl;
1605
1606 // the package URL based graphics are handled in different way currently
1607 // TODO/LATER: actually this is the correct place to handle them
1608 ::rtl::OUString aGraphicProtocol( RTL_CONSTASCII_USTRINGPARAM( sGraphicObjectProtocol ) );
1609 if( aGrfUrl.compareTo( aGraphicProtocol, aGraphicProtocol.getLength() ) == 0 )
1610 {
1611 ByteString sId( aGrfUrl.copy(sizeof(sGraphicObjectProtocol)-1).getStr(), RTL_TEXTENCODING_ASCII_US );
1612 pGrfObj = new GraphicObject( sId );
1613 aGraphic = pGrfObj->GetGraphic();
1614 bApply = true;
1615 }
1616 }
1617 else
1618 {
1619 uno::Reference< graphic::XGraphic > xGraphic;
1620 aValue >>= xGraphic;
1621 if( xGraphic.is() )
1622 {
1623 aGraphic = Graphic( xGraphic );
1624 bApply = true;
1625 }
1626 }
1627
1628 if ( bApply )
1629 {
1630 const :: SwFmtCntnt* pCnt = &pFmt->GetCntnt();
1631 if ( pCnt->GetCntntIdx() && pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ] )
1632 {
1633 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode();
1634
1635 if ( pOleNode )
1636 {
1637 svt::EmbeddedObjectRef xObj = pOleNode->GetOLEObj().GetObject();
1638
1639 ::rtl::OUString aMediaType;
1640 xObj.SetGraphic( aGraphic, aMediaType );
1641 }
1642 }
1643 }
1644 }
1645 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME))))
1646 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME)))
1647 {
1648 OUString uTemp;
1649 aValue >>= uTemp;
1650 String sChainName(uTemp);
1651 if(!sChainName.Len())
1652 {
1653 if(bNextFrame)
1654 pDoc->Unchain(*pFmt);
1655 else
1656 {
1657 SwFmtChain aChain( pFmt->GetChain() );
1658 SwFrmFmt *pPrev = aChain.GetPrev();
1659 if(pPrev)
1660 pDoc->Unchain(*pPrev);
1661 }
1662 }
1663 else
1664 {
1665 sal_uInt16 nCount = pDoc->GetFlyCount(FLYCNTTYPE_FRM);
1666
1667 SwFrmFmt* pChain = 0;
1668 for( sal_uInt16 i = 0; i < nCount; i++)
1669 {
1670 SwFrmFmt* pFmt2 = pDoc->GetFlyNum(i, FLYCNTTYPE_FRM);
1671 if(sChainName == pFmt2->GetName() )
1672 {
1673 pChain = pFmt2;
1674 break;
1675 }
1676 }
1677 if(pChain)
1678 {
1679 SwFrmFmt* pSource = bNextFrame ? pFmt : pChain;
1680 SwFrmFmt* pDest = bNextFrame ? pChain: pFmt;
1681 pDoc->Chain(*pSource, *pDest);
1682 }
1683 }
1684 }
1685 else if(FN_UNO_Z_ORDER == pEntry->nWID)
1686 {
1687 sal_Int32 nZOrder = - 1;
1688 aValue >>= nZOrder;
1689 if( nZOrder >= 0)
1690 {
1691 SdrObject* pObject =
1692 GetOrCreateSdrObject( (SwFlyFrmFmt*)pFmt );
1693 SwDrawModel* pDrawModel = pDoc->GetDrawModel();
1694 pDrawModel->GetPage(0)->
1695 SetObjectOrdNum(pObject->GetOrdNum(), nZOrder);
1696 }
1697 }
1698 else if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == nMemberId)
1699 {
1700 sal_Bool bDone = sal_False;
1701 uno::Reference<text::XTextFrame> xFrame;
1702 if(aValue >>= xFrame)
1703 {
1704 uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
1705 SwXFrame* pFrame = xTunnel.is() ?
1706 reinterpret_cast< SwXFrame * >( sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
1707 : 0;
1708 if(pFrame && this != pFrame && pFrame->GetFrmFmt() && pFrame->GetFrmFmt()->GetDoc() == pDoc)
1709 {
1710 SfxItemSet aSet( pDoc->GetAttrPool(),
1711 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
1712 aSet.SetParent(&pFmt->GetAttrSet());
1713 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID);
1714
1715
1716 SwPosition aPos(*pFrame->GetFrmFmt()->GetCntnt().GetCntntIdx());
1717 aAnchor.SetAnchor(&aPos);
1718 aAnchor.SetType(FLY_AT_FLY);
1719 aSet.Put(aAnchor);
1720 pDoc->SetFlyFrmAttr( *pFmt, aSet );
1721 bDone = sal_True;
1722 }
1723 }
1724 if(!bDone)
1725 throw lang::IllegalArgumentException();
1726 }
1727 else
1728 { //UUUU
1729 // standard UNO API write attributes
1730 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
1731 SfxItemSet aSet( pDoc->GetAttrPool(),
1732 RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
1733 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
1734
1735 //UUUU FillAttribute support
1736 XATTR_FILL_FIRST, XATTR_FILL_LAST,
1737
1738 0L);
1739 bool bDone(false);
1740
1741 aSet.SetParent(&pFmt->GetAttrSet());
1742
1743 if(RES_BACKGROUND == pEntry->nWID)
1744 {
1745 const SwAttrSet& rSet = pFmt->GetAttrSet();
1746 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
1747 SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
1748
1749 aChangedBrushItem.PutValue(aValue, nMemberId);
1750
1751 if(!(aChangedBrushItem == aOriginalBrushItem))
1752 {
1753 setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet);
1754 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
1755 }
1756
1757 bDone = true;
1758 }
1759 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
1760 {
1761 //UUUU
1762 drawing::BitmapMode eMode;
1763
1764 if(!(aValue >>= eMode))
1765 {
1766 sal_Int32 nMode = 0;
1767
1768 if(!(aValue >>= nMode))
1769 {
1770 throw lang::IllegalArgumentException();
1771 }
1772
1773 eMode = (drawing::BitmapMode)nMode;
1774 }
1775
1776 aSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
1777 aSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
1778 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
1779 bDone = true;
1780 }
1781
1782 switch(nMemberId)
1783 {
1784 case MID_NAME:
1785 {
1786 //UUUU when named items get set, replace these with the NameOrIndex items
1787 // which exist already in the pool
1788 switch(pEntry->nWID)
1789 {
1790 case XATTR_FILLGRADIENT:
1791 case XATTR_FILLHATCH:
1792 case XATTR_FILLBITMAP:
1793 case XATTR_FILLFLOATTRANSPARENCE:
1794 {
1795 OUString aTempName;
1796
1797 if(!(aValue >>= aTempName ))
1798 {
1799 throw lang::IllegalArgumentException();
1800 }
1801
1802 bDone = SvxShape::SetFillAttribute(pEntry->nWID, aTempName, aSet);
1803 break;
1804 }
1805 default:
1806 {
1807 break;
1808 }
1809 }
1810 break;
1811 }
1812 case MID_GRAFURL:
1813 {
1814 //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
1815 switch(pEntry->nWID)
1816 {
1817 case XATTR_FILLBITMAP:
1818 {
1819 const Graphic aNullGraphic;
1820 XFillBitmapItem aXFillBitmapItem(aSet.GetPool(), aNullGraphic);
1821
1822 aXFillBitmapItem.PutValue(aValue, nMemberId);
1823 aSet.Put(aXFillBitmapItem);
1824 bDone = true;
1825 break;
1826 }
1827 default:
1828 {
1829 break;
1830 }
1831 }
1832 break;
1833 }
1834 default:
1835 {
1836 break;
1837 }
1838 }
1839
1840 if(!bDone)
1841 {
1842 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1843 }
1844
1845 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == nMemberId)
1846 {
1847 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID);
1848 if(aAnchor.GetAnchorId() == FLY_AT_FLY)
1849 {
1850 const :: SwPosition* pPosition = aAnchor.GetCntntAnchor();
1851 SwFrmFmt* pFlyFmt = pPosition ? pPosition->nNode.GetNode().GetFlyFmt() : 0;
1852 if(!pFlyFmt || pFlyFmt->Which() == RES_DRAWFRMFMT)
1853 {
1854 lang::IllegalArgumentException aExcept;
1855 aExcept.Message = C2U("Anchor to frame: no frame found");
1856 throw aExcept;
1857 }
1858 else
1859 {
1860 SwPosition aPos = *pPosition;
1861 aPos.nNode = *pFlyFmt->GetCntnt().GetCntntIdx();
1862 aAnchor.SetAnchor(&aPos);
1863 aSet.Put(aAnchor);
1864 }
1865 }
1866 else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) &&
1867 !aAnchor.GetCntntAnchor())
1868 {
1869 SwNode& rNode = pDoc->GetNodes().GetEndOfContent();
1870 SwPaM aPam(rNode);
1871 aPam.Move( fnMoveBackward, fnGoDoc );
1872 aAnchor.SetAnchor( aPam.Start() );
1873 aSet.Put(aAnchor);
1874 }
1875
1876 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of
1877 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ),
1878 // if document is currently in reading mode.
1879 if ( !pFmt->GetDoc()->IsInReading() )
1880 {
1881 // see SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet )
1882 SwFlyFrm *pFly = 0;
1883 if (PTR_CAST(SwFlyFrmFmt, pFmt))
1884 pFly = ((SwFlyFrmFmt*)pFmt)->GetFrm();
1885 if (pFly)
1886 {
1887 const :: SfxPoolItem* pItem;
1888 if( SFX_ITEM_SET == aSet.GetItemState( RES_ANCHOR, sal_False, &pItem ))
1889 {
1890 aSet.Put( *pItem );
1891 if ( pFmt->GetDoc()->GetEditShell() != NULL )
1892 {
1893 ::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, aSet );
1894 }
1895 }
1896 }
1897 }
1898 // <--
1899
1900 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
1901 }
1902 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_STREAM_NAME == pEntry->nWID)
1903 {
1904 throw lang::IllegalArgumentException();
1905 }
1906 else
1907 {
1908 pFmt->SetFmtAttr(aSet);
1909 }
1910 }
1911 }
1912 else if(IsDescriptor())
1913 {
1914 pProps->SetProperty(pEntry->nWID, nMemberId, aValue);
1915 if( FN_UNO_FRAME_STYLE_NAME == pEntry->nWID )
1916 {
1917 OUString sStyleName;
1918 aValue >>= sStyleName;
1919 try
1920 {
1921 uno::Any aAny = mxStyleFamily->getByName ( sStyleName );
1922 aAny >>= mxStyleData;
1923 }
1924 catch ( container::NoSuchElementException const & )
1925 {
1926 }
1927 catch ( lang::WrappedTargetException const & )
1928 {
1929 }
1930 catch ( uno::RuntimeException const & )
1931 {
1932 }
1933 }
1934 }
1935 else
1936 throw uno::RuntimeException();
1937 }
1938
getPropertyValue(const OUString & rPropertyName)1939 uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
1940 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1941 {
1942 vos::OGuard aGuard(Application::GetSolarMutex());
1943 uno::Any aAny;
1944 SwFrmFmt* pFmt = GetFrmFmt();
1945 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1946 if (!pEntry)
1947 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1948
1949 //UUUU
1950 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
1951
1952 if(FN_UNO_ANCHOR_TYPES == pEntry->nWID)
1953 {
1954 uno::Sequence<text::TextContentAnchorType> aTypes(5);
1955 text::TextContentAnchorType* pArray = aTypes.getArray();
1956 pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
1957 pArray[1] = text::TextContentAnchorType_AS_CHARACTER;
1958 pArray[2] = text::TextContentAnchorType_AT_PAGE;
1959 pArray[3] = text::TextContentAnchorType_AT_FRAME;
1960 pArray[4] = text::TextContentAnchorType_AT_CHARACTER;
1961 aAny.setValue(&aTypes, ::getCppuType(static_cast<uno::Sequence<text::TextContentAnchorType>*>(0)));
1962 }
1963 else if(pFmt)
1964 {
1965 if( ((eType == FLYCNTTYPE_GRF) || (eType == FLYCNTTYPE_OLE)) &&
1966 pEntry &&
1967 (isGRFATR(pEntry->nWID) ||
1968 pEntry->nWID == FN_PARAM_COUNTOUR_PP ||
1969 pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR ||
1970 pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ))
1971 {
1972 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1973 if(pIdx)
1974 {
1975 SwNodeIndex aIdx(*pIdx, 1);
1976 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1977 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP)
1978 {
1979 PolyPolygon aContour;
1980 if( pNoTxt->GetContourAPI( aContour ) )
1981 {
1982 drawing::PointSequenceSequence aPtSeq(aContour.Count());
1983 drawing::PointSequence* pPSeq = aPtSeq.getArray();
1984 for(sal_uInt16 i = 0; i < aContour.Count(); i++)
1985 {
1986 const Polygon& rPoly = aContour.GetObject(i);
1987 pPSeq[i].realloc(rPoly.GetSize());
1988 awt::Point* pPoints = pPSeq[i].getArray();
1989 for(sal_uInt16 j = 0; j < rPoly.GetSize(); j++)
1990 {
1991 const Point& rPoint = rPoly.GetPoint(j);
1992 pPoints[j].X = rPoint.X();
1993 pPoints[j].Y = rPoint.Y();
1994 }
1995 }
1996 aAny <<= aPtSeq;
1997 }
1998 }
1999 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR )
2000 {
2001 sal_Bool bValue = pNoTxt->HasAutomaticContour();
2002 aAny.setValue( &bValue, ::getBooleanCppuType() );
2003 }
2004 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )
2005 {
2006 sal_Bool bValue = pNoTxt->IsPixelContour();
2007 aAny.setValue( &bValue, ::getBooleanCppuType() );
2008 }
2009 else
2010 {
2011 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
2012 m_pPropSet->getPropertyValue(*pEntry, aSet, aAny);
2013 }
2014 }
2015 }
2016 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID)
2017 {
2018 String sGrfName;
2019 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2020 if ( pIdx )
2021 {
2022 SwNodeIndex aIdx( *pIdx, 1 );
2023 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
2024 if ( !pGrfNode )
2025 throw uno::RuntimeException();
2026 if ( pGrfNode->IsGrfLink() )
2027 {
2028 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*) pFmt, &sGrfName, 0 );
2029 }
2030 else
2031 {
2032 String sPrefix( RTL_CONSTASCII_STRINGPARAM( sGraphicObjectProtocol ) );
2033 String sId( pGrfNode->GetGrfObj().GetUniqueID(),
2034 RTL_TEXTENCODING_ASCII_US );
2035 ( sGrfName = sPrefix ) += sId;
2036 }
2037 }
2038 aAny <<= OUString( sGrfName );
2039 }
2040 else if( FN_UNO_REPLACEMENT_GRAPHIC_U_R_L == pEntry->nWID)
2041 {
2042 String sGrfName;
2043 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2044
2045 if(pIdx)
2046 {
2047 SwNodeIndex aIdx(*pIdx, 1);
2048 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
2049 if(!pGrfNode)
2050 throw uno::RuntimeException();
2051
2052 const GraphicObject* pGraphicObject = pGrfNode->GetReplacementGrfObj();
2053
2054 if(pGraphicObject)
2055 {
2056 String sPrefix( RTL_CONSTASCII_STRINGPARAM(sGraphicObjectProtocol) );
2057 String sId( pGraphicObject->GetUniqueID(), RTL_TEXTENCODING_ASCII_US );
2058 (sGrfName = sPrefix) += sId;
2059 }
2060 }
2061
2062 aAny <<= OUString(sGrfName);
2063 }
2064 else if( FN_UNO_GRAPHIC_FILTER == pEntry->nWID )
2065 {
2066 String sFltName;
2067 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, 0, &sFltName );
2068 aAny <<= OUString(sFltName);
2069 }
2070 else if( FN_UNO_GRAPHIC == pEntry->nWID )
2071 {
2072 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2073 if(pIdx)
2074 {
2075 SwNodeIndex aIdx(*pIdx, 1);
2076 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
2077 if(!pGrfNode)
2078 throw uno::RuntimeException();
2079 aAny <<= pGrfNode->GetGrf().GetXGraphic();
2080 }
2081 }
2082 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID)
2083 {
2084 aAny <<= OUString(SwStyleNameMapper::GetProgName(pFmt->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ) );
2085 }
2086 // --> OD 2009-07-13 #i73249#
2087 // Attribute AlternativeText was never published.
2088 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances
2089 // else if(eType != FLYCNTTYPE_FRM &&
2090 // FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
2091 // {
2092 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2093 // if(pIdx)
2094 // {
2095 // SwNodeIndex aIdx(*pIdx, 1);
2096 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2097 // aAny <<= OUString(pNoTxt->GetAlternateText());
2098 // }
2099 // }
2100 else if( FN_UNO_TITLE == pEntry->nWID )
2101 {
2102 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2103 ASSERT( pFmt,
2104 "unexpected type of <pFmt> --> crash" );
2105 // assure that <SdrObject> instance exists.
2106 GetOrCreateSdrObject( pFlyFmt );
2107 aAny <<= OUString(pFlyFmt->GetObjTitle());
2108 }
2109 // New attribute Description
2110 else if( FN_UNO_DESCRIPTION == pEntry->nWID )
2111 {
2112 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2113 ASSERT( pFmt,
2114 "unexpected type of <pFmt> --> crash" );
2115 // assure that <SdrObject> instance exists.
2116 GetOrCreateSdrObject( pFlyFmt );
2117 aAny <<= OUString(pFlyFmt->GetObjDescription());
2118 }
2119 // <--
2120 else if(eType == FLYCNTTYPE_GRF &&
2121 (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ACTUAL_SIZE))))
2122 {
2123 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2124 if(pIdx)
2125 {
2126 SwNodeIndex aIdx(*pIdx, 1);
2127 // --> OD #i85105#
2128 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2129 // Size aActSize = ((SwGrfNode*)pNoTxt)->GetTwipSize();
2130 Size aActSize;
2131 {
2132 SwGrfNode* pGrfNode = dynamic_cast<SwGrfNode*>(aIdx.GetNode().GetNoTxtNode());
2133 if ( pGrfNode )
2134 {
2135 aActSize = pGrfNode->GetTwipSize();
2136 if ( aActSize.Width() == 0 && aActSize.Height() == 0 &&
2137 pGrfNode->IsLinkedFile() )
2138 {
2139 pGrfNode->SwapIn( sal_True );
2140 aActSize = pGrfNode->GetTwipSize();
2141 }
2142 }
2143 }
2144 // <--
2145 awt::Size aTmp;
2146 aTmp.Width = TWIP_TO_MM100(aActSize.Width());
2147 aTmp.Height = TWIP_TO_MM100(aActSize.Height());
2148 aAny.setValue(&aTmp, ::getCppuType(static_cast<const awt::Size*>(0)));
2149 }
2150 }
2151 else if(FN_PARAM_LINK_DISPLAY_NAME == pEntry->nWID)
2152 {
2153 aAny <<= OUString(pFmt->GetName());
2154 }
2155 else if(FN_UNO_Z_ORDER == pEntry->nWID)
2156 {
2157 const SdrObject* pObj = pFmt->FindRealSdrObject();
2158 if( pObj )
2159 {
2160 aAny <<= (sal_Int32)pObj->GetOrdNum();
2161 }
2162 }
2163 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_MODEL == pEntry->nWID||
2164 FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID||
2165 FN_EMBEDDED_OBJECT == pEntry->nWID)
2166 {
2167 SwDoc* pDoc = pFmt->GetDoc();
2168 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
2169 DBG_ASSERT( pCnt->GetCntntIdx() &&
2170 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
2171 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
2172
2173 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()
2174 ->GetIndex() + 1 ]->GetOLENode();
2175 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
2176 OUString aHexCLSID;
2177 {
2178 SvGlobalName aClassName( xIP->getClassID() );
2179 aHexCLSID = aClassName.GetHexName();
2180 if(FN_UNO_CLSID != pEntry->nWID)
2181 {
2182 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
2183 {
2184 uno::Reference < lang::XComponent > xComp( xIP->getComponent(), uno::UNO_QUERY );
2185 uno::Reference < frame::XModel > xModel( xComp, uno::UNO_QUERY );
2186 if ( FN_EMBEDDED_OBJECT == pEntry->nWID )
2187 {
2188 // ensure the
2189 ASSERT( pDoc->GetDocShell(), "no doc shell => no client site" );
2190 if ( pDoc->GetDocShell() )
2191 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
2192 aAny <<= xIP;
2193 }
2194 else if ( xModel.is() )
2195 aAny <<= xModel;
2196 else if ( FN_UNO_COMPONENT == pEntry->nWID )
2197 aAny <<= xComp;
2198 }
2199 }
2200 }
2201
2202 if(FN_UNO_CLSID == pEntry->nWID)
2203 aAny <<= aHexCLSID;
2204 else if(FN_UNO_STREAM_NAME == pEntry->nWID)
2205 {
2206 aAny <<= ::rtl::OUString(pOleNode->GetOLEObj().GetCurrentPersistName());
2207 }
2208 }
2209 else if(WID_LAYOUT_SIZE == pEntry->nWID)
2210 {
2211 // format document completely in order to get correct value
2212 pFmt->GetDoc()->GetEditShell()->CalcLayout();
2213
2214 SwFrm* pTmpFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt );
2215 if ( pTmpFrm )
2216 {
2217 DBG_ASSERT( pTmpFrm->IsValid(), "frame not valid" );
2218 const SwRect &rRect = pTmpFrm->Frm();
2219 Size aMM100Size = OutputDevice::LogicToLogic(
2220 Size( rRect.Width(), rRect.Height() ),
2221 MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ));
2222 aAny <<= awt::Size( aMM100Size.Width(), aMM100Size.Height() );
2223 }
2224 }
2225 else
2226 { //UUUU
2227 // standard UNO API read attributes
2228 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST
2229 const SwAttrSet& rSet = pFmt->GetAttrSet();
2230 bool bDone(false);
2231
2232 if(RES_BACKGROUND == pEntry->nWID)
2233 {
2234 //UUUU
2235 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
2236
2237 if(!aOriginalBrushItem.QueryValue(aAny, nMemberId))
2238 {
2239 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
2240 }
2241
2242 bDone = true;
2243 }
2244 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2245 {
2246 //UUUU
2247 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
2248 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
2249
2250 if( pTileItem && pTileItem->GetValue() )
2251 {
2252 aAny <<= drawing::BitmapMode_REPEAT;
2253 }
2254 else if( pStretchItem && pStretchItem->GetValue() )
2255 {
2256 aAny <<= drawing::BitmapMode_STRETCH;
2257 }
2258 else
2259 {
2260 aAny <<= drawing::BitmapMode_NO_REPEAT;
2261 }
2262
2263 bDone = true;
2264 }
2265
2266 if(!bDone)
2267 {
2268 m_pPropSet->getPropertyValue(*pEntry, rSet, aAny);
2269 }
2270 }
2271 }
2272 else if(IsDescriptor())
2273 {
2274 if ( ! m_pDoc )
2275 throw uno::RuntimeException();
2276 if(WID_LAYOUT_SIZE != pEntry->nWID) // there is no LayoutSize in a descriptor
2277 {
2278 const uno::Any* pAny = 0;
2279 if( !pProps->GetProperty( pEntry->nWID, nMemberId, pAny ) )
2280 aAny = mxStyleData->getPropertyValue( rPropertyName );
2281 else if ( pAny )
2282 aAny = *pAny;
2283 }
2284 }
2285 else
2286 throw uno::RuntimeException();
2287
2288 //UUUU
2289 if(pEntry && pEntry->pType && *(pEntry->pType) == ::getCppuType((const sal_Int16*)0) && *(pEntry->pType) != aAny.getValueType())
2290 {
2291 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2292 sal_Int32 nValue = 0;
2293 aAny >>= nValue;
2294 aAny <<= (sal_Int16)nValue;
2295 }
2296
2297 //UUUU check for needed metric translation
2298 if(pEntry->nMemberId & SFX_METRIC_ITEM)
2299 {
2300 bool bDoIt(true);
2301
2302 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
2303 {
2304 // exception: If these ItemTypes are used, do not convert when these are negative
2305 // since this means they are intended as percent values
2306 sal_Int32 nValue = 0;
2307
2308 if(aAny >>= nValue)
2309 {
2310 bDoIt = nValue > 0;
2311 }
2312 }
2313
2314 if(bDoIt)
2315 {
2316 const SwDoc* pDoc = (IsDescriptor() ? m_pDoc : GetFrmFmt()->GetDoc());
2317 const SfxItemPool& rPool = pDoc->GetAttrPool();
2318 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
2319
2320 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
2321 {
2322 SvxUnoConvertToMM(eMapUnit, aAny);
2323 }
2324 }
2325 }
2326
2327 return aAny;
2328 }
2329
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)2330 void SwXFrame::addPropertyChangeListener(const OUString& /*PropertyName*/,
2331 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2332 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2333 {
2334 DBG_WARNING("not implemented");
2335 }
2336
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)2337 void SwXFrame::removePropertyChangeListener(const OUString& /*PropertyName*/,
2338 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2339 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2340 {
2341 DBG_WARNING("not implemented");
2342 }
2343
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)2344 void SwXFrame::addVetoableChangeListener(const OUString& /*PropertyName*/,
2345 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2346 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2347 {
2348 DBG_WARNING("not implemented");
2349 }
2350
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)2351 void SwXFrame::removeVetoableChangeListener(
2352 const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2353 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2354 {
2355 DBG_WARNING("not implemented");
2356 }
2357
getPropertyState(const OUString & rPropertyName)2358 beans::PropertyState SwXFrame::getPropertyState( const OUString& rPropertyName )
2359 throw(beans::UnknownPropertyException, uno::RuntimeException)
2360 {
2361 vos::OGuard aGuard(Application::GetSolarMutex());
2362 uno::Sequence< OUString > aPropertyNames(1);
2363 OUString* pNames = aPropertyNames.getArray();
2364 pNames[0] = rPropertyName;
2365 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aPropertyNames);
2366 return aStates.getConstArray()[0];
2367 }
2368
getPropertyStates(const uno::Sequence<OUString> & aPropertyNames)2369 uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates(
2370 const uno::Sequence< OUString >& aPropertyNames )
2371 throw(beans::UnknownPropertyException, uno::RuntimeException)
2372 {
2373 vos::OGuard aGuard(Application::GetSolarMutex());
2374 uno::Sequence< beans::PropertyState > aStates(aPropertyNames.getLength());
2375 beans::PropertyState* pStates = aStates.getArray();
2376 SwFrmFmt* pFmt = GetFrmFmt();
2377 if(pFmt)
2378 {
2379 const OUString* pNames = aPropertyNames.getConstArray();
2380 const SwAttrSet& rFmtSet = pFmt->GetAttrSet();
2381 for(int i = 0; i < aPropertyNames.getLength(); i++)
2382 {
2383 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(pNames[i]);
2384 if (!pEntry)
2385 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
2386
2387 if(pEntry->nWID == FN_UNO_ANCHOR_TYPES||
2388 pEntry->nWID == FN_PARAM_LINK_DISPLAY_NAME||
2389 FN_UNO_FRAME_STYLE_NAME == pEntry->nWID||
2390 FN_UNO_GRAPHIC_U_R_L == pEntry->nWID||
2391 FN_UNO_GRAPHIC_FILTER == pEntry->nWID||
2392 FN_UNO_ACTUAL_SIZE == pEntry->nWID||
2393 FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
2394 {
2395 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2396 }
2397 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2398 {
2399 //UUUU
2400 if(SFX_ITEM_SET == rFmtSet.GetItemState(XATTR_FILLBMP_STRETCH, false)
2401 || SFX_ITEM_SET == rFmtSet.GetItemState(XATTR_FILLBMP_TILE, false))
2402 {
2403 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2404 }
2405 else
2406 {
2407 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2408 }
2409 }
2410 //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND
2411 // as beans::PropertyState_DIRECT_VALUE to let users of this property call
2412 // getPropertyValue where the member properties will be mapped from the
2413 // fill attributes to the according SvxBrushItem entries
2414 else if(RES_BACKGROUND == pEntry->nWID && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFmtSet))
2415 {
2416 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2417 }
2418 else
2419 {
2420 if ((eType == FLYCNTTYPE_GRF) &&
2421 pEntry && isGRFATR(pEntry->nWID))
2422 {
2423 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2424 if(pIdx)
2425 {
2426 SwNodeIndex aIdx(*pIdx, 1);
2427 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2428 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
2429 aSet.GetItemState(pEntry->nWID);
2430 if(SFX_ITEM_SET == aSet.GetItemState( pEntry->nWID, sal_False ))
2431 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2432 }
2433 }
2434 else
2435 {
2436 if(SFX_ITEM_SET == rFmtSet.GetItemState( pEntry->nWID, sal_False ))
2437 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2438 else
2439 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2440 }
2441 }
2442 }
2443 }
2444 else if(IsDescriptor())
2445 {
2446 for(int i = 0; i < aPropertyNames.getLength(); i++)
2447 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2448 }
2449 else
2450 throw uno::RuntimeException();
2451 return aStates;
2452 }
2453
setPropertyToDefault(const OUString & rPropertyName)2454 void SwXFrame::setPropertyToDefault( const OUString& rPropertyName )
2455 throw(beans::UnknownPropertyException, uno::RuntimeException)
2456 {
2457 vos::OGuard aGuard(Application::GetSolarMutex());
2458 SwFrmFmt* pFmt = GetFrmFmt();
2459 if(pFmt)
2460 {
2461 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
2462 if (!pEntry)
2463 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2464 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2465 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2466
2467 sal_Bool bNextFrame;
2468
2469 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2470 {
2471 //UUUU
2472 SwDoc* pDoc = pFmt->GetDoc();
2473 SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
2474 aSet.SetParent(&pFmt->GetAttrSet());
2475
2476 aSet.ClearItem(XATTR_FILLBMP_STRETCH);
2477 aSet.ClearItem(XATTR_FILLBMP_TILE);
2478
2479 pFmt->SetFmtAttr(aSet);
2480 }
2481 else if( pEntry->nWID &&
2482 pEntry->nWID != FN_UNO_ANCHOR_TYPES &&
2483 pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME)
2484 {
2485 if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) )
2486 {
2487 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2488 if(pIdx)
2489 {
2490 SwNodeIndex aIdx(*pIdx, 1);
2491 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
2492 {
2493 SfxItemSet aSet(pNoTxt->GetSwAttrSet());
2494 aSet.ClearItem(pEntry->nWID);
2495 pNoTxt->SetAttr(aSet);
2496 }
2497 }
2498 }
2499 // --> OD 2009-07-13 #i73249#
2500 // Attribute AlternativeText was never published.
2501 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances
2502 // else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == 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 // pNoTxt->SetAlternateText(aEmptyStr);
2510 // }
2511 // }
2512 // New attribute Title
2513 else if( FN_UNO_TITLE == pEntry->nWID )
2514 {
2515 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2516 ASSERT( pFmt,
2517 "unexpected type of <pFmt> --> crash" );
2518 // assure that <SdrObject> instance exists.
2519 GetOrCreateSdrObject( pFlyFmt );
2520 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), aEmptyStr );
2521 }
2522 // New attribute Description
2523 else if( FN_UNO_DESCRIPTION == pEntry->nWID )
2524 {
2525 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
2526 ASSERT( pFmt,
2527 "unexpected type of <pFmt> --> crash" );
2528 // assure that <SdrObject> instance exists.
2529 GetOrCreateSdrObject( pFlyFmt );
2530 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), aEmptyStr );
2531 }
2532 // <--
2533 else
2534 {
2535 SwDoc* pDoc = pFmt->GetDoc();
2536 SfxItemSet aSet( pDoc->GetAttrPool(),
2537 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
2538 aSet.SetParent(&pFmt->GetAttrSet());
2539 aSet.ClearItem(pEntry->nWID);
2540 if(!rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)))
2541 pFmt->SetFmtAttr(aSet);
2542 }
2543 }
2544 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME))))
2545 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME)))
2546 {
2547 SwDoc* pDoc = pFmt->GetDoc();
2548 if(bNextFrame)
2549 pDoc->Unchain(*pFmt);
2550 else
2551 {
2552 SwFmtChain aChain( pFmt->GetChain() );
2553 SwFrmFmt *pPrev = aChain.GetPrev();
2554 if(pPrev)
2555 pDoc->Unchain(*pPrev);
2556 }
2557 }
2558 }
2559 else if(!IsDescriptor())
2560 throw uno::RuntimeException();
2561
2562 }
2563
getPropertyDefault(const OUString & rPropertyName)2564 uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName )
2565 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
2566 {
2567 vos::OGuard aGuard(Application::GetSolarMutex());
2568 uno::Any aRet;
2569 SwFrmFmt* pFmt = GetFrmFmt();
2570 if(pFmt)
2571 {
2572 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
2573 if(pEntry)
2574 {
2575 if ( pEntry->nWID < RES_FRMATR_END )
2576 {
2577 const SfxPoolItem& rDefItem =
2578 pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
2579 //UUUU
2580 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
2581
2582 rDefItem.QueryValue(aRet, nMemberId);
2583 }
2584 }
2585 else
2586 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2587 }
2588 else if(!IsDescriptor())
2589 throw uno::RuntimeException();
2590 return aRet;
2591 }
2592
addEventListener(const uno::Reference<lang::XEventListener> & aListener)2593 void SwXFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2594 {
2595 if(!GetRegisteredIn())
2596 throw uno::RuntimeException();
2597 aLstnrCntnr.AddListener(aListener);
2598 }
2599
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)2600 void SwXFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2601 {
2602 if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener))
2603 throw uno::RuntimeException();
2604 }
2605
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)2606 void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
2607 {
2608 ClientModify(this, pOld, pNew);
2609 if(!GetRegisteredIn())
2610 {
2611 mxStyleData.clear();
2612 mxStyleFamily.clear();
2613 m_pDoc = 0;
2614 aLstnrCntnr.Disposing();
2615 }
2616 }
2617
2618
dispose(void)2619 void SwXFrame::dispose(void) throw( uno::RuntimeException )
2620 {
2621 vos::OGuard aGuard(Application::GetSolarMutex());
2622 SwFrmFmt* pFmt = GetFrmFmt();
2623 if ( pFmt )
2624 {
2625 SdrObject* pObj = pFmt->FindSdrObject();
2626 // OD 11.09.2003 #112039# - add condition to perform delete of
2627 // format/anchor sign, not only if the object is inserted, but also
2628 // if a contact object is registered, which isn't in the destruction.
2629 if ( pObj &&
2630 ( pObj->IsInserted() ||
2631 ( pObj->GetUserCall() &&
2632 !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) )
2633 {
2634 if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
2635 {
2636 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
2637 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
2638 const xub_StrLen nIdx = rPos.nContent.GetIndex();
2639 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
2640 }
2641 else
2642 pFmt->GetDoc()->DelLayoutFmt(pFmt);
2643 }
2644 }
2645
2646 }
2647
getAnchor(void)2648 uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::RuntimeException )
2649 {
2650 vos::OGuard aGuard(Application::GetSolarMutex());
2651 uno::Reference< text::XTextRange > aRef;
2652 SwFrmFmt* pFmt = GetFrmFmt();
2653 if(pFmt)
2654 {
2655 const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
2656 // return an anchor for non-page bound frames
2657 // and for page bound frames that have a page no == NULL and a content position
2658 if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
2659 (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
2660 {
2661 const SwPosition &rPos = *(rAnchor.GetCntntAnchor());
2662 aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
2663 }
2664 }
2665 else
2666 throw uno::RuntimeException();
2667 return aRef;
2668 }
2669
ResetDescriptor()2670 void SwXFrame::ResetDescriptor()
2671 {
2672 bIsDescriptor = sal_False;
2673 mxStyleData.clear();
2674 mxStyleFamily.clear();
2675 DELETEZ(pProps);
2676 }
2677
attachToRange(const uno::Reference<text::XTextRange> & xTextRange)2678 void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
2679 throw( lang::IllegalArgumentException, uno::RuntimeException )
2680 {
2681 vos::OGuard aGuard(Application::GetSolarMutex());
2682 if(!IsDescriptor())
2683 throw uno::RuntimeException();
2684 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2685 SwXTextRange* pRange = 0;
2686 OTextCursorHelper* pCursor = 0;
2687 if(xRangeTunnel.is())
2688 {
2689 pRange = reinterpret_cast< SwXTextRange * >(
2690 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2691 pCursor = reinterpret_cast< OTextCursorHelper * >(
2692 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2693 }
2694
2695 SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
2696 if(pDoc)
2697 {
2698 SwUnoInternalPaM aIntPam(*pDoc);
2699 //das muss jetzt sal_True liefern
2700 ::sw::XTextRangeToSwPaM(aIntPam, xTextRange);
2701
2702 SwNode& rNode = pDoc->GetNodes().GetEndOfContent();
2703 SwPaM aPam(rNode);
2704 aPam.Move( fnMoveBackward, fnGoDoc );
2705 static sal_uInt16 __READONLY_DATA aFrmAttrRange[] =
2706 {
2707 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
2708 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
2709
2710 //UUUU FillAttribute support
2711 XATTR_FILL_FIRST, XATTR_FILL_LAST,
2712
2713 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
2714 0
2715 };
2716 static sal_uInt16 __READONLY_DATA aGrAttrRange[] =
2717 {
2718 RES_GRFATR_BEGIN, RES_GRFATR_END-1,
2719 0
2720 };
2721 SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange );
2722
2723 SfxItemSet aFrmSet(pDoc->GetAttrPool(), aFrmAttrRange );
2724
2725 //UUUU set correct parent to get the XFILL_NONE FillStyle as needed
2726 aFrmSet.SetParent(&pDoc->GetDfltFrmFmt()->GetAttrSet());
2727
2728 //jetzt muessen die passenden Items in den Set
2729 sal_Bool bSizeFound;
2730 if(!pProps->AnyToItemSet( pDoc, aFrmSet, aGrSet, bSizeFound))
2731 throw lang::IllegalArgumentException();
2732 //der TextRange wird einzeln behandelt
2733 *aPam.GetPoint() = *aIntPam.GetPoint();
2734 if(aIntPam.HasMark())
2735 {
2736 aPam.SetMark();
2737 *aPam.GetMark() = *aIntPam.GetMark();
2738 }
2739
2740 const SfxPoolItem* pItem;
2741 RndStdIds eAnchorId = FLY_AT_PARA;
2742 if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) )
2743 {
2744 eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId();
2745 if( FLY_AT_FLY == eAnchorId &&
2746 !aPam.GetNode()->FindFlyStartNode())
2747 {
2748 //rahmengebunden geht nur dort, wo ein Rahmen ist!
2749 SwFmtAnchor aAnchor(FLY_AT_PARA);
2750 aFrmSet.Put(aAnchor);
2751 }
2752 else if ((FLY_AT_PAGE == eAnchorId) &&
2753 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() )
2754 {
2755 SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) );
2756 aAnchor.SetAnchor( aPam.GetPoint() );
2757 aFrmSet.Put(aAnchor);
2758 }
2759 }
2760
2761 const ::uno::Any* pStyle;
2762 SwFrmFmt *pParentFrmFmt = 0;
2763 if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle))
2764 pParentFrmFmt = lcl_GetFrmFmt( *pStyle, pDoc );
2765
2766 SwFlyFrmFmt* pFmt = 0;
2767 if( eType == FLYCNTTYPE_FRM)
2768 {
2769 UnoActionContext aCont(pDoc);
2770 if(m_pCopySource)
2771 {
2772 SwFmtAnchor* pAnchorItem = 0;
2773 // the frame is inserted bound to page
2774 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text
2775 if (eAnchorId != FLY_AT_PAGE)
2776 {
2777 pAnchorItem = static_cast<SwFmtAnchor*>(aFrmSet.Get(RES_ANCHOR).Clone());
2778 aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 ));
2779 }
2780
2781 aPam.DeleteMark(); // mark position node will be deleted!
2782 aIntPam.DeleteMark(); // mark position node will be deleted!
2783 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet,
2784 0,
2785 pParentFrmFmt );
2786 if(pAnchorItem && pFmt)
2787 {
2788 pFmt->DelFrms();
2789 pAnchorItem->SetAnchor( m_pCopySource->Start() );
2790 SfxItemSet aAnchorSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR );
2791 aAnchorSet.Put( *pAnchorItem );
2792 pDoc->SetFlyFrmAttr( *pFmt, aAnchorSet );
2793 delete pAnchorItem;
2794 }
2795 DELETEZ( m_pCopySource );
2796 }
2797 else
2798 {
2799 pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(),
2800 &aFrmSet, pParentFrmFmt );
2801 }
2802 if(pFmt)
2803 {
2804 pFmt->Add(this);
2805 if(sName.Len())
2806 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName);
2807 }
2808 //den SwXText wecken
2809 ((SwXTextFrame*)this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrmFmt()->GetDoc() );
2810 }
2811 else if( eType == FLYCNTTYPE_GRF)
2812 {
2813 UnoActionContext aCont(pDoc);
2814 const ::uno::Any* pGraphicURL;
2815 String sGraphicURL;
2816 GraphicObject *pGrfObj = 0;
2817 if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL))
2818 {
2819 OUString uTemp;
2820 (*pGraphicURL) >>= uTemp;
2821 sGraphicURL = String(uTemp);
2822 if( sGraphicURL.EqualsAscii( sPackageProtocol,
2823 0, sizeof( sPackageProtocol )-1 ) )
2824 {
2825 pGrfObj = new GraphicObject;
2826 pGrfObj->SetUserData( sGraphicURL );
2827 pGrfObj->SetSwapState();
2828 sGraphicURL.Erase();
2829 }
2830 else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol,
2831 0, sizeof(sGraphicObjectProtocol)-1 ) )
2832 {
2833 ByteString sId( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ),
2834 RTL_TEXTENCODING_ASCII_US );
2835 pGrfObj = new GraphicObject( sId );
2836 sGraphicURL.Erase();
2837 }
2838 }
2839 Graphic aGraphic;
2840 const ::uno::Any* pGraphic;
2841 if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic ))
2842 {
2843 uno::Reference< graphic::XGraphic > xGraphic;
2844 (*pGraphic) >>= xGraphic;
2845 aGraphic = Graphic( xGraphic );
2846 }
2847
2848 String sFltName;
2849 const ::uno::Any* pFilter;
2850 if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter))
2851 {
2852 OUString uTemp;
2853 (*pFilter) >>= uTemp;
2854 sFltName = String(uTemp);
2855 }
2856
2857 pFmt =
2858 pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet,
2859 pParentFrmFmt )
2860 : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic,
2861 &aFrmSet, &aGrSet, pParentFrmFmt );
2862 delete pGrfObj;
2863 if(pFmt)
2864 {
2865 SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFmt->GetCntnt().GetCntntIdx()
2866 ->GetIndex()+1 ]->GetGrfNode();
2867 pGrfNd->SetChgTwipSize( !bSizeFound );
2868 pFmt->Add(this);
2869 if(sName.Len())
2870 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName);
2871
2872 }
2873 const ::uno::Any* pSurroundContour;
2874 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour))
2875 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SURROUND_CONTOUR)), *pSurroundContour);
2876 const ::uno::Any* pContourOutside;
2877 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside))
2878 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_OUTSIDE)), *pContourOutside);
2879 const ::uno::Any* pContourPoly;
2880 if(pProps->GetProperty(FN_PARAM_COUNTOUR_PP, 0, pContourPoly))
2881 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_POLY_POLYGON)), *pContourPoly);
2882 const ::uno::Any* pPixelContour;
2883 if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour))
2884 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_PIXEL_CONTOUR)), *pPixelContour);
2885 const ::uno::Any* pAutoContour;
2886 if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour))
2887 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_AUTOMATIC_CONTOUR)), *pAutoContour);
2888 // const ::uno::Any* pAltText;
2889 // if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText))
2890 // setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText);
2891 }
2892 else
2893 {
2894 const ::uno::Any* pCLSID = 0;
2895 const ::uno::Any* pStreamName = 0;
2896 if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName ))
2897 throw uno::RuntimeException();
2898 if(pCLSID)
2899 {
2900 OUString aCLSID;
2901 SvGlobalName aClassName;
2902 uno::Reference < embed::XEmbeddedObject > xIPObj;
2903 std::auto_ptr < comphelper::EmbeddedObjectContainer > pCnt;
2904 if( (*pCLSID) >>= aCLSID )
2905 {
2906 if( !aClassName.MakeId( aCLSID ) )
2907 {
2908 lang::IllegalArgumentException aExcept;
2909 aExcept.Message = OUString::createFromAscii("CLSID invalid");
2910 throw aExcept;
2911 }
2912
2913 pCnt.reset( new comphelper::EmbeddedObjectContainer );
2914 ::rtl::OUString aName;
2915 xIPObj = pCnt->CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
2916 }
2917 if ( xIPObj.is() )
2918 {
2919 //TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE
2920 //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xIPObj->GetMiscStatus() && pDoc->getPrinter( false ) )
2921 // xIPObj->OnDocumentPrinterChanged( pDoc->getPrinter( false ) );
2922
2923 UnoActionContext aAction(pDoc);
2924 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
2925 if(!bSizeFound)
2926 {
2927 //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode?
2928 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
2929
2930 // TODO/LEAN: VisualArea still needs running state
2931 svt::EmbeddedObjectRef::TryRunningState( xIPObj );
2932
2933 // set parent to get correct VisArea(in case of object needing parent printer)
2934 uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY );
2935 if ( xChild.is() )
2936 xChild->setParent( pDoc->GetDocShell()->GetModel() );
2937
2938 //The Size should be suggested by the OLE server if not manually set
2939 MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) );
2940 awt::Size aSize;
2941 try
2942 {
2943 aSize = xIPObj->getVisualAreaSize( nAspect );
2944 }
2945 catch ( embed::NoVisualAreaSizeException& )
2946 {
2947 // the default size will be set later
2948 }
2949
2950 Size aSz( aSize.Width, aSize.Height );
2951 if ( !aSz.Width() || !aSz.Height() )
2952 {
2953 aSz.Width() = aSz.Height() = 5000;
2954 aSz = OutputDevice::LogicToLogic
2955 ( aSz, MapMode( MAP_100TH_MM ), aRefMap );
2956 }
2957 MapMode aMyMap( MAP_TWIP );
2958 aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap );
2959 SwFmtFrmSize aFrmSz;
2960 aFrmSz.SetSize(aSz);
2961 aFrmSet.Put(aFrmSz);
2962 }
2963 SwFlyFrmFmt* pFmt2 = 0;
2964
2965 // TODO/LATER: Is it the only possible aspect here?
2966 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
2967 ::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect );
2968 pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL );
2969 ASSERT( pFmt2, "Doc->Insert(notxt) failed." );
2970
2971 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
2972 pFmt2->Add(this);
2973 if(sName.Len())
2974 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName);
2975 }
2976 }
2977 else if( pStreamName )
2978 {
2979 ::rtl::OUString sStreamName;
2980 (*pStreamName) >>= sStreamName;
2981 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
2982
2983 SwFlyFrmFmt* pFrmFmt = 0;
2984 pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL );
2985 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
2986 pFrmFmt->Add(this);
2987 if(sName.Len())
2988 pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName);
2989 }
2990 }
2991 if( pFmt && pDoc->GetDrawModel() )
2992 GetOrCreateSdrObject( pFmt );
2993 const ::uno::Any* pOrder;
2994 if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) )
2995 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_Z_ORDER)), *pOrder);
2996 const ::uno::Any* pReplacement;
2997 if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) )
2998 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_GRAPHIC)), *pReplacement);
2999 // --> OD 2009-07-13 #i73249#
3000 // new attribute Title
3001 const ::uno::Any* pTitle;
3002 if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) )
3003 {
3004 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_TITLE)), *pTitle);
3005 }
3006 // new attribute Description
3007 const ::uno::Any* pDescription;
3008 if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) )
3009 {
3010 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DESCRIPTION)), *pDescription);
3011 }
3012 // <--
3013 }
3014 else
3015 throw lang::IllegalArgumentException();
3016 //setzt das Flag zurueck und loescht den Descriptor-Pointer
3017 ResetDescriptor();
3018 }
3019
attach(const uno::Reference<text::XTextRange> & xTextRange)3020 void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
3021 throw( lang::IllegalArgumentException, uno::RuntimeException )
3022 {
3023 SwFrmFmt* pFmt;
3024 if(IsDescriptor())
3025 attachToRange(xTextRange);
3026 else if(0 != (pFmt = GetFrmFmt()))
3027 {
3028 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
3029 SwXTextRange* pRange = 0;
3030 OTextCursorHelper* pCursor = 0;
3031 if(xRangeTunnel.is())
3032 {
3033 pRange = reinterpret_cast< SwXTextRange * >(
3034 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
3035 pCursor = reinterpret_cast< OTextCursorHelper * >(
3036 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
3037 }
3038 SwDoc* pDoc = pFmt->GetDoc();
3039 SwUnoInternalPaM aIntPam(*pDoc);
3040 if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange))
3041 {
3042 SfxItemSet aSet( pDoc->GetAttrPool(),
3043 RES_ANCHOR, RES_ANCHOR );
3044 aSet.SetParent(&pFmt->GetAttrSet());
3045 SwFmtAnchor aAnchor = (const SwFmtAnchor&)aSet.Get(RES_ANCHOR);
3046 aAnchor.SetAnchor( aIntPam.Start() );
3047 aSet.Put(aAnchor);
3048 pDoc->SetFlyFrmAttr( *pFmt, aSet );
3049 }
3050 else
3051 throw lang::IllegalArgumentException();
3052 }
3053 }
3054
getPosition(void)3055 awt::Point SwXFrame::getPosition(void) throw( uno::RuntimeException )
3056 {
3057 vos::OGuard aGuard(Application::GetSolarMutex());
3058 uno::RuntimeException aRuntime;
3059 aRuntime.Message = C2U("position cannot be determined with this method");
3060 throw aRuntime;
3061 }
3062
setPosition(const awt::Point &)3063 void SwXFrame::setPosition(const awt::Point& /*aPosition*/) throw( uno::RuntimeException )
3064 {
3065 vos::OGuard aGuard(Application::GetSolarMutex());
3066 uno::RuntimeException aRuntime;
3067 aRuntime.Message = C2U("position cannot be changed with this method");
3068 throw aRuntime;
3069 }
3070
getSize(void)3071 awt::Size SwXFrame::getSize(void) throw( uno::RuntimeException )
3072 {
3073 const ::uno::Any aVal = getPropertyValue(C2U("Size"));
3074 awt::Size* pRet = (awt::Size*)aVal.getValue();
3075 return *pRet;
3076 }
3077
setSize(const awt::Size & aSize)3078 void SwXFrame::setSize(const awt::Size& aSize)
3079 throw( beans::PropertyVetoException, uno::RuntimeException )
3080 {
3081 const ::uno::Any aVal(&aSize, ::getCppuType(static_cast<const awt::Size*>(0)));
3082 setPropertyValue(C2U("Size"), aVal);
3083 }
3084
getShapeType(void)3085 OUString SwXFrame::getShapeType(void) throw( uno::RuntimeException )
3086 {
3087 return C2U("FrameShape");
3088 }
3089
3090
3091 /******************************************************************
3092 * SwXTextFrame
3093 ******************************************************************/
3094
SwXTextFrame(SwDoc * _pDoc)3095 SwXTextFrame::SwXTextFrame( SwDoc *_pDoc ) :
3096 SwXText(0, CURSOR_FRAME),
3097 SwXFrame(FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME), _pDoc )
3098 {
3099 }
3100
SwXTextFrame(SwFrmFmt & rFmt)3101 SwXTextFrame::SwXTextFrame(SwFrmFmt& rFmt) :
3102 SwXText(rFmt.GetDoc(), CURSOR_FRAME),
3103 SwXFrame(rFmt, FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME))
3104 {
3105
3106 }
3107
~SwXTextFrame()3108 SwXTextFrame::~SwXTextFrame()
3109 {
3110 }
3111
acquire()3112 void SAL_CALL SwXTextFrame::acquire( )throw()
3113 {
3114 SwXFrame::acquire();
3115 }
3116
release()3117 void SAL_CALL SwXTextFrame::release( )throw()
3118 {
3119 SwXFrame::release();
3120 }
3121
queryInterface(const uno::Type & aType)3122 ::uno::Any SAL_CALL SwXTextFrame::queryInterface( const uno::Type& aType )
3123 throw (uno::RuntimeException)
3124 {
3125 ::uno::Any aRet = SwXFrame::queryInterface(aType);
3126 if(aRet.getValueType() == ::getCppuVoidType())
3127 aRet = SwXText::queryInterface(aType);
3128 if(aRet.getValueType() == ::getCppuVoidType())
3129 aRet = SwXTextFrameBaseClass::queryInterface(aType);
3130 return aRet;
3131 }
3132
getTypes()3133 uno::Sequence< uno::Type > SAL_CALL SwXTextFrame::getTypes( ) throw(uno::RuntimeException)
3134 {
3135 uno::Sequence< uno::Type > aTextFrameTypes = SwXTextFrameBaseClass::getTypes();
3136 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
3137 uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
3138
3139 long nIndex = aTextFrameTypes.getLength();
3140 aTextFrameTypes.realloc(
3141 aTextFrameTypes.getLength() +
3142 aFrameTypes.getLength() +
3143 aTextTypes.getLength());
3144
3145 uno::Type* pTextFrameTypes = aTextFrameTypes.getArray();
3146 const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
3147 long nPos;
3148 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
3149 pTextFrameTypes[nIndex++] = pFrameTypes[nPos];
3150
3151 const uno::Type* pTextTypes = aTextTypes.getConstArray();
3152 for(nPos = 0; nPos <aTextTypes.getLength(); nPos++)
3153 pTextFrameTypes[nIndex++] = pTextTypes[nPos];
3154
3155 return aTextFrameTypes;
3156 }
3157
getImplementationId()3158 uno::Sequence< sal_Int8 > SAL_CALL SwXTextFrame::getImplementationId( ) throw(uno::RuntimeException)
3159 {
3160 vos::OGuard aGuard(Application::GetSolarMutex());
3161 static uno::Sequence< sal_Int8 > aId( 16 );
3162 static sal_Bool bInit = sal_False;
3163 if(!bInit)
3164 {
3165 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
3166 bInit = sal_True;
3167 }
3168 return aId;
3169 }
3170
getText(void)3171 uno::Reference< text::XText > SwXTextFrame::getText(void) throw( uno::RuntimeException )
3172 {
3173 return this;
3174 }
3175
GetStartNode() const3176 const SwStartNode *SwXTextFrame::GetStartNode() const
3177 {
3178 const SwStartNode *pSttNd = 0;
3179
3180 SwFrmFmt* pFmt = GetFrmFmt();
3181 if(pFmt)
3182 {
3183 const SwFmtCntnt& rFlyCntnt = pFmt->GetCntnt();
3184 if( rFlyCntnt.GetCntntIdx() )
3185 pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode();
3186 }
3187
3188 return pSttNd;
3189 }
3190
3191 uno::Reference< text::XTextCursor >
CreateCursor()3192 SwXTextFrame::CreateCursor() throw (uno::RuntimeException)
3193 {
3194 return createTextCursor();
3195 }
3196
createTextCursor(void)3197 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void) throw( uno::RuntimeException )
3198 {
3199 vos::OGuard aGuard(Application::GetSolarMutex());
3200 uno::Reference< text::XTextCursor > aRef;
3201 SwFrmFmt* pFmt = GetFrmFmt();
3202 if(pFmt)
3203 {
3204 //save current start node to be able to check if there is content after the table -
3205 //otherwise the cursor would be in the body text!
3206 const SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode();
3207 const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode);
3208
3209 SwPaM aPam(rNode);
3210 aPam.Move(fnMoveForward, fnGoNode);
3211 SwTableNode* pTblNode = aPam.GetNode()->FindTableNode();
3212 SwCntntNode* pCont = 0;
3213 while( pTblNode )
3214 {
3215 aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode();
3216 pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode);
3217 pTblNode = pCont->FindTableNode();
3218 }
3219 if(pCont)
3220 aPam.GetPoint()->nContent.Assign(pCont, 0);
3221
3222 const SwStartNode* pNewStartNode =
3223 aPam.GetNode()->FindSttNodeByType(SwFlyStartNode);
3224 if(!pNewStartNode || pNewStartNode != pOwnStartNode)
3225 {
3226 uno::RuntimeException aExcept;
3227 aExcept.Message = C2U("no text available");
3228 throw aExcept;
3229 }
3230
3231 SwXTextCursor *const pXCursor = new SwXTextCursor(
3232 *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint());
3233 aRef = static_cast<text::XWordCursor*>(pXCursor);
3234 #if OSL_DEBUG_LEVEL > 1
3235 SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
3236 (void) pUnoCrsr;
3237 #endif
3238 }
3239 else
3240 throw uno::RuntimeException();
3241 return aRef;
3242 }
3243
createTextCursorByRange(const uno::Reference<text::XTextRange> & aTextPosition)3244 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException )
3245 {
3246 vos::OGuard aGuard(Application::GetSolarMutex());
3247 uno::Reference< text::XTextCursor > aRef;
3248 SwFrmFmt* pFmt = GetFrmFmt();
3249 SwUnoInternalPaM aPam(*GetDoc());
3250 if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition))
3251 {
3252 SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode();
3253 #if OSL_DEBUG_LEVEL > 1
3254 const SwStartNode* p1 = aPam.GetNode()->FindFlyStartNode();
3255 const SwStartNode* p2 = rNode.FindFlyStartNode();
3256 (void)p1;
3257 (void)p2;
3258 #endif
3259 if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode())
3260 {
3261 aRef = static_cast<text::XWordCursor*>(
3262 new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME,
3263 *aPam.GetPoint(), aPam.GetMark()));
3264 }
3265 }
3266 else
3267 throw uno::RuntimeException();
3268 return aRef;
3269 }
3270
createEnumeration(void)3271 uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void) throw( uno::RuntimeException )
3272 {
3273 vos::OGuard aGuard(Application::GetSolarMutex());
3274 uno::Reference< container::XEnumeration > aRef;
3275 SwFrmFmt* pFmt = GetFrmFmt();
3276 if(pFmt)
3277 {
3278 SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode());
3279 ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
3280 GetDoc()->CreateUnoCrsr(aPos, sal_False));
3281 pUnoCursor->Move(fnMoveForward, fnGoNode);
3282 // // no Cursor in protected sections
3283 // SwCrsrSaveState aSave( *pUnoCrsr );
3284 // if(pUnoCrsr->IsInProtectTable( sal_True ) ||
3285 // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS ))
3286 // throw uno::RuntimeException() );
3287 aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME);
3288 }
3289 return aRef;
3290 }
3291
getElementType(void)3292 uno::Type SwXTextFrame::getElementType(void) throw( uno::RuntimeException )
3293 {
3294 return ::getCppuType(static_cast<uno::Reference<text::XTextRange>*>(0));
3295 }
3296
hasElements(void)3297 sal_Bool SwXTextFrame::hasElements(void) throw( uno::RuntimeException )
3298 {
3299 return sal_True;
3300 }
3301
attach(const uno::Reference<text::XTextRange> & xTextRange)3302 void SwXTextFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
3303 throw( lang::IllegalArgumentException, uno::RuntimeException )
3304 {
3305 SwXFrame::attach(xTextRange);
3306 }
3307
getAnchor(void)3308 uno::Reference< text::XTextRange > SwXTextFrame::getAnchor(void) throw( uno::RuntimeException )
3309 {
3310 vos::OGuard aGuard(Application::GetSolarMutex());
3311 return SwXFrame::getAnchor();
3312 }
3313
dispose(void)3314 void SwXTextFrame::dispose(void) throw( uno::RuntimeException )
3315 {
3316 vos::OGuard aGuard(Application::GetSolarMutex());
3317 SwXFrame::dispose();
3318 }
3319
addEventListener(const uno::Reference<lang::XEventListener> & aListener)3320 void SwXTextFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
3321 {
3322 SwXFrame::addEventListener(aListener);
3323 }
3324
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)3325 void SwXTextFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
3326 {
3327 SwXFrame::removeEventListener(aListener);
3328 }
3329
getImplementationName(void)3330 OUString SwXTextFrame::getImplementationName(void) throw( uno::RuntimeException )
3331 {
3332 return C2U("SwXTextFrame");
3333 }
3334
supportsService(const OUString & rServiceName)3335 sal_Bool SwXTextFrame::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
3336 {
3337 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.Text")||
3338 COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextFrame")||
3339 SwXFrame::supportsService(rServiceName);
3340 }
3341
getSupportedServiceNames(void)3342 uno::Sequence< OUString > SwXTextFrame::getSupportedServiceNames(void) throw( uno::RuntimeException )
3343 {
3344 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3345 aRet.realloc(aRet.getLength() + 2);
3346 OUString* pArray = aRet.getArray();
3347 pArray[aRet.getLength() - 2] = C2U("com.sun.star.text.TextFrame");
3348 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.Text");
3349 return aRet;
3350 }
3351
operator new(size_t t)3352 void * SAL_CALL SwXTextFrame::operator new( size_t t) throw()
3353 {
3354 return SwXTextFrameBaseClass::operator new( t);
3355 }
3356
operator delete(void * p)3357 void SAL_CALL SwXTextFrame::operator delete( void * p) throw()
3358 {
3359 SwXTextFrameBaseClass::operator delete(p);
3360 }
3361
getEvents()3362 uno::Reference<container::XNameReplace > SAL_CALL SwXTextFrame::getEvents()
3363 throw(uno::RuntimeException)
3364 {
3365 return new SwFrameEventDescriptor( *this );
3366 }
3367
getSomething(const uno::Sequence<sal_Int8> & rId)3368 sal_Int64 SAL_CALL SwXTextFrame::getSomething( const uno::Sequence< sal_Int8 >& rId )
3369 throw(uno::RuntimeException)
3370 {
3371 sal_Int64 nRet = SwXFrame::getSomething( rId );
3372 if( !nRet )
3373 nRet = SwXText::getSomething( rId );
3374
3375 return nRet;
3376 }
3377
getPropertyValue(const OUString & rPropertyName)3378 ::uno::Any SwXTextFrame::getPropertyValue(const OUString& rPropertyName)
3379 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3380 {
3381 vos::OGuard aGuard(Application::GetSolarMutex());
3382 ::uno::Any aRet;
3383 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))||
3384 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE)))
3385 {
3386 //redline can only be returned if it's a living object
3387 if(!IsDescriptor())
3388 aRet = SwXText::getPropertyValue(rPropertyName);
3389 }
3390 else
3391 aRet = SwXFrame::getPropertyValue(rPropertyName);
3392 return aRet;
3393 }
3394 /******************************************************************
3395 * SwXTextGraphicObject
3396 ******************************************************************/
3397
SwXTextGraphicObject(SwDoc * pDoc)3398 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc *pDoc ) :
3399 SwXFrame(FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC), pDoc)
3400 {
3401 }
3402
SwXTextGraphicObject(SwFrmFmt & rFmt)3403 SwXTextGraphicObject::SwXTextGraphicObject(SwFrmFmt& rFmt) :
3404 SwXFrame(rFmt, FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC))
3405 {
3406
3407 }
3408
~SwXTextGraphicObject()3409 SwXTextGraphicObject::~SwXTextGraphicObject()
3410 {
3411
3412 }
3413
acquire()3414 void SAL_CALL SwXTextGraphicObject::acquire( )throw()
3415 {
3416 SwXFrame::acquire();
3417 }
3418
release()3419 void SAL_CALL SwXTextGraphicObject::release( )throw()
3420 {
3421 SwXFrame::release();
3422 }
3423
queryInterface(const uno::Type & aType)3424 ::uno::Any SAL_CALL SwXTextGraphicObject::queryInterface( const uno::Type& aType )
3425 throw(uno::RuntimeException)
3426 {
3427 ::uno::Any aRet = SwXFrame::queryInterface(aType);
3428 if(aRet.getValueType() == ::getCppuVoidType())
3429 aRet = SwXTextGraphicObjectBaseClass::queryInterface(aType);
3430 return aRet;
3431 }
3432
3433 uno::Sequence< uno::Type > SAL_CALL
getTypes()3434 SwXTextGraphicObject::getTypes( ) throw(uno::RuntimeException)
3435 {
3436 uno::Sequence< uno::Type > aGraphicTypes = SwXTextGraphicObjectBaseClass::getTypes();
3437 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
3438
3439 long nIndex = aGraphicTypes.getLength();
3440 aGraphicTypes.realloc(
3441 aGraphicTypes.getLength() +
3442 aFrameTypes.getLength());
3443
3444 uno::Type* pGraphicTypes = aGraphicTypes.getArray();
3445 const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
3446 long nPos;
3447 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
3448 pGraphicTypes[nIndex++] = pFrameTypes[nPos];
3449
3450 return aGraphicTypes;
3451 }
3452
getImplementationId()3453 uno::Sequence< sal_Int8 > SAL_CALL SwXTextGraphicObject::getImplementationId( ) throw(uno::RuntimeException)
3454 {
3455 vos::OGuard aGuard(Application::GetSolarMutex());
3456 static uno::Sequence< sal_Int8 > aId( 16 );
3457 static sal_Bool bInit = sal_False;
3458 if(!bInit)
3459 {
3460 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
3461 bInit = sal_True;
3462 }
3463 return aId;
3464 }
3465
attach(const uno::Reference<text::XTextRange> & xTextRange)3466 void SwXTextGraphicObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException )
3467 {
3468 SwXFrame::attach(xTextRange);
3469 }
3470
getAnchor(void)3471 uno::Reference< text::XTextRange > SwXTextGraphicObject::getAnchor(void) throw( uno::RuntimeException )
3472 {
3473 vos::OGuard aGuard(Application::GetSolarMutex());
3474 return SwXFrame::getAnchor();
3475 }
3476
dispose(void)3477 void SwXTextGraphicObject::dispose(void) throw( uno::RuntimeException )
3478 {
3479 vos::OGuard aGuard(Application::GetSolarMutex());
3480 SwXFrame::dispose();
3481 }
3482
addEventListener(const uno::Reference<lang::XEventListener> & aListener)3483 void SwXTextGraphicObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
3484 throw( uno::RuntimeException )
3485 {
3486 SwXFrame::addEventListener(aListener);
3487 }
3488
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)3489 void SwXTextGraphicObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
3490 throw( uno::RuntimeException )
3491 {
3492 SwXFrame::removeEventListener(aListener);
3493 }
3494
getImplementationName(void)3495 OUString SwXTextGraphicObject::getImplementationName(void) throw( uno::RuntimeException )
3496 {
3497 return C2U("SwXTextGraphicObject");
3498 }
3499
supportsService(const OUString & rServiceName)3500 sal_Bool SwXTextGraphicObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
3501 {
3502 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextGraphicObject") ||
3503 SwXFrame::supportsService(rServiceName);
3504 }
3505
getSupportedServiceNames(void)3506 uno::Sequence< OUString > SwXTextGraphicObject::getSupportedServiceNames(void)
3507 throw( uno::RuntimeException )
3508 {
3509 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3510 aRet.realloc(aRet.getLength() + 1);
3511 OUString* pArray = aRet.getArray();
3512 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextGraphicObject");
3513 return aRet;
3514 }
3515
operator new(size_t t)3516 void * SAL_CALL SwXTextGraphicObject::operator new( size_t t) throw()
3517 {
3518 return SwXTextGraphicObjectBaseClass::operator new(t);
3519 }
3520
operator delete(void * p)3521 void SAL_CALL SwXTextGraphicObject::operator delete( void * p) throw()
3522 {
3523 SwXTextGraphicObjectBaseClass::operator delete(p);
3524 }
3525
3526 uno::Reference<container::XNameReplace> SAL_CALL
getEvents()3527 SwXTextGraphicObject::getEvents()
3528 throw(uno::RuntimeException)
3529 {
3530 return new SwFrameEventDescriptor( *this );
3531 }
3532
3533 /******************************************************************
3534 *
3535 ******************************************************************/
3536
SwXTextEmbeddedObject(SwDoc * pDoc)3537 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc *pDoc ) :
3538 SwXFrame(FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT), pDoc)
3539 {
3540 }
3541
SwXTextEmbeddedObject(SwFrmFmt & rFmt)3542 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrmFmt& rFmt) :
3543 SwXFrame(rFmt, FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT))
3544 {
3545
3546 }
3547
~SwXTextEmbeddedObject()3548 SwXTextEmbeddedObject::~SwXTextEmbeddedObject()
3549 {
3550
3551 }
3552
acquire()3553 void SAL_CALL SwXTextEmbeddedObject::acquire()throw()
3554 {
3555 SwXFrame::acquire();
3556 }
3557
release()3558 void SAL_CALL SwXTextEmbeddedObject::release()throw()
3559 {
3560 SwXFrame::release();
3561 }
3562
queryInterface(const uno::Type & aType)3563 ::uno::Any SAL_CALL SwXTextEmbeddedObject::queryInterface( const uno::Type& aType )
3564 throw( uno::RuntimeException)
3565 {
3566 ::uno::Any aRet = SwXFrame::queryInterface(aType);;
3567 if(aRet.getValueType() == ::getCppuVoidType())
3568 aRet = SwXTextEmbeddedObjectBaseClass::queryInterface(aType);
3569 return aRet;
3570 }
3571
getTypes()3572 uno::Sequence< uno::Type > SAL_CALL SwXTextEmbeddedObject::getTypes( ) throw(uno::RuntimeException)
3573 {
3574 uno::Sequence< uno::Type > aTextEmbeddedTypes = SwXTextEmbeddedObjectBaseClass::getTypes();
3575 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
3576
3577 long nIndex = aTextEmbeddedTypes.getLength();
3578 aTextEmbeddedTypes.realloc(
3579 aTextEmbeddedTypes.getLength() +
3580 aFrameTypes.getLength());
3581
3582 uno::Type* pTextEmbeddedTypes = aTextEmbeddedTypes.getArray();
3583
3584 const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
3585 long nPos;
3586 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
3587 pTextEmbeddedTypes[nIndex++] = pFrameTypes[nPos];
3588
3589 return aTextEmbeddedTypes;
3590 }
3591
getImplementationId()3592 uno::Sequence< sal_Int8 > SAL_CALL SwXTextEmbeddedObject::getImplementationId( ) throw(uno::RuntimeException)
3593 {
3594 vos::OGuard aGuard(Application::GetSolarMutex());
3595 static uno::Sequence< sal_Int8 > aId( 16 );
3596 static sal_Bool bInit = sal_False;
3597 if(!bInit)
3598 {
3599 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
3600 bInit = sal_True;
3601 }
3602 return aId;
3603 }
3604
attach(const uno::Reference<text::XTextRange> & xTextRange)3605 void SwXTextEmbeddedObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException )
3606 {
3607 SwXFrame::attach(xTextRange);
3608 }
3609
getAnchor(void)3610 uno::Reference< text::XTextRange > SwXTextEmbeddedObject::getAnchor(void) throw( uno::RuntimeException )
3611 {
3612 vos::OGuard aGuard(Application::GetSolarMutex());
3613 return SwXFrame::getAnchor();
3614 }
3615
dispose(void)3616 void SwXTextEmbeddedObject::dispose(void) throw( uno::RuntimeException )
3617 {
3618 vos::OGuard aGuard(Application::GetSolarMutex());
3619 SwXFrame::dispose();
3620 }
3621
addEventListener(const uno::Reference<lang::XEventListener> & aListener)3622 void SwXTextEmbeddedObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
3623 {
3624 SwXFrame::addEventListener(aListener);
3625 }
3626
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)3627 void SwXTextEmbeddedObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
3628 {
3629 SwXFrame::removeEventListener(aListener);
3630 }
3631
getEmbeddedObject(void)3632 uno::Reference< lang::XComponent > SwXTextEmbeddedObject::getEmbeddedObject(void) throw( uno::RuntimeException )
3633 {
3634 uno::Reference< lang::XComponent > xRet;
3635 SwFrmFmt* pFmt = GetFrmFmt();
3636 if(pFmt)
3637 {
3638 SwDoc* pDoc = pFmt->GetDoc();
3639 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3640 DBG_ASSERT( pCnt->GetCntntIdx() &&
3641 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3642 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3643
3644 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()
3645 ->GetIndex() + 1 ]->GetOLENode();
3646 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
3647 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
3648 {
3649 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3650 if ( pDoc->GetDocShell() )
3651 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
3652
3653 xRet = uno::Reference < lang::XComponent >( xIP->getComponent(), uno::UNO_QUERY );
3654 uno::Reference< util::XModifyBroadcaster > xBrdcst( xRet, uno::UNO_QUERY);
3655 uno::Reference< frame::XModel > xModel( xRet, uno::UNO_QUERY);
3656 if( xBrdcst.is() && xModel.is() )
3657 {
3658 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt );
3659 //create a new one if the OLE object doesn't have one already
3660 if( !pListener )
3661 {
3662 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
3663 xBrdcst->addModifyListener( xOLEListener );
3664 }
3665 }
3666 }
3667 }
3668 return xRet;
3669 }
3670
getExtendedControlOverEmbeddedObject()3671 uno::Reference< embed::XEmbeddedObject > SAL_CALL SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject()
3672 throw( uno::RuntimeException )
3673 {
3674 uno::Reference< embed::XEmbeddedObject > xResult;
3675 SwFrmFmt* pFmt = GetFrmFmt();
3676 if(pFmt)
3677 {
3678 SwDoc* pDoc = pFmt->GetDoc();
3679 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3680 DBG_ASSERT( pCnt->GetCntntIdx() &&
3681 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3682 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3683
3684 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()
3685 ->GetIndex() + 1 ]->GetOLENode();
3686 xResult = pOleNode->GetOLEObj().GetOleRef();
3687 if ( svt::EmbeddedObjectRef::TryRunningState( xResult ) )
3688 {
3689 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3690 if ( pDoc->GetDocShell() )
3691 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult, embed::Aspects::MSOLE_CONTENT ) );
3692
3693 uno::Reference < lang::XComponent > xComp( xResult->getComponent(), uno::UNO_QUERY );
3694 uno::Reference< util::XModifyBroadcaster > xBrdcst( xComp, uno::UNO_QUERY);
3695 uno::Reference< frame::XModel > xModel( xComp, uno::UNO_QUERY);
3696 if( xBrdcst.is() && xModel.is() )
3697 {
3698 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt );
3699 //create a new one if the OLE object doesn't have one already
3700 if( !pListener )
3701 {
3702 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
3703 xBrdcst->addModifyListener( xOLEListener );
3704 }
3705 }
3706 }
3707 }
3708 return xResult;
3709 }
3710
getAspect()3711 sal_Int64 SAL_CALL SwXTextEmbeddedObject::getAspect() throw (uno::RuntimeException)
3712 {
3713 SwFrmFmt* pFmt = GetFrmFmt();
3714 if(pFmt)
3715 {
3716 SwDoc* pDoc = pFmt->GetDoc();
3717 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3718 DBG_ASSERT( pCnt->GetCntntIdx() &&
3719 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3720 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3721
3722 return pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect();
3723 }
3724
3725 return embed::Aspects::MSOLE_CONTENT; // return the default value
3726 }
3727
setAspect(sal_Int64 nAspect)3728 void SAL_CALL SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect ) throw (uno::RuntimeException)
3729 {
3730 SwFrmFmt* pFmt = GetFrmFmt();
3731 if(pFmt)
3732 {
3733 SwDoc* pDoc = pFmt->GetDoc();
3734 const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3735 DBG_ASSERT( pCnt->GetCntntIdx() &&
3736 pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3737 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3738
3739 pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect );
3740 }
3741 }
3742
getReplacementGraphic()3743 uno::Reference< graphic::XGraphic > SAL_CALL SwXTextEmbeddedObject::getReplacementGraphic() throw (uno::RuntimeException)
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 Graphic* pGraphic = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic();
3755 if ( pGraphic )
3756 return pGraphic->GetXGraphic();
3757 }
3758
3759 return uno::Reference< graphic::XGraphic >();
3760 }
3761
3762
getImplementationName(void)3763 OUString SwXTextEmbeddedObject::getImplementationName(void) throw( uno::RuntimeException )
3764
3765 {
3766 return C2U("SwXTextEmbeddedObject");
3767 }
3768
supportsService(const OUString & rServiceName)3769 sal_Bool SwXTextEmbeddedObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
3770 {
3771 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextEmbeddedObject")||
3772 SwXFrame::supportsService(rServiceName);
3773 }
3774
getSupportedServiceNames(void)3775 uno::Sequence< OUString > SwXTextEmbeddedObject::getSupportedServiceNames(void)
3776 throw( uno::RuntimeException )
3777 {
3778 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3779 aRet.realloc(aRet.getLength() + 1);
3780 OUString* pArray = aRet.getArray();
3781 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextEmbeddedObject");
3782 return aRet;
3783 }
3784
operator new(size_t t)3785 void * SAL_CALL SwXTextEmbeddedObject::operator new( size_t t) throw()
3786 {
3787 return SwXTextEmbeddedObjectBaseClass::operator new(t);
3788 }
3789
operator delete(void * p)3790 void SAL_CALL SwXTextEmbeddedObject::operator delete( void * p) throw()
3791 {
3792 SwXTextEmbeddedObjectBaseClass::operator delete(p);
3793 }
3794
3795 uno::Reference<container::XNameReplace> SAL_CALL
getEvents()3796 SwXTextEmbeddedObject::getEvents()
3797 throw(uno::RuntimeException)
3798 {
3799 return new SwFrameEventDescriptor( *this );
3800 }
3801
3802
3803 /******************************************************************
3804 *
3805 ******************************************************************/
3806 TYPEINIT1(SwXOLEListener, SwClient);
3807
SwXOLEListener(SwFmt & rOLEFmt,uno::Reference<XModel> xOLE)3808 SwXOLEListener::SwXOLEListener( SwFmt& rOLEFmt, uno::Reference< XModel > xOLE) :
3809 SwClient(&rOLEFmt),
3810 xOLEModel(xOLE)
3811 {
3812 }
3813
~SwXOLEListener()3814 SwXOLEListener::~SwXOLEListener()
3815 {}
3816
modified(const lang::EventObject &)3817 void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
3818 throw( uno::RuntimeException )
3819 {
3820 vos::OGuard aGuard(Application::GetSolarMutex());
3821
3822 SwOLENode* pNd = 0;
3823 SwFmt* pFmt = GetFmt();
3824 if(pFmt)
3825 {const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
3826 if(pIdx)
3827 {
3828 SwNodeIndex aIdx(*pIdx, 1);
3829 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
3830 pNd = pNoTxt->GetOLENode();
3831 }
3832 }
3833 if(!pNd)
3834 throw uno::RuntimeException();
3835
3836 uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef();
3837 if ( xIP.is() )
3838 {
3839 sal_Int32 nState = xIP->getCurrentState();
3840 if ( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE )
3841 return;
3842 }
3843
3844 // if the OLE-Node is UI-Active do nothing
3845 pNd->SetOLESizeInvalid( sal_True );
3846 pNd->GetDoc()->SetOLEObjModified();
3847 }
3848
3849 /* ---------------------------------------------------------------------------
3850
3851 ---------------------------------------------------------------------------*/
disposing(const lang::EventObject & rEvent)3852 void SwXOLEListener::disposing( const lang::EventObject& rEvent )
3853 throw( uno::RuntimeException )
3854 {
3855 vos::OGuard aGuard(Application::GetSolarMutex());
3856
3857 uno::Reference< util::XModifyListener > xListener( this );
3858
3859
3860 uno::Reference< frame::XModel > xModel( rEvent.Source, uno::UNO_QUERY );
3861 uno::Reference< util::XModifyBroadcaster > xBrdcst(xModel, uno::UNO_QUERY);
3862
3863 try
3864 {
3865 if( xBrdcst.is() )
3866 xBrdcst->removeModifyListener( xListener );
3867 }
3868 catch(uno::Exception const &)
3869 {
3870 DBG_ERROR("OLE Listener couldn't be removed");
3871 }
3872 }
3873 /* ---------------------------------------------------------------------------
3874
3875 ---------------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)3876 void SwXOLEListener::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
3877 {
3878 ClientModify(this, pOld, pNew);
3879 if(!GetRegisteredIn())
3880 xOLEModel = 0;
3881 }
3882
3883