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