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