Update ooo320-m1
[ooovba.git] / sw / source / core / unocore / unodraw.cxx
bloba88f0a26c044615397dccf1e62c8b68db7d73bf7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unodraw.cxx,v $
10 * $Revision: 1.82 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <swtypes.hxx>
35 #include <cmdid.h>
37 #include <unomid.h>
38 #include <unodraw.hxx>
39 #include <unocoll.hxx>
40 #include <unoframe.hxx>
41 #include <unoprnms.hxx>
42 #include <svx/unoprnms.hxx>
43 #include <swunohelper.hxx>
44 #include <doc.hxx>
45 #include <fmtflcnt.hxx>
46 #include <txtatr.hxx>
47 #include <docsh.hxx>
48 #include <unomap.hxx>
49 #include <unoport.hxx>
50 #include <unocrsr.hxx>
51 #include <swundo.hxx>
52 #include <dflyobj.hxx>
53 #include <ndtxt.hxx>
54 #include <svx/svdview.hxx>
55 #include <svx/unoshape.hxx>
56 #include <dcontact.hxx>
57 #include <svx/fmglob.hxx>
58 #include <fmtornt.hxx>
59 #include <fmtanchr.hxx>
60 #include <fmtsrnd.hxx>
61 // OD 2004-04-21 #i26791#
62 #include <fmtfollowtextflow.hxx>
63 #include <rootfrm.hxx>
64 #include <svx/lrspitem.hxx>
65 #include <svx/ulspitem.hxx>
66 #include <svx/shapepropertynotifier.hxx>
67 #include <crstate.hxx>
68 #include <vos/mutex.hxx>
69 #include <comphelper/extract.hxx>
70 #include <comphelper/stl_types.hxx>
71 #include <comphelper/makesequence.hxx>
72 #include <svx/scene3d.hxx>
73 #include <com/sun/star/beans/PropertyAttribute.hpp>
74 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
75 #include <com/sun/star/text/HoriOrientation.hpp>
76 #include <com/sun/star/text/VertOrientation.hpp>
77 #include <basegfx/numeric/ftools.hxx>
78 // OD 2004-05-05 #i28701#
79 #include <fmtwrapinfluenceonobjpos.hxx>
80 // --> OD 2004-11-10 #i35007#
81 #include <com/sun/star/text/TextContentAnchorType.hpp>
82 // <--
83 // --> OD 2005-03-10 #i44334#, #i44681#
84 // --> OD 2007-01-03 #i73079# - use correct matrix type
85 #include <basegfx/matrix/b2dhommatrix.hxx>
86 // <--
87 // --> OD 2009-01-16 #i59051
88 #include <com/sun/star/drawing/PointSequence.hpp>
89 // <--
91 #include <vcl/svapp.hxx>
92 #include <slist>
93 #include <iterator>
95 using ::rtl::OUString;
96 using namespace ::com::sun::star;
98 DECLARE_STL_USTRINGACCESS_MAP( uno::Sequence< sal_Int8 > *, SwShapeImplementationIdMap );
100 static SwShapeImplementationIdMap aImplementationIdMap;
102 /* -----------------22.01.99 13:19-------------------
104 * --------------------------------------------------*/
105 class SwShapeDescriptor_Impl
107 SwFmtHoriOrient* pHOrient;
108 SwFmtVertOrient* pVOrient;
109 SwFmtAnchor* pAnchor;
110 SwFmtSurround* pSurround;
111 SvxULSpaceItem* pULSpace;
112 SvxLRSpaceItem* pLRSpace;
113 sal_Bool bOpaque;
114 uno::Reference< text::XTextRange > xTextRange;
115 // OD 2004-04-21 #i26791#
116 SwFmtFollowTextFlow* mpFollowTextFlow;
117 // OD 2004-05-05 #i28701# - add property 'WrapInfluenceOnObjPos'
118 SwFmtWrapInfluenceOnObjPos* pWrapInfluenceOnObjPos;
119 // --> OD 2004-08-06 #i28749#
120 sal_Int16 mnPositionLayoutDir;
121 // <--
123 public:
124 bool bInitializedPropertyNotifier;
126 public:
127 SwShapeDescriptor_Impl() :
128 // --> OD 2004-08-18 #i32349# - no defaults, in order to determine on
129 // adding a shape, if positioning attributes are set or not.
130 pHOrient( 0L ),
131 pVOrient( 0L ),
132 // <--
133 pAnchor(0),
134 pSurround(0),
135 pULSpace(0),
136 pLRSpace(0),
137 bOpaque(sal_False),
138 // OD 2004-04-21 #i26791#
139 mpFollowTextFlow( new SwFmtFollowTextFlow( FALSE ) ),
140 // OD 2004-05-05 #i28701#
141 // --> OD 2004-10-18 #i35017# - constant name has changed
142 pWrapInfluenceOnObjPos( new SwFmtWrapInfluenceOnObjPos(
143 text::WrapInfluenceOnPosition::ONCE_CONCURRENT ) ),
144 // <--
145 // --> OD 2004-08-06 #i28749#
146 mnPositionLayoutDir( text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
147 bInitializedPropertyNotifier(false)
150 ~SwShapeDescriptor_Impl()
152 delete pHOrient;
153 delete pVOrient;
154 delete pAnchor;
155 delete pSurround;
156 delete pULSpace;
157 delete pLRSpace;
158 // OD 2004-04-22 #i26791#
159 delete mpFollowTextFlow;
160 // OD 2004-05-05 #i28701#
161 delete pWrapInfluenceOnObjPos;
163 SwFmtAnchor* GetAnchor(sal_Bool bCreate = sal_False)
165 if(bCreate && !pAnchor)
166 pAnchor = new SwFmtAnchor(FLY_IN_CNTNT);
167 return pAnchor;
169 SwFmtHoriOrient* GetHOrient(sal_Bool bCreate = sal_False)
171 if (bCreate && !pHOrient)
173 // OD 2004-06-03 #i26791# - change default
174 pHOrient = new SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
176 return pHOrient;
178 SwFmtVertOrient* GetVOrient(sal_Bool bCreate = sal_False)
180 if(bCreate && !pVOrient)
182 // OD 2004-04-21 #i26791# - change default
183 pVOrient = new SwFmtVertOrient( 0, text::VertOrientation::NONE, text::RelOrientation::FRAME );
185 return pVOrient;
188 SwFmtSurround* GetSurround(sal_Bool bCreate = sal_False)
190 if(bCreate && !pSurround)
191 pSurround = new SwFmtSurround();
192 return pSurround;
194 SvxLRSpaceItem* GetLRSpace(sal_Bool bCreate = sal_False)
196 if(bCreate && !pLRSpace)
197 pLRSpace = new SvxLRSpaceItem(RES_LR_SPACE);
198 return pLRSpace;
200 SvxULSpaceItem* GetULSpace(sal_Bool bCreate = sal_False)
202 if(bCreate && !pULSpace)
203 pULSpace = new SvxULSpaceItem(RES_UL_SPACE);
204 return pULSpace;
206 uno::Reference< text::XTextRange > & GetTextRange()
208 return xTextRange;
210 sal_Bool IsOpaque()
212 return bOpaque;
214 const sal_Bool& GetOpaque()
216 return bOpaque;
218 void RemoveHOrient(){DELETEZ(pHOrient);}
219 void RemoveVOrient(){DELETEZ(pVOrient);}
220 void RemoveAnchor(){DELETEZ(pAnchor);}
221 void RemoveSurround(){DELETEZ(pSurround);}
222 void RemoveULSpace(){DELETEZ(pULSpace);}
223 void RemoveLRSpace(){DELETEZ(pLRSpace);}
224 void SetOpaque(sal_Bool bSet){bOpaque = bSet;}
226 // OD 2004-04-21 #i26791#
227 SwFmtFollowTextFlow* GetFollowTextFlow( sal_Bool _bCreate = sal_False )
229 if ( _bCreate && !mpFollowTextFlow )
230 mpFollowTextFlow = new SwFmtFollowTextFlow( FALSE );
231 return mpFollowTextFlow;
233 void RemoveFollowTextFlow()
235 DELETEZ(mpFollowTextFlow);
238 // --> OD 2004-08-06 #i28749#
239 sal_Int16 GetPositionLayoutDir() const
241 return mnPositionLayoutDir;
243 void SetPositionLayoutDir( sal_Int16 _nPositionLayoutDir )
245 switch ( _nPositionLayoutDir )
247 case text::PositionLayoutDir::PositionInHoriL2R:
248 case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
250 mnPositionLayoutDir = _nPositionLayoutDir;
252 break;
253 default:
255 ASSERT( false,
256 "<SwShapeDescriptor_Impl::SetPositionLayoutDir(..)> - invalid attribute value." );
260 void RemovePositionLayoutDir()
262 mnPositionLayoutDir = text::PositionLayoutDir::PositionInLayoutDirOfAnchor;
264 // <--
266 // OD 2004-05-05 #i28701#
267 inline SwFmtWrapInfluenceOnObjPos* GetWrapInfluenceOnObjPos(
268 const sal_Bool _bCreate = sal_False )
270 if ( _bCreate && !pWrapInfluenceOnObjPos )
272 pWrapInfluenceOnObjPos = new SwFmtWrapInfluenceOnObjPos(
273 // --> OD 2004-10-18 #i35017# - constant name has changed
274 text::WrapInfluenceOnPosition::ONCE_CONCURRENT );
275 // <--
277 return pWrapInfluenceOnObjPos;
279 inline void RemoveWrapInfluenceOnObjPos()
281 DELETEZ(pWrapInfluenceOnObjPos);
284 /****************************************************************************
285 class SwFmDrawPage
286 ****************************************************************************/
288 /* -----------------28.01.99 12:03-------------------
290 * --------------------------------------------------*/
291 SwFmDrawPage::SwFmDrawPage( SdrPage* pPage ) :
292 SvxFmDrawPage( pPage ), pPageView(0)
296 /*-- 22.01.99 11:13:07---------------------------------------------------
298 -----------------------------------------------------------------------*/
299 SwFmDrawPage::~SwFmDrawPage() throw ()
301 RemovePageView();
303 /*-- 22.01.99 11:13:07---------------------------------------------------
305 -----------------------------------------------------------------------*/
306 const SdrMarkList& SwFmDrawPage::PreGroup(const uno::Reference< drawing::XShapes > & xShapes)
308 _SelectObjectsInView( xShapes, GetPageView() );
309 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
310 return rMarkList;
312 /*-- 22.01.99 11:13:08---------------------------------------------------
314 -----------------------------------------------------------------------*/
315 void SwFmDrawPage::PreUnGroup(const uno::Reference< drawing::XShapeGroup > xShapeGroup)
317 uno::Reference< drawing::XShape > xShape( xShapeGroup, uno::UNO_QUERY);
318 _SelectObjectInView( xShape, GetPageView() );
320 /*-- 22.01.99 11:13:08---------------------------------------------------
322 -----------------------------------------------------------------------*/
323 SdrPageView* SwFmDrawPage::GetPageView()
325 if(!pPageView)
326 pPageView = mpView->ShowSdrPage( mpPage );
327 return pPageView;
329 /*-- 22.01.99 11:13:08---------------------------------------------------
331 -----------------------------------------------------------------------*/
332 void SwFmDrawPage::RemovePageView()
334 if(pPageView && mpView)
335 mpView->HideSdrPage();
336 pPageView = 0;
338 /*-- 22.01.99 11:13:09---------------------------------------------------
340 -----------------------------------------------------------------------*/
341 uno::Reference< uno::XInterface > SwFmDrawPage::GetInterface( SdrObject* pObj )
343 uno::Reference< XInterface > xShape;
344 if( pObj )
346 SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
347 SwXShape* pxShape = (SwXShape*)SwClientIter( *pFmt ).
348 First( TYPE( SwXShape ));
349 if(pxShape)
351 xShape = *(cppu::OWeakObject*)pxShape;
353 else
354 xShape = pObj->getUnoShape();
356 return xShape;
358 /*-- 22.01.99 11:13:09---------------------------------------------------
360 -----------------------------------------------------------------------*/
361 SdrObject* SwFmDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape > & xShape ) throw ()
363 //TODO: stimmt das so - kann die Methode weg?
364 return SvxFmDrawPage::_CreateSdrObject( xShape );
366 /*-- 22.01.99 11:13:09---------------------------------------------------
368 -----------------------------------------------------------------------*/
370 uno::Reference< drawing::XShape > SwFmDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
372 uno::Reference< drawing::XShape > xRet;
373 if(pObj->ISA(SwVirtFlyDrawObj) || pObj->GetObjInventor() == SWGInventor)
375 SwFlyDrawContact* pFlyContact = (SwFlyDrawContact*)pObj->GetUserCall();
376 if(pFlyContact)
378 FlyCntType eType = FLYCNTTYPE_ALL;
379 SwFrmFmt* pFlyFmt = pFlyContact->GetFmt();
380 SwDoc* pDoc = pFlyFmt->GetDoc();
381 const SwNodeIndex* pIdx;
382 if( RES_FLYFRMFMT == pFlyFmt->Which()
383 && 0 != ( pIdx = pFlyFmt->GetCntnt().GetCntntIdx() )
384 && pIdx->GetNodes().IsDocNodes()
387 const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
388 if(!pNd->IsNoTxtNode())
389 eType = FLYCNTTYPE_FRM;
390 else if( pNd->IsGrfNode() )
391 eType = FLYCNTTYPE_GRF;
392 else if( pNd->IsOLENode() )
393 eType = FLYCNTTYPE_OLE;
395 else
397 ASSERT( false,
398 "<SwFmDrawPage::_CreateShape(..)> - could not retrieve type. Thus, no shape created." );
399 return xRet;
401 DBG_ASSERT( eType != FLYCNTTYPE_ALL, "unexpected FlyCntType value for eType" );
402 xRet = SwXFrames::GetObject( *pFlyFmt, eType );
405 else
407 // own block - temporary object has to be destroyed before
408 // the delegator is set #81670#
410 xRet = SvxFmDrawPage::_CreateShape( pObj );
412 uno::Reference< XUnoTunnel > xShapeTunnel(xRet, uno::UNO_QUERY);
413 //don't create an SwXShape if it already exists
414 SwXShape* pShape = 0;
415 if(xShapeTunnel.is())
416 pShape = reinterpret_cast< SwXShape * >(
417 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
418 if(!pShape)
420 xShapeTunnel = 0;
421 uno::Reference< uno::XInterface > xCreate(xRet, uno::UNO_QUERY);
422 xRet = 0;
423 uno::Reference< beans::XPropertySet > xPrSet;
424 if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || ( PTR_CAST(E3dScene,pObj ) != NULL ) ) )
425 xPrSet = new SwXGroupShape( xCreate );
426 else
427 xPrSet = new SwXShape( xCreate );
428 xRet = uno::Reference< drawing::XShape >(xPrSet, uno::UNO_QUERY);
431 return xRet;
434 /****************************************************************************
435 class SwXShapesEnumeration
436 ****************************************************************************/
437 namespace
439 class SwXShapesEnumeration : public SwSimpleEnumerationBaseClass
441 private:
442 typedef ::std::slist< ::com::sun::star::uno::Any > shapescontainer_t;
443 shapescontainer_t m_aShapes;
444 protected:
445 virtual ~SwXShapesEnumeration() {};
446 public:
447 SwXShapesEnumeration(SwXDrawPage* const pDrawPage);
449 //XEnumeration
450 virtual BOOL SAL_CALL hasMoreElements(void) throw(uno::RuntimeException);
451 virtual uno::Any SAL_CALL nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
453 //XServiceInfo
454 virtual OUString SAL_CALL getImplementationName(void) throw(uno::RuntimeException);
455 virtual BOOL SAL_CALL supportsService(const OUString& ServiceName) throw(uno::RuntimeException);
456 virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames(void) throw(uno::RuntimeException);
460 SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage)
461 : m_aShapes()
463 vos::OGuard aGuard(Application::GetSolarMutex());
464 ::std::insert_iterator<shapescontainer_t> pInserter = ::std::insert_iterator<shapescontainer_t>(m_aShapes, m_aShapes.begin());
465 sal_Int32 nCount = pDrawPage->getCount();
466 for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++)
468 uno::Reference<drawing::XShape> xShape = uno::Reference<drawing::XShape>(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY);
469 *pInserter++ = uno::makeAny(xShape);
473 BOOL SwXShapesEnumeration::hasMoreElements(void) throw(uno::RuntimeException)
475 vos::OGuard aGuard(Application::GetSolarMutex());
476 return !m_aShapes.empty();
479 uno::Any SwXShapesEnumeration::nextElement(void) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
481 vos::OGuard aGuard(Application::GetSolarMutex());
482 if(m_aShapes.empty())
483 throw container::NoSuchElementException();
484 uno::Any aResult = *m_aShapes.begin();
485 m_aShapes.pop_front();
486 return aResult;
489 OUString SwXShapesEnumeration::getImplementationName(void) throw(uno::RuntimeException)
491 return C2U("SwXShapeEnumeration");
494 BOOL SwXShapesEnumeration::supportsService(const OUString& ServiceName) throw(uno::RuntimeException)
496 return C2U("com.sun.star.container.XEnumeration") == ServiceName;
499 uno::Sequence< OUString > SwXShapesEnumeration::getSupportedServiceNames(void) throw(uno::RuntimeException)
501 return ::comphelper::makeSequence(C2U("com.sun.star.container.XEnumeration"));
503 /****************************************************************************
504 class SwXDrawPage
505 ****************************************************************************/
506 uno::Reference< container::XEnumeration > SwXDrawPage::createEnumeration(void) throw( uno::RuntimeException )
508 vos::OGuard aGuard(Application::GetSolarMutex());
509 return uno::Reference< container::XEnumeration >(
510 new SwXShapesEnumeration(this));
512 /* -----------------------------06.04.00 13:14--------------------------------
514 ---------------------------------------------------------------------------*/
515 rtl::OUString SwXDrawPage::getImplementationName(void) throw( uno::RuntimeException )
517 return C2U("SwXDrawPage");
519 /* -----------------------------06.04.00 13:14--------------------------------
521 ---------------------------------------------------------------------------*/
522 BOOL SwXDrawPage::supportsService(const rtl::OUString& rServiceName) throw( uno::RuntimeException )
524 return C2U("com.sun.star.drawing.GenericDrawPage") == rServiceName;
526 /* -----------------------------06.04.00 13:14--------------------------------
528 ---------------------------------------------------------------------------*/
529 uno::Sequence< rtl::OUString > SwXDrawPage::getSupportedServiceNames(void) throw( uno::RuntimeException )
531 uno::Sequence< rtl::OUString > aRet(1);
532 rtl::OUString* pArray = aRet.getArray();
533 pArray[0] = C2U("com.sun.star.drawing.GenericDrawPage");
534 return aRet;
536 /*-- 22.01.99 11:22:25---------------------------------------------------
538 -----------------------------------------------------------------------*/
539 SwXDrawPage::SwXDrawPage(SwDoc* pDc) :
540 pDoc(pDc),
541 pDrawPage(0)
544 /*-- 22.01.99 11:22:25---------------------------------------------------
546 -----------------------------------------------------------------------*/
547 SwXDrawPage::~SwXDrawPage()
549 if(xPageAgg.is())
551 uno::Reference< uno::XInterface > xInt;
552 xPageAgg->setDelegator(xInt);
555 /* -----------------------------15.06.00 15:00--------------------------------
557 ---------------------------------------------------------------------------*/
558 uno::Any SwXDrawPage::queryInterface( const uno::Type& aType )
559 throw( uno::RuntimeException )
561 uno::Any aRet = SwXDrawPageBaseClass::queryInterface(aType);
562 if(!aRet.hasValue())
564 // secure with checking if page exists. This may not be the case
565 // either for new SW docs with no yet graphics usage or when
566 // the doc is closed and someone else still holds a UNO reference
567 // to the XDrawPage (in that case, pDoc is set to 0)
568 SwFmDrawPage* pPage = GetSvxPage();
570 if(pPage)
572 aRet = pPage->queryAggregation(aType);
575 return aRet;
577 /* -----------------------------15.06.00 15:01--------------------------------
579 ---------------------------------------------------------------------------*/
580 uno::Sequence< uno::Type > SwXDrawPage::getTypes() throw( uno::RuntimeException )
582 uno::Sequence< uno::Type > aPageTypes = SwXDrawPageBaseClass::getTypes();
583 uno::Sequence< uno::Type > aSvxTypes = GetSvxPage()->getTypes();
585 long nIndex = aPageTypes.getLength();
586 aPageTypes.realloc(aPageTypes.getLength() + aSvxTypes.getLength() + 1);
588 uno::Type* pPageTypes = aPageTypes.getArray();
589 const uno::Type* pSvxTypes = aSvxTypes.getConstArray();
590 long nPos;
591 for(nPos = 0; nPos < aSvxTypes.getLength(); nPos++)
593 pPageTypes[nIndex++] = pSvxTypes[nPos];
595 pPageTypes[nIndex] = ::getCppuType((uno::Reference<form::XFormsSupplier2>*)0);
596 return aPageTypes;
598 /*-- 22.01.99 11:33:44---------------------------------------------------
600 -----------------------------------------------------------------------*/
601 sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException )
603 vos::OGuard aGuard(Application::GetSolarMutex());
604 if(!pDoc)
605 throw uno::RuntimeException();
606 if(!pDoc->GetDrawModel())
607 return 0;
608 else
610 ((SwXDrawPage*)this)->GetSvxPage();
611 return pDrawPage->getCount();
614 /*-- 22.01.99 11:33:46---------------------------------------------------
616 -----------------------------------------------------------------------*/
617 uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex)
618 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
619 uno::RuntimeException )
621 vos::OGuard aGuard(Application::GetSolarMutex());
622 if(!pDoc)
623 throw uno::RuntimeException();
624 if(!pDoc->GetDrawModel())
625 throw lang::IndexOutOfBoundsException();
627 ((SwXDrawPage*)this)->GetSvxPage();
628 return pDrawPage->getByIndex( nIndex );
630 /* -----------------22.01.99 13:13-------------------
632 * --------------------------------------------------*/
633 uno::Type SwXDrawPage::getElementType(void) throw( uno::RuntimeException )
635 return ::getCppuType((const uno::Reference<drawing::XShape>*)0);
637 /* -----------------22.01.99 13:13-------------------
639 * --------------------------------------------------*/
640 sal_Bool SwXDrawPage::hasElements(void) throw( uno::RuntimeException )
642 vos::OGuard aGuard(Application::GetSolarMutex());
643 if(!pDoc)
644 throw uno::RuntimeException();
645 if(!pDoc->GetDrawModel())
646 return sal_False;
647 else
648 return ((SwXDrawPage*)this)->GetSvxPage()->hasElements();
651 /* -----------------22.01.99 12:42-------------------
653 * --------------------------------------------------*/
654 void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
655 throw( uno::RuntimeException )
657 vos::OGuard aGuard(Application::GetSolarMutex());
658 if(!pDoc)
659 throw uno::RuntimeException();
660 uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShape, uno::UNO_QUERY);
661 SwXShape* pShape = 0;
662 SvxShape* pSvxShape = 0;
663 if(xShapeTunnel.is())
665 pShape = reinterpret_cast< SwXShape * >(
666 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
667 pSvxShape = reinterpret_cast< SvxShape * >(
668 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
671 if(!pShape || pShape->GetRegisteredIn() || !pShape->m_bDescriptor )
673 uno::RuntimeException aExcept;
674 if(pShape)
675 aExcept.Message = C2U("object already inserted");
676 else
677 aExcept.Message = C2U("illegal object");
678 throw aExcept;
681 // --> OD, HB
682 if ( pSvxShape->GetSdrObject() )
684 if ( pSvxShape->GetSdrObject()->IsInserted() )
686 return;
689 // <--
690 GetSvxPage()->add(xShape);
692 uno::Reference< uno::XAggregation > xAgg = pShape->GetAggregationInterface();
694 DBG_ASSERT(pSvxShape, "warum gibt es hier kein SvxShape?");
695 //diese Position ist auf jeden Fall in 1/100 mm
696 awt::Point aMM100Pos(pSvxShape->getPosition());
698 //jetzt noch die Properties aus dem SwShapeDescriptor_Impl auswerten
699 SwShapeDescriptor_Impl* pDesc = pShape->GetDescImpl();
701 SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
702 RES_FRMATR_END-1 );
703 SwFmtAnchor aAnchor( FLY_IN_CNTNT );
704 sal_Bool bOpaque = sal_False;
705 if( pDesc )
707 if(pDesc->GetSurround())
708 aSet.Put( *pDesc->GetSurround());
709 //die Items sind schon in Twip gesetzt
710 if(pDesc->GetLRSpace())
712 aSet.Put(*pDesc->GetLRSpace());
714 if(pDesc->GetULSpace())
716 aSet.Put(*pDesc->GetULSpace());
718 if(pDesc->GetAnchor())
719 aAnchor = *pDesc->GetAnchor();
721 // --> OD 2004-08-18 #i32349# - if no horizontal position exists, create one
722 if ( !pDesc->GetHOrient() )
724 SwFmtHoriOrient* pHori = pDesc->GetHOrient( sal_True );
725 SwTwips nHoriPos = MM100_TO_TWIP(aMM100Pos.X);
726 pHori->SetPos( nHoriPos );
728 // <--
730 if(pDesc->GetHOrient()->GetHoriOrient() == text::HoriOrientation::NONE)
731 aMM100Pos.X = TWIP_TO_MM100(pDesc->GetHOrient()->GetPos());
732 aSet.Put( *pDesc->GetHOrient() );
734 // --> OD 2004-08-18 #i32349# - if no vertical position exists, create one
735 if ( !pDesc->GetVOrient() )
737 SwFmtVertOrient* pVert = pDesc->GetVOrient( sal_True );
738 SwTwips nVertPos = MM100_TO_TWIP(aMM100Pos.Y);
739 pVert->SetPos( nVertPos );
741 // <--
743 if(pDesc->GetVOrient()->GetVertOrient() == text::VertOrientation::NONE)
744 aMM100Pos.Y = TWIP_TO_MM100(pDesc->GetVOrient()->GetPos());
745 aSet.Put( *pDesc->GetVOrient() );
748 if(pDesc->GetSurround())
749 aSet.Put( *pDesc->GetSurround());
750 bOpaque = pDesc->IsOpaque();
752 // OD 2004-04-22 #i26791#
753 if ( pDesc->GetFollowTextFlow() )
755 aSet.Put( *pDesc->GetFollowTextFlow() );
758 // OD 2004-05-05 #i28701#
759 if ( pDesc->GetWrapInfluenceOnObjPos() )
761 aSet.Put( *pDesc->GetWrapInfluenceOnObjPos() );
765 pSvxShape->setPosition(aMM100Pos);
766 SdrObject* pObj = pSvxShape->GetSdrObject();
767 // OD 25.06.2003 #108784# - set layer of new drawing object to corresponding
768 // invisible layer.
769 if(FmFormInventor != pObj->GetObjInventor())
770 pObj->SetLayer( bOpaque ? pDoc->GetInvisibleHeavenId() : pDoc->GetInvisibleHellId() );
771 else
772 pObj->SetLayer(pDoc->GetInvisibleControlsId());
774 SwPaM* pPam = new SwPaM(pDoc->GetNodes().GetEndOfContent());
775 SwUnoInternalPaM* pInternalPam = 0;
776 uno::Reference< text::XTextRange > xRg;
777 if( pDesc && (xRg = pDesc->GetTextRange()).is() )
779 pInternalPam = new SwUnoInternalPaM(*pDoc);
780 if(SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg))
782 if(FLY_AT_FLY == aAnchor.GetAnchorId() &&
783 !pInternalPam->GetNode()->FindFlyStartNode())
784 aAnchor.SetType(FLY_IN_CNTNT);
785 else if(FLY_PAGE == aAnchor.GetAnchorId())
786 aAnchor.SetAnchor(pInternalPam->Start());
788 else
789 throw uno::RuntimeException();
791 else if( aAnchor.GetAnchorId() != FLY_PAGE && pDoc->GetRootFrm() )
793 SwCrsrMoveState aState( MV_SETONLYTEXT );
794 Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y));
795 pDoc->GetRootFrm()->GetCrsrOfst( pPam->GetPoint(), aTmp, &aState );
796 aAnchor.SetAnchor( pPam->GetPoint() );
798 // --> OD 2004-08-18 #i32349# - adjustment of vertical positioning
799 // attributes no longer needed, because its already got a default.
801 else
803 aAnchor.SetType(FLY_PAGE);
805 // --> OD 2004-08-18 #i32349# - adjustment of vertical positioning
806 // attributes no longer needed, because its already got a default.
808 aSet.Put(aAnchor);
809 SwPaM* pTemp = pInternalPam;
810 if ( !pTemp )
811 pTemp = pPam;
812 UnoActionContext aAction(pDoc);
813 pDoc->Insert( *pTemp, *pObj, &aSet, NULL );
814 SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
815 if(pFmt)
816 pFmt->Add(pShape);
817 pShape->m_bDescriptor = sal_False;
819 delete pPam;
820 delete pInternalPam;
822 /* -----------------22.01.99 12:42-------------------
824 * --------------------------------------------------*/
825 void SwXDrawPage::remove(const uno::Reference< drawing::XShape > & xShape) throw( uno::RuntimeException )
827 vos::OGuard aGuard(Application::GetSolarMutex());
828 if(!pDoc)
829 throw uno::RuntimeException();
830 uno::Reference<lang::XComponent> xComp(xShape, uno::UNO_QUERY);
831 xComp->dispose();
833 /* -----------------17.02.99 10:38-------------------
835 * --------------------------------------------------*/
836 uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< drawing::XShapes > & xShapes) throw( uno::RuntimeException )
838 vos::OGuard aGuard(Application::GetSolarMutex());
839 if(!pDoc || !xShapes.is())
840 throw uno::RuntimeException();
841 uno::Reference< drawing::XShapeGroup > xRet;
842 if(xPageAgg.is())
845 SwFmDrawPage* pPage = GetSvxPage();
846 if(pPage)//kann das auch Null sein?
848 //markieren und MarkList zurueckgeben
849 const SdrMarkList& rMarkList = pPage->PreGroup(xShapes);
850 if ( rMarkList.GetMarkCount() > 1 )
852 sal_Bool bFlyInCnt = sal_False;
853 for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i )
855 const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
856 if ( FLY_IN_CNTNT == ::FindFrmFmt( (SdrObject*)pObj )->GetAnchor().GetAnchorId() )
857 bFlyInCnt = sal_True;
859 if( bFlyInCnt )
860 throw uno::RuntimeException();
861 if( !bFlyInCnt )
863 UnoActionContext aContext(pDoc);
864 pDoc->StartUndo( UNDO_START, NULL );
866 SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() );
867 pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/,
868 sal_True, sal_False );
870 pPage->GetDrawView()->UnmarkAll();
871 if(pContact)
873 uno::Reference< uno::XInterface > xInt = pPage->GetInterface( pContact->GetMaster() );
874 xRet = uno::Reference< drawing::XShapeGroup >(xInt, uno::UNO_QUERY);
876 pDoc->EndUndo( UNDO_END, NULL );
879 pPage->RemovePageView();
882 return xRet;
884 /* -----------------17.02.99 10:38-------------------
886 * --------------------------------------------------*/
887 void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeGroup) throw( uno::RuntimeException )
889 vos::OGuard aGuard(Application::GetSolarMutex());
890 if(!pDoc)
891 throw uno::RuntimeException();
892 if(xPageAgg.is())
894 SwFmDrawPage* pPage = GetSvxPage();
895 if(pPage)//kann das auch Null sein?
897 pPage->PreUnGroup(xShapeGroup);
898 UnoActionContext aContext(pDoc);
899 pDoc->StartUndo( UNDO_START, NULL );
901 pDoc->UnGroupSelection( *pPage->GetDrawView() );
902 pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/,
903 sal_True, sal_False );
904 pDoc->EndUndo( UNDO_END, NULL );
906 pPage->RemovePageView();
909 /* -----------------05.05.98 17:05-------------------
911 * --------------------------------------------------*/
912 SwFmDrawPage* SwXDrawPage::GetSvxPage()
914 if(!xPageAgg.is() && pDoc)
916 vos::OGuard aGuard(Application::GetSolarMutex());
917 // --> OD 2005-08-08 #i52858# - method name changed
918 SdrModel* pModel = pDoc->GetOrCreateDrawModel();
919 // <--
920 SdrPage* pPage = pModel->GetPage( 0 );
923 // waehrend des queryInterface braucht man ein Ref auf das
924 // Objekt, sonst wird es geloescht.
925 pDrawPage = new SwFmDrawPage(pPage);
926 uno::Reference< drawing::XDrawPage > xPage = pDrawPage;
927 uno::Any aAgg = xPage->queryInterface(::getCppuType((uno::Reference< uno::XAggregation >*)0));
928 if(aAgg.getValueType() == ::getCppuType((uno::Reference< uno::XAggregation >*)0))
929 xPageAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
931 if( xPageAgg.is() )
932 xPageAgg->setDelegator( (cppu::OWeakObject*)this );
934 return pDrawPage;
937 // renamed and outlined to detect where it's called
938 void SwXDrawPage::InvalidateSwDoc()
940 pDoc = 0;
943 /****************************************************************************
945 ****************************************************************************/
946 TYPEINIT1(SwXShape, SwClient);
947 /* -----------------------------10.03.00 18:02--------------------------------
949 ---------------------------------------------------------------------------*/
950 const uno::Sequence< sal_Int8 > & SwXShape::getUnoTunnelId()
952 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
953 return aSeq;
955 /* -----------------------------10.03.00 18:04--------------------------------
957 ---------------------------------------------------------------------------*/
958 sal_Int64 SAL_CALL SwXShape::getSomething( const uno::Sequence< sal_Int8 >& rId )
959 throw(uno::RuntimeException)
961 if( rId.getLength() == 16
962 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
963 rId.getConstArray(), 16 ) )
965 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
968 if( xShapeAgg.is() )
970 const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*)0 );
971 uno::Any aAgg = xShapeAgg->queryAggregation( rTunnelType );
972 if(aAgg.getValueType() == rTunnelType)
974 uno::Reference<lang::XUnoTunnel> xAggTunnel =
975 *(uno::Reference<lang::XUnoTunnel>*)aAgg.getValue();
976 if(xAggTunnel.is())
977 return xAggTunnel->getSomething(rId);
980 return 0;
982 namespace
984 static void lcl_addShapePropertyEventFactories( SdrObject& _rObj, SwXShape& _rShape )
986 ::svx::PPropertyValueProvider pProvider( new ::svx::PropertyValueProvider( _rShape, "AnchorType" ) );
987 _rObj.getShapePropertyChangeNotifier().registerProvider( ::svx::eTextShapeAnchorType, pProvider );
991 /* -----------------01.02.99 11:38-------------------
993 * --------------------------------------------------*/
994 SwXShape::SwXShape(uno::Reference< uno::XInterface > & xShape) :
995 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)),
996 m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)),
997 pImplementationId(0),
998 pImpl(new SwShapeDescriptor_Impl()),
999 m_bDescriptor(sal_True)
1001 if(xShape.is()) // default Ctor
1003 const uno::Type& rAggType = ::getCppuType((const uno::Reference< uno::XAggregation >*)0);
1004 //aAgg contains a reference of the SvxShape!
1006 uno::Any aAgg = xShape->queryInterface(rAggType);
1007 if(aAgg.getValueType() == rAggType)
1008 xShapeAgg = *(uno::Reference< uno::XAggregation >*)aAgg.getValue();
1009 // --> OD 2004-07-23 #i31698#
1010 if ( xShapeAgg.is() )
1012 xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< drawing::XShape >*)0) ) >>= mxShape;
1013 ASSERT( mxShape.is(),
1014 "<SwXShape::SwXShape(..)> - no XShape found at <xShapeAgg>" );
1016 // <--
1018 xShape = 0;
1019 m_refCount++;
1020 if( xShapeAgg.is() )
1021 xShapeAgg->setDelegator( (cppu::OWeakObject*)this );
1022 m_refCount--;
1024 uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
1025 SvxShape* pShape = 0;
1026 if(xShapeTunnel.is())
1027 pShape = reinterpret_cast< SvxShape * >(
1028 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
1030 SdrObject* pObj = pShape ? pShape->GetSdrObject() : 0;
1031 if(pObj)
1033 SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
1034 if(pFmt)
1035 pFmt->Add(this);
1037 lcl_addShapePropertyEventFactories( *pObj, *this );
1038 pImpl->bInitializedPropertyNotifier = true;
1043 /*-- 09.04.09 15:06:13---------------------------------------------------
1045 -----------------------------------------------------------------------*/
1046 void SwXShape::AddExistingShapeToFmt( SdrObject& _rObj )
1048 SwXShape* pSwShape = NULL;
1049 uno::Reference< lang::XUnoTunnel > xShapeTunnel( _rObj.getWeakUnoShape(), uno::UNO_QUERY );
1050 if ( xShapeTunnel.is() )
1051 pSwShape = reinterpret_cast< SwXShape * >(
1052 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething( SwXShape::getUnoTunnelId() ) ) );
1053 if ( pSwShape )
1055 if ( pSwShape->m_bDescriptor )
1057 SwFrmFmt* pFmt = ::FindFrmFmt( &const_cast< SdrObject& >( _rObj ) );
1058 if ( pFmt )
1059 pFmt->Add( pSwShape );
1060 pSwShape->m_bDescriptor = sal_False;
1063 if ( !pSwShape->pImpl->bInitializedPropertyNotifier )
1065 lcl_addShapePropertyEventFactories( _rObj, *pSwShape );
1066 pSwShape->pImpl->bInitializedPropertyNotifier = true;
1071 /*-- 22.01.99 11:42:26---------------------------------------------------
1073 -----------------------------------------------------------------------*/
1074 SwXShape::~SwXShape()
1076 if (xShapeAgg.is())
1078 uno::Reference< uno::XInterface > xRef;
1079 xShapeAgg->setDelegator(xRef);
1081 delete pImpl;
1083 /* -----------------------------16.06.00 12:21--------------------------------
1085 ---------------------------------------------------------------------------*/
1086 uno::Any SwXShape::queryInterface( const uno::Type& aType ) throw( uno::RuntimeException )
1088 uno::Any aRet = SwXShapeBaseClass::queryInterface(aType);
1089 // --> OD 2005-08-15 #i53320# - follow-up of #i31698#
1090 // interface drawing::XShape is overloaded. Thus, provide
1091 // correct object instance.
1092 if(!aRet.hasValue() && xShapeAgg.is())
1094 if(aType == ::getCppuType((uno::Reference<XShape>*)0))
1095 aRet <<= uno::Reference<XShape>(this);
1096 else
1097 aRet = xShapeAgg->queryAggregation(aType);
1099 // <--
1100 return aRet;
1102 /* -----------------------------16.06.00 12:21--------------------------------
1104 ---------------------------------------------------------------------------*/
1105 uno::Sequence< uno::Type > SwXShape::getTypes( ) throw(uno::RuntimeException)
1107 uno::Sequence< uno::Type > aRet = SwXShapeBaseClass::getTypes();
1108 if(xShapeAgg.is())
1110 uno::Any aProv = xShapeAgg->queryAggregation(::getCppuType((uno::Reference< XTypeProvider >*)0));
1111 if(aProv.hasValue())
1113 uno::Reference< XTypeProvider > xAggProv;
1114 aProv >>= xAggProv;
1115 uno::Sequence< uno::Type > aAggTypes = xAggProv->getTypes();
1116 const uno::Type* pAggTypes = aAggTypes.getConstArray();
1117 long nIndex = aRet.getLength();
1119 aRet.realloc(nIndex + aAggTypes.getLength());
1120 uno::Type* pBaseTypes = aRet.getArray();
1122 for(long i = 0; i < aAggTypes.getLength(); i++)
1123 pBaseTypes[nIndex++] = pAggTypes[i];
1126 return aRet;
1128 /* -----------------------------04.04.01 07:37--------------------------------
1130 ---------------------------------------------------------------------------*/
1131 uno::Sequence< sal_Int8 > SwXShape::getImplementationId( ) throw(uno::RuntimeException)
1133 vos::OGuard aGuard( Application::GetSolarMutex() );
1134 // do we need to compute the implementation id for this instance?
1135 if( !pImplementationId && xShapeAgg.is())
1137 uno::Reference< XShape > xAggShape;
1138 xShapeAgg->queryAggregation( ::getCppuType((uno::Reference< XShape >*)0) ) >>= xAggShape;
1140 if( xAggShape.is() )
1142 const rtl::OUString aShapeType( xAggShape->getShapeType() );
1143 // did we already compute an implementation id for the agregated shape type?
1144 SwShapeImplementationIdMap::iterator aIter( aImplementationIdMap.find(aShapeType ) );
1145 if( aIter == aImplementationIdMap.end() )
1147 // we need to create a new implementation id for this
1148 // note: this memory is not free'd until application exists
1149 // but since we have a fixed set of shapetypes and the
1150 // memory will be reused this is ok.
1151 pImplementationId = new uno::Sequence< sal_Int8 >( 16 );
1152 rtl_createUuid( (sal_uInt8 *) pImplementationId->getArray(), 0, sal_True );
1153 aImplementationIdMap[ aShapeType ] = pImplementationId;
1155 else
1157 // use the already computed implementation id
1158 pImplementationId = (*aIter).second;
1162 if( NULL == pImplementationId )
1164 DBG_ERROR( "Could not create an implementation id for a SwXShape!" );
1165 return uno::Sequence< sal_Int8 > ();
1167 else
1169 return *pImplementationId;
1172 /*-- 22.01.99 11:42:26---------------------------------------------------
1174 -----------------------------------------------------------------------*/
1175 uno::Reference< beans::XPropertySetInfo > SwXShape::getPropertySetInfo(void) throw( uno::RuntimeException )
1177 vos::OGuard aGuard(Application::GetSolarMutex());
1178 uno::Reference< beans::XPropertySetInfo > aRet;
1179 if(xShapeAgg.is())
1181 const uno::Type& rPropSetType = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1182 uno::Any aPSet = xShapeAgg->queryAggregation( rPropSetType );
1183 if(aPSet.getValueType() == rPropSetType && aPSet.getValue())
1185 uno::Reference< beans::XPropertySet > xPrSet =
1186 *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
1187 uno::Reference< beans::XPropertySetInfo > xInfo = xPrSet->getPropertySetInfo();
1188 // PropertySetInfo verlaengern!
1189 const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
1190 aRet = new SfxExtItemPropertySetInfo( m_pPropertyMapEntries, aPropSeq );
1193 if(!aRet.is())
1194 aRet = m_pPropSet->getPropertySetInfo();
1195 return aRet;
1197 /*-- 22.01.99 11:42:27---------------------------------------------------
1199 -----------------------------------------------------------------------*/
1200 void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::Any& aValue)
1201 throw( beans::UnknownPropertyException, beans::PropertyVetoException,
1202 lang::IllegalArgumentException, lang::WrappedTargetException,
1203 uno::RuntimeException)
1205 vos::OGuard aGuard(Application::GetSolarMutex());
1206 SwFrmFmt* pFmt = GetFrmFmt();
1207 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1208 if(xShapeAgg.is())
1210 if(pEntry)
1212 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1213 throw beans::PropertyVetoException ( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1214 //mit Layout kann der Anker umgesetzt werden, ohne dass sich die Position aendert
1215 if(pFmt)
1217 SwAttrSet aSet(pFmt->GetAttrSet());
1218 SwDoc* pDoc = pFmt->GetDoc();
1219 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId)
1221 sal_Bool bDone = sal_True;
1222 uno::Reference<text::XTextFrame> xFrame;
1223 if(aValue >>= xFrame)
1225 uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
1226 SwXFrame* pFrame = xTunnel.is() ?
1227 reinterpret_cast< SwXFrame * >(
1228 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
1229 : 0;
1230 if(pFrame && pFrame->GetFrmFmt() &&
1231 pFrame->GetFrmFmt()->GetDoc() == pDoc)
1233 UnoActionContext aCtx(pDoc);
1234 SfxItemSet aItemSet( pDoc->GetAttrPool(),
1235 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 );
1236 aItemSet.SetParent(&pFmt->GetAttrSet());
1237 SwFmtAnchor aAnchor = (const SwFmtAnchor&)aItemSet.Get(pEntry->nWID);
1238 SwPosition aPos(*pFrame->GetFrmFmt()->GetCntnt().GetCntntIdx());
1239 aAnchor.SetAnchor(&aPos);
1240 aAnchor.SetType(FLY_AT_FLY);
1241 aItemSet.Put(aAnchor);
1242 pFmt->SetFmtAttr(aItemSet);
1243 bDone = sal_True;
1246 if(!bDone)
1247 throw lang::IllegalArgumentException();
1249 else if(RES_OPAQUE == pEntry->nWID)
1251 SvxShape* pSvxShape = GetSvxShape();
1252 DBG_ASSERT(pSvxShape, "No SvxShape found!");
1253 if(pSvxShape)
1255 SdrObject* pObj = pSvxShape->GetSdrObject();
1256 // OD 25.06.2003 #108784# - set layer of new drawing
1257 // object to corresponding invisible layer.
1258 bool bIsVisible = pDoc->IsVisibleLayerId( pObj->GetLayer() );
1259 if(FmFormInventor != pObj->GetObjInventor())
1261 pObj->SetLayer( *(sal_Bool*)aValue.getValue()
1262 ? ( bIsVisible ? pDoc->GetHeavenId() : pDoc->GetInvisibleHeavenId() )
1263 : ( bIsVisible ? pDoc->GetHellId() : pDoc->GetInvisibleHellId() ));
1265 else
1267 pObj->SetLayer( bIsVisible ? pDoc->GetControlsId() : pDoc->GetInvisibleControlsId());
1273 // OD 2004-04-22 #i26791# - special handling for property FN_TEXT_RANGE
1274 else if ( FN_TEXT_RANGE == pEntry->nWID )
1276 SwFmtAnchor aAnchor( static_cast<const SwFmtAnchor&>(aSet.Get( RES_ANCHOR )) );
1277 if ( aAnchor.GetAnchorId() == FLY_PAGE )
1279 // set property <TextRange> not valid for to-page anchored shapes
1280 throw lang::IllegalArgumentException();
1282 else
1284 SwUnoInternalPaM* pInternalPam =
1285 new SwUnoInternalPaM( *(pFmt->GetDoc()) );
1286 uno::Reference< text::XTextRange > xRg;
1287 aValue >>= xRg;
1288 if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) )
1290 if(aAnchor.GetAnchorId() == FLY_IN_CNTNT)
1292 //delete old SwFmtFlyCnt
1293 //With AnchorAsCharacter the current TxtAttribute has to be deleted.
1294 //Tbis removes the frame format too.
1295 //To prevent this the connection between format and attribute has to be broken before.
1296 const SwPosition *pPos = aAnchor.GetCntntAnchor();
1297 SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
1298 ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
1299 const xub_StrLen nIdx = pPos->nContent.GetIndex();
1300 SwTxtAttr * const pHnt =
1301 pTxtNode->GetTxtAttrForCharAt(
1302 nIdx, RES_TXTATR_FLYCNT );
1303 DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
1304 "Missing FlyInCnt-Hint." );
1305 DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFmt,
1306 "Wrong TxtFlyCnt-Hint." );
1307 const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
1308 .SetFlyFmt();
1310 //The connection is removed now the attribute can be deleted.
1311 pTxtNode->DeleteAttributes(
1312 RES_TXTATR_FLYCNT, nIdx );
1313 //create a new one
1314 SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode();
1315 DBG_ASSERT( pNd, "Cursor not at TxtNode." );
1316 SwFmtFlyCnt aFmt( pFmt );
1317 pNd->InsertItem(aFmt, pInternalPam->GetPoint()
1318 ->nContent.GetIndex(), 0 );
1320 else
1322 aAnchor.SetAnchor( pInternalPam->GetPoint() );
1323 aSet.Put(aAnchor);
1324 pFmt->SetFmtAttr(aSet);
1327 else
1329 throw uno::RuntimeException();
1331 delete pInternalPam;
1334 // --> OD 2004-08-06 #i28749#
1335 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
1337 sal_Int16 nPositionLayoutDir = 0;
1338 aValue >>= nPositionLayoutDir;
1339 pFmt->SetPositionLayoutDir( nPositionLayoutDir );
1341 // <--
1342 else if( pDoc->GetRootFrm() )
1344 UnoActionContext aCtx(pDoc);
1345 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
1347 SdrObject* pObj = pFmt->FindSdrObject();
1348 SdrMarkList aList;
1349 SdrMark aMark(pObj);
1350 aList.InsertEntry(aMark);
1351 sal_Int32 nAnchor = 0;
1352 cppu::enum2int( nAnchor, aValue );
1353 pDoc->ChgAnchor( aList, (RndStdIds)nAnchor,
1354 sal_False, sal_True );
1356 else
1358 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1359 pFmt->SetFmtAttr(aSet);
1362 else
1364 m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
1366 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
1368 bool bSetAttr = true;
1369 sal_Int32 eNewAnchor = SWUnoHelper::GetEnumAsInt32( aValue );
1371 //if old anchor was in_cntnt the related text attribute has to be removed
1372 const SwFmtAnchor& rOldAnchor = pFmt->GetAnchor();
1373 RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
1374 SdrObject* pObj = pFmt->FindSdrObject();
1375 SwFrmFmt *pFlyFmt = FindFrmFmt( pObj );
1376 pFlyFmt->DelFrms();
1377 if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
1378 FLY_IN_CNTNT == eOldAnchorId )
1380 //With AnchorAsCharacter the current TxtAttribute has to be deleted.
1381 //Tbis removes the frame format too.
1382 //To prevent this the connection between format and attribute has to be broken before.
1383 const SwPosition *pPos = rOldAnchor.GetCntntAnchor();
1384 SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
1385 ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
1386 const xub_StrLen nIdx = pPos->nContent.GetIndex();
1387 SwTxtAttr * const pHnt =
1388 pTxtNode->GetTxtAttrForCharAt(
1389 nIdx, RES_TXTATR_FLYCNT );
1390 DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
1391 "Missing FlyInCnt-Hint." );
1392 DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFlyFmt,
1393 "Wrong TxtFlyCnt-Hint." );
1394 const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
1395 .SetFlyFmt();
1397 //The connection is removed now the attribute can be deleted.
1398 pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
1400 else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
1401 FLY_PAGE == eOldAnchorId )
1403 SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) );
1404 //if the fly has been anchored at page then it needs to be connected
1405 //to the content position
1406 SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
1407 if( pDoc->GetRootFrm() )
1409 SwCrsrMoveState aState( MV_SETONLYTEXT );
1410 Point aTmp( pObj->GetSnapRect().TopLeft() );
1411 pDoc->GetRootFrm()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
1413 else
1415 //without access to the layout the last node of the body will be used as anchor position
1416 aPam.Move( fnMoveBackward, fnGoDoc );
1418 //anchor position has to be inserted after the text attribute has been inserted
1419 aNewAnchor.SetAnchor( aPam.GetPoint() );
1420 aSet.Put( aNewAnchor );
1421 pFmt->SetFmtAttr(aSet);
1422 bSetAttr = false;
1423 if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
1424 FLY_IN_CNTNT != eOldAnchorId )
1426 //the RES_TXTATR_FLYCNT needs to be added now
1427 SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
1428 DBG_ASSERT( pNd, "Crsr is not in a TxtNode." );
1429 SwFmtFlyCnt aFmt( pFlyFmt );
1430 pNd->InsertItem(aFmt,
1431 aPam.GetPoint()->nContent.GetIndex(), 0 );
1432 //aPam.GetPoint()->nContent--;
1436 if( bSetAttr )
1437 pFmt->SetFmtAttr(aSet);
1439 else
1440 pFmt->SetFmtAttr(aSet);
1443 else
1445 SfxPoolItem* pItem = 0;
1446 switch(pEntry->nWID)
1448 case RES_ANCHOR:
1449 pItem = pImpl->GetAnchor(sal_True);
1450 break;
1451 case RES_HORI_ORIENT:
1452 pItem = pImpl->GetHOrient(sal_True);
1453 break;
1454 case RES_VERT_ORIENT:
1455 pItem = pImpl->GetVOrient(sal_True);
1456 break;
1457 case RES_LR_SPACE:
1458 pItem = pImpl->GetLRSpace(sal_True);
1459 break;
1460 case RES_UL_SPACE:
1461 pItem = pImpl->GetULSpace(sal_True);
1462 break;
1463 case RES_SURROUND:
1464 pItem = pImpl->GetSurround(sal_True);
1465 break;
1466 case FN_TEXT_RANGE:
1468 const uno::Type rTextRangeType =
1469 ::getCppuType((uno::Reference< text::XTextRange>*)0);
1470 if(aValue.getValueType() == rTextRangeType)
1472 uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
1473 rRange = *(uno::Reference< text::XTextRange > *)aValue.getValue();
1476 break;
1477 case RES_OPAQUE :
1478 pImpl->SetOpaque(*(sal_Bool*)aValue.getValue());
1479 break;
1480 // OD 2004-04-22 #i26791#
1481 case RES_FOLLOW_TEXT_FLOW:
1483 pItem = pImpl->GetFollowTextFlow( sal_True );
1485 break;
1486 // OD 2004-05-05 #i28701#
1487 case RES_WRAP_INFLUENCE_ON_OBJPOS:
1489 pItem = pImpl->GetWrapInfluenceOnObjPos( sal_True );
1491 break;
1492 // --> OD 2004-08-06 #i28749#
1493 case FN_SHAPE_POSITION_LAYOUT_DIR :
1495 sal_Int16 nPositionLayoutDir = 0;
1496 aValue >>= nPositionLayoutDir;
1497 pImpl->SetPositionLayoutDir( nPositionLayoutDir );
1499 break;
1500 // <--
1502 if(pItem)
1503 ((SfxPoolItem*)pItem)->PutValue(aValue, pEntry->nMemberId);
1506 else
1508 uno::Reference< beans::XPropertySet > xPrSet;
1509 const uno::Type& rPSetType =
1510 ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1511 uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
1512 if(aPSet.getValueType() != rPSetType || !aPSet.getValue())
1513 throw uno::RuntimeException();
1514 xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
1515 // --> OD 2004-08-05 #i31698# - setting the caption point of a
1516 // caption object doesn't have to change the object position.
1517 // Thus, keep the position, before the caption point is set and
1518 // restore it afterwards.
1519 awt::Point aKeepedPosition( 0, 0 );
1520 if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint"))) &&
1521 getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape"))) )
1523 aKeepedPosition = getPosition();
1525 // <--
1526 if( pFmt && pFmt->GetDoc()->GetRootFrm() )
1528 UnoActionContext aCtx(pFmt->GetDoc());
1529 xPrSet->setPropertyValue(rPropertyName, aValue);
1531 else
1532 xPrSet->setPropertyValue(rPropertyName, aValue);
1533 // --> OD 2004-11-11 #i35007# - adjustment of the position
1534 // attributes, if the transformation is set, causes wrong alignments
1535 // and is no longer needed.
1536 // The position attributes are set, if the drawing object is added
1537 // to the draw page - see <SwXDrawPage::add(..)> - and on its first
1538 // positioning - see <SwAnchoredDrawObject::MakeObjPos().
1539 // // --> OD 2004-07-28 #i31698# - additionally adjust the position
1540 // // properties of the shape, if the transformation is set and
1541 // // the shape isn't a group member.
1542 // if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation"))) &&
1543 // !_GetTopGroupObj() )
1544 // {
1545 // drawing::HomogenMatrix3 aMatrix;
1546 // aValue >>= aMatrix;
1547 // awt::Point aNewPos( basegfx::fround( aMatrix.Line1.Column3 ),
1548 // basegfx::fround( aMatrix.Line2.Column3 ) );
1549 // _AdjustPositionProperties( aNewPos );
1550 // }
1551 // --> OD 2004-08-05 #i31698# - restore object position, if caption
1552 // point is set.
1553 if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint"))) &&
1554 getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape"))) )
1556 setPosition( aKeepedPosition );
1561 /*-- 22.01.99 11:42:27---------------------------------------------------
1563 -----------------------------------------------------------------------*/
1564 uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName)
1565 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1566 uno::RuntimeException )
1568 vos::OGuard aGuard(Application::GetSolarMutex());
1569 uno::Any aRet;
1570 SwFrmFmt* pFmt = GetFrmFmt();
1571 if(xShapeAgg.is())
1573 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1574 if(pEntry)
1576 if(pFmt)
1578 if(RES_OPAQUE == pEntry->nWID)
1580 SvxShape* pSvxShape = GetSvxShape();
1581 DBG_ASSERT(pSvxShape, "No SvxShape found!");
1582 if(pSvxShape)
1584 SdrObject* pObj = pSvxShape->GetSdrObject();
1585 // OD 02.07.2003 #108784# - consider invisible layers
1586 sal_Bool bOpaque =
1587 ( pObj->GetLayer() != pFmt->GetDoc()->GetHellId() &&
1588 pObj->GetLayer() != pFmt->GetDoc()->GetInvisibleHellId() );
1589 aRet.setValue(&bOpaque, ::getBooleanCppuType());
1592 else if(FN_ANCHOR_POSITION == pEntry->nWID)
1594 SvxShape* pSvxShape = GetSvxShape();
1595 DBG_ASSERT(pSvxShape, "No SvxShape found!");
1596 if(pSvxShape)
1598 SdrObject* pObj = pSvxShape->GetSdrObject();
1599 Point aPt = pObj->GetAnchorPos();
1600 awt::Point aPoint( TWIP_TO_MM100( aPt.X() ),
1601 TWIP_TO_MM100( aPt.Y() ) );
1602 aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
1605 // OD 2004-04-22 #i26791# - special handling for FN_TEXT_RANGE
1606 else if ( FN_TEXT_RANGE == pEntry->nWID )
1608 const SwFmtAnchor aAnchor = pFmt->GetAnchor();
1609 if ( aAnchor.GetAnchorId() == FLY_PAGE )
1611 // return nothing, because property <TextRange> isn't
1612 // valid for to-page anchored shapes
1613 uno::Any aAny;
1614 aRet = aAny;
1616 else
1618 if ( aAnchor.GetCntntAnchor() )
1620 uno::Reference< text::XTextRange > xTextRange =
1621 SwXTextRange::CreateTextRangeFromPosition(
1622 pFmt->GetDoc(),
1623 *aAnchor.GetCntntAnchor(),
1624 0L );
1625 aRet.setValue(&xTextRange, ::getCppuType((uno::Reference<text::XTextRange>*)0));
1627 else
1629 // return nothing
1630 uno::Any aAny;
1631 aRet = aAny;
1635 // --> OD 2004-08-06 #i28749#
1636 else if ( FN_SHAPE_TRANSFORMATION_IN_HORI_L2R == pEntry->nWID )
1638 // get property <::drawing::Shape::Transformation>
1639 // without conversion to layout direction as below
1640 aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")) );
1642 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
1644 aRet <<= pFmt->GetPositionLayoutDir();
1646 // <--
1647 // --> OD 2004-10-28 #i36248#
1648 else if ( FN_SHAPE_STARTPOSITION_IN_HORI_L2R == pEntry->nWID )
1650 // get property <::drawing::Shape::StartPosition>
1651 // without conversion to layout direction as below
1652 aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")) );
1654 else if ( FN_SHAPE_ENDPOSITION_IN_HORI_L2R == pEntry->nWID )
1656 // get property <::drawing::Shape::EndPosition>
1657 // without conversion to layout direction as below
1658 aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")) );
1660 // <--
1661 else
1663 const SwAttrSet& rSet = pFmt->GetAttrSet();
1664 m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1667 else
1669 SfxPoolItem* pItem = 0;
1670 switch(pEntry->nWID)
1672 case RES_ANCHOR:
1673 pItem = pImpl->GetAnchor();
1674 break;
1675 case RES_HORI_ORIENT:
1676 pItem = pImpl->GetHOrient();
1677 break;
1678 case RES_VERT_ORIENT:
1679 pItem = pImpl->GetVOrient();
1680 break;
1681 case RES_LR_SPACE:
1682 pItem = pImpl->GetLRSpace();
1683 break;
1684 case RES_UL_SPACE:
1685 pItem = pImpl->GetULSpace();
1686 break;
1687 case RES_SURROUND:
1688 pItem = pImpl->GetSurround();
1689 break;
1690 case FN_TEXT_RANGE :
1691 aRet.setValue(&pImpl->GetTextRange(), ::getCppuType((uno::Reference<text::XTextRange>*)0));
1692 break;
1693 case RES_OPAQUE :
1694 aRet.setValue(&pImpl->GetOpaque(), ::getBooleanCppuType());
1695 break;
1696 case FN_ANCHOR_POSITION :
1698 awt::Point aPoint;
1699 aRet.setValue(&aPoint, ::getCppuType( (awt::Point*)0 ));
1701 break;
1702 // OD 2004-04-22 #i26791#
1703 case RES_FOLLOW_TEXT_FLOW :
1705 pItem = pImpl->GetFollowTextFlow();
1707 break;
1708 // OD 2004-05-05 #i28701#
1709 case RES_WRAP_INFLUENCE_ON_OBJPOS:
1711 pItem = pImpl->GetWrapInfluenceOnObjPos();
1713 break;
1714 // --> OD 2004-08-06 #i28749#
1715 case FN_SHAPE_TRANSFORMATION_IN_HORI_L2R:
1717 // get property <::drawing::Shape::Transformation>
1718 // without conversion to layout direction as below
1719 aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")) );
1721 break;
1722 case FN_SHAPE_POSITION_LAYOUT_DIR:
1724 aRet <<= pImpl->GetPositionLayoutDir();
1726 break;
1727 // <--
1728 // --> OD 2004-08-06 #i36248#
1729 case FN_SHAPE_STARTPOSITION_IN_HORI_L2R:
1731 // get property <::drawing::Shape::StartPosition>
1732 // without conversion to layout direction as below
1733 aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")) );
1735 break;
1736 case FN_SHAPE_ENDPOSITION_IN_HORI_L2R:
1738 // get property <::drawing::Shape::StartPosition>
1739 // without conversion to layout direction as below
1740 aRet = _getPropAtAggrObj( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")) );
1742 break;
1743 // <--
1745 if(pItem)
1746 pItem->QueryValue(aRet, pEntry->nMemberId);
1749 else
1751 aRet = _getPropAtAggrObj( rPropertyName );
1753 // --> OD 2004-07-28 #i31698# - convert the position (translation)
1754 // of the drawing object in the transformation
1755 if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation"))) )
1757 drawing::HomogenMatrix3 aMatrix;
1758 aRet >>= aMatrix;
1759 aRet <<= _ConvertTransformationToLayoutDir( aMatrix );
1761 // <--
1762 // --> OD 2004-10-28 #i36248#
1763 else if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))) )
1765 awt::Point aStartPos;
1766 aRet >>= aStartPos;
1767 // --> OD 2009-01-12 #i59051#
1768 aRet <<= _ConvertStartOrEndPosToLayoutDir( aStartPos );
1769 // <--
1771 else if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))) )
1773 awt::Point aEndPos;
1774 aRet >>= aEndPos;
1775 // --> OD 2009-01-12 #i59051#
1776 aRet <<= _ConvertStartOrEndPosToLayoutDir( aEndPos );
1777 // <--
1779 // --> OD 2009-01-16 #i59051#
1780 else if ( rPropertyName.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier"))) )
1782 drawing::PolyPolygonBezierCoords aPath;
1783 aRet >>= aPath;
1784 aRet <<= _ConvertPolyPolygonBezierToLayoutDir( aPath );
1785 // <--
1787 // <--
1790 return aRet;
1793 /** method to get property from aggregation object
1795 OD 2004-10-28 #i36248#
1797 @author OD
1799 uno::Any SwXShape::_getPropAtAggrObj( const ::rtl::OUString& _rPropertyName )
1800 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
1801 uno::RuntimeException )
1803 uno::Any aRet;
1805 uno::Reference< beans::XPropertySet > xPrSet;
1806 const uno::Type& rPSetType =
1807 ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1808 uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
1809 if ( aPSet.getValueType() != rPSetType || !aPSet.getValue() )
1811 throw uno::RuntimeException();
1813 xPrSet = *(uno::Reference< beans::XPropertySet >*)aPSet.getValue();
1814 aRet = xPrSet->getPropertyValue( _rPropertyName );
1816 return aRet;
1820 /* -----------------------------02.11.00 09:41--------------------------------
1822 ---------------------------------------------------------------------------*/
1823 beans::PropertyState SwXShape::getPropertyState( const rtl::OUString& rPropertyName )
1824 throw(beans::UnknownPropertyException, uno::RuntimeException)
1826 vos::OGuard aGuard(Application::GetSolarMutex());
1827 uno::Sequence< rtl::OUString > aNames(1);
1828 rtl::OUString* pStrings = aNames.getArray();
1829 pStrings[0] = rPropertyName;
1830 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
1831 return aStates.getConstArray()[0];
1833 /* -----------------------------02.11.00 09:41--------------------------------
1835 ---------------------------------------------------------------------------*/
1836 uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates(
1837 const uno::Sequence< rtl::OUString >& aPropertyNames )
1838 throw(beans::UnknownPropertyException, uno::RuntimeException)
1840 vos::OGuard aGuard(Application::GetSolarMutex());
1841 SwFrmFmt* pFmt = GetFrmFmt();
1842 uno::Sequence< beans::PropertyState > aRet(aPropertyNames.getLength());
1843 if(xShapeAgg.is())
1845 SvxShape* pSvxShape = GetSvxShape();
1846 sal_Bool bGroupMember = sal_False;
1847 sal_Bool bFormControl = sal_False;
1848 SdrObject* pObject = pSvxShape->GetSdrObject();
1849 if(pObject)
1851 bGroupMember = pObject->GetUpGroup() != 0;
1852 bFormControl = pObject->GetObjInventor() == FmFormInventor;
1854 const rtl::OUString* pNames = aPropertyNames.getConstArray();
1855 beans::PropertyState* pRet = aRet.getArray();
1856 uno::Reference< XPropertyState > xShapePrState;
1857 for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++)
1859 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[nProperty] );
1860 if(pEntry)
1862 if(RES_OPAQUE == pEntry->nWID)
1863 pRet[nProperty] = bFormControl ?
1864 beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
1865 else if(FN_ANCHOR_POSITION == pEntry->nWID)
1866 pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1867 else if(FN_TEXT_RANGE == pEntry->nWID)
1868 pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1869 else if(bGroupMember)
1870 pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1871 else if(pFmt)
1873 const SwAttrSet& rSet = pFmt->GetAttrSet();
1874 SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, FALSE);
1876 if(SFX_ITEM_SET == eItemState)
1877 pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1878 else if(SFX_ITEM_DEFAULT == eItemState)
1879 pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1880 else
1881 pRet[nProperty] = beans::PropertyState_AMBIGUOUS_VALUE;
1883 else
1885 SfxPoolItem* pItem = 0;
1886 switch(pEntry->nWID)
1888 case RES_ANCHOR:
1889 pItem = pImpl->GetAnchor();
1890 break;
1891 case RES_HORI_ORIENT:
1892 pItem = pImpl->GetHOrient();
1893 break;
1894 case RES_VERT_ORIENT:
1895 pItem = pImpl->GetVOrient();
1896 break;
1897 case RES_LR_SPACE:
1898 pItem = pImpl->GetLRSpace();
1899 break;
1900 case RES_UL_SPACE:
1901 pItem = pImpl->GetULSpace();
1902 break;
1903 case RES_SURROUND:
1904 pItem = pImpl->GetSurround();
1905 break;
1906 // OD 2004-05-05 #i28701#
1907 case RES_WRAP_INFLUENCE_ON_OBJPOS:
1909 pItem = pImpl->GetWrapInfluenceOnObjPos();
1911 break;
1913 if(pItem)
1914 pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1915 else
1916 pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1919 else
1921 if(!xShapePrState.is())
1923 const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
1924 uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1925 if(aPState.getValueType() != rPStateType || !aPState.getValue())
1926 throw uno::RuntimeException();
1927 xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
1929 pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]);
1933 else
1934 throw uno::RuntimeException();
1935 return aRet;
1937 /* -----------------------------02.11.00 09:41--------------------------------
1939 ---------------------------------------------------------------------------*/
1940 void SwXShape::setPropertyToDefault( const rtl::OUString& rPropertyName )
1941 throw(beans::UnknownPropertyException, uno::RuntimeException)
1943 vos::OGuard aGuard(Application::GetSolarMutex());
1944 SwFrmFmt* pFmt = GetFrmFmt();
1945 if(xShapeAgg.is())
1947 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1948 if(pEntry)
1950 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1951 throw uno::RuntimeException( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1952 if(pFmt)
1954 const SfxItemSet& rSet = pFmt->GetAttrSet();
1955 SfxItemSet aSet(pFmt->GetDoc()->GetAttrPool(), pEntry->nWID, pEntry->nWID);
1956 aSet.SetParent(&rSet);
1957 aSet.ClearItem(pEntry->nWID);
1958 pFmt->GetDoc()->SetAttr(aSet, *pFmt);
1960 else
1962 switch(pEntry->nWID)
1964 case RES_ANCHOR: pImpl->RemoveAnchor(); break;
1965 case RES_HORI_ORIENT: pImpl->RemoveHOrient(); break;
1966 case RES_VERT_ORIENT: pImpl->RemoveVOrient(); break;
1967 case RES_LR_SPACE: pImpl->RemoveLRSpace(); break;
1968 case RES_UL_SPACE: pImpl->RemoveULSpace(); break;
1969 case RES_SURROUND: pImpl->RemoveSurround();break;
1970 case RES_OPAQUE : pImpl->SetOpaque(sal_False); break;
1971 case FN_TEXT_RANGE :
1972 break;
1973 // OD 2004-04-22 #i26791#
1974 case RES_FOLLOW_TEXT_FLOW:
1976 pImpl->RemoveFollowTextFlow();
1978 break;
1979 // OD 2004-05-05 #i28701#
1980 case RES_WRAP_INFLUENCE_ON_OBJPOS:
1982 pImpl->RemoveWrapInfluenceOnObjPos();
1984 break;
1988 else
1990 const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
1991 uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1992 if(aPState.getValueType() != rPStateType || !aPState.getValue())
1993 throw uno::RuntimeException();
1994 uno::Reference< XPropertyState > xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
1995 xShapePrState->setPropertyToDefault( rPropertyName );
1998 else
1999 throw uno::RuntimeException();
2001 /* -----------------------------02.11.00 09:41--------------------------------
2003 ---------------------------------------------------------------------------*/
2004 uno::Any SwXShape::getPropertyDefault( const rtl::OUString& rPropertyName )
2005 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
2006 uno::RuntimeException )
2008 vos::OGuard aGuard(Application::GetSolarMutex());
2009 SwFrmFmt* pFmt = GetFrmFmt();
2010 uno::Any aRet;
2011 if(xShapeAgg.is())
2013 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
2014 if(pEntry)
2016 if(pEntry->nWID < RES_FRMATR_END && pFmt)
2018 const SfxPoolItem& rDefItem =
2019 pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
2020 rDefItem.QueryValue(aRet, pEntry->nMemberId);
2022 else
2023 throw uno::RuntimeException();
2025 else
2027 const uno::Type& rPStateType = ::getCppuType((uno::Reference< XPropertyState >*)0);
2028 uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
2029 if(aPState.getValueType() != rPStateType || !aPState.getValue())
2030 throw uno::RuntimeException();
2031 uno::Reference< XPropertyState > xShapePrState = *(uno::Reference< XPropertyState >*)aPState.getValue();
2032 xShapePrState->getPropertyDefault( rPropertyName );
2035 else
2036 throw uno::RuntimeException();
2037 return aRet;
2039 /*-- 22.01.99 11:42:27---------------------------------------------------
2041 -----------------------------------------------------------------------*/
2042 void SwXShape::addPropertyChangeListener(
2043 const rtl::OUString& _propertyName,
2044 const uno::Reference< beans::XPropertyChangeListener > & _listener )
2045 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
2046 uno::RuntimeException )
2048 if ( !xShapeAgg.is() )
2049 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no shape aggregate" ) ), *this );
2051 // must be handled by the aggregate
2052 uno::Reference< beans::XPropertySet > xShapeProps;
2053 if ( xShapeAgg->queryAggregation( beans::XPropertySet::static_type() ) >>= xShapeProps )
2054 xShapeProps->addPropertyChangeListener( _propertyName, _listener );
2056 /*-- 22.01.99 11:42:27---------------------------------------------------
2058 -----------------------------------------------------------------------*/
2059 void SwXShape::removePropertyChangeListener(
2060 const rtl::OUString& _propertyName,
2061 const uno::Reference< beans::XPropertyChangeListener > & _listener)
2062 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
2063 uno::RuntimeException )
2065 if ( !xShapeAgg.is() )
2066 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no shape aggregate" ) ), *this );
2068 // must be handled by the aggregate
2069 uno::Reference< beans::XPropertySet > xShapeProps;
2070 if ( xShapeAgg->queryAggregation( beans::XPropertySet::static_type() ) >>= xShapeProps )
2071 xShapeProps->removePropertyChangeListener( _propertyName, _listener );
2073 /*-- 22.01.99 11:42:28---------------------------------------------------
2075 -----------------------------------------------------------------------*/
2076 void SwXShape::addVetoableChangeListener(
2077 const rtl::OUString& /*PropertyName*/,
2078 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/ )
2079 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
2080 uno::RuntimeException )
2082 DBG_WARNING("not implemented");
2084 /*-- 22.01.99 11:42:28---------------------------------------------------
2086 -----------------------------------------------------------------------*/
2087 void SwXShape::removeVetoableChangeListener(
2088 const rtl::OUString& /*PropertyName*/,
2089 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2090 throw( beans::UnknownPropertyException, lang::WrappedTargetException,
2091 uno::RuntimeException )
2093 DBG_WARNING("not implemented");
2095 /*-- 22.01.99 11:42:28---------------------------------------------------
2097 -----------------------------------------------------------------------*/
2098 void SwXShape::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
2100 ClientModify(this, pOld, pNew);
2102 /* -----------------14.04.99 13:02-------------------
2104 * --------------------------------------------------*/
2105 void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
2106 throw( lang::IllegalArgumentException, uno::RuntimeException )
2108 vos::OGuard aGuard(Application::GetSolarMutex());
2110 // get access to SwDoc
2111 // (see also SwXTextRange::XTextRangeToSwPaM)
2112 SwDoc* pDoc = 0;
2113 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2114 if(xRangeTunnel.is())
2116 SwXTextRange* pRange = 0;
2117 OTextCursorHelper* pCursor = 0;
2118 SwXTextPortion* pPortion = 0;
2119 SwXText* pText = 0;
2120 SwXParagraph* pParagraph = 0;
2122 pRange = reinterpret_cast< SwXTextRange * >(
2123 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2124 pText = reinterpret_cast< SwXText * >(
2125 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) ));
2126 pCursor = reinterpret_cast< OTextCursorHelper * >(
2127 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2128 pPortion = reinterpret_cast< SwXTextPortion * >(
2129 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) ));
2130 pParagraph = reinterpret_cast< SwXParagraph * >(
2131 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId( ) ) ) );
2133 if (pRange)
2134 pDoc = pRange->GetDoc();
2135 else if (!pDoc && pText)
2136 pDoc = pText->GetDoc();
2137 else if (!pDoc && pCursor)
2138 pDoc = pCursor->GetDoc();
2139 else if ( !pDoc && pPortion && pPortion->GetCursor() )
2141 pDoc = pPortion->GetCursor()->GetDoc();
2143 else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) )
2144 pDoc = pParagraph->GetTxtNode( )->GetDoc( );
2148 if(!pDoc)
2149 throw uno::RuntimeException();
2150 SwDocShell *pDocSh = pDoc->GetDocShell();
2151 if (pDocSh)
2153 uno::Reference< frame::XModel > xModel;
2154 xModel = pDocSh->GetModel();
2155 uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
2156 if (xDPS.is())
2158 uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
2159 if (xDP.is())
2161 uno::Any aPos;
2162 aPos <<= xTextRange;
2163 setPropertyValue(S2U("TextRange"), aPos);
2164 uno::Reference< drawing::XShape > xTemp( (cppu::OWeakObject*) this, uno::UNO_QUERY );
2165 xDP->add( xTemp );
2170 /* -----------------14.04.99 13:02-------------------
2172 * --------------------------------------------------*/
2173 uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::RuntimeException )
2175 vos::OGuard aGuard(Application::GetSolarMutex());
2176 uno::Reference< text::XTextRange > aRef;
2177 SwFrmFmt* pFmt = GetFrmFmt();
2178 if(pFmt)
2180 const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
2181 // return an anchor for non-page bound frames
2182 // and for page bound frames that have a page no == NULL and a content position
2183 if( rAnchor.GetAnchorId() != FLY_PAGE ||
2184 (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
2186 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
2187 aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0);
2190 else
2191 aRef = pImpl->GetTextRange();
2192 return aRef;
2194 /* -----------------14.04.99 13:02-------------------
2196 * --------------------------------------------------*/
2197 void SwXShape::dispose(void) throw( uno::RuntimeException )
2199 vos::OGuard aGuard(Application::GetSolarMutex());
2200 SwFrmFmt* pFmt = GetFrmFmt();
2201 if(pFmt)
2203 // OD 10.07.2003 #110742# - determine correct <SdrObject>
2204 //SdrObject* pObj = pFmt->FindSdrObject();
2205 SdrObject* pObj = GetSvxShape()->GetSdrObject();
2206 // OD 10.07.2003 #110742# - safety assertion:
2207 // <pObj> must be the same as <pFmt->FindSdrObject()>, if <pObj> isn't
2208 // a 'virtual' drawing object.
2209 // OD 25.08.2003 #111713# - refine assertion for safety reason.
2210 // --> OD 2005-02-02 #119236# - correct assertion and refine it.
2211 ASSERT( !pObj ||
2212 pObj->ISA(SwDrawVirtObj) ||
2213 pObj->GetUpGroup() ||
2214 pObj == pFmt->FindSdrObject(),
2215 "<SwXShape::dispose(..) - different 'master' drawing objects!!" );
2216 // <--
2217 // OD 10.07.2003 #110742# - perform delete of draw frame format *not*
2218 // for 'virtual' drawing objects.
2219 // --> OD 2005-02-02 #119236# - no delete of draw format for members
2220 // of a group
2221 if ( pObj &&
2222 !pObj->ISA(SwDrawVirtObj) &&
2223 !pObj->GetUpGroup() &&
2224 pObj->IsInserted() )
2225 // <--
2227 if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT )
2229 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
2230 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
2231 const xub_StrLen nIdx = rPos.nContent.GetIndex();
2232 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
2234 else
2235 pFmt->GetDoc()->DelLayoutFmt( pFmt );
2238 if(xShapeAgg.is())
2240 uno::Any aAgg(xShapeAgg->queryAggregation( ::getCppuType((uno::Reference<XComponent>*)0)));
2241 uno::Reference<XComponent> xComp;
2242 aAgg >>= xComp;
2243 if(xComp.is())
2244 xComp->dispose();
2247 /* -----------------14.04.99 13:02-------------------
2249 * --------------------------------------------------*/
2250 void SwXShape::addEventListener(
2251 const uno::Reference< lang::XEventListener > & aListener)
2252 throw( uno::RuntimeException )
2254 uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2255 SvxShape* pSvxShape = GetSvxShape();
2256 if(pSvxShape)
2257 pSvxShape->addEventListener(aListener);
2259 /* -----------------14.04.99 13:02-------------------
2261 * --------------------------------------------------*/
2262 void SwXShape::removeEventListener(
2263 const uno::Reference< lang::XEventListener > & aListener)
2264 throw( uno::RuntimeException )
2266 SvxShape* pSvxShape = GetSvxShape();
2267 if(pSvxShape)
2268 pSvxShape->removeEventListener(aListener);
2270 /* -----------------03.06.99 08:53-------------------
2272 * --------------------------------------------------*/
2273 rtl::OUString SwXShape::getImplementationName(void) throw( uno::RuntimeException )
2275 return C2U("SwXShape");
2277 /* -----------------03.06.99 08:53-------------------
2279 * --------------------------------------------------*/
2280 sal_Bool SwXShape::supportsService(const rtl::OUString& rServiceName) throw( uno::RuntimeException )
2282 sal_Bool bRet = sal_False;
2283 if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.drawing.Shape"))
2284 bRet = sal_True;
2285 else if(xShapeAgg.is())
2287 uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2288 SvxShape* pSvxShape = GetSvxShape();
2289 bRet = pSvxShape->supportsService(rServiceName);
2291 return bRet;
2293 /* -----------------03.06.99 08:53-------------------
2295 * --------------------------------------------------*/
2296 uno::Sequence< rtl::OUString > SwXShape::getSupportedServiceNames(void) throw( uno::RuntimeException )
2298 uno::Sequence< rtl::OUString > aSeq;
2299 if(xShapeAgg.is())
2301 uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2302 SvxShape* pSvxShape = GetSvxShape();
2303 if(pSvxShape)
2304 aSeq = pSvxShape->getSupportedServiceNames();
2306 else
2308 aSeq.realloc(1);
2309 aSeq.getArray()[0] = C2U("com.sun.star.drawing.Shape");
2311 return aSeq;
2313 /* -----------------------------15.03.00 14:54--------------------------------
2315 ---------------------------------------------------------------------------*/
2316 SvxShape* SwXShape::GetSvxShape()
2318 SvxShape* pSvxShape = 0;
2319 if(xShapeAgg.is())
2321 uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
2322 if(xShapeTunnel.is())
2323 pSvxShape = reinterpret_cast< SvxShape * >(
2324 sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2326 return pSvxShape;
2329 // --> OD 2004-07-22 #i31698# -
2330 // implementation of virtual methods from drawing::XShape
2331 awt::Point SAL_CALL SwXShape::getPosition() throw ( uno::RuntimeException )
2333 awt::Point aPos( _GetAttrPosition() );
2335 // handle group members
2336 SvxShape* pSvxShape = GetSvxShape();
2337 if ( pSvxShape )
2339 SdrObject* pTopGroupObj = _GetTopGroupObj( pSvxShape );
2340 if ( pTopGroupObj )
2342 // --> OD 2004-10-01 #i34750# - get attribute position of top group
2343 // shape and add offset between top group object and group member
2344 uno::Reference< drawing::XShape > xGroupShape =
2345 uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
2346 uno::UNO_QUERY );
2347 aPos = xGroupShape->getPosition();
2348 // add offset between top group object and group member
2349 // to the determined attribute position
2350 // --> OD 2004-10-01 #i34750# - correction:
2351 // consider the layout direction
2352 const Rectangle aMemberObjRect = GetSvxShape()->GetSdrObject()->GetSnapRect();
2353 const Rectangle aGroupObjRect = pTopGroupObj->GetSnapRect();
2354 // --> OD 2005-08-16 #i53320# - relative position of group member and
2355 // top group object is always given in horizontal left-to-right layout.
2356 // const SwFrmFmt::tLayoutDir eLayoutDir = GetFrmFmt()
2357 // ? GetFrmFmt()->GetLayoutDir()
2358 // : SwFrmFmt::HORI_L2R;
2359 awt::Point aOffset( 0, 0 );
2360 // switch ( eLayoutDir )
2361 // {
2362 // case SwFrmFmt::HORI_L2R:
2364 aOffset.X = ( aMemberObjRect.Left() - aGroupObjRect.Left() );
2365 aOffset.Y = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
2367 // break;
2368 // case SwFrmFmt::HORI_R2L:
2369 // {
2370 // aOffset.X = ( aGroupObjRect.Right() - aMemberObjRect.Right() );
2371 // aOffset.Y = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
2372 // }
2373 // break;
2374 // case SwFrmFmt::VERT_R2L:
2375 // {
2376 // aOffset.X = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
2377 // aOffset.Y = ( aGroupObjRect.Right() - aMemberObjRect.Right() );
2378 // }
2379 // break;
2380 // default:
2381 // {
2382 // ASSERT( false,
2383 // "<SwXShape::getPosition()> - unsupported layout direction" );
2384 // }
2385 // }
2386 // <--
2387 aOffset.X = TWIP_TO_MM100(aOffset.X);
2388 aOffset.Y = TWIP_TO_MM100(aOffset.Y);
2389 aPos.X += aOffset.X;
2390 aPos.Y += aOffset.Y;
2391 // <--
2395 return aPos;
2397 void SAL_CALL SwXShape::setPosition( const awt::Point& aPosition )
2398 throw ( uno::RuntimeException )
2400 SdrObject* pTopGroupObj = _GetTopGroupObj();
2401 if ( !pTopGroupObj )
2403 // --> OD 2005-02-10 #i37877# - no adjustment of position attributes,
2404 // if the position also has to be applied at the drawing object and
2405 // a contact object is already registered at the drawing object.
2406 bool bApplyPosAtDrawObj(false);
2407 bool bNoAdjustOfPosProp(false);
2408 // --> OD 2004-10-19 #i35798# - apply position also to drawing object,
2409 // if drawing object has no anchor position set.
2410 if ( mxShape.is() )
2412 SvxShape* pSvxShape = GetSvxShape();
2413 if ( pSvxShape )
2415 const SdrObject* pObj = pSvxShape->GetSdrObject();
2416 if ( pObj &&
2417 pObj->GetAnchorPos().X() == 0 &&
2418 pObj->GetAnchorPos().Y() == 0 )
2420 bApplyPosAtDrawObj = true;
2421 if ( pObj->GetUserCall() &&
2422 pObj->GetUserCall()->ISA(SwDrawContact) )
2424 bNoAdjustOfPosProp = true;
2429 // <--
2430 // shape isn't a group member. Thus, set positioning attributes
2431 if ( !bNoAdjustOfPosProp )
2433 _AdjustPositionProperties( aPosition );
2435 if ( bApplyPosAtDrawObj )
2437 mxShape->setPosition( aPosition );
2439 // <--
2441 else if ( mxShape.is() )
2443 // shape is a member of a group. Thus, set its position.
2444 awt::Point aNewPos( aPosition );
2445 // The given position is given in the according layout direction. Thus,
2446 // it has to be converted to a position in horizontal left-to-right
2447 // layout.
2448 // convert given absolute attribute position in layout direction into
2449 // position in horizontal left-to-right layout.
2451 aNewPos = _ConvertPositionToHoriL2R( aNewPos, getSize() );
2453 // Convert given absolute position in horizontal left-to-right
2454 // layout into relative position in horizontal left-to-right layout.
2455 uno::Reference< drawing::XShape > xGroupShape =
2456 uno::Reference< drawing::XShape >( pTopGroupObj->getUnoShape(),
2457 uno::UNO_QUERY );
2459 // --> OD 2004-09-29 #i34750# - correction:
2460 // use method <xGroupShape->getPosition()> to get the correct
2461 // position of the top group object.
2462 awt::Point aAttrPosInHoriL2R(
2463 _ConvertPositionToHoriL2R( xGroupShape->getPosition(),
2464 xGroupShape->getSize() ) );
2465 // <--
2466 aNewPos.X -= aAttrPosInHoriL2R.X;
2467 aNewPos.Y -= aAttrPosInHoriL2R.Y;
2469 // convert relative position in horizontal left-to-right layout into
2470 // absolute position in horizontal left-to-right layout
2472 // --> OD 2004-10-01 #i34750# - correction:
2473 // use method <SvxShape->getPosition()> to get the correct
2474 // 'Drawing layer' position of the top group shape.
2475 uno::Reference< lang::XUnoTunnel > xGrpShapeTunnel(
2476 pTopGroupObj->getUnoShape(),
2477 uno::UNO_QUERY );
2478 SvxShape* pSvxGroupShape = reinterpret_cast< SvxShape * >(
2479 sal::static_int_cast< sal_IntPtr >( xGrpShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2480 const awt::Point aGroupPos = pSvxGroupShape->getPosition();
2481 aNewPos.X += aGroupPos.X;
2482 aNewPos.Y += aGroupPos.Y;
2483 // <--
2485 // set position
2486 mxShape->setPosition( aNewPos );
2489 awt::Size SAL_CALL SwXShape::getSize() throw ( uno::RuntimeException )
2491 awt::Size aSize;
2492 if ( mxShape.is() )
2494 aSize = mxShape->getSize();
2496 return aSize;
2498 void SAL_CALL SwXShape::setSize( const awt::Size& aSize )
2499 throw ( beans::PropertyVetoException,
2500 uno::RuntimeException )
2502 if ( mxShape.is() )
2504 mxShape->setSize( aSize );
2507 // <--
2508 // --> OD 2004-07-22 #i31698# -
2509 // implementation of virtual methods from drawing::XShapeDescriptor
2510 ::rtl::OUString SAL_CALL SwXShape::getShapeType() throw ( uno::RuntimeException )
2512 ::rtl::OUString aType;
2513 if ( mxShape.is() )
2515 aType = mxShape->getShapeType();
2517 return aType;
2519 // <--
2520 /** method to determine top group object
2522 OD 2004-08-03 #i31698#
2524 @author OD
2526 SdrObject* SwXShape::_GetTopGroupObj( SvxShape* _pSvxShape )
2528 SdrObject* pTopGroupObj( 0L );
2530 SvxShape* pSvxShape = _pSvxShape ? _pSvxShape : GetSvxShape();
2531 if ( pSvxShape )
2533 SdrObject* pSdrObj = pSvxShape->GetSdrObject();
2534 if ( pSdrObj && pSdrObj->GetUpGroup() )
2536 pTopGroupObj = pSdrObj->GetUpGroup();
2537 while ( pTopGroupObj->GetUpGroup() )
2539 pTopGroupObj = pTopGroupObj->GetUpGroup();
2544 return pTopGroupObj;
2547 /** method to determine position according to the positioning attributes
2549 OD 2004-08-03 #i31698#
2551 @author OD
2553 awt::Point SwXShape::_GetAttrPosition()
2555 awt::Point aAttrPos;
2557 uno::Any aHoriPos( getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")) ) );
2558 aHoriPos >>= aAttrPos.X;
2559 uno::Any aVertPos( getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")) ) );
2560 aVertPos >>= aAttrPos.Y;
2561 // --> OD 2004-10-19 #i35798# - fallback, if attribute position is (0,0)
2562 // and no anchor position is applied to the drawing object
2563 SvxShape* pSvxShape = GetSvxShape();
2564 if ( pSvxShape )
2566 const SdrObject* pObj = pSvxShape->GetSdrObject();
2567 if ( pObj &&
2568 pObj->GetAnchorPos().X() == 0 &&
2569 pObj->GetAnchorPos().Y() == 0 &&
2570 aAttrPos.X == 0 && aAttrPos.Y == 0 )
2572 const Rectangle aObjRect = pObj->GetSnapRect();
2573 aAttrPos.X = TWIP_TO_MM100(aObjRect.Left());
2574 aAttrPos.Y = TWIP_TO_MM100(aObjRect.Top());
2577 // <--
2578 // --> OD 2004-11-10 #i35007# - If drawing object is anchored as-character,
2579 // it's x-position isn't sensible. Thus, return the x-position as zero in this case.
2580 text::TextContentAnchorType eTextAnchorType =
2581 text::TextContentAnchorType_AT_PARAGRAPH;
2583 rtl::OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2584 uno::Any aAny = getPropertyValue( sAnchorType );
2585 aAny >>= eTextAnchorType;
2587 if ( eTextAnchorType == text::TextContentAnchorType_AS_CHARACTER )
2589 aAttrPos.X = 0;
2591 // <--
2593 return aAttrPos;
2596 /** method to convert the position (translation) of the drawing object to
2597 the layout direction horizontal left-to-right.
2599 OD 2004-07-27 #i31698#
2601 @author OD
2603 awt::Point SwXShape::_ConvertPositionToHoriL2R( const awt::Point _aObjPos,
2604 const awt::Size _aObjSize )
2606 awt::Point aObjPosInHoriL2R( _aObjPos );
2608 SwFrmFmt* pFrmFmt = GetFrmFmt();
2609 if ( pFrmFmt )
2611 SwFrmFmt::tLayoutDir eLayoutDir = pFrmFmt->GetLayoutDir();
2612 switch ( eLayoutDir )
2614 case SwFrmFmt::HORI_L2R:
2616 // nothing to do
2618 break;
2619 case SwFrmFmt::HORI_R2L:
2621 aObjPosInHoriL2R.X = -_aObjPos.X - _aObjSize.Width;
2623 break;
2624 case SwFrmFmt::VERT_R2L:
2626 aObjPosInHoriL2R.X = -_aObjPos.Y - _aObjSize.Width;
2627 aObjPosInHoriL2R.Y = _aObjPos.X;
2629 break;
2630 default:
2632 ASSERT( false,
2633 "<SwXShape::_ConvertPositionToHoriL2R(..)> - unsupported layout direction" );
2638 return aObjPosInHoriL2R;
2640 /** method to convert the transformation of the drawing object to the layout
2641 direction, the drawing object is in
2643 OD 2004-07-27 #i31698#
2645 @author OD
2647 drawing::HomogenMatrix3 SwXShape::_ConvertTransformationToLayoutDir(
2648 drawing::HomogenMatrix3 _aMatrixInHoriL2R )
2650 drawing::HomogenMatrix3 aMatrix( _aMatrixInHoriL2R );
2652 // --> OD 2005-03-10 #i44334#, #i44681# - direct manipulation of the
2653 // tranformation structure isn't valid, if it contains rotation.
2654 SvxShape* pSvxShape = GetSvxShape();
2655 ASSERT( pSvxShape,
2656 "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SvxShape found!")
2657 if ( pSvxShape )
2659 const SdrObject* pObj = pSvxShape->GetSdrObject();
2660 ASSERT( pObj,
2661 "<SwXShape::_ConvertTransformationToLayoutDir(..)> - no SdrObject found!")
2662 if ( pObj )
2664 // get position of object in Writer coordinate system.
2665 awt::Point aPos( getPosition() );
2666 // get position of object in Drawing layer coordinate system
2667 const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2668 const awt::Point aObjPos(
2669 TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
2670 TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
2671 // determine difference between these positions according to the
2672 // Writer coordinate system
2673 const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2674 aPos.Y - aObjPos.Y );
2675 // apply translation difference to transformation matrix.
2676 if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2678 // --> OD 2007-01-03 #i73079# - use correct matrix type
2679 ::basegfx::B2DHomMatrix aTempMatrix;
2680 // <--
2682 aTempMatrix.set(0, 0, aMatrix.Line1.Column1 );
2683 aTempMatrix.set(0, 1, aMatrix.Line1.Column2 );
2684 aTempMatrix.set(0, 2, aMatrix.Line1.Column3 );
2685 aTempMatrix.set(1, 0, aMatrix.Line2.Column1 );
2686 aTempMatrix.set(1, 1, aMatrix.Line2.Column2 );
2687 aTempMatrix.set(1, 2, aMatrix.Line2.Column3 );
2688 aTempMatrix.set(2, 0, aMatrix.Line3.Column1 );
2689 aTempMatrix.set(2, 1, aMatrix.Line3.Column2 );
2690 aTempMatrix.set(2, 2, aMatrix.Line3.Column3 );
2692 // --> OD 2007-01-03 #i73079#
2693 aTempMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
2694 // <--
2696 aMatrix.Line1.Column1 = aTempMatrix.get(0, 0);
2697 aMatrix.Line1.Column2 = aTempMatrix.get(0, 1);
2698 aMatrix.Line1.Column3 = aTempMatrix.get(0, 2);
2699 aMatrix.Line2.Column1 = aTempMatrix.get(1, 0);
2700 aMatrix.Line2.Column2 = aTempMatrix.get(1, 1);
2701 aMatrix.Line2.Column3 = aTempMatrix.get(1, 2);
2702 aMatrix.Line3.Column1 = aTempMatrix.get(2, 0);
2703 aMatrix.Line3.Column2 = aTempMatrix.get(2, 1);
2704 aMatrix.Line3.Column3 = aTempMatrix.get(2, 2);
2708 // <--
2710 return aMatrix;
2713 /** method to adjust the positioning properties
2715 OD 2004-08-02 #i31698#
2717 @author OD
2719 void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition )
2721 // handle x-position
2722 // --> OD 2004-11-10 #i35007# - no handling of x-position, if drawing
2723 // object is anchored as-character, because it doesn't make sense.
2724 text::TextContentAnchorType eTextAnchorType =
2725 text::TextContentAnchorType_AT_PARAGRAPH;
2727 rtl::OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2728 uno::Any aAny = getPropertyValue( sAnchorType );
2729 aAny >>= eTextAnchorType;
2731 if ( eTextAnchorType != text::TextContentAnchorType_AS_CHARACTER )
2732 // <--
2734 // determine current x-postion
2735 rtl::OUString aHoriPosPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition") );
2736 uno::Any aHoriPos( getPropertyValue( aHoriPosPropStr ) );
2737 sal_Int32 dCurrX = 0;
2738 aHoriPos >>= dCurrX;
2739 // change x-position attribute, if needed
2740 if ( dCurrX != _aPosition.X )
2742 // adjust x-position orientation to text::HoriOrientation::NONE, if needed
2743 // Note: has to be done before setting x-position attribute
2744 rtl::OUString aHoriOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") );
2745 uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) );
2746 sal_Int16 eHoriOrient;
2747 aHoriOrient >>= eHoriOrient;
2748 if ( eHoriOrient != text::HoriOrientation::NONE )
2750 eHoriOrient = text::HoriOrientation::NONE;
2751 aHoriOrient <<= eHoriOrient;
2752 setPropertyValue( aHoriOrientPropStr, aHoriOrient );
2754 // set x-position attribute
2755 aHoriPos <<= _aPosition.X;
2756 setPropertyValue( aHoriPosPropStr, aHoriPos );
2760 // handle y-position
2762 // determine current y-postion
2763 rtl::OUString aVertPosPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition") );
2764 uno::Any aVertPos( getPropertyValue( aVertPosPropStr ) );
2765 sal_Int32 dCurrY = 0;
2766 aVertPos >>= dCurrY;
2767 // change y-position attribute, if needed
2768 if ( dCurrY != _aPosition.Y )
2770 // adjust y-position orientation to text::VertOrientation::NONE, if needed
2771 // Note: has to be done before setting y-position attribute
2772 rtl::OUString aVertOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrient") );
2773 uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) );
2774 sal_Int16 eVertOrient;
2775 aVertOrient >>= eVertOrient;
2776 if ( eVertOrient != text::VertOrientation::NONE )
2778 eVertOrient = text::VertOrientation::NONE;
2779 aVertOrient <<= eVertOrient;
2780 setPropertyValue( aVertOrientPropStr, aVertOrient );
2782 // set y-position attribute
2783 aVertPos <<= _aPosition.Y;
2784 setPropertyValue( aVertPosPropStr, aVertPos );
2789 /** method to convert start or end position of the drawing object to the
2790 Writer specific position, which is the attribute position in layout direction
2792 OD 2009-01-12 #i59051#
2794 @author OD
2796 ::com::sun::star::awt::Point SwXShape::_ConvertStartOrEndPosToLayoutDir(
2797 const ::com::sun::star::awt::Point& aStartOrEndPos )
2799 awt::Point aConvertedPos( aStartOrEndPos );
2801 SvxShape* pSvxShape = GetSvxShape();
2802 ASSERT( pSvxShape,
2803 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!")
2804 if ( pSvxShape )
2806 const SdrObject* pObj = pSvxShape->GetSdrObject();
2807 ASSERT( pObj,
2808 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!")
2809 if ( pObj )
2811 // get position of object in Writer coordinate system.
2812 awt::Point aPos( getPosition() );
2813 // get position of object in Drawing layer coordinate system
2814 const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2815 const awt::Point aObjPos(
2816 TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
2817 TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
2818 // determine difference between these positions according to the
2819 // Writer coordinate system
2820 const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2821 aPos.Y - aObjPos.Y );
2822 // apply translation difference to transformation matrix.
2823 if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2825 aConvertedPos.X = aConvertedPos.X + aTranslateDiff.X;
2826 aConvertedPos.Y = aConvertedPos.Y + aTranslateDiff.Y;
2831 return aConvertedPos;
2834 ::com::sun::star::drawing::PolyPolygonBezierCoords SwXShape::_ConvertPolyPolygonBezierToLayoutDir(
2835 const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath )
2837 drawing::PolyPolygonBezierCoords aConvertedPath( aPath );
2839 SvxShape* pSvxShape = GetSvxShape();
2840 ASSERT( pSvxShape,
2841 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!")
2842 if ( pSvxShape )
2844 const SdrObject* pObj = pSvxShape->GetSdrObject();
2845 ASSERT( pObj,
2846 "<SwXShape::_ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!")
2847 if ( pObj )
2849 // get position of object in Writer coordinate system.
2850 awt::Point aPos( getPosition() );
2851 // get position of object in Drawing layer coordinate system
2852 const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2853 const awt::Point aObjPos(
2854 TWIP_TO_MM100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
2855 TWIP_TO_MM100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
2856 // determine difference between these positions according to the
2857 // Writer coordinate system
2858 const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2859 aPos.Y - aObjPos.Y );
2860 // apply translation difference to PolyPolygonBezier.
2861 if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2863 basegfx::B2DHomMatrix aMatrix;
2864 aMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
2866 const sal_Int32 nOuterSequenceCount(aConvertedPath.Coordinates.getLength());
2867 drawing::PointSequence* pInnerSequence = aConvertedPath.Coordinates.getArray();
2868 for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
2870 const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
2871 awt::Point* pArray = pInnerSequence->getArray();
2873 for(sal_Int32 b(0); b < nInnerSequenceCount; b++)
2875 basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y);
2876 aNewCoordinatePair *= aMatrix;
2877 pArray->X = basegfx::fround(aNewCoordinatePair.getX());
2878 pArray->Y = basegfx::fround(aNewCoordinatePair.getY());
2879 pArray++;
2886 return aConvertedPath;
2889 /*-- 31.05.01 09:59:19---------------------------------------------------
2891 -----------------------------------------------------------------------*/
2892 SwXGroupShape::SwXGroupShape(uno::Reference< XInterface > & xShape) :
2893 SwXShape(xShape)
2895 #ifdef DBG_UTIL
2896 uno::Reference<XShapes> xShapes(xShapeAgg, uno::UNO_QUERY);
2897 DBG_ASSERT(xShapes.is(), "no SvxShape found or shape is not a group shape");
2898 #endif
2901 /*-- 31.05.01 09:59:19---------------------------------------------------
2903 -----------------------------------------------------------------------*/
2904 SwXGroupShape::~SwXGroupShape()
2907 /*-- 31.05.01 09:59:19---------------------------------------------------
2909 -----------------------------------------------------------------------*/
2910 uno::Any SwXGroupShape::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
2912 uno::Any aRet;
2913 if(rType == ::getCppuType((uno::Reference<XShapes>*)0))
2914 aRet <<= uno::Reference<XShapes>(this);
2915 else
2916 aRet = SwXShape::queryInterface(rType);
2917 return aRet;
2919 /*-- 31.05.01 09:59:19---------------------------------------------------
2921 -----------------------------------------------------------------------*/
2922 void SwXGroupShape::acquire( ) throw()
2924 SwXShape::acquire();
2926 /*-- 31.05.01 09:59:19---------------------------------------------------
2928 -----------------------------------------------------------------------*/
2929 void SwXGroupShape::release( ) throw()
2931 SwXShape::release();
2933 /*-- 31.05.01 09:59:19---------------------------------------------------
2935 -----------------------------------------------------------------------*/
2936 void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException)
2938 vos::OGuard aGuard(Application::GetSolarMutex());
2939 SvxShape* pSvxShape = GetSvxShape();
2940 SwFrmFmt* pFmt = GetFrmFmt();
2941 if(pSvxShape && pFmt)
2943 uno::Reference<XShapes> xShapes;
2944 if( xShapeAgg.is() )
2946 const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
2947 uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2948 aAgg >>= xShapes;
2950 if(xShapes.is())
2951 xShapes->add(xShape);
2952 else
2953 throw uno::RuntimeException();
2955 uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY);
2956 SwXShape* pSwShape = 0;
2957 if(xShape.is())
2958 pSwShape = reinterpret_cast< SwXShape * >(
2959 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
2960 if(pSwShape && pSwShape->m_bDescriptor)
2962 SvxShape* pAddShape = reinterpret_cast< SvxShape * >(
2963 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2964 if(pAddShape)
2966 SdrObject* pObj = pAddShape->GetSdrObject();
2967 if(pObj)
2969 SwDoc* pDoc = pFmt->GetDoc();
2970 // OD 25.06.2003 #108784# - set layer of new drawing
2971 // object to corresponding invisible layer.
2972 if( FmFormInventor != pObj->GetObjInventor())
2974 pObj->SetLayer( pSwShape->pImpl->GetOpaque()
2975 ? pDoc->GetInvisibleHeavenId()
2976 : pDoc->GetInvisibleHellId() );
2978 else
2980 pObj->SetLayer(pDoc->GetInvisibleControlsId());
2984 pSwShape->m_bDescriptor = sal_False;
2985 //add the group member to the format of the group
2986 SwFrmFmt* pShapeFmt = ::FindFrmFmt( pSvxShape->GetSdrObject() );
2987 if(pShapeFmt)
2988 pFmt->Add(pSwShape);
2991 else
2992 throw uno::RuntimeException();
2994 /*-- 31.05.01 09:59:20---------------------------------------------------
2996 -----------------------------------------------------------------------*/
2997 void SwXGroupShape::remove( const uno::Reference< XShape >& xShape ) throw (uno::RuntimeException)
2999 vos::OGuard aGuard(Application::GetSolarMutex());
3000 uno::Reference<XShapes> xShapes;
3001 if( xShapeAgg.is() )
3003 const uno::Type& rType = ::getCppuType((uno::Reference<XShapes>*)0 );
3004 uno::Any aAgg = xShapeAgg->queryAggregation( rType );
3005 aAgg >>= xShapes;
3007 if(!xShapes.is())
3008 throw uno::RuntimeException();
3009 xShapes->remove(xShape);
3011 /*-- 31.05.01 09:59:20---------------------------------------------------
3013 -----------------------------------------------------------------------*/
3014 sal_Int32 SwXGroupShape::getCount(void) throw( uno::RuntimeException )
3016 vos::OGuard aGuard(Application::GetSolarMutex());
3017 uno::Reference<XIndexAccess> xAcc;
3018 if( xShapeAgg.is() )
3020 const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
3021 uno::Any aAgg = xShapeAgg->queryAggregation( rType );
3022 aAgg >>= xAcc;
3024 if(!xAcc.is())
3025 throw uno::RuntimeException();
3026 return xAcc->getCount();
3028 /*-- 31.05.01 09:59:20---------------------------------------------------
3030 -----------------------------------------------------------------------*/
3031 uno::Any SwXGroupShape::getByIndex(sal_Int32 nIndex)
3032 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
3033 uno::RuntimeException )
3035 vos::OGuard aGuard(Application::GetSolarMutex());
3036 uno::Reference<XIndexAccess> xAcc;
3037 if( xShapeAgg.is() )
3039 const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
3040 uno::Any aAgg = xShapeAgg->queryAggregation( rType );
3041 aAgg >>= xAcc;
3043 if(!xAcc.is())
3044 throw uno::RuntimeException();
3045 return xAcc->getByIndex(nIndex);
3047 /*-- 31.05.01 09:59:20---------------------------------------------------
3049 -----------------------------------------------------------------------*/
3050 uno::Type SwXGroupShape::getElementType( ) throw(uno::RuntimeException)
3052 vos::OGuard aGuard(Application::GetSolarMutex());
3053 uno::Reference<XIndexAccess> xAcc;
3054 if( xShapeAgg.is() )
3056 const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
3057 uno::Any aAgg = xShapeAgg->queryAggregation( rType );
3058 aAgg >>= xAcc;
3060 if(!xAcc.is())
3061 throw uno::RuntimeException();
3062 return xAcc->getElementType();
3064 /*-- 31.05.01 09:59:22---------------------------------------------------
3066 -----------------------------------------------------------------------*/
3067 sal_Bool SwXGroupShape::hasElements( ) throw(uno::RuntimeException)
3069 vos::OGuard aGuard(Application::GetSolarMutex());
3070 uno::Reference<XIndexAccess> xAcc;
3071 if( xShapeAgg.is() )
3073 const uno::Type& rType = ::getCppuType((uno::Reference<XIndexAccess>*)0 );
3074 uno::Any aAgg = xShapeAgg->queryAggregation( rType );
3075 aAgg >>= xAcc;
3077 if(!xAcc.is())
3078 throw uno::RuntimeException();
3079 return xAcc->hasElements();