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