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