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