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