xref: /AOO41X/main/sw/source/core/unocore/unoframe.cxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
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_REPLACEMENT_GRAPHIC_U_R_L == pEntry->nWID)
1503         {
1504             String sGrfName;
1505             const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1506 
1507             if(pIdx)
1508             {
1509                 SwNodeIndex aIdx(*pIdx, 1);
1510                 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
1511                 if(!pGrfNode)
1512                     throw uno::RuntimeException();
1513 
1514                 const GraphicObject* pGraphicObject = pGrfNode->GetReplacementGrfObj();
1515 
1516                 if(pGraphicObject)
1517                 {
1518                     String sPrefix( RTL_CONSTASCII_STRINGPARAM(sGraphicObjectProtocol) );
1519                     String sId( pGraphicObject->GetUniqueID(), RTL_TEXTENCODING_ASCII_US );
1520                     (sGrfName = sPrefix) += sId;
1521                 }
1522             }
1523 
1524             aAny <<= OUString(sGrfName);
1525         }
1526         else if( FN_UNO_GRAPHIC_FILTER == pEntry->nWID )
1527         {
1528             String sFltName;
1529             pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, 0, &sFltName );
1530                 aAny <<= OUString(sFltName);
1531         }
1532         else if( FN_UNO_GRAPHIC == pEntry->nWID )
1533         {
1534             const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1535             if(pIdx)
1536             {
1537                 SwNodeIndex aIdx(*pIdx, 1);
1538                 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
1539                 if(!pGrfNode)
1540                     throw uno::RuntimeException();
1541                 aAny <<= pGrfNode->GetGrf().GetXGraphic();
1542             }
1543         }
1544         else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID)
1545         {
1546             aAny <<= OUString(SwStyleNameMapper::GetProgName(pFmt->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ) );
1547         }
1548         // --> OD 2009-07-13 #i73249#
1549         // Attribute AlternativeText was never published.
1550         // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances
1551 //        else if(eType != FLYCNTTYPE_FRM &&
1552 //                FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
1553 //        {
1554 //            const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1555 //            if(pIdx)
1556 //            {
1557 //                SwNodeIndex aIdx(*pIdx, 1);
1558 //                SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1559 //                aAny <<= OUString(pNoTxt->GetAlternateText());
1560 //            }
1561 //        }
1562         else if( FN_UNO_TITLE == pEntry->nWID )
1563         {
1564             SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1565             ASSERT( pFmt,
1566                     "unexpected type of <pFmt> --> crash" );
1567             // assure that <SdrObject> instance exists.
1568             GetOrCreateSdrObject( pFlyFmt );
1569             aAny <<= OUString(pFlyFmt->GetObjTitle());
1570         }
1571         // New attribute Description
1572         else if( FN_UNO_DESCRIPTION == pEntry->nWID )
1573         {
1574             SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1575             ASSERT( pFmt,
1576                     "unexpected type of <pFmt> --> crash" );
1577             // assure that <SdrObject> instance exists.
1578             GetOrCreateSdrObject( pFlyFmt );
1579             aAny <<= OUString(pFlyFmt->GetObjDescription());
1580         }
1581         // <--
1582         else if(eType == FLYCNTTYPE_GRF &&
1583                 (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ACTUAL_SIZE))))
1584         {
1585             const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1586             if(pIdx)
1587             {
1588                 SwNodeIndex aIdx(*pIdx, 1);
1589                 // --> OD #i85105#
1590 //                SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1591 //                Size aActSize = ((SwGrfNode*)pNoTxt)->GetTwipSize();
1592                 Size aActSize;
1593                 {
1594                     SwGrfNode* pGrfNode = dynamic_cast<SwGrfNode*>(aIdx.GetNode().GetNoTxtNode());
1595                     if ( pGrfNode )
1596                     {
1597                         aActSize = pGrfNode->GetTwipSize();
1598                         if ( aActSize.Width() == 0 && aActSize.Height() == 0 &&
1599                              pGrfNode->IsLinkedFile() )
1600                         {
1601                             pGrfNode->SwapIn( sal_True );
1602                             aActSize = pGrfNode->GetTwipSize();
1603                         }
1604                     }
1605                 }
1606                 // <--
1607                 awt::Size aTmp;
1608                 aTmp.Width = TWIP_TO_MM100(aActSize.Width());
1609                 aTmp.Height = TWIP_TO_MM100(aActSize.Height());
1610                 aAny.setValue(&aTmp, ::getCppuType(static_cast<const awt::Size*>(0)));
1611             }
1612         }
1613         else if(FN_PARAM_LINK_DISPLAY_NAME == pEntry->nWID)
1614         {
1615             aAny <<= OUString(pFmt->GetName());
1616         }
1617         else if(FN_UNO_Z_ORDER == pEntry->nWID)
1618         {
1619             const SdrObject* pObj = pFmt->FindRealSdrObject();
1620             if( pObj )
1621             {
1622                 aAny <<= (sal_Int32)pObj->GetOrdNum();
1623             }
1624         }
1625         else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_MODEL == pEntry->nWID||
1626                 FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID||
1627                 FN_EMBEDDED_OBJECT == pEntry->nWID)
1628         {
1629             SwDoc* pDoc = pFmt->GetDoc();
1630             const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
1631             DBG_ASSERT( pCnt->GetCntntIdx() &&
1632                            pDoc->GetNodes()[ pCnt->GetCntntIdx()->
1633                                             GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
1634 
1635             SwOLENode* pOleNode =  pDoc->GetNodes()[ pCnt->GetCntntIdx()
1636                                             ->GetIndex() + 1 ]->GetOLENode();
1637             uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
1638             OUString aHexCLSID;
1639             {
1640                 SvGlobalName aClassName( xIP->getClassID() );
1641                 aHexCLSID = aClassName.GetHexName();
1642                 if(FN_UNO_CLSID != pEntry->nWID)
1643                 {
1644                     if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
1645                     {
1646                         uno::Reference < lang::XComponent > xComp( xIP->getComponent(), uno::UNO_QUERY );
1647                         uno::Reference < frame::XModel > xModel( xComp, uno::UNO_QUERY );
1648                         if ( FN_EMBEDDED_OBJECT == pEntry->nWID )
1649                         {
1650                             // ensure the
1651                             ASSERT( pDoc->GetDocShell(), "no doc shell => no client site" );
1652                             if ( pDoc->GetDocShell() )
1653                                 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
1654                             aAny <<= xIP;
1655                         }
1656                         else if ( xModel.is() )
1657                             aAny <<= xModel;
1658                         else if ( FN_UNO_COMPONENT == pEntry->nWID )
1659                             aAny <<= xComp;
1660                     }
1661                 }
1662             }
1663 
1664             if(FN_UNO_CLSID == pEntry->nWID)
1665                 aAny <<= aHexCLSID;
1666             else if(FN_UNO_STREAM_NAME == pEntry->nWID)
1667             {
1668                 aAny <<= ::rtl::OUString(pOleNode->GetOLEObj().GetCurrentPersistName());
1669             }
1670         }
1671         else if(WID_LAYOUT_SIZE == pEntry->nWID)
1672         {
1673             // format document completely in order to get correct value
1674             pFmt->GetDoc()->GetEditShell()->CalcLayout();
1675 
1676             SwFrm* pTmpFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt );
1677             if ( pTmpFrm )
1678             {
1679                 DBG_ASSERT( pTmpFrm->IsValid(), "frame not valid" );
1680                 const SwRect &rRect = pTmpFrm->Frm();
1681                 Size aMM100Size = OutputDevice::LogicToLogic(
1682                         Size( rRect.Width(), rRect.Height() ),
1683                         MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ));
1684                 aAny <<= awt::Size( aMM100Size.Width(), aMM100Size.Height() );
1685             }
1686         }
1687         else
1688         {
1689             const SwAttrSet& rSet = pFmt->GetAttrSet();
1690             m_pPropSet->getPropertyValue(*pEntry, rSet, aAny);
1691         }
1692     }
1693     else if(IsDescriptor())
1694     {
1695         if ( ! m_pDoc )
1696             throw uno::RuntimeException();
1697         if(WID_LAYOUT_SIZE != pEntry->nWID)  // there is no LayoutSize in a descriptor
1698         {
1699             const uno::Any* pAny = 0;
1700             if( !pProps->GetProperty( pEntry->nWID, pEntry->nMemberId, pAny ) )
1701                 aAny = mxStyleData->getPropertyValue( rPropertyName );
1702             else if ( pAny )
1703                 aAny = *pAny;
1704         }
1705     }
1706     else
1707         throw uno::RuntimeException();
1708     return aAny;
1709 }
1710 
1711 void SwXFrame::addPropertyChangeListener(const OUString& /*PropertyName*/,
1712     const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
1713     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1714 {
1715     DBG_WARNING("not implemented");
1716 }
1717 
1718 void SwXFrame::removePropertyChangeListener(const OUString& /*PropertyName*/,
1719     const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
1720     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1721 {
1722     DBG_WARNING("not implemented");
1723 }
1724 
1725 void SwXFrame::addVetoableChangeListener(const OUString& /*PropertyName*/,
1726                                 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
1727     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1728 {
1729     DBG_WARNING("not implemented");
1730 }
1731 
1732 void SwXFrame::removeVetoableChangeListener(
1733     const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
1734         throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1735 {
1736     DBG_WARNING("not implemented");
1737 }
1738 
1739 beans::PropertyState SwXFrame::getPropertyState( const OUString& rPropertyName )
1740     throw(beans::UnknownPropertyException, uno::RuntimeException)
1741 {
1742     vos::OGuard aGuard(Application::GetSolarMutex());
1743     uno::Sequence< OUString > aPropertyNames(1);
1744     OUString* pNames = aPropertyNames.getArray();
1745     pNames[0] = rPropertyName;
1746     uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aPropertyNames);
1747     return aStates.getConstArray()[0];
1748 }
1749 
1750 uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates(
1751     const uno::Sequence< OUString >& aPropertyNames )
1752         throw(beans::UnknownPropertyException, uno::RuntimeException)
1753 {
1754     vos::OGuard aGuard(Application::GetSolarMutex());
1755     uno::Sequence< beans::PropertyState > aStates(aPropertyNames.getLength());
1756     beans::PropertyState* pStates = aStates.getArray();
1757     SwFrmFmt* pFmt = GetFrmFmt();
1758     if(pFmt)
1759     {
1760         const OUString* pNames = aPropertyNames.getConstArray();
1761         const SwAttrSet& rFmtSet = pFmt->GetAttrSet();
1762         for(int i = 0; i < aPropertyNames.getLength(); i++)
1763         {
1764             const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(pNames[i]);
1765             if (!pEntry)
1766                 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
1767 
1768             if(pEntry->nWID == FN_UNO_ANCHOR_TYPES||
1769                 pEntry->nWID == FN_PARAM_LINK_DISPLAY_NAME||
1770                 FN_UNO_FRAME_STYLE_NAME == pEntry->nWID||
1771                 FN_UNO_GRAPHIC_U_R_L == pEntry->nWID||
1772                 FN_UNO_GRAPHIC_FILTER     == pEntry->nWID||
1773                 FN_UNO_ACTUAL_SIZE == pEntry->nWID||
1774                 FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID)
1775             {
1776                 pStates[i] = beans::PropertyState_DIRECT_VALUE;
1777             }
1778             else
1779             {
1780                 if ((eType == FLYCNTTYPE_GRF) &&
1781                         pEntry && isGRFATR(pEntry->nWID))
1782                 {
1783                     const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1784                     if(pIdx)
1785                     {
1786                         SwNodeIndex aIdx(*pIdx, 1);
1787                         SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1788                         SfxItemSet aSet(pNoTxt->GetSwAttrSet());
1789                         aSet.GetItemState(pEntry->nWID);
1790                         if(SFX_ITEM_SET == aSet.GetItemState( pEntry->nWID, sal_False ))
1791                             pStates[i] = beans::PropertyState_DIRECT_VALUE;
1792                     }
1793                 }
1794                 else
1795                 {
1796                     if(SFX_ITEM_SET == rFmtSet.GetItemState( pEntry->nWID, sal_False ))
1797                         pStates[i] = beans::PropertyState_DIRECT_VALUE;
1798                     else
1799                         pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1800                 }
1801             }
1802         }
1803     }
1804     else if(IsDescriptor())
1805     {
1806         for(int i = 0; i < aPropertyNames.getLength(); i++)
1807             pStates[i] = beans::PropertyState_DIRECT_VALUE;
1808     }
1809     else
1810         throw uno::RuntimeException();
1811     return aStates;
1812 }
1813 
1814 void SwXFrame::setPropertyToDefault( const OUString& rPropertyName )
1815     throw(beans::UnknownPropertyException, uno::RuntimeException)
1816 {
1817     vos::OGuard aGuard(Application::GetSolarMutex());
1818     SwFrmFmt* pFmt = GetFrmFmt();
1819     if(pFmt)
1820     {
1821         const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1822         if (!pEntry)
1823             throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1824         if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1825             throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1826 
1827         sal_Bool bNextFrame;
1828         if( pEntry->nWID &&
1829             pEntry->nWID != FN_UNO_ANCHOR_TYPES &&
1830             pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME)
1831         {
1832             if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) )
1833             {
1834                 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1835                 if(pIdx)
1836                 {
1837                     SwNodeIndex aIdx(*pIdx, 1);
1838                     SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1839                     {
1840                         SfxItemSet aSet(pNoTxt->GetSwAttrSet());
1841                         aSet.ClearItem(pEntry->nWID);
1842                         pNoTxt->SetAttr(aSet);
1843                     }
1844                 }
1845             }
1846             // --> OD 2009-07-13 #i73249#
1847             // Attribute AlternativeText was never published.
1848             // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances
1849 //            else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID )
1850 //            {
1851 //                const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1852 //                if(pIdx)
1853 //                {
1854 //                    SwNodeIndex aIdx(*pIdx, 1);
1855 //                    SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
1856 //                    pNoTxt->SetAlternateText(aEmptyStr);
1857 //                }
1858 //            }
1859             // New attribute Title
1860             else if( FN_UNO_TITLE == pEntry->nWID )
1861             {
1862                 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1863                 ASSERT( pFmt,
1864                         "unexpected type of <pFmt> --> crash" );
1865                 // assure that <SdrObject> instance exists.
1866                 GetOrCreateSdrObject( pFlyFmt );
1867                 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), aEmptyStr );
1868             }
1869             // New attribute Description
1870             else if( FN_UNO_DESCRIPTION == pEntry->nWID )
1871             {
1872                 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt);
1873                 ASSERT( pFmt,
1874                         "unexpected type of <pFmt> --> crash" );
1875                 // assure that <SdrObject> instance exists.
1876                 GetOrCreateSdrObject( pFlyFmt );
1877                 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), aEmptyStr );
1878             }
1879             // <--
1880             else
1881             {
1882                 SwDoc* pDoc = pFmt->GetDoc();
1883                 SfxItemSet aSet( pDoc->GetAttrPool(),
1884                     RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
1885                 aSet.SetParent(&pFmt->GetAttrSet());
1886                 aSet.ClearItem(pEntry->nWID);
1887                 if(!rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)))
1888                     pFmt->SetFmtAttr(aSet);
1889             }
1890         }
1891         else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME))))
1892                 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME)))
1893         {
1894             SwDoc* pDoc = pFmt->GetDoc();
1895             if(bNextFrame)
1896                 pDoc->Unchain(*pFmt);
1897             else
1898             {
1899                 SwFmtChain aChain( pFmt->GetChain() );
1900                 SwFrmFmt *pPrev = aChain.GetPrev();
1901                 if(pPrev)
1902                     pDoc->Unchain(*pPrev);
1903             }
1904         }
1905     }
1906     else if(!IsDescriptor())
1907         throw uno::RuntimeException();
1908 
1909 }
1910 
1911 uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName )
1912     throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1913 {
1914     vos::OGuard aGuard(Application::GetSolarMutex());
1915     uno::Any aRet;
1916     SwFrmFmt* pFmt = GetFrmFmt();
1917     if(pFmt)
1918     {
1919         const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
1920         if(pEntry)
1921         {
1922             if ( pEntry->nWID < RES_FRMATR_END )
1923             {
1924                 const SfxPoolItem& rDefItem =
1925                     pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
1926                 rDefItem.QueryValue(aRet, pEntry->nMemberId);
1927             }
1928         }
1929         else
1930             throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1931     }
1932     else if(!IsDescriptor())
1933         throw uno::RuntimeException();
1934     return aRet;
1935 }
1936 
1937 void SwXFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
1938 {
1939     if(!GetRegisteredIn())
1940         throw uno::RuntimeException();
1941     aLstnrCntnr.AddListener(aListener);
1942 }
1943 
1944 void SwXFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
1945 {
1946     if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener))
1947         throw uno::RuntimeException();
1948 }
1949 
1950 void    SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
1951 {
1952     ClientModify(this, pOld, pNew);
1953     if(!GetRegisteredIn())
1954     {
1955         mxStyleData.clear();
1956         mxStyleFamily.clear();
1957         m_pDoc = 0;
1958         aLstnrCntnr.Disposing();
1959     }
1960 }
1961 
1962 
1963 void SwXFrame::dispose(void) throw( uno::RuntimeException )
1964 {
1965     vos::OGuard aGuard(Application::GetSolarMutex());
1966     SwFrmFmt* pFmt = GetFrmFmt();
1967     if ( pFmt )
1968     {
1969         SdrObject* pObj = pFmt->FindSdrObject();
1970         // OD 11.09.2003 #112039# - add condition to perform delete of
1971         // format/anchor sign, not only if the object is inserted, but also
1972         // if a contact object is registered, which isn't in the destruction.
1973         if ( pObj &&
1974              ( pObj->IsInserted() ||
1975                ( pObj->GetUserCall() &&
1976                  !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) )
1977         {
1978             if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
1979             {
1980                 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
1981                 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
1982                 const xub_StrLen nIdx = rPos.nContent.GetIndex();
1983                 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
1984             }
1985             else
1986                 pFmt->GetDoc()->DelLayoutFmt(pFmt);
1987         }
1988     }
1989 
1990 }
1991 
1992 uno::Reference< text::XTextRange >  SwXFrame::getAnchor(void) throw( uno::RuntimeException )
1993 {
1994     vos::OGuard aGuard(Application::GetSolarMutex());
1995     uno::Reference< text::XTextRange >  aRef;
1996     SwFrmFmt* pFmt = GetFrmFmt();
1997     if(pFmt)
1998     {
1999         const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
2000         // return an anchor for non-page bound frames
2001         // and for page bound frames that have a page no == NULL and a content position
2002         if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
2003             (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
2004         {
2005             const SwPosition &rPos = *(rAnchor.GetCntntAnchor());
2006             aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
2007         }
2008     }
2009     else
2010         throw uno::RuntimeException();
2011     return aRef;
2012 }
2013 
2014 void SwXFrame::ResetDescriptor()
2015 {
2016     bIsDescriptor = sal_False;
2017     mxStyleData.clear();
2018     mxStyleFamily.clear();
2019     DELETEZ(pProps);
2020 }
2021 
2022 void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
2023             throw( lang::IllegalArgumentException, uno::RuntimeException )
2024 {
2025     vos::OGuard aGuard(Application::GetSolarMutex());
2026     if(!IsDescriptor())
2027         throw uno::RuntimeException();
2028     uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2029     SwXTextRange* pRange = 0;
2030     OTextCursorHelper* pCursor = 0;
2031     if(xRangeTunnel.is())
2032     {
2033         pRange  = reinterpret_cast< SwXTextRange * >(
2034                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2035         pCursor = reinterpret_cast< OTextCursorHelper * >(
2036                 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2037     }
2038 
2039     SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
2040     if(pDoc)
2041     {
2042         SwUnoInternalPaM aIntPam(*pDoc);
2043         //das muss jetzt sal_True liefern
2044         ::sw::XTextRangeToSwPaM(aIntPam, xTextRange);
2045 
2046         SwNode& rNode = pDoc->GetNodes().GetEndOfContent();
2047         SwPaM aPam(rNode);
2048         aPam.Move( fnMoveBackward, fnGoDoc );
2049         static sal_uInt16 __READONLY_DATA aFrmAttrRange[] =
2050         {
2051             RES_FRMATR_BEGIN,       RES_FRMATR_END-1,
2052             SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,
2053             RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
2054             0
2055         };
2056         static sal_uInt16 __READONLY_DATA aGrAttrRange[] =
2057         {
2058             RES_GRFATR_BEGIN,       RES_GRFATR_END-1,
2059             0
2060         };
2061         SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange );
2062 
2063         SfxItemSet aFrmSet(pDoc->GetAttrPool(), aFrmAttrRange );
2064         //jetzt muessen die passenden Items in den Set
2065         sal_Bool bSizeFound;
2066         if(!pProps->AnyToItemSet( pDoc, aFrmSet, aGrSet, bSizeFound))
2067             throw lang::IllegalArgumentException();
2068         //der TextRange wird einzeln behandelt
2069         *aPam.GetPoint() = *aIntPam.GetPoint();
2070         if(aIntPam.HasMark())
2071         {
2072             aPam.SetMark();
2073             *aPam.GetMark() = *aIntPam.GetMark();
2074         }
2075 
2076         const SfxPoolItem* pItem;
2077         RndStdIds eAnchorId = FLY_AT_PARA;
2078         if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) )
2079         {
2080             eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId();
2081             if( FLY_AT_FLY == eAnchorId &&
2082                 !aPam.GetNode()->FindFlyStartNode())
2083             {
2084                 //rahmengebunden geht nur dort, wo ein Rahmen ist!
2085                 SwFmtAnchor aAnchor(FLY_AT_PARA);
2086                 aFrmSet.Put(aAnchor);
2087             }
2088             else if ((FLY_AT_PAGE == eAnchorId) &&
2089                      0 == ((const SwFmtAnchor*)pItem)->GetPageNum() )
2090             {
2091                 SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) );
2092                 aAnchor.SetAnchor( aPam.GetPoint() );
2093                 aFrmSet.Put(aAnchor);
2094             }
2095         }
2096 
2097         const ::uno::Any* pStyle;
2098         SwFrmFmt *pParentFrmFmt = 0;
2099         if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle))
2100             pParentFrmFmt = lcl_GetFrmFmt( *pStyle, pDoc );
2101 
2102         SwFlyFrmFmt* pFmt = 0;
2103         if( eType == FLYCNTTYPE_FRM)
2104         {
2105             UnoActionContext aCont(pDoc);
2106             if(m_pCopySource)
2107             {
2108                 SwFmtAnchor* pAnchorItem = 0;
2109                 // the frame is inserted bound to page
2110                 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text
2111                 if (eAnchorId != FLY_AT_PAGE)
2112                 {
2113                     pAnchorItem = static_cast<SwFmtAnchor*>(aFrmSet.Get(RES_ANCHOR).Clone());
2114                     aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 ));
2115                 }
2116 
2117                 aPam.DeleteMark(); // mark position node will be deleted!
2118                 aIntPam.DeleteMark(); // mark position node will be deleted!
2119                 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet,
2120                                0,
2121                                pParentFrmFmt );
2122                 if(pAnchorItem && pFmt)
2123                 {
2124                     pFmt->DelFrms();
2125                     pAnchorItem->SetAnchor( m_pCopySource->Start() );
2126                     SfxItemSet aAnchorSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR );
2127                     aAnchorSet.Put( *pAnchorItem );
2128                     pDoc->SetFlyFrmAttr( *pFmt, aAnchorSet );
2129                     delete pAnchorItem;
2130                 }
2131                 DELETEZ( m_pCopySource );
2132             }
2133             else
2134             {
2135                 pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(),
2136                                          &aFrmSet, pParentFrmFmt );
2137             }
2138             if(pFmt)
2139             {
2140                 pFmt->Add(this);
2141                 if(sName.Len())
2142                     pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName);
2143             }
2144             //den SwXText wecken
2145             ((SwXTextFrame*)this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrmFmt()->GetDoc() );
2146         }
2147         else if( eType == FLYCNTTYPE_GRF)
2148         {
2149             UnoActionContext aCont(pDoc);
2150             const ::uno::Any* pGraphicURL;
2151             String sGraphicURL;
2152             GraphicObject *pGrfObj = 0;
2153             if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL))
2154             {
2155                 OUString uTemp;
2156                 (*pGraphicURL) >>= uTemp;
2157                 sGraphicURL = String(uTemp);
2158                 if( sGraphicURL.EqualsAscii( sPackageProtocol,
2159                                              0, sizeof( sPackageProtocol )-1 ) )
2160                 {
2161                     pGrfObj = new GraphicObject;
2162                     pGrfObj->SetUserData( sGraphicURL );
2163                     pGrfObj->SetSwapState();
2164                     sGraphicURL.Erase();
2165                 }
2166                 else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol,
2167                                        0, sizeof(sGraphicObjectProtocol)-1 ) )
2168                 {
2169                     ByteString sId( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ),
2170                                     RTL_TEXTENCODING_ASCII_US );
2171                     pGrfObj = new GraphicObject( sId );
2172                     sGraphicURL.Erase();
2173                 }
2174             }
2175             Graphic aGraphic;
2176             const ::uno::Any* pGraphic;
2177             if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic ))
2178             {
2179                 uno::Reference< graphic::XGraphic > xGraphic;
2180                 (*pGraphic) >>= xGraphic;
2181                 aGraphic = Graphic( xGraphic );
2182             }
2183 
2184             String sFltName;
2185             const ::uno::Any* pFilter;
2186             if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter))
2187             {
2188                 OUString uTemp;
2189                 (*pFilter) >>= uTemp;
2190                 sFltName = String(uTemp);
2191             }
2192 
2193             pFmt =
2194                 pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet,
2195                                         pParentFrmFmt )
2196                         : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic,
2197                                         &aFrmSet, &aGrSet, pParentFrmFmt  );
2198             delete pGrfObj;
2199             if(pFmt)
2200             {
2201                 SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFmt->GetCntnt().GetCntntIdx()
2202                                             ->GetIndex()+1 ]->GetGrfNode();
2203                 pGrfNd->SetChgTwipSize( !bSizeFound );
2204                 pFmt->Add(this);
2205                 if(sName.Len())
2206                     pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName);
2207 
2208             }
2209             const ::uno::Any* pSurroundContour;
2210             if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour))
2211                 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SURROUND_CONTOUR)), *pSurroundContour);
2212             const ::uno::Any* pContourOutside;
2213             if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside))
2214                 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_OUTSIDE)), *pContourOutside);
2215             const ::uno::Any* pContourPoly;
2216             if(pProps->GetProperty(FN_PARAM_COUNTOUR_PP, 0, pContourPoly))
2217                 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_POLY_POLYGON)), *pContourPoly);
2218             const ::uno::Any* pPixelContour;
2219             if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour))
2220                 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_PIXEL_CONTOUR)), *pPixelContour);
2221             const ::uno::Any* pAutoContour;
2222             if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour))
2223                 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_AUTOMATIC_CONTOUR)), *pAutoContour);
2224 //            const ::uno::Any* pAltText;
2225 //            if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText))
2226 //                setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText);
2227         }
2228         else
2229         {
2230             const ::uno::Any* pCLSID = 0;
2231             const ::uno::Any* pStreamName = 0;
2232             if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName ))
2233                 throw uno::RuntimeException();
2234             if(pCLSID)
2235             {
2236                 OUString aCLSID;
2237                 SvGlobalName aClassName;
2238                 uno::Reference < embed::XEmbeddedObject > xIPObj;
2239                 std::auto_ptr < comphelper::EmbeddedObjectContainer > pCnt;
2240                 if( (*pCLSID) >>= aCLSID )
2241                 {
2242                     if( !aClassName.MakeId( aCLSID ) )
2243                     {
2244                         lang::IllegalArgumentException aExcept;
2245                         aExcept.Message = OUString::createFromAscii("CLSID invalid");
2246                         throw aExcept;
2247                     }
2248 
2249                     pCnt.reset( new comphelper::EmbeddedObjectContainer );
2250                     ::rtl::OUString aName;
2251                     xIPObj = pCnt->CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
2252                 }
2253                 if ( xIPObj.is() )
2254                 {
2255                     //TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE
2256                     //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xIPObj->GetMiscStatus() && pDoc->getPrinter( false ) )
2257                     //    xIPObj->OnDocumentPrinterChanged( pDoc->getPrinter( false ) );
2258 
2259                     UnoActionContext aAction(pDoc);
2260                     pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
2261                     if(!bSizeFound)
2262                     {
2263                         //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode?
2264                         sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
2265 
2266                         // TODO/LEAN: VisualArea still needs running state
2267                         svt::EmbeddedObjectRef::TryRunningState( xIPObj );
2268 
2269                         // set parent to get correct VisArea(in case of object needing parent printer)
2270                         uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY );
2271                         if ( xChild.is() )
2272                             xChild->setParent( pDoc->GetDocShell()->GetModel() );
2273 
2274                         //The Size should be suggested by the OLE server if not manually set
2275                         MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) );
2276                         awt::Size aSize;
2277                         try
2278                         {
2279                             aSize = xIPObj->getVisualAreaSize( nAspect );
2280                         }
2281                         catch ( embed::NoVisualAreaSizeException& )
2282                         {
2283                             // the default size will be set later
2284                         }
2285 
2286                         Size aSz( aSize.Width, aSize.Height );
2287                         if ( !aSz.Width() || !aSz.Height() )
2288                         {
2289                             aSz.Width() = aSz.Height() = 5000;
2290                             aSz = OutputDevice::LogicToLogic
2291                                                     ( aSz, MapMode( MAP_100TH_MM ), aRefMap );
2292                         }
2293                         MapMode aMyMap( MAP_TWIP );
2294                         aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap );
2295                         SwFmtFrmSize aFrmSz;
2296                         aFrmSz.SetSize(aSz);
2297                         aFrmSet.Put(aFrmSz);
2298                     }
2299                     SwFlyFrmFmt* pFmt2 = 0;
2300 
2301                     // TODO/LATER: Is it the only possible aspect here?
2302                     sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
2303                     ::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect );
2304                     pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL );
2305                     ASSERT( pFmt2, "Doc->Insert(notxt) failed." );
2306 
2307                     pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
2308                     pFmt2->Add(this);
2309                     if(sName.Len())
2310                         pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName);
2311                 }
2312             }
2313             else if( pStreamName )
2314             {
2315                 ::rtl::OUString sStreamName;
2316                 (*pStreamName) >>= sStreamName;
2317                 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
2318 
2319                 SwFlyFrmFmt* pFrmFmt = 0;
2320                 pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL );
2321                 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
2322                 pFrmFmt->Add(this);
2323                 if(sName.Len())
2324                     pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName);
2325             }
2326         }
2327         if( pFmt && pDoc->GetDrawModel() )
2328             GetOrCreateSdrObject( pFmt );
2329         const ::uno::Any* pOrder;
2330         if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) )
2331             setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_Z_ORDER)), *pOrder);
2332         const ::uno::Any* pReplacement;
2333         if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) )
2334             setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_GRAPHIC)), *pReplacement);
2335         // --> OD 2009-07-13 #i73249#
2336         // new attribute Title
2337         const ::uno::Any* pTitle;
2338         if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) )
2339         {
2340             setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_TITLE)), *pTitle);
2341         }
2342         // new attribute Description
2343         const ::uno::Any* pDescription;
2344         if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) )
2345         {
2346             setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DESCRIPTION)), *pDescription);
2347         }
2348         // <--
2349     }
2350     else
2351         throw lang::IllegalArgumentException();
2352     //setzt das Flag zurueck und loescht den Descriptor-Pointer
2353     ResetDescriptor();
2354 }
2355 
2356 void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
2357     throw( lang::IllegalArgumentException, uno::RuntimeException )
2358 {
2359     SwFrmFmt* pFmt;
2360     if(IsDescriptor())
2361         attachToRange(xTextRange);
2362     else if(0 != (pFmt = GetFrmFmt()))
2363     {
2364         uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2365         SwXTextRange* pRange = 0;
2366         OTextCursorHelper* pCursor = 0;
2367         if(xRangeTunnel.is())
2368         {
2369             pRange  = reinterpret_cast< SwXTextRange * >(
2370                     sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2371             pCursor = reinterpret_cast< OTextCursorHelper * >(
2372                     sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2373         }
2374         SwDoc* pDoc = pFmt->GetDoc();
2375         SwUnoInternalPaM aIntPam(*pDoc);
2376         if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange))
2377         {
2378             SfxItemSet aSet( pDoc->GetAttrPool(),
2379                         RES_ANCHOR, RES_ANCHOR );
2380             aSet.SetParent(&pFmt->GetAttrSet());
2381             SwFmtAnchor aAnchor = (const SwFmtAnchor&)aSet.Get(RES_ANCHOR);
2382             aAnchor.SetAnchor( aIntPam.Start() );
2383             aSet.Put(aAnchor);
2384             pDoc->SetFlyFrmAttr( *pFmt, aSet );
2385         }
2386         else
2387             throw lang::IllegalArgumentException();
2388     }
2389 }
2390 
2391 awt::Point SwXFrame::getPosition(void) throw( uno::RuntimeException )
2392 {
2393     vos::OGuard aGuard(Application::GetSolarMutex());
2394     uno::RuntimeException aRuntime;
2395     aRuntime.Message = C2U("position cannot be determined with this method");
2396     throw aRuntime;
2397 }
2398 
2399 void SwXFrame::setPosition(const awt::Point& /*aPosition*/) throw( uno::RuntimeException )
2400 {
2401     vos::OGuard aGuard(Application::GetSolarMutex());
2402     uno::RuntimeException aRuntime;
2403     aRuntime.Message = C2U("position cannot be changed with this method");
2404     throw aRuntime;
2405 }
2406 
2407 awt::Size SwXFrame::getSize(void) throw( uno::RuntimeException )
2408 {
2409     const ::uno::Any aVal = getPropertyValue(C2U("Size"));
2410     awt::Size* pRet =  (awt::Size*)aVal.getValue();
2411     return *pRet;
2412 }
2413 
2414 void SwXFrame::setSize(const awt::Size& aSize)
2415     throw( beans::PropertyVetoException, uno::RuntimeException )
2416 {
2417     const ::uno::Any aVal(&aSize, ::getCppuType(static_cast<const awt::Size*>(0)));
2418     setPropertyValue(C2U("Size"), aVal);
2419 }
2420 
2421 OUString SwXFrame::getShapeType(void) throw( uno::RuntimeException )
2422 {
2423     return C2U("FrameShape");
2424 }
2425 
2426 
2427 /******************************************************************
2428  *  SwXTextFrame
2429  ******************************************************************/
2430 
2431 SwXTextFrame::SwXTextFrame( SwDoc *_pDoc ) :
2432     SwXText(0, CURSOR_FRAME),
2433     SwXFrame(FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME), _pDoc )
2434 {
2435 }
2436 
2437 SwXTextFrame::SwXTextFrame(SwFrmFmt& rFmt) :
2438     SwXText(rFmt.GetDoc(), CURSOR_FRAME),
2439     SwXFrame(rFmt, FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME))
2440 {
2441 
2442 }
2443 
2444 SwXTextFrame::~SwXTextFrame()
2445 {
2446 }
2447 
2448 void SAL_CALL SwXTextFrame::acquire(  )throw()
2449 {
2450     SwXFrame::acquire();
2451 }
2452 
2453 void SAL_CALL SwXTextFrame::release(  )throw()
2454 {
2455     SwXFrame::release();
2456 }
2457 
2458 ::uno::Any SAL_CALL SwXTextFrame::queryInterface( const uno::Type& aType )
2459     throw (uno::RuntimeException)
2460 {
2461     ::uno::Any aRet = SwXFrame::queryInterface(aType);
2462     if(aRet.getValueType() == ::getCppuVoidType())
2463         aRet = SwXText::queryInterface(aType);
2464     if(aRet.getValueType() == ::getCppuVoidType())
2465         aRet = SwXTextFrameBaseClass::queryInterface(aType);
2466     return aRet;
2467 }
2468 
2469 uno::Sequence< uno::Type > SAL_CALL SwXTextFrame::getTypes(  ) throw(uno::RuntimeException)
2470 {
2471     uno::Sequence< uno::Type > aTextFrameTypes = SwXTextFrameBaseClass::getTypes();
2472     uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
2473     uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
2474 
2475     long nIndex = aTextFrameTypes.getLength();
2476     aTextFrameTypes.realloc(
2477         aTextFrameTypes.getLength() +
2478         aFrameTypes.getLength() +
2479         aTextTypes.getLength());
2480 
2481     uno::Type* pTextFrameTypes = aTextFrameTypes.getArray();
2482     const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
2483     long nPos;
2484     for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
2485         pTextFrameTypes[nIndex++] = pFrameTypes[nPos];
2486 
2487     const uno::Type* pTextTypes = aTextTypes.getConstArray();
2488     for(nPos = 0; nPos <aTextTypes.getLength(); nPos++)
2489         pTextFrameTypes[nIndex++] = pTextTypes[nPos];
2490 
2491     return aTextFrameTypes;
2492 }
2493 
2494 uno::Sequence< sal_Int8 > SAL_CALL SwXTextFrame::getImplementationId(  ) throw(uno::RuntimeException)
2495 {
2496     vos::OGuard aGuard(Application::GetSolarMutex());
2497     static uno::Sequence< sal_Int8 > aId( 16 );
2498     static sal_Bool bInit = sal_False;
2499     if(!bInit)
2500     {
2501         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
2502         bInit = sal_True;
2503     }
2504     return aId;
2505 }
2506 
2507 uno::Reference< text::XText >  SwXTextFrame::getText(void) throw( uno::RuntimeException )
2508 {
2509     return this;
2510 }
2511 
2512 const SwStartNode *SwXTextFrame::GetStartNode() const
2513 {
2514     const SwStartNode *pSttNd = 0;
2515 
2516     SwFrmFmt* pFmt = GetFrmFmt();
2517     if(pFmt)
2518     {
2519         const SwFmtCntnt& rFlyCntnt = pFmt->GetCntnt();
2520         if( rFlyCntnt.GetCntntIdx() )
2521             pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode();
2522     }
2523 
2524     return pSttNd;
2525 }
2526 
2527 uno::Reference< text::XTextCursor >
2528 SwXTextFrame::CreateCursor() throw (uno::RuntimeException)
2529 {
2530     return createTextCursor();
2531 }
2532 
2533 uno::Reference< text::XTextCursor >  SwXTextFrame::createTextCursor(void) throw( uno::RuntimeException )
2534 {
2535     vos::OGuard aGuard(Application::GetSolarMutex());
2536     uno::Reference< text::XTextCursor >  aRef;
2537     SwFrmFmt* pFmt = GetFrmFmt();
2538     if(pFmt)
2539     {
2540         //save current start node to be able to check if there is content after the table -
2541         //otherwise the cursor would be in the body text!
2542         const SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode();
2543         const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode);
2544 
2545         SwPaM aPam(rNode);
2546         aPam.Move(fnMoveForward, fnGoNode);
2547         SwTableNode* pTblNode = aPam.GetNode()->FindTableNode();
2548         SwCntntNode* pCont = 0;
2549         while( pTblNode )
2550         {
2551             aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode();
2552             pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode);
2553             pTblNode = pCont->FindTableNode();
2554         }
2555         if(pCont)
2556             aPam.GetPoint()->nContent.Assign(pCont, 0);
2557 
2558         const SwStartNode* pNewStartNode =
2559             aPam.GetNode()->FindSttNodeByType(SwFlyStartNode);
2560         if(!pNewStartNode || pNewStartNode != pOwnStartNode)
2561         {
2562             uno::RuntimeException aExcept;
2563             aExcept.Message = S2U("no text available");
2564             throw aExcept;
2565         }
2566 
2567         SwXTextCursor *const pXCursor = new SwXTextCursor(
2568                  *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint());
2569         aRef =  static_cast<text::XWordCursor*>(pXCursor);
2570 #if OSL_DEBUG_LEVEL > 1
2571         SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
2572         (void) pUnoCrsr;
2573 #endif
2574     }
2575     else
2576         throw uno::RuntimeException();
2577     return aRef;
2578 }
2579 
2580 uno::Reference< text::XTextCursor >  SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException )
2581 {
2582     vos::OGuard aGuard(Application::GetSolarMutex());
2583     uno::Reference< text::XTextCursor >  aRef;
2584     SwFrmFmt* pFmt = GetFrmFmt();
2585     SwUnoInternalPaM aPam(*GetDoc());
2586     if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition))
2587     {
2588         SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode();
2589 #if OSL_DEBUG_LEVEL > 1
2590         const SwStartNode* p1 = aPam.GetNode()->FindFlyStartNode();
2591         const SwStartNode* p2 = rNode.FindFlyStartNode();
2592         (void)p1;
2593         (void)p2;
2594 #endif
2595         if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode())
2596         {
2597             aRef = static_cast<text::XWordCursor*>(
2598                     new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME,
2599                         *aPam.GetPoint(), aPam.GetMark()));
2600         }
2601     }
2602     else
2603         throw uno::RuntimeException();
2604     return aRef;
2605 }
2606 
2607 uno::Reference< container::XEnumeration >  SwXTextFrame::createEnumeration(void) throw( uno::RuntimeException )
2608 {
2609     vos::OGuard aGuard(Application::GetSolarMutex());
2610     uno::Reference< container::XEnumeration >  aRef;
2611     SwFrmFmt* pFmt = GetFrmFmt();
2612     if(pFmt)
2613     {
2614         SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode());
2615         ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
2616                 GetDoc()->CreateUnoCrsr(aPos, sal_False));
2617         pUnoCursor->Move(fnMoveForward, fnGoNode);
2618 //      // no Cursor in protected sections
2619 //      SwCrsrSaveState aSave( *pUnoCrsr );
2620 //      if(pUnoCrsr->IsInProtectTable( sal_True ) ||
2621 //          pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS ))
2622 //          throw  uno::RuntimeException() );
2623         aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME);
2624     }
2625     return aRef;
2626 }
2627 
2628 uno::Type  SwXTextFrame::getElementType(void) throw( uno::RuntimeException )
2629 {
2630     return ::getCppuType(static_cast<uno::Reference<text::XTextRange>*>(0));
2631 }
2632 
2633 sal_Bool SwXTextFrame::hasElements(void) throw( uno::RuntimeException )
2634 {
2635     return sal_True;
2636 }
2637 
2638 void SwXTextFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
2639     throw( lang::IllegalArgumentException, uno::RuntimeException )
2640 {
2641     SwXFrame::attach(xTextRange);
2642 }
2643 
2644 uno::Reference< text::XTextRange >  SwXTextFrame::getAnchor(void) throw( uno::RuntimeException )
2645 {
2646     vos::OGuard aGuard(Application::GetSolarMutex());
2647     return SwXFrame::getAnchor();
2648 }
2649 
2650 void SwXTextFrame::dispose(void) throw( uno::RuntimeException )
2651 {
2652     vos::OGuard aGuard(Application::GetSolarMutex());
2653     SwXFrame::dispose();
2654 }
2655 
2656 void SwXTextFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2657 {
2658     SwXFrame::addEventListener(aListener);
2659 }
2660 
2661 void SwXTextFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2662 {
2663     SwXFrame::removeEventListener(aListener);
2664 }
2665 
2666 OUString SwXTextFrame::getImplementationName(void) throw( uno::RuntimeException )
2667 {
2668     return C2U("SwXTextFrame");
2669 }
2670 
2671 sal_Bool SwXTextFrame::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
2672 {
2673     return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.Text")||
2674             COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextFrame")||
2675                     SwXFrame::supportsService(rServiceName);
2676 }
2677 
2678 uno::Sequence< OUString > SwXTextFrame::getSupportedServiceNames(void) throw( uno::RuntimeException )
2679 {
2680     uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
2681     aRet.realloc(aRet.getLength() + 2);
2682     OUString* pArray = aRet.getArray();
2683     pArray[aRet.getLength() - 2] = C2U("com.sun.star.text.TextFrame");
2684     pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.Text");
2685     return aRet;
2686 }
2687 
2688 void * SAL_CALL SwXTextFrame::operator new( size_t t) throw()
2689 {
2690     return SwXTextFrameBaseClass::operator new( t);
2691 }
2692 
2693 void SAL_CALL SwXTextFrame::operator delete( void * p) throw()
2694 {
2695     SwXTextFrameBaseClass::operator delete(p);
2696 }
2697 
2698 uno::Reference<container::XNameReplace > SAL_CALL SwXTextFrame::getEvents()
2699     throw(uno::RuntimeException)
2700 {
2701     return new SwFrameEventDescriptor( *this );
2702 }
2703 
2704 sal_Int64 SAL_CALL SwXTextFrame::getSomething( const uno::Sequence< sal_Int8 >& rId )
2705     throw(uno::RuntimeException)
2706 {
2707     sal_Int64 nRet = SwXFrame::getSomething( rId );
2708     if( !nRet )
2709         nRet = SwXText::getSomething( rId );
2710 
2711     return nRet;
2712 }
2713 
2714 ::uno::Any SwXTextFrame::getPropertyValue(const OUString& rPropertyName)
2715     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2716 {
2717     vos::OGuard aGuard(Application::GetSolarMutex());
2718     ::uno::Any aRet;
2719     if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))||
2720             rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE)))
2721     {
2722         //redline can only be returned if it's a living object
2723         if(!IsDescriptor())
2724             aRet = SwXText::getPropertyValue(rPropertyName);
2725     }
2726     else
2727         aRet = SwXFrame::getPropertyValue(rPropertyName);
2728     return aRet;
2729 }
2730 /******************************************************************
2731  *  SwXTextGraphicObject
2732  ******************************************************************/
2733 
2734 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc *pDoc ) :
2735     SwXFrame(FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC), pDoc)
2736 {
2737 }
2738 
2739 SwXTextGraphicObject::SwXTextGraphicObject(SwFrmFmt& rFmt) :
2740     SwXFrame(rFmt, FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC))
2741 {
2742 
2743 }
2744 
2745 SwXTextGraphicObject::~SwXTextGraphicObject()
2746 {
2747 
2748 }
2749 
2750 void SAL_CALL SwXTextGraphicObject::acquire(  )throw()
2751 {
2752     SwXFrame::acquire();
2753 }
2754 
2755 void SAL_CALL SwXTextGraphicObject::release(  )throw()
2756 {
2757     SwXFrame::release();
2758 }
2759 
2760 ::uno::Any SAL_CALL SwXTextGraphicObject::queryInterface( const uno::Type& aType )
2761     throw(uno::RuntimeException)
2762 {
2763     ::uno::Any aRet = SwXFrame::queryInterface(aType);
2764     if(aRet.getValueType() == ::getCppuVoidType())
2765         aRet = SwXTextGraphicObjectBaseClass::queryInterface(aType);
2766     return aRet;
2767 }
2768 
2769 uno::Sequence< uno::Type > SAL_CALL
2770     SwXTextGraphicObject::getTypes(  ) throw(uno::RuntimeException)
2771 {
2772     uno::Sequence< uno::Type > aGraphicTypes = SwXTextGraphicObjectBaseClass::getTypes();
2773     uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
2774 
2775     long nIndex = aGraphicTypes.getLength();
2776     aGraphicTypes.realloc(
2777         aGraphicTypes.getLength() +
2778         aFrameTypes.getLength());
2779 
2780     uno::Type* pGraphicTypes = aGraphicTypes.getArray();
2781     const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
2782     long nPos;
2783     for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
2784         pGraphicTypes[nIndex++] = pFrameTypes[nPos];
2785 
2786     return aGraphicTypes;
2787 }
2788 
2789 uno::Sequence< sal_Int8 > SAL_CALL SwXTextGraphicObject::getImplementationId(  ) throw(uno::RuntimeException)
2790 {
2791     vos::OGuard aGuard(Application::GetSolarMutex());
2792     static uno::Sequence< sal_Int8 > aId( 16 );
2793     static sal_Bool bInit = sal_False;
2794     if(!bInit)
2795     {
2796         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
2797         bInit = sal_True;
2798     }
2799     return aId;
2800 }
2801 
2802 void SwXTextGraphicObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException )
2803 {
2804     SwXFrame::attach(xTextRange);
2805 }
2806 
2807 uno::Reference< text::XTextRange >  SwXTextGraphicObject::getAnchor(void) throw( uno::RuntimeException )
2808 {
2809     vos::OGuard aGuard(Application::GetSolarMutex());
2810     return SwXFrame::getAnchor();
2811 }
2812 
2813 void SwXTextGraphicObject::dispose(void) throw( uno::RuntimeException )
2814 {
2815     vos::OGuard aGuard(Application::GetSolarMutex());
2816     SwXFrame::dispose();
2817 }
2818 
2819 void SwXTextGraphicObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
2820                                                     throw( uno::RuntimeException )
2821 {
2822     SwXFrame::addEventListener(aListener);
2823 }
2824 
2825 void SwXTextGraphicObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
2826                                                     throw( uno::RuntimeException )
2827 {
2828     SwXFrame::removeEventListener(aListener);
2829 }
2830 
2831 OUString SwXTextGraphicObject::getImplementationName(void) throw( uno::RuntimeException )
2832 {
2833     return C2U("SwXTextGraphicObject");
2834 }
2835 
2836 sal_Bool SwXTextGraphicObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
2837 {
2838     return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextGraphicObject") ||
2839                     SwXFrame::supportsService(rServiceName);
2840 }
2841 
2842 uno::Sequence< OUString > SwXTextGraphicObject::getSupportedServiceNames(void)
2843         throw( uno::RuntimeException )
2844 {
2845     uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
2846     aRet.realloc(aRet.getLength() + 1);
2847     OUString* pArray = aRet.getArray();
2848     pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextGraphicObject");
2849     return aRet;
2850 }
2851 
2852 void * SAL_CALL SwXTextGraphicObject::operator new( size_t t) throw()
2853 {
2854     return SwXTextGraphicObjectBaseClass::operator new(t);
2855 }
2856 
2857 void SAL_CALL SwXTextGraphicObject::operator delete( void * p) throw()
2858 {
2859     SwXTextGraphicObjectBaseClass::operator delete(p);
2860 }
2861 
2862 uno::Reference<container::XNameReplace> SAL_CALL
2863     SwXTextGraphicObject::getEvents()
2864         throw(uno::RuntimeException)
2865 {
2866     return new SwFrameEventDescriptor( *this );
2867 }
2868 
2869 /******************************************************************
2870  *
2871  ******************************************************************/
2872 
2873 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc *pDoc ) :
2874     SwXFrame(FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT), pDoc)
2875 {
2876 }
2877 
2878 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrmFmt& rFmt) :
2879     SwXFrame(rFmt, FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT))
2880 {
2881 
2882 }
2883 
2884 SwXTextEmbeddedObject::~SwXTextEmbeddedObject()
2885 {
2886 
2887 }
2888 
2889 void SAL_CALL SwXTextEmbeddedObject::acquire()throw()
2890 {
2891     SwXFrame::acquire();
2892 }
2893 
2894 void SAL_CALL SwXTextEmbeddedObject::release()throw()
2895 {
2896     SwXFrame::release();
2897 }
2898 
2899 ::uno::Any SAL_CALL SwXTextEmbeddedObject::queryInterface( const uno::Type& aType )
2900     throw( uno::RuntimeException)
2901 {
2902     ::uno::Any aRet = SwXFrame::queryInterface(aType);;
2903     if(aRet.getValueType() == ::getCppuVoidType())
2904         aRet = SwXTextEmbeddedObjectBaseClass::queryInterface(aType);
2905     return aRet;
2906 }
2907 
2908 uno::Sequence< uno::Type > SAL_CALL SwXTextEmbeddedObject::getTypes(  ) throw(uno::RuntimeException)
2909 {
2910     uno::Sequence< uno::Type > aTextEmbeddedTypes = SwXTextEmbeddedObjectBaseClass::getTypes();
2911     uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes();
2912 
2913     long nIndex = aTextEmbeddedTypes.getLength();
2914     aTextEmbeddedTypes.realloc(
2915         aTextEmbeddedTypes.getLength() +
2916         aFrameTypes.getLength());
2917 
2918     uno::Type* pTextEmbeddedTypes = aTextEmbeddedTypes.getArray();
2919 
2920     const uno::Type* pFrameTypes = aFrameTypes.getConstArray();
2921     long nPos;
2922     for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++)
2923         pTextEmbeddedTypes[nIndex++] = pFrameTypes[nPos];
2924 
2925     return aTextEmbeddedTypes;
2926 }
2927 
2928 uno::Sequence< sal_Int8 > SAL_CALL SwXTextEmbeddedObject::getImplementationId(  ) throw(uno::RuntimeException)
2929 {
2930     vos::OGuard aGuard(Application::GetSolarMutex());
2931     static uno::Sequence< sal_Int8 > aId( 16 );
2932     static sal_Bool bInit = sal_False;
2933     if(!bInit)
2934     {
2935         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
2936         bInit = sal_True;
2937     }
2938     return aId;
2939 }
2940 
2941 void SwXTextEmbeddedObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException )
2942 {
2943     SwXFrame::attach(xTextRange);
2944 }
2945 
2946 uno::Reference< text::XTextRange >  SwXTextEmbeddedObject::getAnchor(void) throw( uno::RuntimeException )
2947 {
2948     vos::OGuard aGuard(Application::GetSolarMutex());
2949     return SwXFrame::getAnchor();
2950 }
2951 
2952 void SwXTextEmbeddedObject::dispose(void) throw( uno::RuntimeException )
2953 {
2954     vos::OGuard aGuard(Application::GetSolarMutex());
2955     SwXFrame::dispose();
2956 }
2957 
2958 void SwXTextEmbeddedObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2959 {
2960     SwXFrame::addEventListener(aListener);
2961 }
2962 
2963 void SwXTextEmbeddedObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
2964 {
2965     SwXFrame::removeEventListener(aListener);
2966 }
2967 
2968 uno::Reference< lang::XComponent >  SwXTextEmbeddedObject::getEmbeddedObject(void) throw( uno::RuntimeException )
2969 {
2970     uno::Reference< lang::XComponent >  xRet;
2971     SwFrmFmt*   pFmt = GetFrmFmt();
2972     if(pFmt)
2973     {
2974         SwDoc* pDoc = pFmt->GetDoc();
2975         const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
2976         DBG_ASSERT( pCnt->GetCntntIdx() &&
2977                        pDoc->GetNodes()[ pCnt->GetCntntIdx()->
2978                                         GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
2979 
2980         SwOLENode* pOleNode =  pDoc->GetNodes()[ pCnt->GetCntntIdx()
2981                                         ->GetIndex() + 1 ]->GetOLENode();
2982         uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef();
2983         if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
2984         {
2985             // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
2986             if ( pDoc->GetDocShell() )
2987                 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) );
2988 
2989             xRet = uno::Reference < lang::XComponent >( xIP->getComponent(), uno::UNO_QUERY );
2990             uno::Reference< util::XModifyBroadcaster >  xBrdcst( xRet, uno::UNO_QUERY);
2991             uno::Reference< frame::XModel > xModel( xRet, uno::UNO_QUERY);
2992             if( xBrdcst.is() && xModel.is() )
2993             {
2994                 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt );
2995                 //create a new one if the OLE object doesn't have one already
2996                 if( !pListener )
2997                 {
2998                     uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
2999                     xBrdcst->addModifyListener( xOLEListener );
3000                 }
3001             }
3002         }
3003     }
3004     return xRet;
3005 }
3006 
3007 uno::Reference< embed::XEmbeddedObject > SAL_CALL SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject()
3008         throw( uno::RuntimeException )
3009 {
3010     uno::Reference< embed::XEmbeddedObject > xResult;
3011     SwFrmFmt*   pFmt = GetFrmFmt();
3012     if(pFmt)
3013     {
3014         SwDoc* pDoc = pFmt->GetDoc();
3015         const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3016         DBG_ASSERT( pCnt->GetCntntIdx() &&
3017                        pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3018                                         GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3019 
3020         SwOLENode* pOleNode =  pDoc->GetNodes()[ pCnt->GetCntntIdx()
3021                                         ->GetIndex() + 1 ]->GetOLENode();
3022         xResult = pOleNode->GetOLEObj().GetOleRef();
3023         if ( svt::EmbeddedObjectRef::TryRunningState( xResult ) )
3024         {
3025             // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here
3026             if ( pDoc->GetDocShell() )
3027                 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult, embed::Aspects::MSOLE_CONTENT ) );
3028 
3029             uno::Reference < lang::XComponent > xComp( xResult->getComponent(), uno::UNO_QUERY );
3030             uno::Reference< util::XModifyBroadcaster >  xBrdcst( xComp, uno::UNO_QUERY);
3031             uno::Reference< frame::XModel > xModel( xComp, uno::UNO_QUERY);
3032             if( xBrdcst.is() && xModel.is() )
3033             {
3034                 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt );
3035                 //create a new one if the OLE object doesn't have one already
3036                 if( !pListener )
3037                 {
3038                     uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel);
3039                     xBrdcst->addModifyListener( xOLEListener );
3040                 }
3041             }
3042         }
3043     }
3044     return xResult;
3045 }
3046 
3047 sal_Int64 SAL_CALL SwXTextEmbeddedObject::getAspect() throw (uno::RuntimeException)
3048 {
3049     SwFrmFmt*   pFmt = GetFrmFmt();
3050     if(pFmt)
3051     {
3052         SwDoc* pDoc = pFmt->GetDoc();
3053         const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3054         DBG_ASSERT( pCnt->GetCntntIdx() &&
3055                        pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3056                                         GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3057 
3058         return pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect();
3059     }
3060 
3061     return embed::Aspects::MSOLE_CONTENT; // return the default value
3062 }
3063 
3064 void SAL_CALL SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect ) throw (uno::RuntimeException)
3065 {
3066     SwFrmFmt*   pFmt = GetFrmFmt();
3067     if(pFmt)
3068     {
3069         SwDoc* pDoc = pFmt->GetDoc();
3070         const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3071         DBG_ASSERT( pCnt->GetCntntIdx() &&
3072                        pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3073                                         GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3074 
3075         pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect );
3076     }
3077 }
3078 
3079 uno::Reference< graphic::XGraphic > SAL_CALL SwXTextEmbeddedObject::getReplacementGraphic() throw (uno::RuntimeException)
3080 {
3081     SwFrmFmt*   pFmt = GetFrmFmt();
3082     if(pFmt)
3083     {
3084         SwDoc* pDoc = pFmt->GetDoc();
3085         const SwFmtCntnt* pCnt = &pFmt->GetCntnt();
3086         DBG_ASSERT( pCnt->GetCntntIdx() &&
3087                        pDoc->GetNodes()[ pCnt->GetCntntIdx()->
3088                                         GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?");
3089 
3090         Graphic* pGraphic = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic();
3091         if ( pGraphic )
3092             return pGraphic->GetXGraphic();
3093     }
3094 
3095     return uno::Reference< graphic::XGraphic >();
3096 }
3097 
3098 
3099 OUString SwXTextEmbeddedObject::getImplementationName(void) throw( uno::RuntimeException )
3100 
3101 {
3102     return C2U("SwXTextEmbeddedObject");
3103 }
3104 
3105 sal_Bool SwXTextEmbeddedObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
3106 {
3107     return  COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextEmbeddedObject")||
3108                     SwXFrame::supportsService(rServiceName);
3109 }
3110 
3111 uno::Sequence< OUString > SwXTextEmbeddedObject::getSupportedServiceNames(void)
3112         throw( uno::RuntimeException )
3113 {
3114     uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames();
3115     aRet.realloc(aRet.getLength() + 1);
3116     OUString* pArray = aRet.getArray();
3117     pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextEmbeddedObject");
3118     return aRet;
3119 }
3120 
3121 void * SAL_CALL SwXTextEmbeddedObject::operator new( size_t t) throw()
3122 {
3123     return SwXTextEmbeddedObjectBaseClass::operator new(t);
3124 }
3125 
3126 void SAL_CALL SwXTextEmbeddedObject::operator delete( void * p) throw()
3127 {
3128     SwXTextEmbeddedObjectBaseClass::operator delete(p);
3129 }
3130 
3131 uno::Reference<container::XNameReplace> SAL_CALL
3132     SwXTextEmbeddedObject::getEvents()
3133         throw(uno::RuntimeException)
3134 {
3135     return new SwFrameEventDescriptor( *this );
3136 }
3137 
3138 
3139 /******************************************************************
3140  *
3141  ******************************************************************/
3142 TYPEINIT1(SwXOLEListener, SwClient);
3143 
3144 SwXOLEListener::SwXOLEListener( SwFmt& rOLEFmt, uno::Reference< XModel > xOLE) :
3145     SwClient(&rOLEFmt),
3146     xOLEModel(xOLE)
3147 {
3148 }
3149 
3150 SwXOLEListener::~SwXOLEListener()
3151 {}
3152 
3153 void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
3154                                         throw( uno::RuntimeException )
3155 {
3156     vos::OGuard aGuard(Application::GetSolarMutex());
3157 
3158     SwOLENode* pNd = 0;
3159     SwFmt* pFmt = GetFmt();
3160     if(pFmt)
3161     {const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
3162         if(pIdx)
3163         {
3164             SwNodeIndex aIdx(*pIdx, 1);
3165             SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode();
3166             pNd = pNoTxt->GetOLENode();
3167         }
3168     }
3169     if(!pNd)
3170         throw uno::RuntimeException();
3171 
3172     uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef();
3173     if ( xIP.is() )
3174     {
3175         sal_Int32 nState = xIP->getCurrentState();
3176         if ( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE )
3177             return;
3178     }
3179 
3180     // if the OLE-Node is UI-Active do nothing
3181     pNd->SetOLESizeInvalid( sal_True );
3182     pNd->GetDoc()->SetOLEObjModified();
3183 }
3184 
3185 /* ---------------------------------------------------------------------------
3186 
3187  ---------------------------------------------------------------------------*/
3188 void SwXOLEListener::disposing( const lang::EventObject& rEvent )
3189                         throw( uno::RuntimeException )
3190 {
3191     vos::OGuard aGuard(Application::GetSolarMutex());
3192 
3193     uno::Reference< util::XModifyListener >  xListener( this );
3194 
3195 
3196     uno::Reference< frame::XModel >  xModel( rEvent.Source, uno::UNO_QUERY );
3197     uno::Reference< util::XModifyBroadcaster >  xBrdcst(xModel, uno::UNO_QUERY);
3198 
3199     try
3200     {
3201         if( xBrdcst.is() )
3202             xBrdcst->removeModifyListener( xListener );
3203     }
3204     catch(uno::Exception const &)
3205     {
3206         DBG_ERROR("OLE Listener couldn't be removed");
3207     }
3208 }
3209 /* ---------------------------------------------------------------------------
3210 
3211  ---------------------------------------------------------------------------*/
3212 void SwXOLEListener::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
3213 {
3214     ClientModify(this, pOld, pNew);
3215     if(!GetRegisteredIn())
3216         xOLEModel = 0;
3217 }
3218 
3219