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