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