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