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