Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <swtypes.hxx>
31 : : #include <cmdid.h>
32 : :
33 : : #include <unomid.h>
34 : : #include <unodraw.hxx>
35 : : #include <unocoll.hxx>
36 : : #include <unoframe.hxx>
37 : : #include <unoparagraph.hxx>
38 : : #include <unotextrange.hxx>
39 : : #include <unoprnms.hxx>
40 : : #include <editeng/unoprnms.hxx>
41 : : #include <svx/svditer.hxx>
42 : : #include <swunohelper.hxx>
43 : : #include <doc.hxx>
44 : : #include <IDocumentUndoRedo.hxx>
45 : : #include <fmtcntnt.hxx>
46 : : #include <fmtflcnt.hxx>
47 : : #include <txtatr.hxx>
48 : : #include <docsh.hxx>
49 : : #include <unomap.hxx>
50 : : #include <unoport.hxx>
51 : : #include <unocrsr.hxx>
52 : : #include <TextCursorHelper.hxx>
53 : : #include <swundo.hxx>
54 : : #include <dflyobj.hxx>
55 : : #include <ndtxt.hxx>
56 : : #include <svx/svdview.hxx>
57 : : #include <svx/unoshape.hxx>
58 : : #include <dcontact.hxx>
59 : : #include <svx/fmglob.hxx>
60 : : #include <fmtornt.hxx>
61 : : #include <fmtanchr.hxx>
62 : : #include <fmtsrnd.hxx>
63 : : #include <fmtfollowtextflow.hxx>
64 : : #include <rootfrm.hxx>
65 : : #include <editeng/lrspitem.hxx>
66 : : #include <editeng/ulspitem.hxx>
67 : : #include <svx/shapepropertynotifier.hxx>
68 : : #include <crstate.hxx>
69 : : #include <osl/mutex.hxx>
70 : : #include <comphelper/extract.hxx>
71 : : #include <comphelper/stl_types.hxx>
72 : : #include <comphelper/makesequence.hxx>
73 : : #include <comphelper/servicehelper.hxx>
74 : : #include <svx/scene3d.hxx>
75 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
76 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
77 : : #include <com/sun/star/text/HoriOrientation.hpp>
78 : : #include <com/sun/star/text/VertOrientation.hpp>
79 : : #include <basegfx/numeric/ftools.hxx>
80 : : #include <algorithm>
81 : : #include <fmtwrapinfluenceonobjpos.hxx>
82 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
83 : : #include <basegfx/matrix/b2dhommatrix.hxx>
84 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
85 : : #include <com/sun/star/drawing/PointSequence.hpp>
86 : : #include <vcl/svapp.hxx>
87 : : #include <list>
88 : : #include <iterator>
89 : : #include <switerator.hxx>
90 : :
91 : : using ::rtl::OUString;
92 : : using namespace ::com::sun::star;
93 : :
94 : : DECLARE_STL_USTRINGACCESS_MAP( uno::Sequence< sal_Int8 > *, SwShapeImplementationIdMap );
95 : :
96 : 73 : static SwShapeImplementationIdMap aImplementationIdMap;
97 : :
98 : : class SwShapeDescriptor_Impl
99 : : {
100 : : SwFmtHoriOrient* pHOrient;
101 : : SwFmtVertOrient* pVOrient;
102 : : SwFmtAnchor* pAnchor;
103 : : SwFmtSurround* pSurround;
104 : : SvxULSpaceItem* pULSpace;
105 : : SvxLRSpaceItem* pLRSpace;
106 : : sal_Bool bOpaque;
107 : : uno::Reference< text::XTextRange > xTextRange;
108 : : // #i26791#
109 : : SwFmtFollowTextFlow* mpFollowTextFlow;
110 : : // #i28701#
111 : : SwFmtWrapInfluenceOnObjPos* pWrapInfluenceOnObjPos;
112 : : // #i28749#
113 : : sal_Int16 mnPositionLayoutDir;
114 : :
115 : : public:
116 : : bool bInitializedPropertyNotifier;
117 : :
118 : : public:
119 : 1077 : SwShapeDescriptor_Impl() :
120 : : // #i32349# - no defaults, in order to determine on
121 : : // adding a shape, if positioning attributes are set or not.
122 : : pHOrient( 0L ),
123 : : pVOrient( 0L ),
124 : : pAnchor(0),
125 : : pSurround(0),
126 : : pULSpace(0),
127 : : pLRSpace(0),
128 : : bOpaque(sal_False),
129 : : // #i26791#
130 [ + - ]: 1077 : mpFollowTextFlow( new SwFmtFollowTextFlow( sal_False ) ),
131 : : // #i28701# #i35017#
132 : : pWrapInfluenceOnObjPos( new SwFmtWrapInfluenceOnObjPos(
133 [ + - ]: 1077 : text::WrapInfluenceOnPosition::ONCE_CONCURRENT ) ),
134 : : // #i28749#
135 : : mnPositionLayoutDir( text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
136 [ + - ][ + - ]: 2154 : bInitializedPropertyNotifier(false)
137 : 1077 : {}
138 : :
139 : 1077 : ~SwShapeDescriptor_Impl()
140 : 1077 : {
141 [ + + ][ + - ]: 1077 : delete pHOrient;
142 [ + + ][ + - ]: 1077 : delete pVOrient;
143 [ + + ][ + - ]: 1077 : delete pAnchor;
144 [ - + ][ # # ]: 1077 : delete pSurround;
145 [ - + ][ # # ]: 1077 : delete pULSpace;
146 [ - + ][ # # ]: 1077 : delete pLRSpace;
147 : : // #i26791#
148 [ + - ][ + - ]: 1077 : delete mpFollowTextFlow;
149 : : // #i28701#
150 [ + - ][ + - ]: 1077 : delete pWrapInfluenceOnObjPos;
151 : 1077 : }
152 : 740 : SwFmtAnchor* GetAnchor(sal_Bool bCreate = sal_False)
153 : : {
154 [ + + ][ + - ]: 740 : if(bCreate && !pAnchor)
155 : : {
156 [ + - ]: 23 : pAnchor = new SwFmtAnchor(FLY_AS_CHAR);
157 : : }
158 : 740 : return pAnchor;
159 : : }
160 : 3564 : SwFmtHoriOrient* GetHOrient(sal_Bool bCreate = sal_False)
161 : : {
162 [ + + ][ + - ]: 3564 : if (bCreate && !pHOrient)
163 : : {
164 : : // #i26791#
165 [ + - ]: 573 : pHOrient = new SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
166 : : }
167 : 3564 : return pHOrient;
168 : : }
169 : 3567 : SwFmtVertOrient* GetVOrient(sal_Bool bCreate = sal_False)
170 : : {
171 [ + + ][ + - ]: 3567 : if(bCreate && !pVOrient)
172 : : {
173 : : // #i26791#
174 [ + - ]: 576 : pVOrient = new SwFmtVertOrient( 0, text::VertOrientation::NONE, text::RelOrientation::FRAME );
175 : : }
176 : 3567 : return pVOrient;
177 : : }
178 : :
179 : 1142 : SwFmtSurround* GetSurround(sal_Bool bCreate = sal_False)
180 : : {
181 [ - + ][ # # ]: 1142 : if(bCreate && !pSurround)
182 [ # # ]: 0 : pSurround = new SwFmtSurround();
183 : 1142 : return pSurround;
184 : : }
185 : 571 : SvxLRSpaceItem* GetLRSpace(sal_Bool bCreate = sal_False)
186 : : {
187 [ - + ][ # # ]: 571 : if(bCreate && !pLRSpace)
188 [ # # ]: 0 : pLRSpace = new SvxLRSpaceItem(RES_LR_SPACE);
189 : 571 : return pLRSpace;
190 : : }
191 : 571 : SvxULSpaceItem* GetULSpace(sal_Bool bCreate = sal_False)
192 : : {
193 [ - + ][ # # ]: 571 : if(bCreate && !pULSpace)
194 [ # # ]: 0 : pULSpace = new SvxULSpaceItem(RES_UL_SPACE);
195 : 571 : return pULSpace;
196 : : }
197 : 594 : uno::Reference< text::XTextRange > & GetTextRange()
198 : : {
199 : 594 : return xTextRange;
200 : : }
201 : 571 : sal_Bool IsOpaque() const
202 : : {
203 : 571 : return bOpaque;
204 : : }
205 : 12 : const sal_Bool& GetOpaque() const
206 : : {
207 : 12 : return bOpaque;
208 : : }
209 [ # # ]: 0 : void RemoveHOrient(){DELETEZ(pHOrient);}
210 [ # # ]: 0 : void RemoveVOrient(){DELETEZ(pVOrient);}
211 [ # # ]: 0 : void RemoveAnchor(){DELETEZ(pAnchor);}
212 [ # # ]: 0 : void RemoveSurround(){DELETEZ(pSurround);}
213 [ # # ]: 0 : void RemoveULSpace(){DELETEZ(pULSpace);}
214 [ # # ]: 0 : void RemoveLRSpace(){DELETEZ(pLRSpace);}
215 : 0 : void SetOpaque(sal_Bool bSet){bOpaque = bSet;}
216 : :
217 : : // #i26791#
218 : 1142 : SwFmtFollowTextFlow* GetFollowTextFlow( sal_Bool _bCreate = sal_False )
219 : : {
220 [ - + ][ # # ]: 1142 : if ( _bCreate && !mpFollowTextFlow )
221 [ # # ]: 0 : mpFollowTextFlow = new SwFmtFollowTextFlow( sal_False );
222 : 1142 : return mpFollowTextFlow;
223 : : }
224 : 0 : void RemoveFollowTextFlow()
225 : : {
226 [ # # ]: 0 : DELETEZ(mpFollowTextFlow);
227 : 0 : }
228 : :
229 : : // #i28749#
230 : 0 : sal_Int16 GetPositionLayoutDir() const
231 : : {
232 : 0 : return mnPositionLayoutDir;
233 : : }
234 : 0 : void SetPositionLayoutDir( sal_Int16 _nPositionLayoutDir )
235 : : {
236 [ # # ]: 0 : switch ( _nPositionLayoutDir )
237 : : {
238 : : case text::PositionLayoutDir::PositionInHoriL2R:
239 : : case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
240 : : {
241 : 0 : mnPositionLayoutDir = _nPositionLayoutDir;
242 : : }
243 : 0 : break;
244 : : default:
245 : : {
246 : : OSL_FAIL( "<SwShapeDescriptor_Impl::SetPositionLayoutDir(..)> - invalid attribute value." );
247 : : }
248 : : }
249 : 0 : }
250 : : void RemovePositionLayoutDir()
251 : : {
252 : : mnPositionLayoutDir = text::PositionLayoutDir::PositionInLayoutDirOfAnchor;
253 : : }
254 : :
255 : : // #i28701#
256 : 1142 : inline SwFmtWrapInfluenceOnObjPos* GetWrapInfluenceOnObjPos(
257 : : const sal_Bool _bCreate = sal_False )
258 : : {
259 [ - + ][ # # ]: 1142 : if ( _bCreate && !pWrapInfluenceOnObjPos )
260 : : {
261 : : pWrapInfluenceOnObjPos = new SwFmtWrapInfluenceOnObjPos(
262 : : // #i35017#
263 [ # # ]: 0 : text::WrapInfluenceOnPosition::ONCE_CONCURRENT );
264 : : }
265 : 1142 : return pWrapInfluenceOnObjPos;
266 : : }
267 : 0 : inline void RemoveWrapInfluenceOnObjPos()
268 : : {
269 [ # # ]: 0 : DELETEZ(pWrapInfluenceOnObjPos);
270 : 0 : }
271 : : };
272 : :
273 : : /****************************************************************************
274 : : class SwFmDrawPage
275 : : ****************************************************************************/
276 : 1302 : SwFmDrawPage::SwFmDrawPage( SdrPage* pPage ) :
277 : 1302 : SvxFmDrawPage( pPage ), pPageView(0)
278 : : {
279 : 1302 : }
280 : :
281 : 1215 : SwFmDrawPage::~SwFmDrawPage() throw ()
282 : : {
283 [ + - ]: 1215 : RemovePageView();
284 [ - + ]: 2430 : }
285 : :
286 : 0 : const SdrMarkList& SwFmDrawPage::PreGroup(const uno::Reference< drawing::XShapes > & xShapes)
287 : : {
288 : 0 : _SelectObjectsInView( xShapes, GetPageView() );
289 : 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
290 : 0 : return rMarkList;
291 : : }
292 : :
293 : 0 : void SwFmDrawPage::PreUnGroup(const uno::Reference< drawing::XShapeGroup > xShapeGroup)
294 : : {
295 [ # # ]: 0 : uno::Reference< drawing::XShape > xShape( xShapeGroup, uno::UNO_QUERY);
296 [ # # ]: 0 : _SelectObjectInView( xShape, GetPageView() );
297 : 0 : }
298 : :
299 : 0 : SdrPageView* SwFmDrawPage::GetPageView()
300 : : {
301 [ # # ]: 0 : if(!pPageView)
302 : 0 : pPageView = mpView->ShowSdrPage( mpPage );
303 : 0 : return pPageView;
304 : : }
305 : :
306 : 1215 : void SwFmDrawPage::RemovePageView()
307 : : {
308 [ - + ][ # # ]: 1215 : if(pPageView && mpView)
309 : 0 : mpView->HideSdrPage();
310 : 1215 : pPageView = 0;
311 : 1215 : }
312 : :
313 : 0 : uno::Reference< uno::XInterface > SwFmDrawPage::GetInterface( SdrObject* pObj )
314 : : {
315 : 0 : uno::Reference< XInterface > xShape;
316 [ # # ]: 0 : if( pObj )
317 : : {
318 [ # # ]: 0 : SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
319 [ # # ]: 0 : SwXShape* pxShape = SwIterator<SwXShape,SwFmt>::FirstElement( *pFmt );
320 [ # # ]: 0 : if(pxShape)
321 : : {
322 [ # # ][ # # ]: 0 : xShape = *(cppu::OWeakObject*)pxShape;
323 : : }
324 : : else
325 [ # # ][ # # ]: 0 : xShape = pObj->getUnoShape();
326 : : }
327 : 0 : return xShape;
328 : : }
329 : :
330 : 116 : SdrObject* SwFmDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xShape ) throw ()
331 : : {
332 : : //TODO: stimmt das so - kann die Methode weg?
333 : 116 : return SvxFmDrawPage::_CreateSdrObject( xShape );
334 : : }
335 : :
336 : 644 : uno::Reference< drawing::XShape > SwFmDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
337 : : {
338 : 644 : uno::Reference< drawing::XShape > xRet;
339 [ + - ][ + + ]: 644 : if(pObj->ISA(SwVirtFlyDrawObj) || pObj->GetObjInventor() == SWGInventor)
[ + - ][ - + ]
[ + + ][ + - ]
340 : : {
341 [ + - ]: 168 : SwFlyDrawContact* pFlyContact = (SwFlyDrawContact*)pObj->GetUserCall();
342 [ + - ]: 168 : if(pFlyContact)
343 : : {
344 : 168 : FlyCntType eType = FLYCNTTYPE_ALL;
345 : 168 : SwFrmFmt* pFlyFmt = pFlyContact->GetFmt();
346 : 168 : SwDoc* pDoc = pFlyFmt->GetDoc();
347 : : const SwNodeIndex* pIdx;
348 [ + - ][ + - ]: 504 : if( RES_FLYFRMFMT == pFlyFmt->Which()
[ + - ][ + - ]
349 [ + - ]: 168 : && 0 != ( pIdx = pFlyFmt->GetCntnt().GetCntntIdx() )
350 [ + - ]: 168 : && pIdx->GetNodes().IsDocNodes()
351 : : )
352 : : {
353 [ + - ][ + - ]: 168 : const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
354 [ + + ]: 168 : if(!pNd->IsNoTxtNode())
355 : 24 : eType = FLYCNTTYPE_FRM;
356 [ + + ]: 144 : else if( pNd->IsGrfNode() )
357 : 18 : eType = FLYCNTTYPE_GRF;
358 [ + - ]: 126 : else if( pNd->IsOLENode() )
359 : 126 : eType = FLYCNTTYPE_OLE;
360 : : }
361 : : else
362 : : {
363 : : OSL_FAIL( "<SwFmDrawPage::_CreateShape(..)> - could not retrieve type. Thus, no shape created." );
364 : 0 : return xRet;
365 : : }
366 : : OSL_ENSURE( eType != FLYCNTTYPE_ALL, "unexpected FlyCntType value for eType" );
367 [ + - ][ + - ]: 168 : xRet = SwXFrames::GetObject( *pFlyFmt, eType );
[ + - ]
368 : : }
369 : : }
370 : : else
371 : : {
372 : : // own block - temporary object has to be destroyed before
373 : : // the delegator is set #81670#
374 : : {
375 [ + - ]: 476 : xRet = SvxFmDrawPage::_CreateShape( pObj );
376 : : }
377 [ + - ]: 476 : uno::Reference< XUnoTunnel > xShapeTunnel(xRet, uno::UNO_QUERY);
378 : : //don't create an SwXShape if it already exists
379 : 476 : SwXShape* pShape = 0;
380 [ + - ]: 476 : if(xShapeTunnel.is())
381 : : pShape = reinterpret_cast< SwXShape * >(
382 [ + - ][ + - ]: 476 : sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
[ + - ]
383 [ + - ]: 476 : if(!pShape)
384 : : {
385 [ + - ]: 476 : xShapeTunnel = 0;
386 [ + - ]: 476 : uno::Reference< uno::XInterface > xCreate(xRet, uno::UNO_QUERY);
387 [ + - ]: 476 : xRet = 0;
388 : 476 : uno::Reference< beans::XPropertySet > xPrSet;
389 [ + + ][ + - ]: 476 : if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || ( PTR_CAST(E3dScene,pObj ) != NULL ) ) )
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + + ][ + - ]
390 [ + - ][ + - ]: 3 : xPrSet = new SwXGroupShape( xCreate );
[ + - ]
391 : : else
392 [ + - ][ + - ]: 473 : xPrSet = new SwXShape( xCreate );
[ + - ]
393 [ + - ][ + - ]: 476 : xRet = uno::Reference< drawing::XShape >(xPrSet, uno::UNO_QUERY);
394 : 476 : }
395 : : }
396 : 644 : return xRet;
397 : : }
398 : :
399 : : /****************************************************************************
400 : : class SwXShapesEnumeration
401 : : ****************************************************************************/
402 : : namespace
403 : : {
404 : : class SwXShapesEnumeration
405 : : : public SwSimpleEnumeration_Base
406 : : {
407 : : private:
408 : : typedef ::std::list< ::com::sun::star::uno::Any > shapescontainer_t;
409 : : shapescontainer_t m_aShapes;
410 : : protected:
411 [ - + ]: 168 : virtual ~SwXShapesEnumeration() {};
412 : : public:
413 : : SwXShapesEnumeration(SwXDrawPage* const pDrawPage);
414 : :
415 : : //XEnumeration
416 : : virtual sal_Bool SAL_CALL hasMoreElements(void) throw(uno::RuntimeException);
417 : : virtual uno::Any SAL_CALL nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
418 : :
419 : : //XServiceInfo
420 : : virtual OUString SAL_CALL getImplementationName(void) throw(uno::RuntimeException);
421 : : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(uno::RuntimeException);
422 : : virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames(void) throw(uno::RuntimeException);
423 : : };
424 : : }
425 : :
426 : 84 : SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage)
427 [ + - ]: 84 : : m_aShapes()
428 : : {
429 [ + - ]: 84 : SolarMutexGuard aGuard;
430 : 84 : ::std::insert_iterator<shapescontainer_t> pInserter = ::std::insert_iterator<shapescontainer_t>(m_aShapes, m_aShapes.begin());
431 [ + - ]: 84 : sal_Int32 nCount = pDrawPage->getCount();
432 [ - + ]: 84 : for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++)
433 : : {
434 [ # # ][ # # ]: 0 : uno::Reference<drawing::XShape> xShape = uno::Reference<drawing::XShape>(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY);
435 [ # # ][ # # ]: 0 : *pInserter++ = uno::makeAny(xShape);
436 [ + - ]: 84 : }
437 : 84 : }
438 : :
439 : 84 : sal_Bool SwXShapesEnumeration::hasMoreElements(void) throw(uno::RuntimeException)
440 : : {
441 [ + - ]: 84 : SolarMutexGuard aGuard;
442 [ + - ]: 84 : return !m_aShapes.empty();
443 : : }
444 : :
445 : 0 : uno::Any SwXShapesEnumeration::nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
446 : : {
447 [ # # ]: 0 : SolarMutexGuard aGuard;
448 [ # # ]: 0 : if(m_aShapes.empty())
449 [ # # ]: 0 : throw container::NoSuchElementException();
450 : 0 : uno::Any aResult = *m_aShapes.begin();
451 [ # # ]: 0 : m_aShapes.pop_front();
452 [ # # ]: 0 : return aResult;
453 : : }
454 : :
455 : 0 : OUString SwXShapesEnumeration::getImplementationName(void) throw(uno::RuntimeException)
456 : : {
457 : 0 : return C2U("SwXShapeEnumeration");
458 : : }
459 : :
460 : 0 : sal_Bool SwXShapesEnumeration::supportsService(const OUString& ServiceName) throw(uno::RuntimeException)
461 : : {
462 : 0 : return C2U("com.sun.star.container.XEnumeration") == ServiceName;
463 : : }
464 : :
465 : 0 : uno::Sequence< OUString > SwXShapesEnumeration::getSupportedServiceNames(void) throw(uno::RuntimeException)
466 : : {
467 [ # # ]: 0 : return ::comphelper::makeSequence(C2U("com.sun.star.container.XEnumeration"));
468 : : }
469 : :
470 : : /****************************************************************************
471 : : class SwXDrawPage
472 : : ****************************************************************************/
473 : 84 : uno::Reference< container::XEnumeration > SwXDrawPage::createEnumeration(void) throw( uno::RuntimeException )
474 : : {
475 [ + - ]: 84 : SolarMutexGuard aGuard;
476 : : return uno::Reference< container::XEnumeration >(
477 [ + - ][ + - ]: 84 : new SwXShapesEnumeration(this));
[ + - ][ + - ]
478 : : }
479 : :
480 : 2 : rtl::OUString SwXDrawPage::getImplementationName(void) throw( uno::RuntimeException )
481 : : {
482 : 2 : return C2U("SwXDrawPage");
483 : : }
484 : :
485 : 2 : sal_Bool SwXDrawPage::supportsService(const rtl::OUString& rServiceName) throw( uno::RuntimeException )
486 : : {
487 : 2 : return C2U("com.sun.star.drawing.GenericDrawPage") == rServiceName;
488 : : }
489 : :
490 : 4 : uno::Sequence< rtl::OUString > SwXDrawPage::getSupportedServiceNames(void) throw( uno::RuntimeException )
491 : : {
492 : 4 : uno::Sequence< rtl::OUString > aRet(1);
493 [ + - ]: 4 : rtl::OUString* pArray = aRet.getArray();
494 [ + - ]: 4 : pArray[0] = C2U("com.sun.star.drawing.GenericDrawPage");
495 : 4 : return aRet;
496 : : }
497 : :
498 : 1302 : SwXDrawPage::SwXDrawPage(SwDoc* pDc) :
499 : : pDoc(pDc),
500 : 1302 : pDrawPage(0)
501 : : {
502 : 1302 : }
503 : :
504 : 1215 : SwXDrawPage::~SwXDrawPage()
505 : : {
506 [ + - ]: 1215 : if(xPageAgg.is())
507 : : {
508 : 1215 : uno::Reference< uno::XInterface > xInt;
509 [ + - ][ + - ]: 1215 : xPageAgg->setDelegator(xInt);
510 : : }
511 [ - + ]: 2430 : }
512 : :
513 : 79935 : uno::Any SwXDrawPage::queryInterface( const uno::Type& aType )
514 : : throw( uno::RuntimeException )
515 : : {
516 : 79935 : uno::Any aRet = SwXDrawPageBaseClass::queryInterface(aType);
517 [ + + ]: 79935 : if(!aRet.hasValue())
518 : : {
519 : : // secure with checking if page exists. This may not be the case
520 : : // either for new SW docs with no yet graphics usage or when
521 : : // the doc is closed and someone else still holds a UNO reference
522 : : // to the XDrawPage (in that case, pDoc is set to 0)
523 [ + - ]: 4399 : SwFmDrawPage* pPage = GetSvxPage();
524 : :
525 [ + - ]: 4399 : if(pPage)
526 : : {
527 [ + - ]: 4399 : aRet = pPage->queryAggregation(aType);
528 : : }
529 : : }
530 : 79935 : return aRet;
531 : : }
532 : :
533 : 0 : uno::Sequence< uno::Type > SwXDrawPage::getTypes() throw( uno::RuntimeException )
534 : : {
535 [ # # ]: 0 : uno::Sequence< uno::Type > aPageTypes = SwXDrawPageBaseClass::getTypes();
536 [ # # ][ # # ]: 0 : uno::Sequence< uno::Type > aSvxTypes = GetSvxPage()->getTypes();
537 : :
538 : 0 : long nIndex = aPageTypes.getLength();
539 [ # # ]: 0 : aPageTypes.realloc(aPageTypes.getLength() + aSvxTypes.getLength() + 1);
540 : :
541 [ # # ]: 0 : uno::Type* pPageTypes = aPageTypes.getArray();
542 : 0 : const uno::Type* pSvxTypes = aSvxTypes.getConstArray();
543 : : long nPos;
544 [ # # ]: 0 : for(nPos = 0; nPos < aSvxTypes.getLength(); nPos++)
545 : : {
546 : 0 : pPageTypes[nIndex++] = pSvxTypes[nPos];
547 : : }
548 [ # # ]: 0 : pPageTypes[nIndex] = ::getCppuType((uno::Reference<form::XFormsSupplier2>*)0);
549 [ # # ]: 0 : return aPageTypes;
550 : : }
551 : :
552 : 211 : sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException )
553 : : {
554 [ + - ]: 211 : SolarMutexGuard aGuard;
555 [ - + ]: 211 : if(!pDoc)
556 [ # # ]: 0 : throw uno::RuntimeException();
557 [ + - ][ - + ]: 211 : if(!pDoc->GetDrawModel())
558 : 0 : return 0;
559 : : else
560 : : {
561 [ + - ]: 211 : ((SwXDrawPage*)this)->GetSvxPage();
562 [ + - ]: 211 : return pDrawPage->getCount();
563 [ + - ]: 211 : }
564 : : }
565 : :
566 : 145 : uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex)
567 : : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
568 : : uno::RuntimeException )
569 : : {
570 [ + - ]: 145 : SolarMutexGuard aGuard;
571 [ - + ]: 145 : if(!pDoc)
572 [ # # ]: 0 : throw uno::RuntimeException();
573 [ + - ][ - + ]: 145 : if(!pDoc->GetDrawModel())
574 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
575 : :
576 [ + - ]: 145 : ((SwXDrawPage*)this)->GetSvxPage();
577 [ + + ][ + - ]: 145 : return pDrawPage->getByIndex( nIndex );
578 : : }
579 : :
580 : 2 : uno::Type SwXDrawPage::getElementType(void) throw( uno::RuntimeException )
581 : : {
582 : 2 : return ::getCppuType((const uno::Reference<drawing::XShape>*)0);
583 : : }
584 : :
585 : 2 : sal_Bool SwXDrawPage::hasElements(void) throw( uno::RuntimeException )
586 : : {
587 [ + - ]: 2 : SolarMutexGuard aGuard;
588 [ - + ]: 2 : if(!pDoc)
589 [ # # ]: 0 : throw uno::RuntimeException();
590 [ + - ][ - + ]: 2 : if(!pDoc->GetDrawModel())
591 : 0 : return sal_False;
592 : : else
593 [ + - ][ + - ]: 2 : return ((SwXDrawPage*)this)->GetSvxPage()->hasElements();
[ + - ]
594 : : }
595 : :
596 : 631 : void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
597 : : throw( uno::RuntimeException )
598 : : {
599 [ + - ]: 631 : SolarMutexGuard aGuard;
600 [ - + ]: 631 : if(!pDoc)
601 [ # # ]: 0 : throw uno::RuntimeException();
602 [ + - ]: 631 : uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShape, uno::UNO_QUERY);
603 : 631 : SwXShape* pShape = 0;
604 : 631 : SvxShape* pSvxShape = 0;
605 [ + - ]: 631 : if(xShapeTunnel.is())
606 : : {
607 : : pShape = reinterpret_cast< SwXShape * >(
608 [ + - ][ + - ]: 631 : sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
[ + - ]
609 : : pSvxShape = reinterpret_cast< SvxShape * >(
610 [ + - ][ + - ]: 631 : sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
611 : : }
612 : :
613 [ + - ][ + + ]: 631 : if(!pShape || pShape->GetRegisteredIn() || !pShape->m_bDescriptor )
[ - + ][ + + ]
614 : : {
615 [ + - ]: 60 : uno::RuntimeException aExcept;
616 [ + - ]: 60 : if(pShape)
617 [ + - ]: 60 : aExcept.Message = C2U("object already inserted");
618 : : else
619 [ # # ]: 0 : aExcept.Message = C2U("illegal object");
620 [ + - ]: 60 : throw aExcept;
621 : : }
622 : :
623 [ + - ][ + + ]: 571 : if ( pSvxShape->GetSdrObject() )
624 : : {
625 [ + - ][ + - ]: 467 : if ( pSvxShape->GetSdrObject()->IsInserted() )
[ - + ]
626 : : {
627 : 571 : return;
628 : : }
629 : : }
630 [ + - ][ + - ]: 571 : GetSvxPage()->add(xShape);
631 : :
632 [ + - ]: 571 : uno::Reference< uno::XAggregation > xAgg = pShape->GetAggregationInterface();
633 : :
634 : : OSL_ENSURE(pSvxShape, "warum gibt es hier kein SvxShape?");
635 : : //diese Position ist auf jeden Fall in 1/100 mm
636 [ + - ]: 571 : awt::Point aMM100Pos(pSvxShape->getPosition());
637 : :
638 : : //jetzt noch die Properties aus dem SwShapeDescriptor_Impl auswerten
639 : 571 : SwShapeDescriptor_Impl* pDesc = pShape->GetDescImpl();
640 : :
641 : 571 : SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
642 [ + - ]: 571 : RES_FRMATR_END-1 );
643 [ + - ]: 571 : SwFmtAnchor aAnchor( FLY_AS_CHAR );
644 : 571 : sal_Bool bOpaque = sal_False;
645 [ + - ]: 571 : if( pDesc )
646 : : {
647 [ + - ][ - + ]: 571 : if(pDesc->GetSurround())
648 [ # # ][ # # ]: 0 : aSet.Put( *pDesc->GetSurround());
649 : : //die Items sind schon in Twip gesetzt
650 [ + - ][ - + ]: 571 : if(pDesc->GetLRSpace())
651 : : {
652 [ # # ][ # # ]: 0 : aSet.Put(*pDesc->GetLRSpace());
653 : : }
654 [ + - ][ - + ]: 571 : if(pDesc->GetULSpace())
655 : : {
656 [ # # ][ # # ]: 0 : aSet.Put(*pDesc->GetULSpace());
657 : : }
658 [ + - ][ + + ]: 571 : if(pDesc->GetAnchor())
659 [ + - ][ + - ]: 20 : aAnchor = *pDesc->GetAnchor();
660 : :
661 : : // #i32349# - if no horizontal position exists, create one
662 [ + - ][ + + ]: 571 : if ( !pDesc->GetHOrient() )
663 : : {
664 [ + - ]: 563 : SwFmtHoriOrient* pHori = pDesc->GetHOrient( sal_True );
665 [ + - ]: 563 : SwTwips nHoriPos = MM100_TO_TWIP(aMM100Pos.X);
666 : 563 : pHori->SetPos( nHoriPos );
667 : : }
668 : : {
669 [ + - ][ + - ]: 571 : if(pDesc->GetHOrient()->GetHoriOrient() == text::HoriOrientation::NONE)
670 [ + - ][ + - ]: 571 : aMM100Pos.X = TWIP_TO_MM100(pDesc->GetHOrient()->GetPos());
[ + - ][ # # ]
671 [ + - ][ + - ]: 571 : aSet.Put( *pDesc->GetHOrient() );
672 : : }
673 : : // #i32349# - if no vertical position exists, create one
674 [ + - ][ + + ]: 571 : if ( !pDesc->GetVOrient() )
675 : : {
676 [ + - ]: 563 : SwFmtVertOrient* pVert = pDesc->GetVOrient( sal_True );
677 [ + - ]: 563 : SwTwips nVertPos = MM100_TO_TWIP(aMM100Pos.Y);
678 : 563 : pVert->SetPos( nVertPos );
679 : : }
680 : : {
681 [ + - ][ + - ]: 571 : if(pDesc->GetVOrient()->GetVertOrient() == text::VertOrientation::NONE)
682 [ + - ][ + - ]: 571 : aMM100Pos.Y = TWIP_TO_MM100(pDesc->GetVOrient()->GetPos());
[ + - ][ # # ]
683 [ + - ][ + - ]: 571 : aSet.Put( *pDesc->GetVOrient() );
684 : : }
685 : :
686 [ + - ][ - + ]: 571 : if(pDesc->GetSurround())
687 [ # # ][ # # ]: 0 : aSet.Put( *pDesc->GetSurround());
688 : 571 : bOpaque = pDesc->IsOpaque();
689 : :
690 : : // #i26791#
691 [ + - ][ + - ]: 571 : if ( pDesc->GetFollowTextFlow() )
692 : : {
693 [ + - ][ + - ]: 571 : aSet.Put( *pDesc->GetFollowTextFlow() );
694 : : }
695 : :
696 : : // #i28701#
697 [ + - ][ + - ]: 571 : if ( pDesc->GetWrapInfluenceOnObjPos() )
698 : : {
699 [ + - ][ + - ]: 571 : aSet.Put( *pDesc->GetWrapInfluenceOnObjPos() );
700 : : }
701 : : }
702 : :
703 [ + - ]: 571 : pSvxShape->setPosition(aMM100Pos);
704 [ + - ]: 571 : SdrObject* pObj = pSvxShape->GetSdrObject();
705 : : // #108784# - set layer of new drawing object to corresponding
706 : : // invisible layer.
707 [ + - ][ + + ]: 571 : if(FmFormInventor != pObj->GetObjInventor())
708 [ - + ][ # # ]: 104 : pObj->SetLayer( bOpaque ? pDoc->GetInvisibleHeavenId() : pDoc->GetInvisibleHellId() );
[ + - ][ + - ]
709 : : else
710 [ + - ][ + - ]: 467 : pObj->SetLayer(pDoc->GetInvisibleControlsId());
711 : :
712 [ + - ][ + - ]: 571 : SwPaM* pPam = new SwPaM(pDoc->GetNodes().GetEndOfContent());
[ + - ]
713 : 571 : SwUnoInternalPaM* pInternalPam = 0;
714 : 571 : uno::Reference< text::XTextRange > xRg;
715 [ + - ][ + + ]: 571 : if( pDesc && (xRg = pDesc->GetTextRange()).is() )
[ + + ][ + - ]
716 : : {
717 [ + - ][ + - ]: 20 : pInternalPam = new SwUnoInternalPaM(*pDoc);
718 [ + - ][ + - ]: 20 : if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg))
719 : : {
720 [ - + ][ # # ]: 20 : if(FLY_AT_FLY == aAnchor.GetAnchorId() &&
[ - + ]
721 [ # # ]: 0 : !pInternalPam->GetNode()->FindFlyStartNode())
722 : : {
723 : 0 : aAnchor.SetType(FLY_AS_CHAR);
724 : : }
725 [ + + ]: 20 : else if (FLY_AT_PAGE == aAnchor.GetAnchorId())
726 : : {
727 [ + - ][ + - ]: 14 : aAnchor.SetAnchor(pInternalPam->Start());
728 : : }
729 : : }
730 : : else
731 [ # # ]: 0 : throw uno::RuntimeException();
732 : : }
733 [ + - ][ + - ]: 551 : else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetCurrentLayout())
[ + + ][ + + ]
734 : : {
735 : 458 : SwCrsrMoveState aState( MV_SETONLYTEXT );
736 [ + - ][ + - ]: 458 : Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y));
737 [ + - ][ + - ]: 458 : pDoc->GetCurrentLayout()->GetCrsrOfst( pPam->GetPoint(), aTmp, &aState ); //swmod 080218
738 [ + - ]: 458 : aAnchor.SetAnchor( pPam->GetPoint() );
739 : :
740 : : // #i32349# - adjustment of vertical positioning
741 : : // attributes no longer needed, because its already got a default.
742 : : }
743 : : else
744 : : {
745 : 93 : aAnchor.SetType(FLY_AT_PAGE);
746 : :
747 : : // #i32349# - adjustment of vertical positioning
748 : : // attributes no longer needed, because its already got a default.
749 : : }
750 [ + - ]: 571 : aSet.Put(aAnchor);
751 : 571 : SwPaM* pTemp = pInternalPam;
752 [ + + ]: 571 : if ( !pTemp )
753 : 551 : pTemp = pPam;
754 [ + - ]: 571 : UnoActionContext aAction(pDoc);
755 [ + - ]: 571 : pDoc->Insert( *pTemp, *pObj, &aSet, NULL );
756 [ + - ]: 571 : SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
757 [ + - ]: 571 : if(pFmt)
758 [ + - ][ + - ]: 571 : pFmt->Add(pShape);
759 : 571 : pShape->m_bDescriptor = sal_False;
760 : :
761 [ + - ][ + - ]: 571 : delete pPam;
762 [ + + ][ + - ]: 631 : delete pInternalPam;
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
763 : : }
764 : :
765 : 8 : void SwXDrawPage::remove(const uno::Reference< drawing::XShape > & xShape) throw( uno::RuntimeException )
766 : : {
767 [ + - ]: 8 : SolarMutexGuard aGuard;
768 [ - + ]: 8 : if(!pDoc)
769 [ # # ]: 0 : throw uno::RuntimeException();
770 [ + - ]: 8 : uno::Reference<lang::XComponent> xComp(xShape, uno::UNO_QUERY);
771 [ + - ][ + - ]: 8 : xComp->dispose();
[ + - ]
772 : 8 : }
773 : :
774 : 0 : uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< drawing::XShapes > & xShapes) throw( uno::RuntimeException )
775 : : {
776 [ # # ]: 0 : SolarMutexGuard aGuard;
777 [ # # ][ # # ]: 0 : if(!pDoc || !xShapes.is())
[ # # ]
778 [ # # ]: 0 : throw uno::RuntimeException();
779 : 0 : uno::Reference< drawing::XShapeGroup > xRet;
780 [ # # ]: 0 : if(xPageAgg.is())
781 : : {
782 : :
783 [ # # ]: 0 : SwFmDrawPage* pPage = GetSvxPage();
784 [ # # ]: 0 : if(pPage)//kann das auch Null sein?
785 : : {
786 : : //markieren und MarkList zurueckgeben
787 [ # # ]: 0 : const SdrMarkList& rMarkList = pPage->PreGroup(xShapes);
788 [ # # ]: 0 : if ( rMarkList.GetMarkCount() > 1 )
789 : : {
790 : 0 : sal_Bool bFlyInCnt = sal_False;
791 [ # # ][ # # ]: 0 : for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i )
[ # # ]
792 : : {
793 [ # # ][ # # ]: 0 : const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
794 [ # # ]: 0 : if (FLY_AS_CHAR == ::FindFrmFmt(const_cast<SdrObject*>(
795 [ # # ][ # # ]: 0 : pObj))->GetAnchor().GetAnchorId())
796 : : {
797 : 0 : bFlyInCnt = sal_True;
798 : : }
799 : : }
800 [ # # ]: 0 : if( bFlyInCnt )
801 [ # # ]: 0 : throw uno::RuntimeException();
802 [ # # ]: 0 : if( !bFlyInCnt )
803 : : {
804 [ # # ]: 0 : UnoActionContext aContext(pDoc);
805 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
806 : :
807 [ # # ]: 0 : SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() );
808 : : pDoc->ChgAnchor(
809 : 0 : pPage->GetDrawView()->GetMarkedObjectList(),
810 : : FLY_AT_PARA/*int eAnchorId*/,
811 [ # # ]: 0 : sal_True, sal_False );
812 : :
813 [ # # ]: 0 : pPage->GetDrawView()->UnmarkAll();
814 [ # # ]: 0 : if(pContact)
815 : : {
816 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface > xInt = pPage->GetInterface( pContact->GetMaster() );
817 [ # # ][ # # ]: 0 : xRet = uno::Reference< drawing::XShapeGroup >(xInt, uno::UNO_QUERY);
818 : : }
819 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
[ # # ]
820 : : }
821 : : }
822 [ # # ]: 0 : pPage->RemovePageView();
823 : : }
824 : : }
825 [ # # ]: 0 : return xRet;
826 : : }
827 : :
828 : 0 : void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeGroup) throw( uno::RuntimeException )
829 : : {
830 [ # # ]: 0 : SolarMutexGuard aGuard;
831 [ # # ]: 0 : if(!pDoc)
832 [ # # ]: 0 : throw uno::RuntimeException();
833 [ # # ]: 0 : if(xPageAgg.is())
834 : : {
835 [ # # ]: 0 : SwFmDrawPage* pPage = GetSvxPage();
836 [ # # ]: 0 : if(pPage)//kann das auch Null sein?
837 : : {
838 [ # # ]: 0 : pPage->PreUnGroup(xShapeGroup);
839 [ # # ]: 0 : UnoActionContext aContext(pDoc);
840 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
841 : :
842 [ # # ]: 0 : pDoc->UnGroupSelection( *pPage->GetDrawView() );
843 : 0 : pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(),
844 : : FLY_AT_PARA/*int eAnchorId*/,
845 [ # # ]: 0 : sal_True, sal_False );
846 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
[ # # ]
847 : : }
848 [ # # ]: 0 : pPage->RemovePageView();
849 [ # # ]: 0 : }
850 : 0 : }
851 : :
852 : 5328 : SwFmDrawPage* SwXDrawPage::GetSvxPage()
853 : : {
854 [ + + ][ + - ]: 5328 : if(!xPageAgg.is() && pDoc)
[ + + ]
855 : : {
856 [ + - ]: 1302 : SolarMutexGuard aGuard;
857 : : // #i52858#
858 [ + - ]: 1302 : SdrModel* pModel = pDoc->GetOrCreateDrawModel();
859 [ + - ]: 1302 : SdrPage* pPage = pModel->GetPage( 0 );
860 : :
861 : : {
862 : : // waehrend des queryInterface braucht man ein Ref auf das
863 : : // Objekt, sonst wird es geloescht.
864 [ + - ]: 1302 : pDrawPage = new SwFmDrawPage(pPage);
865 [ + - ][ + - ]: 1302 : uno::Reference< drawing::XDrawPage > xPage = pDrawPage;
866 [ + - ][ + - ]: 1302 : uno::Any aAgg = xPage->queryInterface(::getCppuType((uno::Reference< uno::XAggregation >*)0));
[ + - ]
867 [ + - ][ + - ]: 1302 : if(aAgg.getValueType() == ::getCppuType((uno::Reference< uno::XAggregation >*)0))
868 [ + - ]: 1302 : xPageAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
869 : : }
870 [ + - ]: 1302 : if( xPageAgg.is() )
871 [ + - ][ + - ]: 1302 : xPageAgg->setDelegator( (cppu::OWeakObject*)this );
[ + - ][ + - ]
872 : : }
873 : 5328 : return pDrawPage;
874 : : }
875 : :
876 : : // renamed and outlined to detect where it's called
877 : 1215 : void SwXDrawPage::InvalidateSwDoc()
878 : : {
879 : 1215 : pDoc = 0;
880 : 1215 : }
881 : :
882 [ - + ][ + - ]: 741 : TYPEINIT1(SwXShape, SwClient);
883 : :
884 : : namespace
885 : : {
886 : : class theSwXShapeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXShapeUnoTunnelId > {};
887 : : }
888 : :
889 : 6758 : const uno::Sequence< sal_Int8 > & SwXShape::getUnoTunnelId()
890 : : {
891 : 6758 : return theSwXShapeUnoTunnelId::get().getSeq();
892 : : }
893 : :
894 : 5077 : sal_Int64 SAL_CALL SwXShape::getSomething( const uno::Sequence< sal_Int8 >& rId )
895 : : throw(uno::RuntimeException)
896 : : {
897 [ + - + + ]: 10154 : if( rId.getLength() == 16
[ + + ]
898 : 5077 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
899 : 5077 : rId.getConstArray(), 16 ) )
900 : : {
901 : 1205 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
902 : : }
903 : :
904 [ + - ]: 3872 : if( xShapeAgg.is() )
905 : : {
906 [ + - ]: 3872 : const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*)0 );
907 [ + - ][ + - ]: 3872 : uno::Any aAgg = xShapeAgg->queryAggregation( rTunnelType );
908 [ + - ]: 3872 : if(aAgg.getValueType() == rTunnelType)
909 : : {
910 : : uno::Reference<lang::XUnoTunnel> xAggTunnel =
911 : 3872 : *(uno::Reference<lang::XUnoTunnel>*)aAgg.getValue();
912 [ + - ]: 3872 : if(xAggTunnel.is())
913 [ + - ][ + - ]: 3872 : return xAggTunnel->getSomething(rId);
[ - + ]
914 [ - + ]: 3872 : }
915 : : }
916 : 5077 : return 0;
917 : : }
918 : : namespace
919 : : {
920 : 1045 : static void lcl_addShapePropertyEventFactories( SdrObject& _rObj, SwXShape& _rShape )
921 : : {
922 [ + - ][ + - ]: 1045 : ::svx::PPropertyValueProvider pProvider( new ::svx::PropertyValueProvider( _rShape, "AnchorType" ) );
[ + - ]
923 [ + - ][ + - ]: 1045 : _rObj.getShapePropertyChangeNotifier().registerProvider( ::svx::eTextShapeAnchorType, pProvider );
[ + - ][ + - ]
[ + - ]
924 : 1045 : }
925 : : }
926 : :
927 : :
928 : 1077 : SwXShape::SwXShape(uno::Reference< uno::XInterface > & xShape) :
929 [ + - ]: 1077 : m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)),
930 [ + - ]: 1077 : m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)),
931 : : pImplementationId(0),
932 : 0 : pImpl(new SwShapeDescriptor_Impl()),
933 [ + - ][ + - ]: 2154 : m_bDescriptor(sal_True)
934 : : {
935 [ + - ]: 1077 : if(xShape.is()) // default Ctor
936 : : {
937 [ + - ]: 1077 : const uno::Type& rAggType = ::getCppuType((const uno::Reference< uno::XAggregation >*)0);
938 : : //aAgg contains a reference of the SvxShape!
939 : : {
940 [ + - ][ + - ]: 1077 : uno::Any aAgg = xShape->queryInterface(rAggType);
941 [ + - ]: 1077 : if(aAgg.getValueType() == rAggType)
942 [ + - ]: 1077 : xShapeAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
943 : : // #i31698#
944 [ + - ]: 1077 : if ( xShapeAgg.is() )
945 : : {
946 [ + - ][ + - ]: 1077 : xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< drawing::XShape >*)0) ) >>= mxShape;
[ + - ][ + - ]
947 : : OSL_ENSURE( mxShape.is(),
948 : : "<SwXShape::SwXShape(..)> - no XShape found at <xShapeAgg>" );
949 : 1077 : }
950 : : }
951 [ + - ]: 1077 : xShape = 0;
952 : 1077 : m_refCount++;
953 [ + - ]: 1077 : if( xShapeAgg.is() )
954 [ + - ][ + - ]: 1077 : xShapeAgg->setDelegator( (cppu::OWeakObject*)this );
[ + - ]
955 : 1077 : m_refCount--;
956 : :
957 [ + - ]: 1077 : uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
958 : 1077 : SvxShape* pShape = 0;
959 [ + - ]: 1077 : if(xShapeTunnel.is())
960 : : pShape = reinterpret_cast< SvxShape * >(
961 [ + - ][ + - ]: 1077 : sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
962 : :
963 [ + - ][ + - ]: 1077 : SdrObject* pObj = pShape ? pShape->GetSdrObject() : 0;
964 [ + + ]: 1077 : if(pObj)
965 : : {
966 [ + - ]: 950 : SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
967 [ + + ]: 950 : if(pFmt)
968 [ + - ]: 185 : pFmt->Add(this);
969 : :
970 [ + - ]: 950 : lcl_addShapePropertyEventFactories( *pObj, *this );
971 : 950 : pImpl->bInitializedPropertyNotifier = true;
972 : 1077 : }
973 : : }
974 : 1077 : }
975 : :
976 : 688 : void SwXShape::AddExistingShapeToFmt( SdrObject& _rObj )
977 : : {
978 [ + - ]: 688 : SdrObjListIter aIter( _rObj, IM_DEEPNOGROUPS );
979 [ + + ]: 1691 : while ( aIter.IsMore() )
980 : : {
981 [ + - ]: 1003 : SdrObject* pCurrent = aIter.Next();
982 : : OSL_ENSURE( pCurrent, "SwXShape::AddExistingShapeToFmt: invalid object list element!" );
983 [ - + ]: 1003 : if ( !pCurrent )
984 : 0 : continue;
985 : :
986 : 1003 : SwXShape* pSwShape = NULL;
987 [ + - ][ + - ]: 1003 : uno::Reference< lang::XUnoTunnel > xShapeTunnel( pCurrent->getWeakUnoShape(), uno::UNO_QUERY );
[ + - ][ + - ]
988 [ + + ]: 1003 : if ( xShapeTunnel.is() )
989 : : pSwShape = reinterpret_cast< SwXShape * >(
990 [ + - ][ + - ]: 562 : sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething( SwXShape::getUnoTunnelId() ) ) );
[ + - ]
991 [ + + ]: 1003 : if ( pSwShape )
992 : : {
993 [ + - ]: 562 : if ( pSwShape->m_bDescriptor )
994 : : {
995 [ + - ]: 562 : SwFrmFmt* pFmt = ::FindFrmFmt( const_cast< SdrObject* >( pCurrent ) );
996 [ + - ]: 562 : if ( pFmt )
997 [ + - ][ + - ]: 562 : pFmt->Add( pSwShape );
998 : 562 : pSwShape->m_bDescriptor = sal_False;
999 : : }
1000 : :
1001 [ + + ]: 562 : if ( !pSwShape->pImpl->bInitializedPropertyNotifier )
1002 : : {
1003 [ + - ]: 95 : lcl_addShapePropertyEventFactories( *pCurrent, *pSwShape );
1004 : 95 : pSwShape->pImpl->bInitializedPropertyNotifier = true;
1005 : : }
1006 : : }
1007 : 1691 : }
1008 : 688 : }
1009 : :
1010 [ + - ]: 1077 : SwXShape::~SwXShape()
1011 : : {
1012 [ + - ]: 1077 : if (xShapeAgg.is())
1013 : : {
1014 : 1077 : uno::Reference< uno::XInterface > xRef;
1015 [ + - ][ + - ]: 1077 : xShapeAgg->setDelegator(xRef);
1016 : : }
1017 [ + - ][ + - ]: 1077 : delete pImpl;
1018 [ - + ]: 2142 : }
1019 : :
1020 : 23241 : uno::Any SwXShape::queryInterface( const uno::Type& aType ) throw( uno::RuntimeException )
1021 : : {
1022 : 23241 : uno::Any aRet = SwXShapeBaseClass::queryInterface(aType);
1023 : : // #i53320# - follow-up of #i31698#
1024 : : // interface drawing::XShape is overloaded. Thus, provide
1025 : : // correct object instance.
1026 [ + - ][ + + ]: 23241 : if(!aRet.hasValue() && xShapeAgg.is())
[ + + ]
1027 : : {
1028 [ + - ][ - + ]: 885 : if(aType == ::getCppuType((uno::Reference<XShape>*)0))
1029 [ # # ][ # # ]: 0 : aRet <<= uno::Reference<XShape>(this);
1030 : : else
1031 [ + - ][ + - ]: 885 : aRet = xShapeAgg->queryAggregation(aType);
1032 : : }
1033 : 23241 : return aRet;
1034 : : }
1035 : :
1036 : 0 : uno::Sequence< uno::Type > SwXShape::getTypes( ) throw(uno::RuntimeException)
1037 : : {
1038 : 0 : uno::Sequence< uno::Type > aRet = SwXShapeBaseClass::getTypes();
1039 [ # # ]: 0 : if(xShapeAgg.is())
1040 : : {
1041 [ # # ][ # # ]: 0 : uno::Any aProv = xShapeAgg->queryAggregation(::getCppuType((uno::Reference< XTypeProvider >*)0));
[ # # ]
1042 [ # # ]: 0 : if(aProv.hasValue())
1043 : : {
1044 : 0 : uno::Reference< XTypeProvider > xAggProv;
1045 [ # # ]: 0 : aProv >>= xAggProv;
1046 [ # # ][ # # ]: 0 : uno::Sequence< uno::Type > aAggTypes = xAggProv->getTypes();
1047 : 0 : const uno::Type* pAggTypes = aAggTypes.getConstArray();
1048 : 0 : long nIndex = aRet.getLength();
1049 : :
1050 [ # # ]: 0 : aRet.realloc(nIndex + aAggTypes.getLength());
1051 [ # # ]: 0 : uno::Type* pBaseTypes = aRet.getArray();
1052 : :
1053 [ # # ]: 0 : for(long i = 0; i < aAggTypes.getLength(); i++)
1054 [ # # ]: 0 : pBaseTypes[nIndex++] = pAggTypes[i];
1055 : 0 : }
1056 : : }
1057 : 0 : return aRet;
1058 : : }
1059 : :
1060 : 0 : uno::Sequence< sal_Int8 > SwXShape::getImplementationId( ) throw(uno::RuntimeException)
1061 : : {
1062 [ # # ]: 0 : SolarMutexGuard aGuard;
1063 : : // do we need to compute the implementation id for this instance?
1064 [ # # ][ # # ]: 0 : if( !pImplementationId && xShapeAgg.is())
[ # # ]
1065 : : {
1066 : 0 : uno::Reference< XShape > xAggShape;
1067 [ # # ][ # # ]: 0 : xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< XShape >*)0) ) >>= xAggShape;
[ # # ][ # # ]
1068 : :
1069 [ # # ]: 0 : if( xAggShape.is() )
1070 : : {
1071 [ # # ][ # # ]: 0 : const rtl::OUString aShapeType( xAggShape->getShapeType() );
1072 : : // did we already compute an implementation id for the agregated shape type?
1073 [ # # ]: 0 : SwShapeImplementationIdMap::iterator aIter( aImplementationIdMap.find(aShapeType ) );
1074 [ # # ]: 0 : if( aIter == aImplementationIdMap.end() )
1075 : : {
1076 : : // we need to create a new implementation id for this
1077 : : // note: this memory is not free'd until application exists
1078 : : // but since we have a fixed set of shapetypes and the
1079 : : // memory will be reused this is ok.
1080 [ # # ]: 0 : pImplementationId = new uno::Sequence< sal_Int8 >( 16 );
1081 [ # # ][ # # ]: 0 : rtl_createUuid( (sal_uInt8 *) pImplementationId->getArray(), 0, sal_True );
1082 [ # # ]: 0 : aImplementationIdMap[ aShapeType ] = pImplementationId;
1083 : : }
1084 : : else
1085 : : {
1086 : : // use the already computed implementation id
1087 : 0 : pImplementationId = (*aIter).second;
1088 : 0 : }
1089 : 0 : }
1090 : : }
1091 [ # # ]: 0 : if( NULL == pImplementationId )
1092 : : {
1093 : : OSL_FAIL( "Could not create an implementation id for a SwXShape!" );
1094 [ # # ]: 0 : return uno::Sequence< sal_Int8 > ();
1095 : : }
1096 : : else
1097 : : {
1098 [ # # ]: 0 : return *pImplementationId;
1099 [ # # ]: 0 : }
1100 : : }
1101 : :
1102 : 203 : uno::Reference< beans::XPropertySetInfo > SwXShape::getPropertySetInfo(void) throw( uno::RuntimeException )
1103 : : {
1104 [ + - ]: 203 : SolarMutexGuard aGuard;
1105 : 203 : uno::Reference< beans::XPropertySetInfo > aRet;
1106 [ + - ]: 203 : if(xShapeAgg.is())
1107 : : {
1108 [ + - ]: 203 : const uno::Type& rPropSetType = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1109 [ + - ][ + - ]: 203 : uno::Any aPSet = xShapeAgg->queryAggregation( rPropSetType );
1110 [ + - ][ + - ]: 203 : if(aPSet.getValueType() == rPropSetType && aPSet.getValue())
[ + - ]
1111 : : {
1112 : : uno::Reference< beans::XPropertySet > xPrSet =
1113 : 203 : *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
1114 [ + - ][ + - ]: 203 : uno::Reference< beans::XPropertySetInfo > xInfo = xPrSet->getPropertySetInfo();
1115 : : // PropertySetInfo verlaengern!
1116 [ + - ][ + - ]: 203 : const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
1117 [ + - ][ + - ]: 203 : aRet = new SfxExtItemPropertySetInfo( m_pPropertyMapEntries, aPropSeq );
[ + - ][ + - ]
1118 : 203 : }
1119 : : }
1120 [ - + ]: 203 : if(!aRet.is())
1121 [ # # ][ # # ]: 0 : aRet = m_pPropSet->getPropertySetInfo();
1122 [ + - ]: 203 : return aRet;
1123 : : }
1124 : :
1125 : 1286 : void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::Any& aValue)
1126 : : throw( beans::UnknownPropertyException, beans::PropertyVetoException,
1127 : : lang::IllegalArgumentException, lang::WrappedTargetException,
1128 : : uno::RuntimeException)
1129 : : {
1130 [ + - ]: 1286 : SolarMutexGuard aGuard;
1131 : 1286 : SwFrmFmt* pFmt = GetFrmFmt();
1132 [ + - ]: 1286 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1133 [ + - ]: 1286 : if(xShapeAgg.is())
1134 : : {
1135 [ + + ]: 1286 : if(pEntry)
1136 : : {
1137 [ - + ]: 485 : if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1138 [ # # ][ # # ]: 0 : throw beans::PropertyVetoException ( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
1139 : : //mit Layout kann der Anker umgesetzt werden, ohne dass sich die Position aendert
1140 [ + + ]: 485 : if(pFmt)
1141 : : {
1142 [ + - ]: 416 : SwAttrSet aSet(pFmt->GetAttrSet());
1143 : 416 : SwDoc* pDoc = pFmt->GetDoc();
1144 [ - + ][ + + ]: 416 : if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId)
1145 : : {
1146 : 0 : sal_Bool bDone = sal_True;
1147 : 0 : uno::Reference<text::XTextFrame> xFrame;
1148 [ # # ][ # # ]: 0 : if(aValue >>= xFrame)
1149 : : {
1150 [ # # ]: 0 : uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
1151 : 0 : SwXFrame* pFrame = xTunnel.is() ?
1152 : : reinterpret_cast< SwXFrame * >(
1153 [ # # ][ # # ]: 0 : sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
[ # # ]
1154 [ # # ]: 0 : : 0;
1155 [ # # ][ # # ]: 0 : if(pFrame && pFrame->GetFrmFmt() &&
[ # # # # ]
[ # # ]
1156 [ # # ]: 0 : pFrame->GetFrmFmt()->GetDoc() == pDoc)
1157 : : {
1158 [ # # ]: 0 : UnoActionContext aCtx(pDoc);
1159 : 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(),
1160 [ # # ]: 0 : RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
1161 : 0 : aItemSet.SetParent(&pFmt->GetAttrSet());
1162 [ # # ][ # # ]: 0 : SwFmtAnchor aAnchor = (const SwFmtAnchor&)aItemSet.Get(pEntry->nWID);
1163 [ # # ][ # # ]: 0 : SwPosition aPos(*pFrame->GetFrmFmt()->GetCntnt().GetCntntIdx());
[ # # ]
1164 [ # # ]: 0 : aAnchor.SetAnchor(&aPos);
1165 : 0 : aAnchor.SetType(FLY_AT_FLY);
1166 [ # # ]: 0 : aItemSet.Put(aAnchor);
1167 [ # # ]: 0 : pFmt->SetFmtAttr(aItemSet);
1168 [ # # ][ # # ]: 0 : bDone = sal_True;
[ # # ][ # # ]
1169 : 0 : }
1170 : : }
1171 [ # # ]: 0 : if(!bDone)
1172 [ # # ]: 0 : throw lang::IllegalArgumentException();
1173 : : }
1174 [ + + ]: 416 : else if(RES_OPAQUE == pEntry->nWID)
1175 : : {
1176 [ + - ]: 27 : SvxShape* pSvxShape = GetSvxShape();
1177 : : SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
1178 [ + - ]: 27 : if(pSvxShape)
1179 : : {
1180 [ + - ]: 27 : SdrObject* pObj = pSvxShape->GetSdrObject();
1181 : : // set layer of new drawing
1182 : : // object to corresponding invisible layer.
1183 [ + - ][ + - ]: 27 : bool bIsVisible = pDoc->IsVisibleLayerId( pObj->GetLayer() );
1184 [ + - ][ + - ]: 27 : if(FmFormInventor != pObj->GetObjInventor())
1185 : : {
1186 : 27 : pObj->SetLayer( *(sal_Bool*)aValue.getValue()
1187 [ # # ][ + - ]: 21 : ? ( bIsVisible ? pDoc->GetHeavenId() : pDoc->GetInvisibleHeavenId() )
1188 [ - + ][ - + ]: 48 : : ( bIsVisible ? pDoc->GetHellId() : pDoc->GetInvisibleHellId() ));
[ # # ][ + - ]
[ + - ][ + + ]
1189 : : }
1190 : : else
1191 : : {
1192 [ # # ][ # # ]: 0 : pObj->SetLayer( bIsVisible ? pDoc->GetControlsId() : pDoc->GetInvisibleControlsId());
[ # # ][ # # ]
1193 : : }
1194 : :
1195 : : }
1196 : :
1197 : : }
1198 : : // #i26791# - special handling for property FN_TEXT_RANGE
1199 [ + + ]: 389 : else if ( FN_TEXT_RANGE == pEntry->nWID )
1200 : : {
1201 [ + - ][ + - ]: 63 : SwFmtAnchor aAnchor( static_cast<const SwFmtAnchor&>(aSet.Get( RES_ANCHOR )) );
1202 [ - + ]: 63 : if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
1203 : : {
1204 : : // set property <TextRange> not valid for to-page anchored shapes
1205 [ # # ]: 0 : throw lang::IllegalArgumentException();
1206 : : }
1207 : : else
1208 : : {
1209 : : SwUnoInternalPaM* pInternalPam =
1210 [ + - ][ + - ]: 63 : new SwUnoInternalPaM( *(pFmt->GetDoc()) );
1211 : 63 : uno::Reference< text::XTextRange > xRg;
1212 [ + - ]: 63 : aValue >>= xRg;
1213 [ + - ][ + - ]: 63 : if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
1214 : : {
1215 [ + + ]: 63 : if (aAnchor.GetAnchorId() == FLY_AS_CHAR)
1216 : : {
1217 : : //delete old SwFmtFlyCnt
1218 : : //With AnchorAsCharacter the current TxtAttribute has to be deleted.
1219 : : //Tbis removes the frame format too.
1220 : : //To prevent this the connection between format and attribute has to be broken before.
1221 [ + - ]: 12 : const SwPosition *pPos = aAnchor.GetCntntAnchor();
1222 : 12 : SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
1223 : : SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
1224 : 12 : const xub_StrLen nIdx = pPos->nContent.GetIndex();
1225 : : SwTxtAttr * const pHnt =
1226 : : pTxtNode->GetTxtAttrForCharAt(
1227 [ + - ]: 12 : nIdx, RES_TXTATR_FLYCNT );
1228 : : SAL_WARN_IF( !pHnt || pHnt->Which() != RES_TXTATR_FLYCNT,
1229 : : "sw.uno", "Missing FlyInCnt-Hint." );
1230 : : SAL_WARN_IF( !pHnt || pHnt->GetFlyCnt().GetFrmFmt() != pFmt,
1231 : : "sw.uno", "Wrong TxtFlyCnt-Hint." );
1232 : 12 : const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
1233 : 12 : .SetFlyFmt();
1234 : :
1235 : : //The connection is removed now the attribute can be deleted.
1236 : : pTxtNode->DeleteAttributes(
1237 [ + - ]: 12 : RES_TXTATR_FLYCNT, nIdx );
1238 : : //create a new one
1239 : 12 : SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode();
1240 : : SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TxtNode." );
1241 [ + - ]: 12 : SwFmtFlyCnt aFmt( pFmt );
1242 : 12 : pNd->InsertItem(aFmt, pInternalPam->GetPoint()
1243 [ + - ][ + - ]: 12 : ->nContent.GetIndex(), 0 );
1244 : : }
1245 : : else
1246 : : {
1247 [ + - ]: 51 : aAnchor.SetAnchor( pInternalPam->GetPoint() );
1248 [ + - ]: 51 : aSet.Put(aAnchor);
1249 [ + - ]: 51 : pFmt->SetFmtAttr(aSet);
1250 : : }
1251 : : }
1252 : : else
1253 : : {
1254 [ # # ]: 0 : throw uno::RuntimeException();
1255 : : }
1256 [ + - ][ + - ]: 63 : delete pInternalPam;
1257 [ + - ]: 63 : }
1258 : : }
1259 : : // #i28749#
1260 [ + + ]: 326 : else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
1261 : : {
1262 : 6 : sal_Int16 nPositionLayoutDir = 0;
1263 : 6 : aValue >>= nPositionLayoutDir;
1264 [ + - ]: 6 : pFmt->SetPositionLayoutDir( nPositionLayoutDir );
1265 : : }
1266 [ + - ][ - + ]: 320 : else if( pDoc->GetCurrentLayout()) //swmod 080218
1267 : : {
1268 [ # # ]: 0 : UnoActionContext aCtx(pDoc);
1269 [ # # ][ # # ]: 0 : if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
1270 : : {
1271 [ # # ]: 0 : SdrObject* pObj = pFmt->FindSdrObject();
1272 [ # # ]: 0 : SdrMarkList aList;
1273 [ # # ]: 0 : SdrMark aMark(pObj);
1274 [ # # ]: 0 : aList.InsertEntry(aMark);
1275 : 0 : sal_Int32 nAnchor = 0;
1276 : 0 : cppu::enum2int( nAnchor, aValue );
1277 : : pDoc->ChgAnchor( aList, (RndStdIds)nAnchor,
1278 [ # # ][ # # ]: 0 : sal_False, sal_True );
[ # # ]
1279 : : }
1280 : : else
1281 : : {
1282 [ # # ]: 0 : m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1283 [ # # ]: 0 : pFmt->SetFmtAttr(aSet);
1284 [ # # ]: 0 : }
1285 : : }
1286 : : else
1287 : : {
1288 [ + - ]: 320 : m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
1289 : :
1290 [ + + ][ + + ]: 320 : if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
1291 : : {
1292 : 75 : bool bSetAttr = true;
1293 [ + - ]: 75 : sal_Int32 eNewAnchor = SWUnoHelper::GetEnumAsInt32( aValue );
1294 : :
1295 : : //if old anchor was in_cntnt the related text attribute has to be removed
1296 [ + - ]: 75 : const SwFmtAnchor& rOldAnchor = pFmt->GetAnchor();
1297 : 75 : RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
1298 [ + - ]: 75 : SdrObject* pObj = pFmt->FindSdrObject();
1299 [ + - ]: 75 : SwFrmFmt *pFlyFmt = FindFrmFmt( pObj );
1300 [ + - ]: 75 : pFlyFmt->DelFrms();
1301 [ + + ][ - + ]: 75 : if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
1302 : : (FLY_AS_CHAR == eOldAnchorId))
1303 : : {
1304 : : //With AnchorAsCharacter the current TxtAttribute has to be deleted.
1305 : : //Tbis removes the frame format too.
1306 : : //To prevent this the connection between format and attribute has to be broken before.
1307 [ # # ]: 0 : const SwPosition *pPos = rOldAnchor.GetCntntAnchor();
1308 : 0 : SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
1309 : : SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
1310 : 0 : const xub_StrLen nIdx = pPos->nContent.GetIndex();
1311 : : SwTxtAttr * const pHnt =
1312 : : pTxtNode->GetTxtAttrForCharAt(
1313 [ # # ]: 0 : nIdx, RES_TXTATR_FLYCNT );
1314 : : SAL_WARN_IF( !pHnt || pHnt->Which() != RES_TXTATR_FLYCNT,
1315 : : "sw.uno", "Missing FlyInCnt-Hint." );
1316 : : SAL_WARN_IF( !pHnt || pHnt->GetFlyCnt().GetFrmFmt() != pFlyFmt,
1317 : : "sw.uno", "Wrong TxtFlyCnt-Hint." );
1318 : 0 : const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
1319 : 0 : .SetFlyFmt();
1320 : :
1321 : : //The connection is removed now the attribute can be deleted.
1322 [ # # ]: 0 : pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
1323 : : }
1324 [ + + ][ + + ]: 75 : else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
1325 : : (FLY_AT_PAGE == eOldAnchorId))
1326 : : {
1327 [ + - ][ + - ]: 60 : SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) );
[ + - ]
1328 : : //if the fly has been anchored at page then it needs to be connected
1329 : : //to the content position
1330 [ + - ][ + - ]: 60 : SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
1331 [ + - ][ - + ]: 60 : if( pDoc->GetCurrentLayout() )
1332 : : {
1333 : 0 : SwCrsrMoveState aState( MV_SETONLYTEXT );
1334 [ # # ]: 0 : Point aTmp( pObj->GetSnapRect().TopLeft() );
1335 [ # # ][ # # ]: 0 : pDoc->GetCurrentLayout()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
1336 : : }
1337 : : else
1338 : : {
1339 : : //without access to the layout the last node of the body will be used as anchor position
1340 [ + - ]: 60 : aPam.Move( fnMoveBackward, fnGoDoc );
1341 : : }
1342 : : //anchor position has to be inserted after the text attribute has been inserted
1343 [ + - ]: 60 : aNewAnchor.SetAnchor( aPam.GetPoint() );
1344 [ + - ]: 60 : aSet.Put( aNewAnchor );
1345 [ + - ]: 60 : pFmt->SetFmtAttr(aSet);
1346 [ + - ][ + - ]: 60 : bSetAttr = false;
1347 : : }
1348 [ + + ][ + - ]: 75 : if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
1349 : : (FLY_AS_CHAR != eOldAnchorId))
1350 : : {
1351 [ + - ][ + - ]: 9 : SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
1352 [ + - ][ - + ]: 9 : if( pDoc->GetCurrentLayout() )
1353 : : {
1354 : 0 : SwCrsrMoveState aState( MV_SETONLYTEXT );
1355 [ # # ]: 0 : Point aTmp( pObj->GetSnapRect().TopLeft() );
1356 [ # # ][ # # ]: 0 : pDoc->GetCurrentLayout()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
1357 : : }
1358 : : else
1359 : : {
1360 : : //without access to the layout the last node of the body will be used as anchor position
1361 [ + - ]: 9 : aPam.Move( fnMoveBackward, fnGoDoc );
1362 : : }
1363 : : //the RES_TXTATR_FLYCNT needs to be added now
1364 : 9 : SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
1365 : : SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
1366 [ + - ]: 9 : SwFmtFlyCnt aFmt( pFlyFmt );
1367 : : pNd->InsertItem(aFmt,
1368 [ + - ][ + - ]: 9 : aPam.GetPoint()->nContent.GetIndex(), 0 );
[ + - ]
1369 : : //aPam.GetPoint()->nContent--;
1370 : : }
1371 [ + + ]: 75 : if( bSetAttr )
1372 [ + - ]: 75 : pFmt->SetFmtAttr(aSet);
1373 : : }
1374 : : else
1375 [ + - ]: 245 : pFmt->SetFmtAttr(aSet);
1376 [ + - ]: 416 : }
1377 : : }
1378 : : else
1379 : : {
1380 : 69 : SfxPoolItem* pItem = 0;
1381 [ + + + - : 69 : switch(pEntry->nWID)
- - + - -
- - - ]
1382 : : {
1383 : : case RES_ANCHOR:
1384 [ + - ]: 23 : pItem = pImpl->GetAnchor(sal_True);
1385 : 23 : break;
1386 : : case RES_HORI_ORIENT:
1387 [ + - ]: 10 : pItem = pImpl->GetHOrient(sal_True);
1388 : 10 : break;
1389 : : case RES_VERT_ORIENT:
1390 [ + - ]: 13 : pItem = pImpl->GetVOrient(sal_True);
1391 : 13 : break;
1392 : : case RES_LR_SPACE:
1393 [ # # ]: 0 : pItem = pImpl->GetLRSpace(sal_True);
1394 : 0 : break;
1395 : : case RES_UL_SPACE:
1396 [ # # ]: 0 : pItem = pImpl->GetULSpace(sal_True);
1397 : 0 : break;
1398 : : case RES_SURROUND:
1399 [ # # ]: 0 : pItem = pImpl->GetSurround(sal_True);
1400 : 0 : break;
1401 : : case FN_TEXT_RANGE:
1402 : : {
1403 : : const uno::Type rTextRangeType =
1404 [ + - ]: 23 : ::getCppuType((uno::Reference< text::XTextRange>*)0);
1405 [ + - ]: 23 : if(aValue.getValueType() == rTextRangeType)
1406 : : {
1407 : 23 : uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
1408 [ + - ]: 23 : rRange = *(uno::Reference< text::XTextRange > *)aValue.getValue();
1409 : 23 : }
1410 : : }
1411 : 23 : break;
1412 : : case RES_OPAQUE :
1413 : 0 : pImpl->SetOpaque(*(sal_Bool*)aValue.getValue());
1414 : 0 : break;
1415 : : // #i26791#
1416 : : case RES_FOLLOW_TEXT_FLOW:
1417 : : {
1418 [ # # ]: 0 : pItem = pImpl->GetFollowTextFlow( sal_True );
1419 : : }
1420 : 0 : break;
1421 : : // #i28701#
1422 : : case RES_WRAP_INFLUENCE_ON_OBJPOS:
1423 : : {
1424 [ # # ]: 0 : pItem = pImpl->GetWrapInfluenceOnObjPos( sal_True );
1425 : : }
1426 : 0 : break;
1427 : : // #i28749#
1428 : : case FN_SHAPE_POSITION_LAYOUT_DIR :
1429 : : {
1430 : 0 : sal_Int16 nPositionLayoutDir = 0;
1431 : 0 : aValue >>= nPositionLayoutDir;
1432 : 0 : pImpl->SetPositionLayoutDir( nPositionLayoutDir );
1433 : : }
1434 : 0 : break;
1435 : : }
1436 [ + + ]: 69 : if(pItem)
1437 [ + - ]: 46 : ((SfxPoolItem*)pItem)->PutValue(aValue, pEntry->nMemberId);
1438 : : }
1439 : : }
1440 : : else
1441 : : {
1442 : 801 : uno::Reference< beans::XPropertySet > xPrSet;
1443 : : const uno::Type& rPSetType =
1444 [ + - ]: 801 : ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1445 [ + - ][ + - ]: 801 : uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
1446 [ + - ][ - + ]: 801 : if(aPSet.getValueType() != rPSetType || !aPSet.getValue())
[ - + ]
1447 [ # # ]: 0 : throw uno::RuntimeException();
1448 [ + - ]: 801 : xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
1449 : : // #i31698# - setting the caption point of a
1450 : : // caption object doesn't have to change the object position.
1451 : : // Thus, keep the position, before the caption point is set and
1452 : : // restore it afterwards.
1453 : 801 : awt::Point aKeepedPosition( 0, 0 );
1454 [ # # ][ # # ]: 801 : if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
[ - + ]
[ - + # # ]
[ - + ]
1455 : : {
1456 [ # # ]: 0 : aKeepedPosition = getPosition();
1457 : : }
1458 [ + + ][ + - ]: 801 : if( pFmt && pFmt->GetDoc()->GetCurrentViewShell() ) //swmod 071108//swmod 071225
[ - + ][ - + ]
1459 : : {
1460 [ # # ]: 0 : UnoActionContext aCtx(pFmt->GetDoc());
1461 [ # # ][ # # ]: 0 : xPrSet->setPropertyValue(rPropertyName, aValue);
[ # # ]
1462 : : }
1463 : : else
1464 [ + - ][ + - ]: 801 : xPrSet->setPropertyValue(rPropertyName, aValue);
1465 : : // #i31698# - restore object position, if caption point is set.
1466 [ - + ][ # # ]: 801 : if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
[ # # ][ - + ]
[ - + # # ]
1467 : : {
1468 [ # # ]: 0 : setPosition( aKeepedPosition );
1469 : 801 : }
1470 : : }
1471 [ + - ]: 1286 : }
1472 : 1286 : }
1473 : :
1474 : 872 : uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName)
1475 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1476 : : uno::RuntimeException )
1477 : : {
1478 [ + - ]: 872 : SolarMutexGuard aGuard;
1479 : 872 : uno::Any aRet;
1480 : 872 : SwFrmFmt* pFmt = GetFrmFmt();
1481 [ + - ]: 872 : if(xShapeAgg.is())
1482 : : {
1483 [ + - ]: 872 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1484 [ + + ]: 872 : if(pEntry)
1485 : : {
1486 [ + + ]: 713 : if(pFmt)
1487 : : {
1488 [ + + ]: 315 : if(RES_OPAQUE == pEntry->nWID)
1489 : : {
1490 [ + - ]: 3 : SvxShape* pSvxShape = GetSvxShape();
1491 : : OSL_ENSURE(pSvxShape, "No SvxShape found!");
1492 [ + - ]: 3 : if(pSvxShape)
1493 : : {
1494 [ + - ]: 3 : SdrObject* pObj = pSvxShape->GetSdrObject();
1495 : : // consider invisible layers
1496 : : sal_Bool bOpaque =
1497 [ + - ][ + - ]: 3 : ( pObj->GetLayer() != pFmt->GetDoc()->GetHellId() &&
1498 [ - + ][ # # ]: 3 : pObj->GetLayer() != pFmt->GetDoc()->GetInvisibleHellId() );
[ # # ][ # # ]
1499 [ + - ]: 3 : aRet.setValue(&bOpaque, ::getBooleanCppuType());
1500 : : }
1501 : : }
1502 [ + + ]: 312 : else if(FN_ANCHOR_POSITION == pEntry->nWID)
1503 : : {
1504 [ + - ]: 9 : SvxShape* pSvxShape = GetSvxShape();
1505 : : OSL_ENSURE(pSvxShape, "No SvxShape found!");
1506 [ + - ]: 9 : if(pSvxShape)
1507 : : {
1508 [ + - ]: 9 : SdrObject* pObj = pSvxShape->GetSdrObject();
1509 [ + - ]: 9 : Point aPt = pObj->GetAnchorPos();
1510 : 18 : awt::Point aPoint( TWIP_TO_MM100( aPt.X() ),
1511 [ + - ][ + - ]: 27 : TWIP_TO_MM100( aPt.Y() ) );
1512 [ + - ]: 9 : aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
1513 : : }
1514 : : }
1515 : : // #i26791# - special handling for FN_TEXT_RANGE
1516 [ - + ]: 303 : else if ( FN_TEXT_RANGE == pEntry->nWID )
1517 : : {
1518 [ # # ][ # # ]: 0 : const SwFmtAnchor aAnchor = pFmt->GetAnchor();
1519 [ # # ]: 0 : if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
1520 : : {
1521 : : // return nothing, because property <TextRange> isn't
1522 : : // valid for to-page anchored shapes
1523 : 0 : uno::Any aAny;
1524 : 0 : aRet = aAny;
1525 : : }
1526 : : else
1527 : : {
1528 [ # # ][ # # ]: 0 : if ( aAnchor.GetCntntAnchor() )
1529 : : {
1530 : : const uno::Reference< text::XTextRange > xTextRange
1531 : : = SwXTextRange::CreateXTextRange(
1532 : 0 : *pFmt->GetDoc(),
1533 [ # # ]: 0 : *aAnchor.GetCntntAnchor(),
1534 [ # # ]: 0 : 0L );
1535 [ # # ]: 0 : aRet.setValue(&xTextRange, ::getCppuType((uno::Reference<text::XTextRange>*)0));
1536 : : }
1537 : : else
1538 : : {
1539 : : // return nothing
1540 : 0 : uno::Any aAny;
1541 : 0 : aRet = aAny;
1542 : : }
1543 [ # # ]: 0 : }
1544 : : }
1545 : : // #i28749#
1546 [ - + ]: 303 : else if ( FN_SHAPE_TRANSFORMATION_IN_HORI_L2R == pEntry->nWID )
1547 : : {
1548 : : // get property <::drawing::Shape::Transformation>
1549 : : // without conversion to layout direction as below
1550 [ # # ][ # # ]: 0 : aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")) );
1551 : : }
1552 [ - + ]: 303 : else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
1553 : : {
1554 [ # # ][ # # ]: 0 : aRet <<= pFmt->GetPositionLayoutDir();
1555 : : }
1556 : : // #i36248#
1557 [ - + ]: 303 : else if ( FN_SHAPE_STARTPOSITION_IN_HORI_L2R == pEntry->nWID )
1558 : : {
1559 : : // get property <::drawing::Shape::StartPosition>
1560 : : // without conversion to layout direction as below
1561 [ # # ][ # # ]: 0 : aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")) );
1562 : : }
1563 [ - + ]: 303 : else if ( FN_SHAPE_ENDPOSITION_IN_HORI_L2R == pEntry->nWID )
1564 : : {
1565 : : // get property <::drawing::Shape::EndPosition>
1566 : : // without conversion to layout direction as below
1567 [ # # ][ # # ]: 0 : aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")) );
1568 : : }
1569 : : else
1570 : : {
1571 : 303 : const SwAttrSet& rSet = pFmt->GetAttrSet();
1572 [ + - ]: 303 : m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1573 : : }
1574 : : }
1575 : : else
1576 : : {
1577 : 398 : SfxPoolItem* pItem = 0;
1578 [ + + + - : 398 : switch(pEntry->nWID)
- - - - -
- - - - -
- - ]
1579 : : {
1580 : : case RES_ANCHOR:
1581 [ + - ]: 126 : pItem = pImpl->GetAnchor();
1582 : 126 : break;
1583 : : case RES_HORI_ORIENT:
1584 [ + - ]: 136 : pItem = pImpl->GetHOrient();
1585 : 136 : break;
1586 : : case RES_VERT_ORIENT:
1587 [ + - ]: 136 : pItem = pImpl->GetVOrient();
1588 : 136 : break;
1589 : : case RES_LR_SPACE:
1590 [ # # ]: 0 : pItem = pImpl->GetLRSpace();
1591 : 0 : break;
1592 : : case RES_UL_SPACE:
1593 [ # # ]: 0 : pItem = pImpl->GetULSpace();
1594 : 0 : break;
1595 : : case RES_SURROUND:
1596 [ # # ]: 0 : pItem = pImpl->GetSurround();
1597 : 0 : break;
1598 : : case FN_TEXT_RANGE :
1599 [ # # ]: 0 : aRet.setValue(&pImpl->GetTextRange(), ::getCppuType((uno::Reference<text::XTextRange>*)0));
1600 : 0 : break;
1601 : : case RES_OPAQUE :
1602 [ # # ]: 0 : aRet.setValue(&pImpl->GetOpaque(), ::getBooleanCppuType());
1603 : 0 : break;
1604 : : case FN_ANCHOR_POSITION :
1605 : : {
1606 : 0 : awt::Point aPoint;
1607 [ # # ]: 0 : aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
1608 : : }
1609 : 0 : break;
1610 : : // #i26791#
1611 : : case RES_FOLLOW_TEXT_FLOW :
1612 : : {
1613 [ # # ]: 0 : pItem = pImpl->GetFollowTextFlow();
1614 : : }
1615 : 0 : break;
1616 : : // #i28701#
1617 : : case RES_WRAP_INFLUENCE_ON_OBJPOS:
1618 : : {
1619 [ # # ]: 0 : pItem = pImpl->GetWrapInfluenceOnObjPos();
1620 : : }
1621 : 0 : break;
1622 : : // #i28749#
1623 : : case FN_SHAPE_TRANSFORMATION_IN_HORI_L2R:
1624 : : {
1625 : : // get property <::drawing::Shape::Transformation>
1626 : : // without conversion to layout direction as below
1627 [ # # ][ # # ]: 0 : aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")) );
1628 : : }
1629 : 0 : break;
1630 : : case FN_SHAPE_POSITION_LAYOUT_DIR:
1631 : : {
1632 [ # # ]: 0 : aRet <<= pImpl->GetPositionLayoutDir();
1633 : : }
1634 : 0 : break;
1635 : : // #i36248#
1636 : : case FN_SHAPE_STARTPOSITION_IN_HORI_L2R:
1637 : : {
1638 : : // get property <::drawing::Shape::StartPosition>
1639 : : // without conversion to layout direction as below
1640 [ # # ][ # # ]: 0 : aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")) );
1641 : : }
1642 : 0 : break;
1643 : : case FN_SHAPE_ENDPOSITION_IN_HORI_L2R:
1644 : : {
1645 : : // get property <::drawing::Shape::StartPosition>
1646 : : // without conversion to layout direction as below
1647 [ # # ][ # # ]: 0 : aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")) );
1648 : : }
1649 : 0 : break;
1650 : : }
1651 [ + + ]: 398 : if(pItem)
1652 [ + - ]: 19 : pItem->QueryValue(aRet, pEntry->nMemberId);
1653 : : }
1654 : : }
1655 : : else
1656 : : {
1657 [ + + ]: 159 : aRet = _getPropAtAggrObj( rPropertyName );
1658 : :
1659 : : // #i31698# - convert the position (translation)
1660 : : // of the drawing object in the transformation
1661 [ - + ]: 156 : if ( rPropertyName == "Transformation" )
1662 : : {
1663 : 0 : drawing::HomogenMatrix3 aMatrix;
1664 [ # # ]: 0 : aRet >>= aMatrix;
1665 [ # # ][ # # ]: 0 : aRet <<= _ConvertTransformationToLayoutDir( aMatrix );
1666 : : }
1667 : : // #i36248#
1668 [ - + ]: 156 : else if ( rPropertyName == "StartPosition" )
1669 : : {
1670 : 0 : awt::Point aStartPos;
1671 [ # # ]: 0 : aRet >>= aStartPos;
1672 : : // #i59051#
1673 [ # # ][ # # ]: 0 : aRet <<= _ConvertStartOrEndPosToLayoutDir( aStartPos );
1674 : : }
1675 [ - + ]: 156 : else if ( rPropertyName == "EndPosition" )
1676 : : {
1677 : 0 : awt::Point aEndPos;
1678 [ # # ]: 0 : aRet >>= aEndPos;
1679 : : // #i59051#
1680 [ # # ][ # # ]: 0 : aRet <<= _ConvertStartOrEndPosToLayoutDir( aEndPos );
1681 : : }
1682 : : // #i59051#
1683 [ - + ]: 156 : else if ( rPropertyName == "PolyPolygonBezier" )
1684 : : {
1685 [ # # ]: 0 : drawing::PolyPolygonBezierCoords aPath;
1686 [ # # ]: 0 : aRet >>= aPath;
1687 [ # # ][ # # ]: 0 : aRet <<= _ConvertPolyPolygonBezierToLayoutDir( aPath );
[ # # ][ # # ]
1688 : : }
1689 : : }
1690 : : }
1691 [ + - ]: 872 : return aRet;
1692 : : }
1693 : :
1694 : 159 : uno::Any SwXShape::_getPropAtAggrObj( const ::rtl::OUString& _rPropertyName )
1695 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1696 : : uno::RuntimeException )
1697 : : {
1698 : 159 : uno::Any aRet;
1699 : :
1700 : 159 : uno::Reference< beans::XPropertySet > xPrSet;
1701 : : const uno::Type& rPSetType =
1702 [ + - ]: 159 : ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1703 [ + - ][ + - ]: 159 : uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
1704 [ + - ][ - + ]: 159 : if ( aPSet.getValueType() != rPSetType || !aPSet.getValue() )
[ - + ]
1705 : : {
1706 [ # # ]: 0 : throw uno::RuntimeException();
1707 : : }
1708 [ + - ]: 159 : xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
1709 [ + - ][ + + ]: 159 : aRet = xPrSet->getPropertyValue( _rPropertyName );
1710 : :
1711 : 159 : return aRet;
1712 : : }
1713 : :
1714 : 3 : beans::PropertyState SwXShape::getPropertyState( const rtl::OUString& rPropertyName )
1715 : : throw(beans::UnknownPropertyException, uno::RuntimeException)
1716 : : {
1717 [ + - ]: 3 : SolarMutexGuard aGuard;
1718 [ + - ]: 3 : uno::Sequence< rtl::OUString > aNames(1);
1719 [ + - ]: 3 : rtl::OUString* pStrings = aNames.getArray();
1720 : 3 : pStrings[0] = rPropertyName;
1721 [ + - ]: 3 : uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
1722 [ + - ][ + - ]: 3 : return aStates.getConstArray()[0];
[ + - ]
1723 : : }
1724 : :
1725 : 3 : uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates(
1726 : : const uno::Sequence< rtl::OUString >& aPropertyNames )
1727 : : throw(beans::UnknownPropertyException, uno::RuntimeException)
1728 : : {
1729 [ + - ]: 3 : SolarMutexGuard aGuard;
1730 : 3 : SwFrmFmt* pFmt = GetFrmFmt();
1731 [ + - ]: 3 : uno::Sequence< beans::PropertyState > aRet(aPropertyNames.getLength());
1732 [ + - ]: 3 : if(xShapeAgg.is())
1733 : : {
1734 [ + - ]: 3 : SvxShape* pSvxShape = GetSvxShape();
1735 : 3 : sal_Bool bGroupMember = sal_False;
1736 : 3 : sal_Bool bFormControl = sal_False;
1737 [ + - ]: 3 : SdrObject* pObject = pSvxShape->GetSdrObject();
1738 [ + - ]: 3 : if(pObject)
1739 : : {
1740 [ + - ]: 3 : bGroupMember = pObject->GetUpGroup() != 0;
1741 [ + - ]: 3 : bFormControl = pObject->GetObjInventor() == FmFormInventor;
1742 : : }
1743 : 3 : const rtl::OUString* pNames = aPropertyNames.getConstArray();
1744 [ + - ]: 3 : beans::PropertyState* pRet = aRet.getArray();
1745 : 3 : uno::Reference< XPropertyState > xShapePrState;
1746 [ + + ]: 6 : for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++)
1747 : : {
1748 [ + - ]: 3 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( pNames[nProperty] );
1749 [ - + ]: 3 : if(pEntry)
1750 : : {
1751 [ # # ]: 0 : if(RES_OPAQUE == pEntry->nWID)
1752 : 0 : pRet[nProperty] = bFormControl ?
1753 [ # # ]: 0 : beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
1754 [ # # ]: 0 : else if(FN_ANCHOR_POSITION == pEntry->nWID)
1755 : 0 : pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1756 [ # # ]: 0 : else if(FN_TEXT_RANGE == pEntry->nWID)
1757 : 0 : pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1758 [ # # ]: 0 : else if(bGroupMember)
1759 : 0 : pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1760 [ # # ]: 0 : else if(pFmt)
1761 : : {
1762 : 0 : const SwAttrSet& rSet = pFmt->GetAttrSet();
1763 [ # # ]: 0 : SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, sal_False);
1764 : :
1765 [ # # ]: 0 : if(SFX_ITEM_SET == eItemState)
1766 : 0 : pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1767 [ # # ]: 0 : else if(SFX_ITEM_DEFAULT == eItemState)
1768 : 0 : pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1769 : : else
1770 : 0 : pRet[nProperty] = beans::PropertyState_AMBIGUOUS_VALUE;
1771 : : }
1772 : : else
1773 : : {
1774 : 0 : SfxPoolItem* pItem = 0;
1775 [ # # # # : 0 : switch(pEntry->nWID)
# # # # ]
1776 : : {
1777 : : case RES_ANCHOR:
1778 [ # # ]: 0 : pItem = pImpl->GetAnchor();
1779 : 0 : break;
1780 : : case RES_HORI_ORIENT:
1781 [ # # ]: 0 : pItem = pImpl->GetHOrient();
1782 : 0 : break;
1783 : : case RES_VERT_ORIENT:
1784 [ # # ]: 0 : pItem = pImpl->GetVOrient();
1785 : 0 : break;
1786 : : case RES_LR_SPACE:
1787 [ # # ]: 0 : pItem = pImpl->GetLRSpace();
1788 : 0 : break;
1789 : : case RES_UL_SPACE:
1790 [ # # ]: 0 : pItem = pImpl->GetULSpace();
1791 : 0 : break;
1792 : : case RES_SURROUND:
1793 [ # # ]: 0 : pItem = pImpl->GetSurround();
1794 : 0 : break;
1795 : : // #i28701#
1796 : : case RES_WRAP_INFLUENCE_ON_OBJPOS:
1797 : : {
1798 [ # # ]: 0 : pItem = pImpl->GetWrapInfluenceOnObjPos();
1799 : : }
1800 : 0 : break;
1801 : : }
1802 [ # # ]: 0 : if(pItem)
1803 : 0 : pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1804 : : else
1805 : 0 : pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1806 : : }
1807 : : }
1808 : : else
1809 : : {
1810 [ + - ]: 3 : if(!xShapePrState.is())
1811 : : {
1812 [ + - ]: 3 : const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
1813 [ + - ][ + - ]: 3 : uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1814 [ + - ][ - + ]: 3 : if(aPState.getValueType() != rPStateType || !aPState.getValue())
[ - + ]
1815 [ # # ]: 0 : throw uno::RuntimeException();
1816 [ + - ]: 3 : xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
1817 : : }
1818 [ + - ][ + - ]: 3 : pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]);
1819 : : }
1820 : 3 : }
1821 : : }
1822 : : else
1823 [ # # ]: 3 : throw uno::RuntimeException();
1824 [ + - ]: 6 : return aRet;
1825 : : }
1826 : :
1827 : 0 : void SwXShape::setPropertyToDefault( const rtl::OUString& rPropertyName )
1828 : : throw(beans::UnknownPropertyException, uno::RuntimeException)
1829 : : {
1830 [ # # ]: 0 : SolarMutexGuard aGuard;
1831 : 0 : SwFrmFmt* pFmt = GetFrmFmt();
1832 [ # # ]: 0 : if(xShapeAgg.is())
1833 : : {
1834 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1835 [ # # ]: 0 : if(pEntry)
1836 : : {
1837 [ # # ]: 0 : if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1838 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
1839 [ # # ]: 0 : if(pFmt)
1840 : : {
1841 : 0 : const SfxItemSet& rSet = pFmt->GetAttrSet();
1842 [ # # ]: 0 : SfxItemSet aSet(pFmt->GetDoc()->GetAttrPool(), pEntry->nWID, pEntry->nWID);
1843 : 0 : aSet.SetParent(&rSet);
1844 [ # # ]: 0 : aSet.ClearItem(pEntry->nWID);
1845 [ # # ][ # # ]: 0 : pFmt->GetDoc()->SetAttr(aSet, *pFmt);
1846 : : }
1847 : : else
1848 : : {
1849 [ # # # # : 0 : switch(pEntry->nWID)
# # # # #
# # ]
1850 : : {
1851 [ # # ]: 0 : case RES_ANCHOR: pImpl->RemoveAnchor(); break;
1852 [ # # ]: 0 : case RES_HORI_ORIENT: pImpl->RemoveHOrient(); break;
1853 [ # # ]: 0 : case RES_VERT_ORIENT: pImpl->RemoveVOrient(); break;
1854 [ # # ]: 0 : case RES_LR_SPACE: pImpl->RemoveLRSpace(); break;
1855 [ # # ]: 0 : case RES_UL_SPACE: pImpl->RemoveULSpace(); break;
1856 [ # # ]: 0 : case RES_SURROUND: pImpl->RemoveSurround();break;
1857 : 0 : case RES_OPAQUE : pImpl->SetOpaque(sal_False); break;
1858 : : case FN_TEXT_RANGE :
1859 : 0 : break;
1860 : : // #i26791#
1861 : : case RES_FOLLOW_TEXT_FLOW:
1862 : : {
1863 [ # # ]: 0 : pImpl->RemoveFollowTextFlow();
1864 : : }
1865 : 0 : break;
1866 : : // #i28701#
1867 : : case RES_WRAP_INFLUENCE_ON_OBJPOS:
1868 : : {
1869 [ # # ]: 0 : pImpl->RemoveWrapInfluenceOnObjPos();
1870 : : }
1871 : 0 : break;
1872 : : }
1873 : : }
1874 : : }
1875 : : else
1876 : : {
1877 [ # # ]: 0 : const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
1878 [ # # ][ # # ]: 0 : uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1879 [ # # ][ # # ]: 0 : if(aPState.getValueType() != rPStateType || !aPState.getValue())
[ # # ]
1880 [ # # ]: 0 : throw uno::RuntimeException();
1881 : 0 : uno::Reference< XPropertyState > xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
1882 [ # # ][ # # ]: 0 : xShapePrState->setPropertyToDefault( rPropertyName );
1883 : : }
1884 : : }
1885 : : else
1886 [ # # ][ # # ]: 0 : throw uno::RuntimeException();
1887 : 0 : }
1888 : :
1889 : 0 : uno::Any SwXShape::getPropertyDefault( const rtl::OUString& rPropertyName )
1890 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1891 : : uno::RuntimeException )
1892 : : {
1893 [ # # ]: 0 : SolarMutexGuard aGuard;
1894 : 0 : SwFrmFmt* pFmt = GetFrmFmt();
1895 : 0 : uno::Any aRet;
1896 [ # # ]: 0 : if(xShapeAgg.is())
1897 : : {
1898 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1899 [ # # ]: 0 : if(pEntry)
1900 : : {
1901 [ # # ][ # # ]: 0 : if(pEntry->nWID < RES_FRMATR_END && pFmt)
1902 : : {
1903 : : const SfxPoolItem& rDefItem =
1904 [ # # ]: 0 : pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
1905 [ # # ]: 0 : rDefItem.QueryValue(aRet, pEntry->nMemberId);
1906 : : }
1907 : : else
1908 [ # # ]: 0 : throw uno::RuntimeException();
1909 : : }
1910 : : else
1911 : : {
1912 [ # # ]: 0 : const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
1913 [ # # ][ # # ]: 0 : uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1914 [ # # ][ # # ]: 0 : if(aPState.getValueType() != rPStateType || !aPState.getValue())
[ # # ]
1915 [ # # ]: 0 : throw uno::RuntimeException();
1916 : 0 : uno::Reference< XPropertyState > xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
1917 [ # # ][ # # ]: 0 : xShapePrState->getPropertyDefault( rPropertyName );
1918 : : }
1919 : : }
1920 : : else
1921 [ # # ]: 0 : throw uno::RuntimeException();
1922 [ # # ]: 0 : return aRet;
1923 : : }
1924 : :
1925 : 0 : void SwXShape::addPropertyChangeListener(
1926 : : const rtl::OUString& _propertyName,
1927 : : const uno::Reference< beans::XPropertyChangeListener > & _listener )
1928 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1929 : : uno::RuntimeException )
1930 : : {
1931 [ # # ]: 0 : if ( !xShapeAgg.is() )
1932 [ # # ][ # # ]: 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no shape aggregate" ) ), *this );
[ # # ]
1933 : :
1934 : : // must be handled by the aggregate
1935 : 0 : uno::Reference< beans::XPropertySet > xShapeProps;
1936 [ # # ][ # # ]: 0 : if ( xShapeAgg->queryAggregation( beans::XPropertySet::static_type() ) >>= xShapeProps )
[ # # ][ # # ]
[ # # ]
1937 [ # # ][ # # ]: 0 : xShapeProps->addPropertyChangeListener( _propertyName, _listener );
1938 : 0 : }
1939 : :
1940 : 0 : void SwXShape::removePropertyChangeListener(
1941 : : const rtl::OUString& _propertyName,
1942 : : const uno::Reference< beans::XPropertyChangeListener > & _listener)
1943 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1944 : : uno::RuntimeException )
1945 : : {
1946 [ # # ]: 0 : if ( !xShapeAgg.is() )
1947 [ # # ][ # # ]: 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no shape aggregate" ) ), *this );
[ # # ]
1948 : :
1949 : : // must be handled by the aggregate
1950 : 0 : uno::Reference< beans::XPropertySet > xShapeProps;
1951 [ # # ][ # # ]: 0 : if ( xShapeAgg->queryAggregation( beans::XPropertySet::static_type() ) >>= xShapeProps )
[ # # ][ # # ]
[ # # ]
1952 [ # # ][ # # ]: 0 : xShapeProps->removePropertyChangeListener( _propertyName, _listener );
1953 : 0 : }
1954 : :
1955 : 0 : void SwXShape::addVetoableChangeListener(
1956 : : const rtl::OUString& /*PropertyName*/,
1957 : : const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/ )
1958 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1959 : : uno::RuntimeException )
1960 : : {
1961 : : OSL_FAIL("not implemented");
1962 : 0 : }
1963 : :
1964 : 0 : void SwXShape::removeVetoableChangeListener(
1965 : : const rtl::OUString& /*PropertyName*/,
1966 : : const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
1967 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1968 : : uno::RuntimeException )
1969 : : {
1970 : : OSL_FAIL("not implemented");
1971 : 0 : }
1972 : :
1973 : 704 : void SwXShape::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
1974 : : {
1975 : 704 : ClientModify(this, pOld, pNew);
1976 : 704 : }
1977 : :
1978 : 80 : void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
1979 : : throw( lang::IllegalArgumentException, uno::RuntimeException )
1980 : : {
1981 [ + - ]: 80 : SolarMutexGuard aGuard;
1982 : :
1983 : : // get access to SwDoc
1984 : : // (see also SwXTextRange::XTextRangeToSwPaM)
1985 : 80 : SwDoc* pDoc = 0;
1986 [ + - ]: 80 : uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1987 [ + - ]: 80 : if(xRangeTunnel.is())
1988 : : {
1989 : 80 : SwXTextRange* pRange = 0;
1990 : 80 : OTextCursorHelper* pCursor = 0;
1991 : 80 : SwXTextPortion* pPortion = 0;
1992 : 80 : SwXText* pText = 0;
1993 : 80 : SwXParagraph* pParagraph = 0;
1994 : :
1995 : : pRange = reinterpret_cast< SwXTextRange * >(
1996 [ + - ][ + - ]: 80 : sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
[ + - ]
1997 : : pText = reinterpret_cast< SwXText * >(
1998 [ + - ][ + - ]: 80 : sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) ));
[ + - ]
1999 : : pCursor = reinterpret_cast< OTextCursorHelper * >(
2000 [ + - ][ + - ]: 80 : sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
[ + - ]
2001 : : pPortion = reinterpret_cast< SwXTextPortion * >(
2002 [ + - ][ + - ]: 80 : sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) ));
[ + - ]
2003 : : pParagraph = reinterpret_cast< SwXParagraph * >(
2004 [ + - ][ + - ]: 80 : sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId( ) ) ) );
[ + - ]
2005 : :
2006 [ + - ]: 80 : if (pRange)
2007 [ + - ]: 80 : pDoc = pRange->GetDoc();
2008 [ # # ][ # # ]: 0 : else if (!pDoc && pText)
2009 [ # # ]: 0 : pDoc = pText->GetDoc();
2010 [ # # ][ # # ]: 0 : else if (!pDoc && pCursor)
2011 [ # # ]: 0 : pDoc = pCursor->GetDoc();
2012 [ # # ][ # # ]: 0 : else if ( !pDoc && pPortion && pPortion->GetCursor() )
[ # # ][ # # ]
2013 : : {
2014 : 0 : pDoc = pPortion->GetCursor()->GetDoc();
2015 : : }
2016 [ # # ][ # # ]: 0 : else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) )
[ # # ][ # # ]
[ # # ]
2017 : : {
2018 [ # # ]: 80 : pDoc = const_cast<SwDoc*>(pParagraph->GetTxtNode()->GetDoc());
2019 : : }
2020 : :
2021 : : }
2022 : :
2023 [ - + ]: 80 : if(!pDoc)
2024 [ # # ]: 0 : throw uno::RuntimeException();
2025 : 80 : SwDocShell *pDocSh = pDoc->GetDocShell();
2026 [ + - ]: 80 : if (pDocSh)
2027 : : {
2028 : 80 : uno::Reference< frame::XModel > xModel;
2029 [ + - ][ + - ]: 80 : xModel = pDocSh->GetModel();
2030 [ + - ]: 80 : uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
2031 [ + - ]: 80 : if (xDPS.is())
2032 : : {
2033 [ + - ][ + - ]: 80 : uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
2034 [ + - ]: 80 : if (xDP.is())
2035 : : {
2036 : 80 : uno::Any aPos;
2037 [ + - ]: 80 : aPos <<= xTextRange;
2038 [ + - ][ + - ]: 80 : setPropertyValue(S2U("TextRange"), aPos);
2039 [ + - ]: 80 : uno::Reference< drawing::XShape > xTemp( (cppu::OWeakObject*) this, uno::UNO_QUERY );
2040 [ + - ][ + + ]: 80 : xDP->add( xTemp );
2041 : 80 : }
2042 : 80 : }
2043 [ + - ]: 80 : }
2044 : 20 : }
2045 : :
2046 : 0 : uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::RuntimeException )
2047 : : {
2048 [ # # ]: 0 : SolarMutexGuard aGuard;
2049 : 0 : uno::Reference< text::XTextRange > aRef;
2050 : 0 : SwFrmFmt* pFmt = GetFrmFmt();
2051 [ # # ]: 0 : if(pFmt)
2052 : : {
2053 [ # # ]: 0 : const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
2054 : : // return an anchor for non-page bound frames
2055 : : // and for page bound frames that have a page no == NULL and a content position
2056 [ # # ]: 0 : if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
[ # # # # ]
[ # # ]
2057 [ # # ]: 0 : (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
2058 : : {
2059 [ # # ][ # # ]: 0 : const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
2060 [ # # ][ # # ]: 0 : aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
2061 : : }
2062 : : }
2063 : : else
2064 [ # # ]: 0 : aRef = pImpl->GetTextRange();
2065 [ # # ]: 0 : return aRef;
2066 : : }
2067 : :
2068 : 465 : void SwXShape::dispose(void) throw( uno::RuntimeException )
2069 : : {
2070 [ + - ]: 465 : SolarMutexGuard aGuard;
2071 : 465 : SwFrmFmt* pFmt = GetFrmFmt();
2072 [ + - ]: 465 : if(pFmt)
2073 : : {
2074 : : // determine correct <SdrObject>
2075 [ + - ][ + - ]: 465 : SdrObject* pObj = GetSvxShape()->GetSdrObject();
2076 : : // safety assertion:
2077 : : // <pObj> must be the same as <pFmt->FindSdrObject()>, if <pObj> isn't
2078 : : // a 'virtual' drawing object.
2079 : : // correct assertion and refine it for safety reason.
2080 : : OSL_ENSURE( !pObj ||
2081 : : pObj->ISA(SwDrawVirtObj) ||
2082 : : pObj->GetUpGroup() ||
2083 : : pObj == pFmt->FindSdrObject(),
2084 : : "<SwXShape::dispose(..) - different 'master' drawing objects!!" );
2085 : : // perform delete of draw frame format *not*
2086 : : // for 'virtual' drawing objects.
2087 : : // no delete of draw format for members
2088 : : // of a group
2089 [ + + ][ + - ]: 489 : if ( pObj &&
[ + - ][ + - ]
[ + + ]
2090 [ + - ][ + - ]: 8 : !pObj->ISA(SwDrawVirtObj) &&
2091 [ + - ]: 8 : !pObj->GetUpGroup() &&
2092 [ + - ]: 8 : pObj->IsInserted() )
2093 : : {
2094 [ + - ][ + + ]: 8 : if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
2095 : : {
2096 [ + - ][ + - ]: 2 : const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
2097 : 2 : SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
2098 : 2 : const xub_StrLen nIdx = rPos.nContent.GetIndex();
2099 [ + - ]: 2 : pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
2100 : : }
2101 : : else
2102 [ + - ]: 6 : pFmt->GetDoc()->DelLayoutFmt( pFmt );
2103 : : }
2104 : : }
2105 [ + - ]: 465 : if(xShapeAgg.is())
2106 : : {
2107 [ + - ][ + - ]: 465 : uno::Any aAgg(xShapeAgg->queryAggregation( ::getCppuType((uno::Reference<XComponent>*)0)));
[ + - ]
2108 : 465 : uno::Reference<XComponent> xComp;
2109 [ + - ]: 465 : aAgg >>= xComp;
2110 [ + - ]: 465 : if(xComp.is())
2111 [ + - ][ + - ]: 465 : xComp->dispose();
2112 [ + - ]: 465 : }
2113 : 465 : }
2114 : :
2115 : 0 : void SwXShape::addEventListener(
2116 : : const uno::Reference< lang::XEventListener > & aListener)
2117 : : throw( uno::RuntimeException )
2118 : : {
2119 [ # # ]: 0 : uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2120 [ # # ]: 0 : SvxShape* pSvxShape = GetSvxShape();
2121 [ # # ]: 0 : if(pSvxShape)
2122 [ # # ]: 0 : pSvxShape->addEventListener(aListener);
2123 : 0 : }
2124 : :
2125 : 0 : void SwXShape::removeEventListener(
2126 : : const uno::Reference< lang::XEventListener > & aListener)
2127 : : throw( uno::RuntimeException )
2128 : : {
2129 : 0 : SvxShape* pSvxShape = GetSvxShape();
2130 [ # # ]: 0 : if(pSvxShape)
2131 : 0 : pSvxShape->removeEventListener(aListener);
2132 : 0 : }
2133 : :
2134 : 0 : rtl::OUString SwXShape::getImplementationName(void) throw( uno::RuntimeException )
2135 : : {
2136 : 0 : return C2U("SwXShape");
2137 : : }
2138 : :
2139 : 135 : sal_Bool SwXShape::supportsService(const rtl::OUString& rServiceName) throw( uno::RuntimeException )
2140 : : {
2141 : 135 : sal_Bool bRet = sal_False;
2142 [ - + ]: 135 : if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.drawing.Shape"))
2143 : 0 : bRet = sal_True;
2144 [ + - ]: 135 : else if(xShapeAgg.is())
2145 : : {
2146 [ + - ]: 135 : uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2147 [ + - ]: 135 : SvxShape* pSvxShape = GetSvxShape();
2148 [ + - ]: 135 : bRet = pSvxShape->supportsService(rServiceName);
2149 : : }
2150 : 135 : return bRet;
2151 : : }
2152 : :
2153 : 0 : uno::Sequence< rtl::OUString > SwXShape::getSupportedServiceNames(void) throw( uno::RuntimeException )
2154 : : {
2155 : 0 : uno::Sequence< rtl::OUString > aSeq;
2156 [ # # ]: 0 : if(xShapeAgg.is())
2157 : : {
2158 [ # # ]: 0 : uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2159 [ # # ]: 0 : SvxShape* pSvxShape = GetSvxShape();
2160 [ # # ]: 0 : if(pSvxShape)
2161 [ # # ][ # # ]: 0 : aSeq = pSvxShape->getSupportedServiceNames();
[ # # ]
2162 : : }
2163 : : else
2164 : : {
2165 [ # # ]: 0 : aSeq.realloc(1);
2166 [ # # ][ # # ]: 0 : aSeq.getArray()[0] = C2U("com.sun.star.drawing.Shape");
2167 : : }
2168 : 0 : return aSeq;
2169 : : }
2170 : :
2171 : 1092 : SvxShape* SwXShape::GetSvxShape()
2172 : : {
2173 : 1092 : SvxShape* pSvxShape = 0;
2174 [ + - ]: 1092 : if(xShapeAgg.is())
2175 : : {
2176 [ + - ]: 1092 : uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2177 [ + - ]: 1092 : if(xShapeTunnel.is())
2178 : : pSvxShape = reinterpret_cast< SvxShape * >(
2179 [ + - ][ + - ]: 1092 : sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2180 : : }
2181 : 1092 : return pSvxShape;
2182 : : }
2183 : :
2184 : : // #i31698#
2185 : : // implementation of virtual methods from drawing::XShape
2186 : 146 : awt::Point SAL_CALL SwXShape::getPosition() throw ( uno::RuntimeException )
2187 : : {
2188 : 146 : awt::Point aPos( _GetAttrPosition() );
2189 : :
2190 : : // handle group members
2191 : 146 : SvxShape* pSvxShape = GetSvxShape();
2192 [ + - ]: 146 : if ( pSvxShape )
2193 : : {
2194 : 146 : SdrObject* pTopGroupObj = _GetTopGroupObj( pSvxShape );
2195 [ - + ]: 146 : if ( pTopGroupObj )
2196 : : {
2197 : : // #i34750# - get attribute position of top group
2198 : : // shape and add offset between top group object and group member
2199 : : uno::Reference< drawing::XShape > xGroupShape =
2200 : 0 : uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
2201 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
2202 [ # # ][ # # ]: 0 : aPos = xGroupShape->getPosition();
2203 : : // add offset between top group object and group member
2204 : : // to the determined attribute position
2205 : : // #i34750#:
2206 : : // consider the layout direction
2207 [ # # ][ # # ]: 0 : const Rectangle aMemberObjRect = GetSvxShape()->GetSdrObject()->GetSnapRect();
[ # # ]
2208 [ # # ]: 0 : const Rectangle aGroupObjRect = pTopGroupObj->GetSnapRect();
2209 : : // #i53320# - relative position of group member and
2210 : : // top group object is always given in horizontal left-to-right layout.
2211 : 0 : awt::Point aOffset( 0, 0 );
2212 : : {
2213 : 0 : aOffset.X = ( aMemberObjRect.Left() - aGroupObjRect.Left() );
2214 : 0 : aOffset.Y = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
2215 : : }
2216 [ # # ]: 0 : aOffset.X = TWIP_TO_MM100(aOffset.X);
2217 [ # # ]: 0 : aOffset.Y = TWIP_TO_MM100(aOffset.Y);
2218 : 0 : aPos.X += aOffset.X;
2219 : 0 : aPos.Y += aOffset.Y;
2220 : : }
2221 : : }
2222 : :
2223 : 146 : return aPos;
2224 : : }
2225 : :
2226 : 73 : void SAL_CALL SwXShape::setPosition( const awt::Point& aPosition )
2227 : : throw ( uno::RuntimeException )
2228 : : {
2229 : 73 : SdrObject* pTopGroupObj = _GetTopGroupObj();
2230 [ + - ]: 73 : if ( !pTopGroupObj )
2231 : : {
2232 : : // #i37877# - no adjustment of position attributes,
2233 : : // if the position also has to be applied at the drawing object and
2234 : : // a contact object is already registered at the drawing object.
2235 : 73 : bool bApplyPosAtDrawObj(false);
2236 : 73 : bool bNoAdjustOfPosProp(false);
2237 : : // #i35798# - apply position also to drawing object,
2238 : : // if drawing object has no anchor position set.
2239 [ + - ]: 73 : if ( mxShape.is() )
2240 : : {
2241 : 73 : SvxShape* pSvxShape = GetSvxShape();
2242 [ + - ]: 73 : if ( pSvxShape )
2243 : : {
2244 : 73 : const SdrObject* pObj = pSvxShape->GetSdrObject();
2245 [ + + ][ + + : 199 : if ( pObj &&
+ - + - ]
2246 : 63 : pObj->GetAnchorPos().X() == 0 &&
2247 : 63 : pObj->GetAnchorPos().Y() == 0 )
2248 : : {
2249 : 63 : bApplyPosAtDrawObj = true;
2250 [ + - + - ]: 126 : if ( pObj->GetUserCall() &&
[ + - ]
2251 : 63 : pObj->GetUserCall()->ISA(SwDrawContact) )
2252 : : {
2253 : 63 : bNoAdjustOfPosProp = true;
2254 : : }
2255 : : }
2256 : : }
2257 : : }
2258 : : // shape isn't a group member. Thus, set positioning attributes
2259 [ + + ]: 73 : if ( !bNoAdjustOfPosProp )
2260 : : {
2261 : 10 : _AdjustPositionProperties( aPosition );
2262 : : }
2263 [ + + ]: 73 : if ( bApplyPosAtDrawObj )
2264 : : {
2265 : 63 : mxShape->setPosition( aPosition );
2266 : : }
2267 : : }
2268 [ # # ]: 0 : else if ( mxShape.is() )
2269 : : {
2270 : : // shape is a member of a group. Thus, set its position.
2271 : 0 : awt::Point aNewPos( aPosition );
2272 : : // The given position is given in the according layout direction. Thus,
2273 : : // it has to be converted to a position in horizontal left-to-right
2274 : : // layout.
2275 : : // convert given absolute attribute position in layout direction into
2276 : : // position in horizontal left-to-right layout.
2277 : : {
2278 [ # # ][ # # ]: 0 : aNewPos = _ConvertPositionToHoriL2R( aNewPos, getSize() );
2279 : : }
2280 : : // Convert given absolute position in horizontal left-to-right
2281 : : // layout into relative position in horizontal left-to-right layout.
2282 : : uno::Reference< drawing::XShape > xGroupShape =
2283 : 0 : uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
2284 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
2285 : : {
2286 : : // #i34750#
2287 : : // use method <xGroupShape->getPosition()> to get the correct
2288 : : // position of the top group object.
2289 : : awt::Point aAttrPosInHoriL2R(
2290 [ # # ]: 0 : _ConvertPositionToHoriL2R( xGroupShape->getPosition(),
2291 [ # # ][ # # ]: 0 : xGroupShape->getSize() ) );
[ # # ][ # # ]
2292 : 0 : aNewPos.X -= aAttrPosInHoriL2R.X;
2293 : 0 : aNewPos.Y -= aAttrPosInHoriL2R.Y;
2294 : : }
2295 : : // convert relative position in horizontal left-to-right layout into
2296 : : // absolute position in horizontal left-to-right layout
2297 : : {
2298 : : // #i34750#
2299 : : // use method <SvxShape->getPosition()> to get the correct
2300 : : // 'Drawing layer' position of the top group shape.
2301 : : uno::Reference< lang::XUnoTunnel > xGrpShapeTunnel(
2302 : 0 : pTopGroupObj->getUnoShape(),
2303 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
2304 : : SvxShape* pSvxGroupShape = reinterpret_cast< SvxShape * >(
2305 [ # # ][ # # ]: 0 : sal::static_int_cast< sal_IntPtr >( xGrpShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2306 [ # # ]: 0 : const awt::Point aGroupPos = pSvxGroupShape->getPosition();
2307 : 0 : aNewPos.X += aGroupPos.X;
2308 : 0 : aNewPos.Y += aGroupPos.Y;
2309 : : }
2310 : : // set position
2311 [ # # ][ # # ]: 0 : mxShape->setPosition( aNewPos );
2312 : : }
2313 : 73 : }
2314 : :
2315 : 182 : awt::Size SAL_CALL SwXShape::getSize() throw ( uno::RuntimeException )
2316 : : {
2317 : 182 : awt::Size aSize;
2318 [ + - ]: 182 : if ( mxShape.is() )
2319 : : {
2320 : 182 : aSize = mxShape->getSize();
2321 : : }
2322 : 182 : return aSize;
2323 : : }
2324 : :
2325 : 79 : void SAL_CALL SwXShape::setSize( const awt::Size& aSize )
2326 : : throw ( beans::PropertyVetoException,
2327 : : uno::RuntimeException )
2328 : : {
2329 [ + - ]: 79 : if ( mxShape.is() )
2330 : : {
2331 : 79 : mxShape->setSize( aSize );
2332 : : }
2333 : 79 : }
2334 : : // #i31698#
2335 : : // implementation of virtual methods from drawing::XShapeDescriptor
2336 : 235 : ::rtl::OUString SAL_CALL SwXShape::getShapeType() throw ( uno::RuntimeException )
2337 : : {
2338 : 235 : ::rtl::OUString aType;
2339 [ + - ]: 235 : if ( mxShape.is() )
2340 : : {
2341 [ + - ][ + - ]: 235 : aType = mxShape->getShapeType();
2342 : : }
2343 : 235 : return aType;
2344 : : }
2345 : : /** method to determine top group object
2346 : : #i31698#
2347 : : */
2348 : 219 : SdrObject* SwXShape::_GetTopGroupObj( SvxShape* _pSvxShape )
2349 : : {
2350 : 219 : SdrObject* pTopGroupObj( 0L );
2351 : :
2352 [ + + ]: 219 : SvxShape* pSvxShape = _pSvxShape ? _pSvxShape : GetSvxShape();
2353 [ + - ]: 219 : if ( pSvxShape )
2354 : : {
2355 : 219 : SdrObject* pSdrObj = pSvxShape->GetSdrObject();
2356 [ - + ][ - + ]: 219 : if ( pSdrObj && pSdrObj->GetUpGroup() )
[ + + ]
2357 : : {
2358 : 0 : pTopGroupObj = pSdrObj->GetUpGroup();
2359 [ # # ]: 0 : while ( pTopGroupObj->GetUpGroup() )
2360 : : {
2361 : 0 : pTopGroupObj = pTopGroupObj->GetUpGroup();
2362 : : }
2363 : : }
2364 : : }
2365 : :
2366 : 219 : return pTopGroupObj;
2367 : : }
2368 : :
2369 : : /** method to determine position according to the positioning attributes
2370 : : #i31698#
2371 : : */
2372 : 146 : awt::Point SwXShape::_GetAttrPosition()
2373 : : {
2374 : 146 : awt::Point aAttrPos;
2375 : :
2376 [ + - ][ + - ]: 146 : uno::Any aHoriPos( getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")) ) );
2377 : 146 : aHoriPos >>= aAttrPos.X;
2378 [ + - ][ + - ]: 146 : uno::Any aVertPos( getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")) ) );
2379 : 146 : aVertPos >>= aAttrPos.Y;
2380 : : // #i35798# - fallback, if attribute position is (0,0)
2381 : : // and no anchor position is applied to the drawing object
2382 [ + - ]: 146 : SvxShape* pSvxShape = GetSvxShape();
2383 [ + - ]: 146 : if ( pSvxShape )
2384 : : {
2385 [ + - ]: 146 : const SdrObject* pObj = pSvxShape->GetSdrObject();
2386 [ + + + + : 197 : if ( pObj &&
+ - ][ + + ]
[ + - ][ + + ]
2387 [ + - ]: 30 : pObj->GetAnchorPos().X() == 0 &&
2388 [ + - ]: 21 : pObj->GetAnchorPos().Y() == 0 &&
2389 : : aAttrPos.X == 0 && aAttrPos.Y == 0 )
2390 : : {
2391 [ + - ]: 15 : const Rectangle aObjRect = pObj->GetSnapRect();
2392 [ + - ]: 15 : aAttrPos.X = TWIP_TO_MM100(aObjRect.Left());
2393 [ + - ]: 15 : aAttrPos.Y = TWIP_TO_MM100(aObjRect.Top());
2394 : : }
2395 : : }
2396 : : // #i35007# - If drawing object is anchored as-character,
2397 : : // it's x-position isn't sensible. Thus, return the x-position as zero in this case.
2398 : : text::TextContentAnchorType eTextAnchorType =
2399 : 146 : text::TextContentAnchorType_AT_PARAGRAPH;
2400 : : {
2401 [ + - ]: 146 : rtl::OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2402 [ + - ]: 146 : uno::Any aAny = getPropertyValue( sAnchorType );
2403 [ + - ]: 146 : aAny >>= eTextAnchorType;
2404 : : }
2405 [ + + ]: 146 : if ( eTextAnchorType == text::TextContentAnchorType_AS_CHARACTER )
2406 : : {
2407 : 6 : aAttrPos.X = 0;
2408 : : }
2409 : :
2410 : 146 : return aAttrPos;
2411 : : }
2412 : :
2413 : : /** method to convert the position (translation) of the drawing object to
2414 : : the layout direction horizontal left-to-right.
2415 : : #i31698#
2416 : : */
2417 : 0 : awt::Point SwXShape::_ConvertPositionToHoriL2R( const awt::Point _aObjPos,
2418 : : const awt::Size _aObjSize )
2419 : : {
2420 : 0 : awt::Point aObjPosInHoriL2R( _aObjPos );
2421 : :
2422 : 0 : SwFrmFmt* pFrmFmt = GetFrmFmt();
2423 [ # # ]: 0 : if ( pFrmFmt )
2424 : : {
2425 : 0 : SwFrmFmt::tLayoutDir eLayoutDir = pFrmFmt->GetLayoutDir();
2426 [ # # # # ]: 0 : switch ( eLayoutDir )
2427 : : {
2428 : : case SwFrmFmt::HORI_L2R:
2429 : : {
2430 : : // nothing to do
2431 : : }
2432 : 0 : break;
2433 : : case SwFrmFmt::HORI_R2L:
2434 : : {
2435 : 0 : aObjPosInHoriL2R.X = -_aObjPos.X - _aObjSize.Width;
2436 : : }
2437 : 0 : break;
2438 : : case SwFrmFmt::VERT_R2L:
2439 : : {
2440 : 0 : aObjPosInHoriL2R.X = -_aObjPos.Y - _aObjSize.Width;
2441 : 0 : aObjPosInHoriL2R.Y = _aObjPos.X;
2442 : : }
2443 : 0 : break;
2444 : : default:
2445 : : {
2446 : : OSL_FAIL( "<SwXShape::_ConvertPositionToHoriL2R(..)> - unsupported layout direction" );
2447 : : }
2448 : : }
2449 : : }
2450 : :
2451 : 0 : return aObjPosInHoriL2R;
2452 : : }
2453 : :
2454 : : /** method to convert the transformation of the drawing object to the layout
2455 : : direction, the drawing object is in
2456 : : #i31698#
2457 : : */
2458 : 0 : drawing::HomogenMatrix3 SwXShape::_ConvertTransformationToLayoutDir(
2459 : : drawing::HomogenMatrix3 _aMatrixInHoriL2R )
2460 : : {
2461 : 0 : drawing::HomogenMatrix3 aMatrix( _aMatrixInHoriL2R );
2462 : :
2463 : : // #i44334#, #i44681# - direct manipulation of the
2464 : : // tranformation structure isn't valid, if it contains rotation.
2465 : 0 : SvxShape* pSvxShape = GetSvxShape();
2466 : : OSL_ENSURE( pSvxShape,
2467 : : "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SvxShape found!");
2468 [ # # ]: 0 : if ( pSvxShape )
2469 : : {
2470 : 0 : const SdrObject* pObj = pSvxShape->GetSdrObject();
2471 : : OSL_ENSURE( pObj,
2472 : : "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SdrObject found!");
2473 [ # # ]: 0 : if ( pObj )
2474 : : {
2475 : : // get position of object in Writer coordinate system.
2476 [ # # ]: 0 : awt::Point aPos( getPosition() );
2477 : : // get position of object in Drawing layer coordinate system
2478 [ # # ]: 0 : const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2479 : : const awt::Point aObjPos(
2480 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
[ # # ]
2481 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
[ # # ][ # # ]
[ # # ]
2482 : : // determine difference between these positions according to the
2483 : : // Writer coordinate system
2484 : : const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2485 : 0 : aPos.Y - aObjPos.Y );
2486 : : // apply translation difference to transformation matrix.
2487 [ # # ][ # # ]: 0 : if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2488 : : {
2489 : : // #i73079# - use correct matrix type
2490 [ # # ]: 0 : ::basegfx::B2DHomMatrix aTempMatrix;
2491 : :
2492 [ # # ]: 0 : aTempMatrix.set(0, 0, aMatrix.Line1.Column1 );
2493 [ # # ]: 0 : aTempMatrix.set(0, 1, aMatrix.Line1.Column2 );
2494 [ # # ]: 0 : aTempMatrix.set(0, 2, aMatrix.Line1.Column3 );
2495 [ # # ]: 0 : aTempMatrix.set(1, 0, aMatrix.Line2.Column1 );
2496 [ # # ]: 0 : aTempMatrix.set(1, 1, aMatrix.Line2.Column2 );
2497 [ # # ]: 0 : aTempMatrix.set(1, 2, aMatrix.Line2.Column3 );
2498 [ # # ]: 0 : aTempMatrix.set(2, 0, aMatrix.Line3.Column1 );
2499 [ # # ]: 0 : aTempMatrix.set(2, 1, aMatrix.Line3.Column2 );
2500 [ # # ]: 0 : aTempMatrix.set(2, 2, aMatrix.Line3.Column3 );
2501 : : // #i73079#
2502 [ # # ]: 0 : aTempMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
2503 [ # # ]: 0 : aMatrix.Line1.Column1 = aTempMatrix.get(0, 0);
2504 [ # # ]: 0 : aMatrix.Line1.Column2 = aTempMatrix.get(0, 1);
2505 [ # # ]: 0 : aMatrix.Line1.Column3 = aTempMatrix.get(0, 2);
2506 [ # # ]: 0 : aMatrix.Line2.Column1 = aTempMatrix.get(1, 0);
2507 [ # # ]: 0 : aMatrix.Line2.Column2 = aTempMatrix.get(1, 1);
2508 [ # # ]: 0 : aMatrix.Line2.Column3 = aTempMatrix.get(1, 2);
2509 [ # # ]: 0 : aMatrix.Line3.Column1 = aTempMatrix.get(2, 0);
2510 [ # # ]: 0 : aMatrix.Line3.Column2 = aTempMatrix.get(2, 1);
2511 [ # # ][ # # ]: 0 : aMatrix.Line3.Column3 = aTempMatrix.get(2, 2);
2512 : : }
2513 : : }
2514 : : }
2515 : :
2516 : 0 : return aMatrix;
2517 : : }
2518 : :
2519 : : /** method to adjust the positioning properties
2520 : : #i31698#
2521 : : */
2522 : 10 : void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition )
2523 : : {
2524 : : // handle x-position
2525 : : // #i35007# - no handling of x-position, if drawing
2526 : : // object is anchored as-character, because it doesn't make sense.
2527 : : text::TextContentAnchorType eTextAnchorType =
2528 : 10 : text::TextContentAnchorType_AT_PARAGRAPH;
2529 : : {
2530 [ + - ]: 10 : rtl::OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2531 [ + - ]: 10 : uno::Any aAny = getPropertyValue( sAnchorType );
2532 [ + - ]: 10 : aAny >>= eTextAnchorType;
2533 : : }
2534 [ + - ]: 10 : if ( eTextAnchorType != text::TextContentAnchorType_AS_CHARACTER )
2535 : : {
2536 : : // determine current x-postion
2537 [ + - ]: 10 : rtl::OUString aHoriPosPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition") );
2538 [ + - ]: 10 : uno::Any aHoriPos( getPropertyValue( aHoriPosPropStr ) );
2539 : 10 : sal_Int32 dCurrX = 0;
2540 : 10 : aHoriPos >>= dCurrX;
2541 : : // change x-position attribute, if needed
2542 [ + - ]: 10 : if ( dCurrX != _aPosition.X )
2543 : : {
2544 : : // adjust x-position orientation to text::HoriOrientation::NONE, if needed
2545 : : // Note: has to be done before setting x-position attribute
2546 [ + - ]: 10 : rtl::OUString aHoriOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") );
2547 [ + - ]: 10 : uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) );
2548 : : sal_Int16 eHoriOrient;
2549 [ - + ]: 10 : if (aHoriOrient >>= eHoriOrient) // may be void
2550 : : {
2551 [ # # ]: 0 : if ( eHoriOrient != text::HoriOrientation::NONE )
2552 : : {
2553 : 0 : eHoriOrient = text::HoriOrientation::NONE;
2554 [ # # ]: 0 : aHoriOrient <<= eHoriOrient;
2555 [ # # ]: 0 : setPropertyValue( aHoriOrientPropStr, aHoriOrient );
2556 : : }
2557 : : }
2558 : : // set x-position attribute
2559 [ + - ]: 10 : aHoriPos <<= _aPosition.X;
2560 [ + - ]: 10 : setPropertyValue( aHoriPosPropStr, aHoriPos );
2561 : 10 : }
2562 : : }
2563 : :
2564 : : // handle y-position
2565 : : {
2566 : : // determine current y-postion
2567 [ + - ]: 10 : rtl::OUString aVertPosPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition") );
2568 [ + - ]: 10 : uno::Any aVertPos( getPropertyValue( aVertPosPropStr ) );
2569 : 10 : sal_Int32 dCurrY = 0;
2570 : 10 : aVertPos >>= dCurrY;
2571 : : // change y-position attribute, if needed
2572 [ + - ]: 10 : if ( dCurrY != _aPosition.Y )
2573 : : {
2574 : : // adjust y-position orientation to text::VertOrientation::NONE, if needed
2575 : : // Note: has to be done before setting y-position attribute
2576 [ + - ]: 10 : rtl::OUString aVertOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrient") );
2577 [ + - ]: 10 : uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) );
2578 : : sal_Int16 eVertOrient;
2579 [ - + ]: 10 : if (aVertOrient >>= eVertOrient) // may be void
2580 : : {
2581 [ # # ]: 0 : if ( eVertOrient != text::VertOrientation::NONE )
2582 : : {
2583 : 0 : eVertOrient = text::VertOrientation::NONE;
2584 [ # # ]: 0 : aVertOrient <<= eVertOrient;
2585 [ # # ]: 0 : setPropertyValue( aVertOrientPropStr, aVertOrient );
2586 : : }
2587 : : }
2588 : : // set y-position attribute
2589 [ + - ]: 10 : aVertPos <<= _aPosition.Y;
2590 [ + - ]: 10 : setPropertyValue( aVertPosPropStr, aVertPos );
2591 : 10 : }
2592 : : }
2593 : 10 : }
2594 : :
2595 : : /** method to convert start or end position of the drawing object to the
2596 : : Writer specific position, which is the attribute position in layout direction
2597 : : #i59051#
2598 : : */
2599 : 0 : ::com::sun::star::awt::Point SwXShape::_ConvertStartOrEndPosToLayoutDir(
2600 : : const ::com::sun::star::awt::Point& aStartOrEndPos )
2601 : : {
2602 : 0 : awt::Point aConvertedPos( aStartOrEndPos );
2603 : :
2604 : 0 : SvxShape* pSvxShape = GetSvxShape();
2605 : : OSL_ENSURE( pSvxShape,
2606 : : "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
2607 [ # # ]: 0 : if ( pSvxShape )
2608 : : {
2609 : 0 : const SdrObject* pObj = pSvxShape->GetSdrObject();
2610 : : OSL_ENSURE( pObj,
2611 : : "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
2612 [ # # ]: 0 : if ( pObj )
2613 : : {
2614 : : // get position of object in Writer coordinate system.
2615 [ # # ]: 0 : awt::Point aPos( getPosition() );
2616 : : // get position of object in Drawing layer coordinate system
2617 [ # # ]: 0 : const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2618 : : const awt::Point aObjPos(
2619 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
[ # # ]
2620 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
[ # # ][ # # ]
[ # # ]
2621 : : // determine difference between these positions according to the
2622 : : // Writer coordinate system
2623 : : const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2624 : 0 : aPos.Y - aObjPos.Y );
2625 : : // apply translation difference to transformation matrix.
2626 [ # # ][ # # ]: 0 : if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2627 : : {
2628 : 0 : aConvertedPos.X = aConvertedPos.X + aTranslateDiff.X;
2629 : 0 : aConvertedPos.Y = aConvertedPos.Y + aTranslateDiff.Y;
2630 : : }
2631 : : }
2632 : : }
2633 : :
2634 : 0 : return aConvertedPos;
2635 : : }
2636 : :
2637 : 0 : ::com::sun::star::drawing::PolyPolygonBezierCoords SwXShape::_ConvertPolyPolygonBezierToLayoutDir(
2638 : : const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath )
2639 : : {
2640 : 0 : drawing::PolyPolygonBezierCoords aConvertedPath( aPath );
2641 : :
2642 [ # # ]: 0 : SvxShape* pSvxShape = GetSvxShape();
2643 : : OSL_ENSURE( pSvxShape,
2644 : : "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
2645 [ # # ]: 0 : if ( pSvxShape )
2646 : : {
2647 [ # # ]: 0 : const SdrObject* pObj = pSvxShape->GetSdrObject();
2648 : : OSL_ENSURE( pObj,
2649 : : "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
2650 [ # # ]: 0 : if ( pObj )
2651 : : {
2652 : : // get position of object in Writer coordinate system.
2653 [ # # ]: 0 : awt::Point aPos( getPosition() );
2654 : : // get position of object in Drawing layer coordinate system
2655 [ # # ]: 0 : const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2656 : : const awt::Point aObjPos(
2657 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
[ # # ]
2658 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
[ # # ][ # # ]
[ # # ]
2659 : : // determine difference between these positions according to the
2660 : : // Writer coordinate system
2661 : : const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2662 : 0 : aPos.Y - aObjPos.Y );
2663 : : // apply translation difference to PolyPolygonBezier.
2664 [ # # ][ # # ]: 0 : if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2665 : : {
2666 : : const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
2667 [ # # ]: 0 : aTranslateDiff.X, aTranslateDiff.Y));
2668 : :
2669 : 0 : const sal_Int32 nOuterSequenceCount(aConvertedPath.Coordinates.getLength());
2670 [ # # ]: 0 : drawing::PointSequence* pInnerSequence = aConvertedPath.Coordinates.getArray();
2671 [ # # ]: 0 : for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
2672 : : {
2673 : 0 : const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
2674 [ # # ]: 0 : awt::Point* pArray = pInnerSequence->getArray();
2675 : :
2676 [ # # ]: 0 : for(sal_Int32 b(0); b < nInnerSequenceCount; b++)
2677 : : {
2678 : 0 : basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y);
2679 [ # # ]: 0 : aNewCoordinatePair *= aMatrix;
2680 : 0 : pArray->X = basegfx::fround(aNewCoordinatePair.getX());
2681 : 0 : pArray->Y = basegfx::fround(aNewCoordinatePair.getY());
2682 : 0 : pArray++;
2683 : 0 : }
2684 [ # # ]: 0 : }
2685 : : }
2686 : : }
2687 : : }
2688 : :
2689 : 0 : return aConvertedPath;
2690 : : }
2691 : :
2692 : 12 : SwXGroupShape::SwXGroupShape(uno::Reference< XInterface > & xShape) :
2693 : 12 : SwXShape(xShape)
2694 : : {
2695 : : #if OSL_DEBUG_LEVEL > 0
2696 : : uno::Reference<XShapes> xShapes(xShapeAgg, uno::UNO_QUERY);
2697 : : OSL_ENSURE(xShapes.is(), "no SvxShape found or shape is not a group shape");
2698 : : #endif
2699 : 12 : }
2700 : :
2701 : 12 : SwXGroupShape::~SwXGroupShape()
2702 : : {
2703 [ - + ]: 24 : }
2704 : :
2705 : 264 : uno::Any SwXGroupShape::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
2706 : : {
2707 : 264 : uno::Any aRet;
2708 [ + + ][ + - ]: 264 : if(rType == ::getCppuType((uno::Reference<XShapes>*)0))
2709 [ + - ][ + - ]: 9 : aRet <<= uno::Reference<XShapes>(this);
2710 : : else
2711 [ + - ]: 255 : aRet = SwXShape::queryInterface(rType);
2712 : 264 : return aRet;
2713 : : }
2714 : :
2715 : 2868 : void SwXGroupShape::acquire( ) throw()
2716 : : {
2717 : 2868 : SwXShape::acquire();
2718 : 2868 : }
2719 : :
2720 : 2868 : void SwXGroupShape::release( ) throw()
2721 : : {
2722 : 2868 : SwXShape::release();
2723 : 2868 : }
2724 : :
2725 : 12 : void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException)
2726 : : {
2727 [ + - ]: 12 : SolarMutexGuard aGuard;
2728 [ + - ]: 12 : SvxShape* pSvxShape = GetSvxShape();
2729 : 12 : SwFrmFmt* pFmt = GetFrmFmt();
2730 [ + - ][ + - ]: 12 : if(pSvxShape && pFmt)
2731 : : {
2732 : 12 : uno::Reference<XShapes> xShapes;
2733 [ + - ]: 12 : if( xShapeAgg.is() )
2734 : : {
2735 [ + - ]: 12 : const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
2736 [ + - ][ + - ]: 12 : uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2737 [ + - ]: 12 : aAgg >>= xShapes;
2738 : : }
2739 [ + - ]: 12 : if(xShapes.is())
2740 [ + - ][ + - ]: 12 : xShapes->add(xShape);
2741 : : else
2742 [ # # ]: 0 : throw uno::RuntimeException();
2743 : :
2744 [ + - ]: 12 : uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY);
2745 : 12 : SwXShape* pSwShape = 0;
2746 [ + - ]: 12 : if(xShape.is())
2747 : : pSwShape = reinterpret_cast< SwXShape * >(
2748 [ + - ][ + - ]: 12 : sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
[ + - ]
2749 [ + - ][ + - ]: 12 : if(pSwShape && pSwShape->m_bDescriptor)
2750 : : {
2751 : : SvxShape* pAddShape = reinterpret_cast< SvxShape * >(
2752 [ + - ][ + - ]: 12 : sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2753 [ + - ]: 12 : if(pAddShape)
2754 : : {
2755 [ + - ]: 12 : SdrObject* pObj = pAddShape->GetSdrObject();
2756 [ + - ]: 12 : if(pObj)
2757 : : {
2758 : 12 : SwDoc* pDoc = pFmt->GetDoc();
2759 : : // set layer of new drawing
2760 : : // object to corresponding invisible layer.
2761 [ + - ][ + - ]: 12 : if( FmFormInventor != pObj->GetObjInventor())
2762 : : {
2763 : 12 : pObj->SetLayer( pSwShape->pImpl->GetOpaque()
2764 [ # # ]: 0 : ? pDoc->GetInvisibleHeavenId()
2765 [ + - ][ + - ]: 12 : : pDoc->GetInvisibleHellId() );
[ - + ]
2766 : : }
2767 : : else
2768 : : {
2769 [ # # ][ # # ]: 0 : pObj->SetLayer(pDoc->GetInvisibleControlsId());
2770 : : }
2771 : : }
2772 : : }
2773 : 12 : pSwShape->m_bDescriptor = sal_False;
2774 : : //add the group member to the format of the group
2775 [ + - ][ + - ]: 12 : SwFrmFmt* pShapeFmt = ::FindFrmFmt( pSvxShape->GetSdrObject() );
2776 [ + - ]: 12 : if(pShapeFmt)
2777 [ + - ][ + - ]: 12 : pFmt->Add(pSwShape);
2778 : 12 : }
2779 : : }
2780 : : else
2781 [ # # ][ + - ]: 12 : throw uno::RuntimeException();
2782 : 12 : }
2783 : :
2784 : 0 : void SwXGroupShape::remove( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException)
2785 : : {
2786 [ # # ]: 0 : SolarMutexGuard aGuard;
2787 : 0 : uno::Reference<XShapes> xShapes;
2788 [ # # ]: 0 : if( xShapeAgg.is() )
2789 : : {
2790 [ # # ]: 0 : const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
2791 [ # # ][ # # ]: 0 : uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2792 [ # # ]: 0 : aAgg >>= xShapes;
2793 : : }
2794 [ # # ]: 0 : if(!xShapes.is())
2795 [ # # ]: 0 : throw uno::RuntimeException();
2796 [ # # ][ # # ]: 0 : xShapes->remove(xShape);
[ # # ]
2797 : 0 : }
2798 : :
2799 : 0 : sal_Int32 SwXGroupShape::getCount(void) throw( uno::RuntimeException )
2800 : : {
2801 [ # # ]: 0 : SolarMutexGuard aGuard;
2802 : 0 : uno::Reference<XIndexAccess> xAcc;
2803 [ # # ]: 0 : if( xShapeAgg.is() )
2804 : : {
2805 [ # # ]: 0 : const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
2806 [ # # ][ # # ]: 0 : uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2807 [ # # ]: 0 : aAgg >>= xAcc;
2808 : : }
2809 [ # # ]: 0 : if(!xAcc.is())
2810 [ # # ]: 0 : throw uno::RuntimeException();
2811 [ # # ][ # # ]: 0 : return xAcc->getCount();
[ # # ]
2812 : : }
2813 : :
2814 : 0 : uno::Any SwXGroupShape::getByIndex(sal_Int32 nIndex)
2815 : : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
2816 : : uno::RuntimeException )
2817 : : {
2818 [ # # ]: 0 : SolarMutexGuard aGuard;
2819 : 0 : uno::Reference<XIndexAccess> xAcc;
2820 [ # # ]: 0 : if( xShapeAgg.is() )
2821 : : {
2822 [ # # ]: 0 : const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
2823 [ # # ][ # # ]: 0 : uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2824 [ # # ]: 0 : aAgg >>= xAcc;
2825 : : }
2826 [ # # ]: 0 : if(!xAcc.is())
2827 [ # # ]: 0 : throw uno::RuntimeException();
2828 [ # # ][ # # ]: 0 : return xAcc->getByIndex(nIndex);
[ # # ]
2829 : : }
2830 : :
2831 : 0 : uno::Type SwXGroupShape::getElementType( ) throw(uno::RuntimeException)
2832 : : {
2833 [ # # ]: 0 : SolarMutexGuard aGuard;
2834 : 0 : uno::Reference<XIndexAccess> xAcc;
2835 [ # # ]: 0 : if( xShapeAgg.is() )
2836 : : {
2837 [ # # ]: 0 : const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
2838 [ # # ][ # # ]: 0 : uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2839 [ # # ]: 0 : aAgg >>= xAcc;
2840 : : }
2841 [ # # ]: 0 : if(!xAcc.is())
2842 [ # # ]: 0 : throw uno::RuntimeException();
2843 [ # # ][ # # ]: 0 : return xAcc->getElementType();
[ # # ]
2844 : : }
2845 : :
2846 : 6 : sal_Bool SwXGroupShape::hasElements( ) throw(uno::RuntimeException)
2847 : : {
2848 [ + - ]: 6 : SolarMutexGuard aGuard;
2849 : 6 : uno::Reference<XIndexAccess> xAcc;
2850 [ + - ]: 6 : if( xShapeAgg.is() )
2851 : : {
2852 [ + - ]: 6 : const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
2853 [ + - ][ + - ]: 6 : uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2854 [ + - ]: 6 : aAgg >>= xAcc;
2855 : : }
2856 [ - + ]: 6 : if(!xAcc.is())
2857 [ # # ]: 0 : throw uno::RuntimeException();
2858 [ + - ][ + - ]: 6 : return xAcc->hasElements();
[ + - ]
2859 [ + - ][ + - ]: 219 : }
2860 : :
2861 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|