xref: /trunk/main/svx/source/unodraw/unoshap2.cxx (revision ddde725d65c83fe3ba1186d46f6e3e08f12ba47e)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _SVX_USE_UNOGLOBALS_
28cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
29cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
30cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>  //added by BerryJia for fixing Bug102407 2002-11-4
34cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>   //added by BerryJia for fixing Bug102407 2002-11-4
35cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp>
37cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
38cdf0e10cSrcweir #include <tools/urlobj.hxx>
39cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <vos/mutex.hxx>
42cdf0e10cSrcweir #include <svtools/fltcall.hxx>
43cdf0e10cSrcweir #include <svtools/filter.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
46cdf0e10cSrcweir #include <svx/svdpool.hxx>
47cdf0e10cSrcweir #include <rtl/uuid.h>
48cdf0e10cSrcweir #include <rtl/memory.h>
49cdf0e10cSrcweir #include <tools/urlobj.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <editeng/unoprnms.hxx>
52cdf0e10cSrcweir #include <svx/unoshape.hxx>
53cdf0e10cSrcweir #include <svx/unopage.hxx>
54cdf0e10cSrcweir #include <svx/svdobj.hxx>
55cdf0e10cSrcweir #include <svx/svdpage.hxx>
56cdf0e10cSrcweir #include <svx/svdmodel.hxx>
57cdf0e10cSrcweir #include <svx/svdouno.hxx>
58cdf0e10cSrcweir #include "shapeimpl.hxx"
59cdf0e10cSrcweir #include "svx/unoshprp.hxx"
60cdf0e10cSrcweir #include <svx/svdoashp.hxx>
61cdf0e10cSrcweir #include "unopolyhelper.hxx"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // #i29181#
64cdf0e10cSrcweir #include "svx/svdviter.hxx"
65cdf0e10cSrcweir #include <svx/svdview.hxx>
66cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
67cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
68cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
69cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir using ::rtl::OUString;
72cdf0e10cSrcweir using namespace ::osl;
73cdf0e10cSrcweir using namespace ::vos;
74cdf0e10cSrcweir using namespace ::cppu;
75cdf0e10cSrcweir using namespace ::com::sun::star;
76cdf0e10cSrcweir using namespace ::com::sun::star::uno;
77cdf0e10cSrcweir using namespace ::com::sun::star::lang;
78cdf0e10cSrcweir using namespace ::com::sun::star::container;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir #define INTERFACE_TYPE( xint ) \
81cdf0e10cSrcweir     ::getCppuType((const Reference< xint >*)0)
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #define QUERYINT( xint ) \
84cdf0e10cSrcweir     if( rType == ::getCppuType((const Reference< xint >*)0) ) \
85cdf0e10cSrcweir         aAny <<= Reference< xint >(this)
86cdf0e10cSrcweir 
87cdf0e10cSrcweir class GDIMetaFile;
88cdf0e10cSrcweir class SvStream;
89cdf0e10cSrcweir sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
90cdf0e10cSrcweir                               FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir /***********************************************************************
93cdf0e10cSrcweir * class SvxShapeGroup                                                  *
94cdf0e10cSrcweir ***********************************************************************/
95cdf0e10cSrcweir 
96cdf0e10cSrcweir SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage  )  throw() :
97cdf0e10cSrcweir     SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_GROUP), aSvxMapProvider.GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ),
98cdf0e10cSrcweir     mxPage( pDrawPage )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir //----------------------------------------------------------------------
103cdf0e10cSrcweir SvxShapeGroup::~SvxShapeGroup() throw()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //----------------------------------------------------------------------
108cdf0e10cSrcweir void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     SvxShape::Create( pNewObj, pNewPage );
111cdf0e10cSrcweir     mxPage = pNewPage;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //----------------------------------------------------------------------
115cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType )
116cdf0e10cSrcweir     throw(uno::RuntimeException)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     return SvxShape::queryInterface( rType );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeGroup::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     uno::Any aAny;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     QUERYINT( drawing::XShapeGroup );
126cdf0e10cSrcweir     else QUERYINT( drawing::XShapes );
127cdf0e10cSrcweir     else QUERYINT( container::XIndexAccess );
128cdf0e10cSrcweir     else QUERYINT( container::XElementAccess );
129cdf0e10cSrcweir     else
130cdf0e10cSrcweir         return SvxShape::queryAggregation( rType );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     return aAny;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::acquire() throw ( )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     SvxShape::acquire();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::release() throw ( )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     SvxShape::release();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes()
146cdf0e10cSrcweir     throw (uno::RuntimeException)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     return SvxShape::getTypes();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxShapeGroup::getImplementationId()
152cdf0e10cSrcweir     throw (uno::RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aId;
155cdf0e10cSrcweir     if( aId.getLength() == 0 )
156cdf0e10cSrcweir     {
157cdf0e10cSrcweir         aId.realloc( 16 );
158cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
159cdf0e10cSrcweir     }
160cdf0e10cSrcweir     return aId;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // ::com::sun::star::drawing::XShape
164cdf0e10cSrcweir 
165cdf0e10cSrcweir //----------------------------------------------------------------------
166cdf0e10cSrcweir OUString SAL_CALL SvxShapeGroup::getShapeType()
167cdf0e10cSrcweir     throw( uno::RuntimeException )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     return SvxShape::getShapeType();
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //------------------------------------------------------------------1----
173cdf0e10cSrcweir awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     return SvxShape::getPosition();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir //----------------------------------------------------------------------
179cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     SvxShape::setPosition(Position);
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir //----------------------------------------------------------------------
185cdf0e10cSrcweir 
186cdf0e10cSrcweir awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     return SvxShape::getSize();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir //----------------------------------------------------------------------
192cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::setSize( const awt::Size& rSize )
193cdf0e10cSrcweir     throw(beans::PropertyVetoException, uno::RuntimeException)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     SvxShape::setSize( rSize );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir // drawing::XShapeGroup
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //----------------------------------------------------------------------
201cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::enterGroup(  ) throw(uno::RuntimeException)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir     // Todo
204cdf0e10cSrcweir //  pDrView->EnterMarkedGroup();
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir //----------------------------------------------------------------------
208cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::leaveGroup(  ) throw(uno::RuntimeException)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir     // Todo
211cdf0e10cSrcweir //  pDrView->LeaveOneGroup();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir //----------------------------------------------------------------------
215cdf0e10cSrcweir 
216cdf0e10cSrcweir // XShapes
217cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::add( const uno::Reference< drawing::XShape >& xShape )
218cdf0e10cSrcweir     throw( uno::RuntimeException )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     SvxShape* pShape = SvxShape::getImplementation( xShape );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     if( mpObj.is()&& mxPage.is() && pShape )
225cdf0e10cSrcweir     {
226cdf0e10cSrcweir         SdrObject* pSdrShape = pShape->GetSdrObject();
227cdf0e10cSrcweir         if( pSdrShape == NULL )
228cdf0e10cSrcweir             pSdrShape = mxPage->_CreateSdrObject( xShape );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir         if( pSdrShape->IsInserted() )
231cdf0e10cSrcweir             pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         mpObj->GetSubList()->InsertObject( pSdrShape );
234cdf0e10cSrcweir         pSdrShape->SetModel(mpObj->GetModel());
235cdf0e10cSrcweir 
236cdf0e10cSrcweir         // #85922# It makes no sense to set the layer asked
237cdf0e10cSrcweir         // from the group object since these is an iteration
238cdf0e10cSrcweir         // over the contained objects. In consequence, this
239cdf0e10cSrcweir         // statement erases all layer information from the draw
240cdf0e10cSrcweir         // objects. Layers need to be set at draw objects directly
241cdf0e10cSrcweir         // and have nothing to do with grouping at all.
242cdf0e10cSrcweir         // pSdrShape->SetLayer(pObject->GetLayer());
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         // Establish connection between new SdrObject and its wrapper before
245cdf0e10cSrcweir         // inserting the new shape into the group.  There a new wrapper
246cdf0e10cSrcweir         // would be created when this connection would not already exist.
247cdf0e10cSrcweir         if(pShape)
248cdf0e10cSrcweir             pShape->Create( pSdrShape, mxPage.get() );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         if( mpModel )
251cdf0e10cSrcweir             mpModel->SetChanged();
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir     else
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         DBG_ERROR("could not add XShape to group shape!");
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir //----------------------------------------------------------------------
260cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xShape )
261cdf0e10cSrcweir     throw( uno::RuntimeException )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     SdrObject* pSdrShape = NULL;
266cdf0e10cSrcweir     SvxShape* pShape = SvxShape::getImplementation( xShape );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     if( pShape )
269cdf0e10cSrcweir         pSdrShape = pShape->GetSdrObject();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     if( !mpObj.is() || pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
272cdf0e10cSrcweir         throw uno::RuntimeException();
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     SdrObjList& rList = *pSdrShape->GetObjList();
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     const sal_uInt32 nObjCount = rList.GetObjCount();
277cdf0e10cSrcweir     sal_uInt32 nObjNum = 0;
278cdf0e10cSrcweir     while( nObjNum < nObjCount )
279cdf0e10cSrcweir     {
280cdf0e10cSrcweir         if(rList.GetObj( nObjNum ) == pSdrShape )
281cdf0e10cSrcweir             break;
282cdf0e10cSrcweir         nObjNum++;
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     if( nObjNum < nObjCount )
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir         // #i29181#
288cdf0e10cSrcweir         // If the SdrObject which is about to be deleted is in any selection,
289cdf0e10cSrcweir         // deselect it first.
290cdf0e10cSrcweir         SdrViewIter aIter( pSdrShape );
291cdf0e10cSrcweir 
292cdf0e10cSrcweir         for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
293cdf0e10cSrcweir         {
294cdf0e10cSrcweir             if(CONTAINER_ENTRY_NOTFOUND != pView->TryToFindMarkedObject(pSdrShape))
295cdf0e10cSrcweir             {
296cdf0e10cSrcweir                 pView->MarkObj(pSdrShape, pView->GetSdrPageView(), sal_True, sal_False);
297cdf0e10cSrcweir             }
298cdf0e10cSrcweir         }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir         SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
301cdf0e10cSrcweir         SdrObject::Free( pObject );
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir     else
304cdf0e10cSrcweir     {
305cdf0e10cSrcweir         DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
306cdf0e10cSrcweir     }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     if( mpModel )
309cdf0e10cSrcweir         mpModel->SetChanged();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir // XIndexAccess
313cdf0e10cSrcweir 
314cdf0e10cSrcweir //----------------------------------------------------------------------
315cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShapeGroup::getCount() throw( uno::RuntimeException )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     sal_Int32 nRetval = 0;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     if(mpObj.is() && mpObj->GetSubList())
322cdf0e10cSrcweir         nRetval = mpObj->GetSubList()->GetObjCount();
323cdf0e10cSrcweir     else
324cdf0e10cSrcweir         throw uno::RuntimeException();
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     return nRetval;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir //----------------------------------------------------------------------
330cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
331cdf0e10cSrcweir     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir     if( !mpObj.is() || mpObj->GetSubList() == NULL )
336cdf0e10cSrcweir         throw uno::RuntimeException();
337cdf0e10cSrcweir 
338cdf0e10cSrcweir     if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index )
339cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     if(pDestObj == NULL)
344cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
345cdf0e10cSrcweir 
346cdf0e10cSrcweir     Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY );
347cdf0e10cSrcweir     return uno::makeAny( xShape );
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir // ::com::sun::star::container::XElementAccess
351cdf0e10cSrcweir 
352cdf0e10cSrcweir //----------------------------------------------------------------------
353cdf0e10cSrcweir uno::Type SAL_CALL SvxShapeGroup::getElementType() throw( uno::RuntimeException )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     return ::getCppuType(( const Reference< drawing::XShape >*)0);
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir //----------------------------------------------------------------------
359cdf0e10cSrcweir sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
364cdf0e10cSrcweir }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir //----------------------------------------------------------------------
367cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
368cdf0e10cSrcweir 
369cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
370cdf0e10cSrcweir     throw(uno::RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir     return SvxShape::getSupportedServiceNames();
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir /***********************************************************************
376cdf0e10cSrcweir *                                                                      *
377cdf0e10cSrcweir ***********************************************************************/
378cdf0e10cSrcweir 
379cdf0e10cSrcweir SvxShapeConnector::SvxShapeConnector( SdrObject* pObj )  throw() :
380cdf0e10cSrcweir     SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONNECTOR), aSvxMapProvider.GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir //----------------------------------------------------------------------
385cdf0e10cSrcweir SvxShapeConnector::~SvxShapeConnector() throw()
386cdf0e10cSrcweir {
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir //----------------------------------------------------------------------
390cdf0e10cSrcweir 
391cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType )
392cdf0e10cSrcweir     throw(uno::RuntimeException)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     return SvxShapeText::queryInterface( rType );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeConnector::queryAggregation( const uno::Type & rType )
398cdf0e10cSrcweir     throw(uno::RuntimeException)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir     uno::Any aAny;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     QUERYINT( drawing::XConnectorShape );
403cdf0e10cSrcweir     else
404cdf0e10cSrcweir         return SvxShapeText::queryAggregation( rType );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     return aAny;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::acquire() throw ( )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir     SvxShapeText::acquire();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::release() throw ( )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir     SvxShapeText::release();
417cdf0e10cSrcweir }
418cdf0e10cSrcweir // XTypeProvider
419cdf0e10cSrcweir 
420cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxShapeConnector::getTypes()
421cdf0e10cSrcweir     throw (uno::RuntimeException)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     return SvxShape::getTypes();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
426cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxShapeConnector::getImplementationId()
427cdf0e10cSrcweir     throw (uno::RuntimeException)
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aId;
430cdf0e10cSrcweir     if( aId.getLength() == 0 )
431cdf0e10cSrcweir     {
432cdf0e10cSrcweir         aId.realloc( 16 );
433cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
434cdf0e10cSrcweir     }
435cdf0e10cSrcweir     return aId;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // ::com::sun::star::drawing::XShape
439cdf0e10cSrcweir 
440cdf0e10cSrcweir //----------------------------------------------------------------------
441cdf0e10cSrcweir OUString SAL_CALL SvxShapeConnector::getShapeType()
442cdf0e10cSrcweir     throw( uno::RuntimeException )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir     return SvxShapeText::getShapeType();
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir //------------------------------------------------------------------1----
448cdf0e10cSrcweir awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir     return SvxShapeText::getPosition();
451cdf0e10cSrcweir }
452cdf0e10cSrcweir 
453cdf0e10cSrcweir //----------------------------------------------------------------------
454cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     SvxShapeText::setPosition(Position);
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir //----------------------------------------------------------------------
460cdf0e10cSrcweir 
461cdf0e10cSrcweir awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException)
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     return SvxShapeText::getSize();
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir //----------------------------------------------------------------------
467cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::setSize( const awt::Size& rSize )
468cdf0e10cSrcweir     throw(beans::PropertyVetoException, uno::RuntimeException)
469cdf0e10cSrcweir {
470cdf0e10cSrcweir     SvxShapeText::setSize( rSize );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir 
473cdf0e10cSrcweir //----------------------------------------------------------------------
474cdf0e10cSrcweir 
475cdf0e10cSrcweir // XConnectorShape
476cdf0e10cSrcweir 
477cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType ) throw( uno::RuntimeException )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
480cdf0e10cSrcweir 
481cdf0e10cSrcweir     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
482cdf0e10cSrcweir     SvxShape* pShape = SvxShape::getImplementation( xRef );
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     if( pShape )
485cdf0e10cSrcweir         mpObj->ConnectToNode( sal_True, pShape->mpObj.get() );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     if( mpModel )
488cdf0e10cSrcweir         mpModel->SetChanged();
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir //----------------------------------------------------------------------
492cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType  )
493cdf0e10cSrcweir     throw( uno::RuntimeException )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
496cdf0e10cSrcweir 
497cdf0e10cSrcweir     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
498cdf0e10cSrcweir     SvxShape* pShape = SvxShape::getImplementation( xRef );
499cdf0e10cSrcweir 
500cdf0e10cSrcweir     if( mpObj.is() && pShape )
501cdf0e10cSrcweir         mpObj->ConnectToNode( sal_False, pShape->mpObj.get() );
502cdf0e10cSrcweir 
503cdf0e10cSrcweir     if( mpModel )
504cdf0e10cSrcweir         mpModel->SetChanged();
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir //----------------------------------------------------------------------
508cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing::XConnectableShape >&  )
509cdf0e10cSrcweir     throw( uno::RuntimeException )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
512cdf0e10cSrcweir 
513cdf0e10cSrcweir     if(mpObj.is())
514cdf0e10cSrcweir         mpObj->DisconnectFromNode( sal_True );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir     if( mpModel )
517cdf0e10cSrcweir         mpModel->SetChanged();
518cdf0e10cSrcweir }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir //----------------------------------------------------------------------
521cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::XConnectableShape >& )
522cdf0e10cSrcweir     throw( uno::RuntimeException )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     if(mpObj.is())
527cdf0e10cSrcweir         mpObj->DisconnectFromNode( sal_False );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     if( mpModel )
530cdf0e10cSrcweir         mpModel->SetChanged();
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir //----------------------------------------------------------------------
534cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
535cdf0e10cSrcweir //----------------------------------------------------------------------
536cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
539cdf0e10cSrcweir }
540cdf0e10cSrcweir 
541cdf0e10cSrcweir /***********************************************************************
542cdf0e10cSrcweir * class SvxShapeControl                                                *
543cdf0e10cSrcweir ***********************************************************************/
544cdf0e10cSrcweir DBG_NAME(SvxShapeControl)
545cdf0e10cSrcweir 
546cdf0e10cSrcweir SvxShapeControl::SvxShapeControl( SdrObject* pObj )  throw() :
547cdf0e10cSrcweir     SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONTROL), aSvxMapProvider.GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir     DBG_CTOR(SvxShapeControl,NULL);
550cdf0e10cSrcweir     setShapeKind( OBJ_UNO );
551cdf0e10cSrcweir }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir //----------------------------------------------------------------------
554cdf0e10cSrcweir SvxShapeControl::~SvxShapeControl() throw()
555cdf0e10cSrcweir {
556cdf0e10cSrcweir     DBG_DTOR(SvxShapeControl,NULL);
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir //----------------------------------------------------------------------
560cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType )
561cdf0e10cSrcweir     throw(uno::RuntimeException)
562cdf0e10cSrcweir {
563cdf0e10cSrcweir     return SvxShapeText::queryInterface( rType );
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
567cdf0e10cSrcweir {
568cdf0e10cSrcweir     uno::Any aAny;
569cdf0e10cSrcweir 
570cdf0e10cSrcweir     QUERYINT( drawing::XControlShape );
571cdf0e10cSrcweir     else
572cdf0e10cSrcweir         return SvxShapeText::queryAggregation( rType );
573cdf0e10cSrcweir 
574cdf0e10cSrcweir     return aAny;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir void SAL_CALL SvxShapeControl::acquire() throw ( )
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     SvxShapeText::acquire();
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
582cdf0e10cSrcweir void SAL_CALL SvxShapeControl::release() throw ( )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir     SvxShapeText::release();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir // XTypeProvider
587cdf0e10cSrcweir 
588cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxShapeControl::getTypes()
589cdf0e10cSrcweir     throw (uno::RuntimeException)
590cdf0e10cSrcweir {
591cdf0e10cSrcweir     return SvxShape::getTypes();
592cdf0e10cSrcweir }
593cdf0e10cSrcweir 
594cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxShapeControl::getImplementationId()
595cdf0e10cSrcweir     throw (uno::RuntimeException)
596cdf0e10cSrcweir {
597cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aId;
598cdf0e10cSrcweir     if( aId.getLength() == 0 )
599cdf0e10cSrcweir     {
600cdf0e10cSrcweir         aId.realloc( 16 );
601cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir     return aId;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir // ::com::sun::star::drawing::XShape
607cdf0e10cSrcweir 
608cdf0e10cSrcweir //----------------------------------------------------------------------
609cdf0e10cSrcweir OUString SAL_CALL SvxShapeControl::getShapeType()
610cdf0e10cSrcweir     throw( uno::RuntimeException )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir     return SvxShapeText::getShapeType();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir //------------------------------------------------------------------1----
616cdf0e10cSrcweir awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException)
617cdf0e10cSrcweir {
618cdf0e10cSrcweir     return SvxShapeText::getPosition();
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
621cdf0e10cSrcweir //----------------------------------------------------------------------
622cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
623cdf0e10cSrcweir {
624cdf0e10cSrcweir     SvxShapeText::setPosition(Position);
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir //----------------------------------------------------------------------
628cdf0e10cSrcweir 
629cdf0e10cSrcweir awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException)
630cdf0e10cSrcweir {
631cdf0e10cSrcweir     return SvxShapeText::getSize();
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir //----------------------------------------------------------------------
635cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setSize( const awt::Size& rSize )
636cdf0e10cSrcweir     throw(beans::PropertyVetoException, uno::RuntimeException)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir     SvxShapeText::setSize( rSize );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir //----------------------------------------------------------------------
642cdf0e10cSrcweir // XControlShape
643cdf0e10cSrcweir 
644cdf0e10cSrcweir Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
645cdf0e10cSrcweir     throw( uno::RuntimeException )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     Reference< awt::XControlModel > xModel;
650cdf0e10cSrcweir 
651cdf0e10cSrcweir     SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
652cdf0e10cSrcweir     if( pUnoObj )
653cdf0e10cSrcweir         xModel = pUnoObj->GetUnoControlModel();
654cdf0e10cSrcweir 
655cdf0e10cSrcweir     return xModel;
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir //----------------------------------------------------------------------
659cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >& xControl )
660cdf0e10cSrcweir     throw( uno::RuntimeException )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
665cdf0e10cSrcweir     if( pUnoObj )
666cdf0e10cSrcweir         pUnoObj->SetUnoControlModel( xControl );
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     if( mpModel )
669cdf0e10cSrcweir         mpModel->SetChanged();
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir // XServiceInfo
673cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir static struct
679cdf0e10cSrcweir {
680cdf0e10cSrcweir     const sal_Char* mpAPIName;
681cdf0e10cSrcweir     sal_uInt16 mnAPINameLen;
682cdf0e10cSrcweir 
683cdf0e10cSrcweir     const sal_Char* mpFormName;
684cdf0e10cSrcweir     sal_uInt16 mnFormNameLen;
685cdf0e10cSrcweir }
686cdf0e10cSrcweir SvxShapeControlPropertyMapping[] =
687cdf0e10cSrcweir {
688cdf0e10cSrcweir     // Warning: The first entry must be FontSlant because the any needs to be converted
689cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), MAP_CHAR_LEN("FontSlant")  }, //  const sal_Int16 => ::com::sun::star::awt::FontSlant
690cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), MAP_CHAR_LEN("FontName") },
691cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), MAP_CHAR_LEN("FontStyleName") },
692cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), MAP_CHAR_LEN("FontFamily") },
693cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), MAP_CHAR_LEN("FontCharset") },
694cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), MAP_CHAR_LEN("FontHeight") },
695cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), MAP_CHAR_LEN("FontPitch" ) },
696cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), MAP_CHAR_LEN("FontWeight" ) },
697cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), MAP_CHAR_LEN("FontUnderline") },
698cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), MAP_CHAR_LEN("FontStrikeout") },
699cdf0e10cSrcweir     { MAP_CHAR_LEN("CharKerning"), MAP_CHAR_LEN("FontKerning") },
700cdf0e10cSrcweir     { MAP_CHAR_LEN("CharWordMode"), MAP_CHAR_LEN("FontWordLineMode" ) },
701cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR),   MAP_CHAR_LEN("TextColor") },
702cdf0e10cSrcweir     { MAP_CHAR_LEN("CharRelief"),   MAP_CHAR_LEN("FontRelief") },
703cdf0e10cSrcweir     { MAP_CHAR_LEN("CharUnderlineColor"),   MAP_CHAR_LEN("TextLineColor") },
704cdf0e10cSrcweir     { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), MAP_CHAR_LEN("Align") },
705cdf0e10cSrcweir     { MAP_CHAR_LEN("TextVerticalAdjust"), MAP_CHAR_LEN("VerticalAlign") },
706cdf0e10cSrcweir     { MAP_CHAR_LEN("ControlBackground"), MAP_CHAR_LEN("BackgroundColor") },
707cdf0e10cSrcweir     { MAP_CHAR_LEN("ControlSymbolColor"), MAP_CHAR_LEN("SymbolColor") },
708cdf0e10cSrcweir     { MAP_CHAR_LEN("ControlBorder"), MAP_CHAR_LEN("Border") },
709cdf0e10cSrcweir     { MAP_CHAR_LEN("ControlBorderColor"), MAP_CHAR_LEN("BorderColor") },
710cdf0e10cSrcweir     { MAP_CHAR_LEN("ControlTextEmphasis"),  MAP_CHAR_LEN("FontEmphasisMark") },
711cdf0e10cSrcweir     { MAP_CHAR_LEN("ImageScaleMode"),  MAP_CHAR_LEN("ScaleMode") },
712cdf0e10cSrcweir     { MAP_CHAR_LEN("ControlWritingMode"), MAP_CHAR_LEN("WritingMode") },
713cdf0e10cSrcweir     { NULL,0, NULL, 0 }
714cdf0e10cSrcweir };
715cdf0e10cSrcweir 
716cdf0e10cSrcweir namespace
717cdf0e10cSrcweir {
718cdf0e10cSrcweir     static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
719cdf0e10cSrcweir     {
720cdf0e10cSrcweir         sal_uInt16 i = 0;
721cdf0e10cSrcweir         while( SvxShapeControlPropertyMapping[i].mpAPIName )
722cdf0e10cSrcweir         {
723cdf0e10cSrcweir             if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 )
724cdf0e10cSrcweir             {
725cdf0e10cSrcweir                 rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US );
726cdf0e10cSrcweir             }
727cdf0e10cSrcweir             ++i;
728cdf0e10cSrcweir         }
729cdf0e10cSrcweir         return rInternalName.getLength() > 0;
730cdf0e10cSrcweir     }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     struct EnumConversionMap
733cdf0e10cSrcweir     {
734cdf0e10cSrcweir         sal_Int16   nAPIValue;
735cdf0e10cSrcweir         sal_Int16   nFormValue;
736cdf0e10cSrcweir     };
737cdf0e10cSrcweir 
738cdf0e10cSrcweir     EnumConversionMap aMapAdjustToAlign[] =
739cdf0e10cSrcweir     {
740cdf0e10cSrcweir         // note that order matters:
741cdf0e10cSrcweir         // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
742cdf0e10cSrcweir         // and use the first matching entry
743cdf0e10cSrcweir         {style::ParagraphAdjust_LEFT,           (sal_Int16)awt::TextAlign::LEFT},
744cdf0e10cSrcweir         {style::ParagraphAdjust_CENTER,         (sal_Int16)awt::TextAlign::CENTER},
745cdf0e10cSrcweir         {style::ParagraphAdjust_RIGHT,          (sal_Int16)awt::TextAlign::RIGHT},
746cdf0e10cSrcweir         {style::ParagraphAdjust_BLOCK,          (sal_Int16)awt::TextAlign::RIGHT},
747cdf0e10cSrcweir         {style::ParagraphAdjust_STRETCH,        (sal_Int16)awt::TextAlign::LEFT},
748cdf0e10cSrcweir         {-1,-1}
749cdf0e10cSrcweir     };
750cdf0e10cSrcweir 
751cdf0e10cSrcweir     static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap )
752cdf0e10cSrcweir     {
753cdf0e10cSrcweir         sal_Int16 nValue = sal_Int16();
754cdf0e10cSrcweir         OSL_VERIFY( _rValue >>= nValue );
755cdf0e10cSrcweir 
756cdf0e10cSrcweir         const EnumConversionMap* pEntry = _pMap;
757cdf0e10cSrcweir         while ( pEntry && ( pEntry->nFormValue != -1 ) )
758cdf0e10cSrcweir         {
759cdf0e10cSrcweir             if ( nValue == pEntry->nFormValue )
760cdf0e10cSrcweir             {
761cdf0e10cSrcweir                 _rValue <<= pEntry->nAPIValue;
762cdf0e10cSrcweir                 return;
763cdf0e10cSrcweir             }
764cdf0e10cSrcweir             ++pEntry;
765cdf0e10cSrcweir         }
766cdf0e10cSrcweir     }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir     static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap )
769cdf0e10cSrcweir     {
770cdf0e10cSrcweir         sal_Int32 nValue = 0;
771cdf0e10cSrcweir         OSL_VERIFY( _rValue >>= nValue );
772cdf0e10cSrcweir 
773cdf0e10cSrcweir         const EnumConversionMap* pEntry = _pMap;
774cdf0e10cSrcweir         while ( pEntry && ( pEntry->nAPIValue != -1 ) )
775cdf0e10cSrcweir         {
776cdf0e10cSrcweir             if ( nValue == pEntry->nAPIValue )
777cdf0e10cSrcweir             {
778cdf0e10cSrcweir                 _rValue <<= pEntry->nFormValue;
779cdf0e10cSrcweir                 return;
780cdf0e10cSrcweir             }
781cdf0e10cSrcweir             ++pEntry;
782cdf0e10cSrcweir         }
783cdf0e10cSrcweir     }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir     static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue )
786cdf0e10cSrcweir     {
787cdf0e10cSrcweir         lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign );
788cdf0e10cSrcweir     }
789cdf0e10cSrcweir 
790cdf0e10cSrcweir     static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue )
791cdf0e10cSrcweir     {
792cdf0e10cSrcweir         lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign );
793cdf0e10cSrcweir     }
794cdf0e10cSrcweir 
795cdf0e10cSrcweir     void convertVerticalAdjustToVerticalAlign( Any& _rValue ) SAL_THROW( ( lang::IllegalArgumentException ) )
796cdf0e10cSrcweir     {
797cdf0e10cSrcweir         if ( !_rValue.hasValue() )
798cdf0e10cSrcweir             return;
799cdf0e10cSrcweir 
800cdf0e10cSrcweir         drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
801cdf0e10cSrcweir         style::VerticalAlignment    eAlign  = style::VerticalAlignment_TOP;
802cdf0e10cSrcweir         if ( !( _rValue >>= eAdjust ) )
803cdf0e10cSrcweir             throw lang::IllegalArgumentException();
804cdf0e10cSrcweir         switch ( eAdjust )
805cdf0e10cSrcweir         {
806cdf0e10cSrcweir         case drawing::TextVerticalAdjust_TOP:    eAlign = style::VerticalAlignment_TOP; break;
807cdf0e10cSrcweir         case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break;
808cdf0e10cSrcweir         default:                                 eAlign = style::VerticalAlignment_MIDDLE; break;
809cdf0e10cSrcweir         }
810cdf0e10cSrcweir         _rValue <<= eAlign;
811cdf0e10cSrcweir     }
812cdf0e10cSrcweir 
813cdf0e10cSrcweir     void convertVerticalAlignToVerticalAdjust( Any& _rValue )
814cdf0e10cSrcweir     {
815cdf0e10cSrcweir         if ( !_rValue.hasValue() )
816cdf0e10cSrcweir             return;
817cdf0e10cSrcweir         style::VerticalAlignment    eAlign  = style::VerticalAlignment_TOP;
818cdf0e10cSrcweir         drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
819cdf0e10cSrcweir         OSL_VERIFY( _rValue >>= eAlign );
820cdf0e10cSrcweir         switch ( eAlign )
821cdf0e10cSrcweir         {
822cdf0e10cSrcweir         case style::VerticalAlignment_TOP:    eAdjust = drawing::TextVerticalAdjust_TOP; break;
823cdf0e10cSrcweir         case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break;
824cdf0e10cSrcweir         default:                              eAdjust = drawing::TextVerticalAdjust_CENTER; break;
825cdf0e10cSrcweir         }
826cdf0e10cSrcweir         _rValue <<= eAdjust;
827cdf0e10cSrcweir     }
828cdf0e10cSrcweir }
829cdf0e10cSrcweir 
830cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
831cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
832cdf0e10cSrcweir {
833cdf0e10cSrcweir     OUString aFormsName;
834cdf0e10cSrcweir     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
835cdf0e10cSrcweir     {
836cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
837cdf0e10cSrcweir         if( xControl.is() )
838cdf0e10cSrcweir         {
839cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
840cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
841cdf0e10cSrcweir             {
842cdf0e10cSrcweir                 uno::Any aConvertedValue( aValue );
843cdf0e10cSrcweir                 if ( aFormsName.equalsAscii( "FontSlant" ) )
844cdf0e10cSrcweir                 {
845cdf0e10cSrcweir                     awt::FontSlant nSlant;
846cdf0e10cSrcweir                     if( !(aValue >>= nSlant ) )
847cdf0e10cSrcweir                         throw lang::IllegalArgumentException();
848cdf0e10cSrcweir                     aConvertedValue <<= (sal_Int16)nSlant;
849cdf0e10cSrcweir                 }
850cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "Align" ) )
851cdf0e10cSrcweir                 {
852cdf0e10cSrcweir                     lcl_convertParaAdjustmentToTextAlignment( aConvertedValue );
853cdf0e10cSrcweir                 }
854cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
855cdf0e10cSrcweir                 {
856cdf0e10cSrcweir                     convertVerticalAdjustToVerticalAlign( aConvertedValue );
857cdf0e10cSrcweir                 }
858cdf0e10cSrcweir 
859cdf0e10cSrcweir                 xControl->setPropertyValue( aFormsName, aConvertedValue );
860cdf0e10cSrcweir             }
861cdf0e10cSrcweir         }
862cdf0e10cSrcweir     }
863cdf0e10cSrcweir     else
864cdf0e10cSrcweir     {
865cdf0e10cSrcweir         SvxShape::setPropertyValue( aPropertyName, aValue );
866cdf0e10cSrcweir     }
867cdf0e10cSrcweir }
868cdf0e10cSrcweir 
869cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName )
870cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     OUString aFormsName;
873cdf0e10cSrcweir     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
874cdf0e10cSrcweir     {
875cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
876cdf0e10cSrcweir 
877cdf0e10cSrcweir         uno::Any aValue;
878cdf0e10cSrcweir         if( xControl.is() )
879cdf0e10cSrcweir         {
880cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
881cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
882cdf0e10cSrcweir             {
883cdf0e10cSrcweir                 aValue = xControl->getPropertyValue( aFormsName );
884cdf0e10cSrcweir                 if ( aFormsName.equalsAscii( "FontSlant" ) )
885cdf0e10cSrcweir                 {
886cdf0e10cSrcweir                     awt::FontSlant eSlant = awt::FontSlant_NONE;
887cdf0e10cSrcweir                     sal_Int16 nSlant = sal_Int16();
888cdf0e10cSrcweir                     if ( aValue >>= nSlant )
889cdf0e10cSrcweir                     {
890cdf0e10cSrcweir                         eSlant = (awt::FontSlant)nSlant;
891cdf0e10cSrcweir                     }
892cdf0e10cSrcweir                     else
893cdf0e10cSrcweir                     {
894cdf0e10cSrcweir                         OSL_VERIFY( aValue >>= eSlant );
895cdf0e10cSrcweir                     }
896cdf0e10cSrcweir                     aValue <<= eSlant;
897cdf0e10cSrcweir                 }
898cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "Align" ) )
899cdf0e10cSrcweir                 {
900cdf0e10cSrcweir                     lcl_convertTextAlignmentToParaAdjustment( aValue );
901cdf0e10cSrcweir                 }
902cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
903cdf0e10cSrcweir                 {
904cdf0e10cSrcweir                     convertVerticalAlignToVerticalAdjust( aValue );
905cdf0e10cSrcweir                 }
906cdf0e10cSrcweir             }
907cdf0e10cSrcweir         }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir         return aValue;
910cdf0e10cSrcweir     }
911cdf0e10cSrcweir     else
912cdf0e10cSrcweir     {
913cdf0e10cSrcweir         return SvxShape::getPropertyValue( aPropertyName );
914cdf0e10cSrcweir     }
915cdf0e10cSrcweir 
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir // XPropertyState
919cdf0e10cSrcweir beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
920cdf0e10cSrcweir {
921cdf0e10cSrcweir     OUString aFormsName;
922cdf0e10cSrcweir     if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
923cdf0e10cSrcweir     {
924cdf0e10cSrcweir         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
925cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
926cdf0e10cSrcweir 
927cdf0e10cSrcweir         if( xControl.is() && xPropSet.is() )
928cdf0e10cSrcweir         {
929cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
930cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
931cdf0e10cSrcweir             {
932cdf0e10cSrcweir                 return xControl->getPropertyState( aFormsName );
933cdf0e10cSrcweir             }
934cdf0e10cSrcweir         }
935cdf0e10cSrcweir 
936cdf0e10cSrcweir         return beans::PropertyState_DEFAULT_VALUE;
937cdf0e10cSrcweir     }
938cdf0e10cSrcweir     else
939cdf0e10cSrcweir     {
940cdf0e10cSrcweir         return SvxShape::getPropertyState( PropertyName );
941cdf0e10cSrcweir     }
942cdf0e10cSrcweir }
943cdf0e10cSrcweir 
944cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir     OUString aFormsName;
947cdf0e10cSrcweir     if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
948cdf0e10cSrcweir     {
949cdf0e10cSrcweir         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
950cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
951cdf0e10cSrcweir 
952cdf0e10cSrcweir         if( xControl.is() && xPropSet.is() )
953cdf0e10cSrcweir         {
954cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
955cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
956cdf0e10cSrcweir             {
957cdf0e10cSrcweir                 xControl->setPropertyToDefault( aFormsName );
958cdf0e10cSrcweir             }
959cdf0e10cSrcweir         }
960cdf0e10cSrcweir     }
961cdf0e10cSrcweir     else
962cdf0e10cSrcweir     {
963cdf0e10cSrcweir         SvxShape::setPropertyToDefault( PropertyName );
964cdf0e10cSrcweir     }
965cdf0e10cSrcweir }
966cdf0e10cSrcweir 
967cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const ::rtl::OUString& aPropertyName )
968cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
969cdf0e10cSrcweir {
970cdf0e10cSrcweir     OUString aFormsName;
971cdf0e10cSrcweir     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
972cdf0e10cSrcweir     {
973cdf0e10cSrcweir         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
974cdf0e10cSrcweir 
975cdf0e10cSrcweir         if( xControl.is() )
976cdf0e10cSrcweir         {
977cdf0e10cSrcweir             Any aDefault( xControl->getPropertyDefault( aFormsName ) );
978cdf0e10cSrcweir             if ( aFormsName.equalsAscii( "FontSlant" ) )
979cdf0e10cSrcweir             {
980cdf0e10cSrcweir                 sal_Int16 nSlant( 0 );
981cdf0e10cSrcweir                 aDefault >>= nSlant;
982cdf0e10cSrcweir                 aDefault <<= (awt::FontSlant)nSlant;
983cdf0e10cSrcweir             }
984cdf0e10cSrcweir             else if ( aFormsName.equalsAscii( "Align" ) )
985cdf0e10cSrcweir             {
986cdf0e10cSrcweir                 lcl_convertTextAlignmentToParaAdjustment( aDefault );
987cdf0e10cSrcweir             }
988cdf0e10cSrcweir             else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
989cdf0e10cSrcweir             {
990cdf0e10cSrcweir                 convertVerticalAlignToVerticalAdjust( aDefault );
991cdf0e10cSrcweir             }
992cdf0e10cSrcweir             return aDefault;
993cdf0e10cSrcweir         }
994cdf0e10cSrcweir 
995cdf0e10cSrcweir         throw beans::UnknownPropertyException();
996cdf0e10cSrcweir     }
997cdf0e10cSrcweir     else
998cdf0e10cSrcweir     {
999cdf0e10cSrcweir         return SvxShape::getPropertyDefault( aPropertyName );
1000cdf0e10cSrcweir     }
1001cdf0e10cSrcweir }
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir /***********************************************************************
1005cdf0e10cSrcweir * class SvxShapeDimensioning                                           *
1006cdf0e10cSrcweir ***********************************************************************/
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir //----------------------------------------------------------------------
1009cdf0e10cSrcweir SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw()
1010cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_DIMENSIONING), aSvxMapProvider.GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir //----------------------------------------------------------------------
1015cdf0e10cSrcweir SvxShapeDimensioning::~SvxShapeDimensioning() throw()
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
1020cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir /***********************************************************************
1026cdf0e10cSrcweir *                                                                      *
1027cdf0e10cSrcweir ***********************************************************************/
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir //----------------------------------------------------------------------
1030cdf0e10cSrcweir SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
1031cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CIRCLE), aSvxMapProvider.GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir //----------------------------------------------------------------------
1036cdf0e10cSrcweir SvxShapeCircle::~SvxShapeCircle() throw()
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir }
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
1041cdf0e10cSrcweir // XServiceInfo
1042cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException )
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1045cdf0e10cSrcweir }
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir /***********************************************************************
1048cdf0e10cSrcweir *                                                                      *
1049cdf0e10cSrcweir ***********************************************************************/
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir #include <svx/svdopath.hxx>
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir //----------------------------------------------------------------------
1054cdf0e10cSrcweir SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
1055cdf0e10cSrcweir  throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
1056cdf0e10cSrcweir : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGON), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
1057cdf0e10cSrcweir , mePolygonKind( eNew )
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir //----------------------------------------------------------------------
1062cdf0e10cSrcweir SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw()
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir     basegfx::B2DPolyPolygon aRetval;
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir     // Zeiger auf innere sequences holen
1071cdf0e10cSrcweir     const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray();
1072cdf0e10cSrcweir     const drawing::PointSequence* pInnerSeqEnd   = pInnerSequence + pOuterSequence->getLength();
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir     for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence)
1075cdf0e10cSrcweir     {
1076cdf0e10cSrcweir         // Neues Polygon vorbereiten
1077cdf0e10cSrcweir         basegfx::B2DPolygon aNewPolygon;
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir         // Zeiger auf Arrays holen
1080cdf0e10cSrcweir         const awt::Point* pArray    = pInnerSequence->getConstArray();
1081cdf0e10cSrcweir         const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength();
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir         for(;pArray != pArrayEnd;++pArray)
1084cdf0e10cSrcweir         {
1085cdf0e10cSrcweir             aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1086cdf0e10cSrcweir         }
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir         // check for closed state flag
1089cdf0e10cSrcweir         basegfx::tools::checkClosed(aNewPolygon);
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir         // Neues Teilpolygon einfuegen
1092cdf0e10cSrcweir         aRetval.append(aNewPolygon);
1093cdf0e10cSrcweir     }
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir     return aRetval;
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir //----------------------------------------------------------------------
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir bool SvxShapePolyPolygon::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir     switch( pProperty->nWID )
1103cdf0e10cSrcweir     {
1104cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGON:
1105cdf0e10cSrcweir     {
1106cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ) )
1107cdf0e10cSrcweir         {
1108cdf0e10cSrcweir             basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( (drawing::PointSequenceSequence*)rValue.getValue()));
1109cdf0e10cSrcweir             SetPolygon(aNewPolyPolygon);
1110cdf0e10cSrcweir             return true;
1111cdf0e10cSrcweir         }
1112cdf0e10cSrcweir         break;
1113cdf0e10cSrcweir     }
1114cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1115cdf0e10cSrcweir     {
1116cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0)))
1117cdf0e10cSrcweir         {
1118cdf0e10cSrcweir             if( mpObj.is() )
1119cdf0e10cSrcweir             {
1120cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aNewPolyPolygon;
1121cdf0e10cSrcweir                 basegfx::B2DHomMatrix aNewHomogenMatrix;
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir                 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1124cdf0e10cSrcweir                 aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon((drawing::PointSequenceSequence*)rValue.getValue());
1125cdf0e10cSrcweir                 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1126cdf0e10cSrcweir             }
1127cdf0e10cSrcweir             return true;
1128cdf0e10cSrcweir         }
1129cdf0e10cSrcweir         break;
1130cdf0e10cSrcweir     }
1131cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGON:
1132cdf0e10cSrcweir     {
1133cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ))
1134cdf0e10cSrcweir         {
1135cdf0e10cSrcweir             drawing::PointSequence* pSequence = (drawing::PointSequence*)rValue.getValue();
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir             // Neues Polygon vorbereiten
1138cdf0e10cSrcweir             basegfx::B2DPolygon aNewPolygon;
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir             // Zeiger auf Arrays holen
1141cdf0e10cSrcweir             // Zeiger auf Arrays holen
1142cdf0e10cSrcweir             const awt::Point* pArray    = pSequence->getConstArray();
1143cdf0e10cSrcweir             const awt::Point* pArrayEnd = pArray + pSequence->getLength();
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir             for(;pArray != pArrayEnd;++pArray)
1146cdf0e10cSrcweir             {
1147cdf0e10cSrcweir                 aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1148cdf0e10cSrcweir             }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir             // check for closed state flag
1151cdf0e10cSrcweir             basegfx::tools::checkClosed(aNewPolygon);
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir             // Polygon setzen
1154cdf0e10cSrcweir             SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon));
1155cdf0e10cSrcweir             return true;
1156cdf0e10cSrcweir         }
1157cdf0e10cSrcweir         break;
1158cdf0e10cSrcweir     }
1159cdf0e10cSrcweir     default:
1160cdf0e10cSrcweir         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1161cdf0e10cSrcweir     }
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir     throw lang::IllegalArgumentException();
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval )
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir     if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() )
1169cdf0e10cSrcweir         rRetval.realloc( rPolyPoly.count() );
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir     // Zeiger auf aeussere Arrays holen
1172cdf0e10cSrcweir     drawing::PointSequence* pOuterSequence = rRetval.getArray();
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++)
1175cdf0e10cSrcweir     {
1176cdf0e10cSrcweir         // Einzelpolygon holen
1177cdf0e10cSrcweir         const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(a));
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir         // #i75974# take closed stae into account, the API polygon still uses the old closed definition
1180cdf0e10cSrcweir         // with last/first point are identical (cannot hold information about open polygons with identical
1181cdf0e10cSrcweir         // first and last point, though)
1182cdf0e10cSrcweir         const sal_uInt32 nPointCount(aPoly.count());
1183cdf0e10cSrcweir         const bool bIsClosed(aPoly.isClosed());
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir         // Platz in Arrays schaffen
1186cdf0e10cSrcweir         pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount);
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir         // Pointer auf arrays holen
1189cdf0e10cSrcweir         awt::Point* pInnerSequence = pOuterSequence->getArray();
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir         for(sal_uInt32 b(0L); b < nPointCount; b++)
1192cdf0e10cSrcweir         {
1193cdf0e10cSrcweir             const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1194cdf0e10cSrcweir             *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1195cdf0e10cSrcweir             pInnerSequence++;
1196cdf0e10cSrcweir         }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir         // #i75974# copy first point
1199cdf0e10cSrcweir         if(bIsClosed)
1200cdf0e10cSrcweir         {
1201cdf0e10cSrcweir             *pInnerSequence = *pOuterSequence->getArray();
1202cdf0e10cSrcweir         }
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir         pOuterSequence++;
1205cdf0e10cSrcweir     }
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir //----------------------------------------------------------------------
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir bool SvxShapePolyPolygon::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir     switch( pProperty->nWID )
1213cdf0e10cSrcweir     {
1214cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGON:
1215cdf0e10cSrcweir     {
1216cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1217cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1218cdf0e10cSrcweir         drawing::PointSequenceSequence aRetval( rPolyPoly.count() );
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir         B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval );
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir         rValue <<= aRetval;
1223cdf0e10cSrcweir         break;
1224cdf0e10cSrcweir     }
1225cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1226cdf0e10cSrcweir     {
1227cdf0e10cSrcweir         // pack a PolyPolygon in struct PolyPolygon
1228cdf0e10cSrcweir         basegfx::B2DPolyPolygon aNewPolyPolygon;
1229cdf0e10cSrcweir         basegfx::B2DHomMatrix aNewHomogenMatrix;
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir         if(mpObj.is())
1232cdf0e10cSrcweir             mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir         drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
1235cdf0e10cSrcweir         B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
1236cdf0e10cSrcweir         rValue <<= aRetval;
1237cdf0e10cSrcweir         break;
1238cdf0e10cSrcweir     }
1239cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGON:
1240cdf0e10cSrcweir     {
1241cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1242cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir         sal_Int32 nCount = 0;
1245cdf0e10cSrcweir         if( rPolyPoly.count() > 0 )
1246cdf0e10cSrcweir             nCount = rPolyPoly.getB2DPolygon(0L).count();
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir         drawing::PointSequence aRetval( nCount );
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir         if( nCount > 0 )
1251cdf0e10cSrcweir         {
1252cdf0e10cSrcweir             // Einzelpolygon holen
1253cdf0e10cSrcweir             const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L));
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir             // Pointer auf arrays holen
1256cdf0e10cSrcweir             awt::Point* pSequence = aRetval.getArray();
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir             for(sal_Int32 b=0;b<nCount;b++)
1259cdf0e10cSrcweir             {
1260cdf0e10cSrcweir                 const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1261cdf0e10cSrcweir                 *pSequence++ = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1262cdf0e10cSrcweir             }
1263cdf0e10cSrcweir         }
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir         rValue <<= aRetval;
1266cdf0e10cSrcweir         break;
1267cdf0e10cSrcweir     }
1268cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGONKIND:
1269cdf0e10cSrcweir     {
1270cdf0e10cSrcweir         rValue <<= GetPolygonKind();
1271cdf0e10cSrcweir         break;
1272cdf0e10cSrcweir     }
1273cdf0e10cSrcweir     default:
1274cdf0e10cSrcweir         return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1275cdf0e10cSrcweir     }
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir     return true;
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir //----------------------------------------------------------------------
1281cdf0e10cSrcweir drawing::PolygonKind SvxShapePolyPolygon::GetPolygonKind() const throw()
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir     return mePolygonKind;
1284cdf0e10cSrcweir }
1285cdf0e10cSrcweir 
1286cdf0e10cSrcweir //----------------------------------------------------------------------
1287cdf0e10cSrcweir void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
1288cdf0e10cSrcweir {
1289cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir     if(mpObj.is())
1292cdf0e10cSrcweir         ((SdrPathObj*)mpObj.get())->SetPathPoly(rNew);
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir //----------------------------------------------------------------------
1296cdf0e10cSrcweir basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir     if(mpObj.is())
1301cdf0e10cSrcweir     {
1302cdf0e10cSrcweir         return ((SdrPathObj*)mpObj.get())->GetPathPoly();
1303cdf0e10cSrcweir     }
1304cdf0e10cSrcweir     else
1305cdf0e10cSrcweir     {
1306cdf0e10cSrcweir         return basegfx::B2DPolyPolygon();
1307cdf0e10cSrcweir     }
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
1311cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException )
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir /***********************************************************************
1317cdf0e10cSrcweir * class SvxShapePolyPolygonBezier                                      *
1318cdf0e10cSrcweir ***********************************************************************/
1319cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
1320cdf0e10cSrcweir #include <com/sun/star/drawing/FlagSequence.hpp>
1321cdf0e10cSrcweir //----------------------------------------------------------------------
1322cdf0e10cSrcweir SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw()
1323cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGONBEZIER), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) )
1324cdf0e10cSrcweir ,   mePolygonKind( eNew )
1325cdf0e10cSrcweir {
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir //----------------------------------------------------------------------
1329cdf0e10cSrcweir SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw()
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir basegfx::B2DPolyPolygon SvxConvertPolyPolygonBezierToB2DPolyPolygon(const drawing::PolyPolygonBezierCoords* pSourcePolyPolygon)
1334cdf0e10cSrcweir     throw( IllegalArgumentException )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir     const sal_Int32 nOuterSequenceCount(pSourcePolyPolygon->Coordinates.getLength());
1337cdf0e10cSrcweir     basegfx::B2DPolyPolygon aNewPolyPolygon;
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir     if(pSourcePolyPolygon->Flags.getLength() != nOuterSequenceCount)
1340cdf0e10cSrcweir     {
1341cdf0e10cSrcweir         throw IllegalArgumentException();
1342cdf0e10cSrcweir     }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir     // get pointers to inner sequence
1345cdf0e10cSrcweir     const drawing::PointSequence* pInnerSequence = pSourcePolyPolygon->Coordinates.getConstArray();
1346cdf0e10cSrcweir     const drawing::FlagSequence* pInnerSequenceFlags = pSourcePolyPolygon->Flags.getConstArray();
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir     for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
1349cdf0e10cSrcweir     {
1350cdf0e10cSrcweir         const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir         if(pInnerSequenceFlags->getLength() != nInnerSequenceCount)
1353cdf0e10cSrcweir         {
1354cdf0e10cSrcweir             throw IllegalArgumentException();
1355cdf0e10cSrcweir         }
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir         // prepare new polygon
1358cdf0e10cSrcweir         basegfx::B2DPolygon aNewPolygon;
1359cdf0e10cSrcweir         const awt::Point* pArray = pInnerSequence->getConstArray();
1360cdf0e10cSrcweir         const drawing::PolygonFlags* pArrayFlags = pInnerSequenceFlags->getConstArray();
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir         // get first point and flag
1363cdf0e10cSrcweir         basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y); pArray++;
1364cdf0e10cSrcweir         XPolyFlags ePolyFlag((XPolyFlags)((sal_uInt16)*pArrayFlags)); pArrayFlags++;
1365cdf0e10cSrcweir         basegfx::B2DPoint aControlA;
1366cdf0e10cSrcweir         basegfx::B2DPoint aControlB;
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir         // first point is not allowed to be a control point
1369cdf0e10cSrcweir         if(XPOLY_CONTROL == ePolyFlag)
1370cdf0e10cSrcweir         {
1371cdf0e10cSrcweir             throw IllegalArgumentException();
1372cdf0e10cSrcweir         }
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir         // add first point as start point
1375cdf0e10cSrcweir         aNewPolygon.append(aNewCoordinatePair);
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir         for(sal_Int32 b(1); b < nInnerSequenceCount;)
1378cdf0e10cSrcweir         {
1379cdf0e10cSrcweir             // prepare loop
1380cdf0e10cSrcweir             bool bControlA(false);
1381cdf0e10cSrcweir             bool bControlB(false);
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir             // get next point and flag
1384cdf0e10cSrcweir             aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
1385cdf0e10cSrcweir             ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
1386cdf0e10cSrcweir             pArray++; pArrayFlags++; b++;
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir             if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag)
1389cdf0e10cSrcweir             {
1390cdf0e10cSrcweir                 aControlA = aNewCoordinatePair;
1391cdf0e10cSrcweir                 bControlA = true;
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir                 // get next point and flag
1394cdf0e10cSrcweir                 aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
1395cdf0e10cSrcweir                 ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
1396cdf0e10cSrcweir                 pArray++; pArrayFlags++; b++;
1397cdf0e10cSrcweir             }
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir             if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag)
1400cdf0e10cSrcweir             {
1401cdf0e10cSrcweir                 aControlB = aNewCoordinatePair;
1402cdf0e10cSrcweir                 bControlB = true;
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir                 // get next point and flag
1405cdf0e10cSrcweir                 aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
1406cdf0e10cSrcweir                 ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
1407cdf0e10cSrcweir                 pArray++; pArrayFlags++; b++;
1408cdf0e10cSrcweir             }
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir             // two or no control points are consumed, another one would be an error.
1411cdf0e10cSrcweir             // It's also an error if only one control point was read
1412cdf0e10cSrcweir             if(XPOLY_CONTROL == ePolyFlag || bControlA != bControlB)
1413cdf0e10cSrcweir             {
1414cdf0e10cSrcweir                 throw IllegalArgumentException();
1415cdf0e10cSrcweir             }
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir             // the previous writes used the B2DPolyPoygon -> PolyPolygon converter
1418cdf0e10cSrcweir             // which did not create minimal PolyPolygons, but created all control points
1419cdf0e10cSrcweir             // as null vectors (identical points). Because of the former P(CA)(CB)-norm of
1420cdf0e10cSrcweir             // B2DPolygon and it's unused sign of being the zero-vector and CA and CB being
1421cdf0e10cSrcweir             // relative to P, an empty edge was exported as P == CA == CB. Luckily, the new
1422cdf0e10cSrcweir             // export format can be read without errors by the old OOo-versions, so we need only
1423cdf0e10cSrcweir             // to correct here at read and do not need to export a wrong but compatible version
1424cdf0e10cSrcweir             // for the future.
1425cdf0e10cSrcweir             if(bControlA
1426cdf0e10cSrcweir                 && aControlA.equal(aControlB)
1427cdf0e10cSrcweir                 && aControlA.equal(aNewPolygon.getB2DPoint(aNewPolygon.count() - 1)))
1428cdf0e10cSrcweir             {
1429cdf0e10cSrcweir                 bControlA = bControlB = false;
1430cdf0e10cSrcweir             }
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir             if(bControlA)
1433cdf0e10cSrcweir             {
1434cdf0e10cSrcweir                 // add bezier edge
1435cdf0e10cSrcweir                 aNewPolygon.appendBezierSegment(aControlA, aControlB, aNewCoordinatePair);
1436cdf0e10cSrcweir             }
1437cdf0e10cSrcweir             else
1438cdf0e10cSrcweir             {
1439cdf0e10cSrcweir                 // add edge
1440cdf0e10cSrcweir                 aNewPolygon.append(aNewCoordinatePair);
1441cdf0e10cSrcweir             }
1442cdf0e10cSrcweir         }
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir         // next sequence
1445cdf0e10cSrcweir         pInnerSequence++;
1446cdf0e10cSrcweir         pInnerSequenceFlags++;
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir         // #i72807# API import uses old line start/end-equal definition for closed,
1449cdf0e10cSrcweir         // so we need to correct this to closed state here
1450cdf0e10cSrcweir         basegfx::tools::checkClosed(aNewPolygon);
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir         // add new subpolygon
1453cdf0e10cSrcweir         aNewPolyPolygon.append(aNewPolygon);
1454cdf0e10cSrcweir     }
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir     return aNewPolyPolygon;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir //----------------------------------------------------------------------
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1462cdf0e10cSrcweir {
1463cdf0e10cSrcweir     switch( pProperty->nWID )
1464cdf0e10cSrcweir     {
1465cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1466cdf0e10cSrcweir     {
1467cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0) ) )
1468cdf0e10cSrcweir         {
1469cdf0e10cSrcweir             basegfx::B2DPolyPolygon aNewPolyPolygon(SvxConvertPolyPolygonBezierToB2DPolyPolygon( (drawing::PolyPolygonBezierCoords*)rValue.getValue()));
1470cdf0e10cSrcweir             SetPolygon(aNewPolyPolygon);
1471cdf0e10cSrcweir             return true;
1472cdf0e10cSrcweir         }
1473cdf0e10cSrcweir         break;
1474cdf0e10cSrcweir     }
1475cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1476cdf0e10cSrcweir     {
1477cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0)) )
1478cdf0e10cSrcweir         {
1479cdf0e10cSrcweir             if( mpObj.is() )
1480cdf0e10cSrcweir             {
1481cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aNewPolyPolygon;
1482cdf0e10cSrcweir                 basegfx::B2DHomMatrix aNewHomogenMatrix;
1483cdf0e10cSrcweir 
1484cdf0e10cSrcweir                 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1485cdf0e10cSrcweir                 aNewPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon((drawing::PolyPolygonBezierCoords*)rValue.getValue());
1486cdf0e10cSrcweir                 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1487cdf0e10cSrcweir             }
1488cdf0e10cSrcweir             return true;
1489cdf0e10cSrcweir         }
1490cdf0e10cSrcweir         break;
1491cdf0e10cSrcweir     }
1492cdf0e10cSrcweir     default:
1493cdf0e10cSrcweir         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1494cdf0e10cSrcweir     }
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir     throw IllegalArgumentException();
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir void SvxConvertB2DPolyPolygonToPolyPolygonBezier( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PolyPolygonBezierCoords& rRetval )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir     // use PolyPolygon converter as base. Since PolyPolygonBezierCoords uses
1502cdf0e10cSrcweir     // integer coordinates, this is no precision loss at all.
1503cdf0e10cSrcweir     const PolyPolygon aPolyPoly(rPolyPoly);
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir     // Polygone innerhalb vrobereiten
1506cdf0e10cSrcweir     rRetval.Coordinates.realloc((sal_Int32)aPolyPoly.Count());
1507cdf0e10cSrcweir     rRetval.Flags.realloc((sal_Int32)aPolyPoly.Count());
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir     // Zeiger auf aeussere Arrays holen
1510cdf0e10cSrcweir     drawing::PointSequence* pOuterSequence = rRetval.Coordinates.getArray();
1511cdf0e10cSrcweir     drawing::FlagSequence*  pOuterFlags = rRetval.Flags.getArray();
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir     for(sal_uInt16 a=0;a<aPolyPoly.Count();a++)
1514cdf0e10cSrcweir     {
1515cdf0e10cSrcweir         // Einzelpolygon holen
1516cdf0e10cSrcweir         const Polygon& rPoly = aPolyPoly[a];
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir         // Platz in Arrays schaffen
1519cdf0e10cSrcweir         pOuterSequence->realloc((sal_Int32)rPoly.GetSize());
1520cdf0e10cSrcweir         pOuterFlags->realloc((sal_Int32)rPoly.GetSize());
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir         // Pointer auf arrays holen
1523cdf0e10cSrcweir         awt::Point* pInnerSequence = pOuterSequence->getArray();
1524cdf0e10cSrcweir         drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir         for(sal_uInt16 b=0;b<rPoly.GetSize();b++)
1527cdf0e10cSrcweir         {
1528cdf0e10cSrcweir             *pInnerSequence++ = awt::Point( rPoly[b].X(), rPoly[b].Y() );
1529cdf0e10cSrcweir             *pInnerFlags++ = (drawing::PolygonFlags)((sal_uInt16)rPoly.GetFlags(b));
1530cdf0e10cSrcweir         }
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir         pOuterSequence++;
1533cdf0e10cSrcweir         pOuterFlags++;
1534cdf0e10cSrcweir     }
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir //----------------------------------------------------------------------
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1540cdf0e10cSrcweir {
1541cdf0e10cSrcweir     switch( pProperty->nWID )
1542cdf0e10cSrcweir     {
1543cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1544cdf0e10cSrcweir     {
1545cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1546cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1547cdf0e10cSrcweir         drawing::PolyPolygonBezierCoords aRetval;
1548cdf0e10cSrcweir         SvxConvertB2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval );
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir         rValue <<= aRetval;
1551cdf0e10cSrcweir         break;
1552cdf0e10cSrcweir     }
1553cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1554cdf0e10cSrcweir     {
1555cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1556cdf0e10cSrcweir         basegfx::B2DPolyPolygon aNewPolyPolygon;
1557cdf0e10cSrcweir         basegfx::B2DHomMatrix aNewHomogenMatrix;
1558cdf0e10cSrcweir         mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1559cdf0e10cSrcweir         drawing::PolyPolygonBezierCoords aRetval;
1560cdf0e10cSrcweir         SvxConvertB2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir         rValue <<= aRetval;
1563cdf0e10cSrcweir         break;
1564cdf0e10cSrcweir     }
1565cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGONKIND:
1566cdf0e10cSrcweir     {
1567cdf0e10cSrcweir         rValue <<= mePolygonKind;
1568cdf0e10cSrcweir         break;
1569cdf0e10cSrcweir     }
1570cdf0e10cSrcweir     default:
1571cdf0e10cSrcweir         return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1572cdf0e10cSrcweir     }
1573cdf0e10cSrcweir     return true;
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir //----------------------------------------------------------------------
1577cdf0e10cSrcweir drawing::PolygonKind SvxShapePolyPolygonBezier::GetPolygonKind() const throw()
1578cdf0e10cSrcweir {
1579cdf0e10cSrcweir     return mePolygonKind;
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir //----------------------------------------------------------------------
1583cdf0e10cSrcweir void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
1584cdf0e10cSrcweir {
1585cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir     if(mpObj.is())
1588cdf0e10cSrcweir         static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
1589cdf0e10cSrcweir }
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir //----------------------------------------------------------------------
1592cdf0e10cSrcweir basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
1593cdf0e10cSrcweir {
1594cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir     if(mpObj.is())
1597cdf0e10cSrcweir     {
1598cdf0e10cSrcweir         return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
1599cdf0e10cSrcweir     }
1600cdf0e10cSrcweir     else
1601cdf0e10cSrcweir     {
1602cdf0e10cSrcweir         return basegfx::B2DPolyPolygon();
1603cdf0e10cSrcweir     }
1604cdf0e10cSrcweir }
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
1608cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException )
1609cdf0e10cSrcweir {
1610cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1611cdf0e10cSrcweir }
1612cdf0e10cSrcweir 
1613cdf0e10cSrcweir /***********************************************************************
1614cdf0e10cSrcweir * class SvxGraphicObject                                               *
1615cdf0e10cSrcweir ***********************************************************************/
1616cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
1617cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
1618cdf0e10cSrcweir #include <svx/svdograf.hxx>
1619cdf0e10cSrcweir #ifndef SVX_LIGHT
1620cdf0e10cSrcweir #ifndef _SFXDOCFILE_HXX
1621cdf0e10cSrcweir #include <sfx2/docfile.hxx>
1622cdf0e10cSrcweir #endif
1623cdf0e10cSrcweir #include <sfx2/app.hxx>
1624cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
1625cdf0e10cSrcweir #endif
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir #include "toolkit/unohlp.hxx"
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir //----------------------------------------------------------------------
1630cdf0e10cSrcweir SvxGraphicObject::SvxGraphicObject( SdrObject* pObj ) throw()
1631cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_GRAPHICOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
1632cdf0e10cSrcweir {
1633cdf0e10cSrcweir }
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir //----------------------------------------------------------------------
1636cdf0e10cSrcweir SvxGraphicObject::~SvxGraphicObject() throw()
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir }
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir //----------------------------------------------------------------------
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir bool SvxGraphicObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir     bool bOk = false;
1645cdf0e10cSrcweir     switch( pProperty->nWID )
1646cdf0e10cSrcweir     {
1647cdf0e10cSrcweir     case OWN_ATTR_VALUE_FILLBITMAP:
1648cdf0e10cSrcweir     {
1649cdf0e10cSrcweir         if( rValue.getValue() )
1650cdf0e10cSrcweir         {
1651cdf0e10cSrcweir             if( rValue.getValueType() == ::getCppuType(( const uno::Sequence< sal_Int8 >*)0) )
1652cdf0e10cSrcweir             {
1653cdf0e10cSrcweir                 uno::Sequence<sal_Int8>* pSeq( (uno::Sequence<sal_Int8>*)rValue.getValue() );
1654cdf0e10cSrcweir                 SvMemoryStream  aMemStm;
1655cdf0e10cSrcweir                 Graphic         aGraphic;
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir                 aMemStm.SetBuffer( (char*)pSeq->getConstArray(), pSeq->getLength(), sal_False, pSeq->getLength() );
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir                 if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
1660cdf0e10cSrcweir                 {
1661cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
1662cdf0e10cSrcweir                     bOk = true;
1663cdf0e10cSrcweir                 }
1664cdf0e10cSrcweir             }
1665cdf0e10cSrcweir         }
1666cdf0e10cSrcweir         else if( (rValue.getValueType() == awt::XBitmap::static_type()) || (rValue.getValueType() == graphic::XGraphic::static_type()))
1667cdf0e10cSrcweir         {
1668cdf0e10cSrcweir             Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY );
1669cdf0e10cSrcweir             if( xGraphic.is() )
1670cdf0e10cSrcweir             {
1671cdf0e10cSrcweir                 ((SdrGrafObj*)mpObj.get())->SetGraphic(Graphic(xGraphic));
1672cdf0e10cSrcweir                 bOk = true;
1673cdf0e10cSrcweir             }
1674cdf0e10cSrcweir             else
1675cdf0e10cSrcweir             {
1676cdf0e10cSrcweir                 // Bitmap in das Objekt packen
1677cdf0e10cSrcweir                 Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
1678cdf0e10cSrcweir                 if( xBmp.is() )
1679cdf0e10cSrcweir                 {
1680cdf0e10cSrcweir                     // Bitmap einsetzen
1681cdf0e10cSrcweir                     Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp ));
1682cdf0e10cSrcweir                     ((SdrGrafObj*)mpObj.get())->SetGraphic(aGraphic);
1683cdf0e10cSrcweir                     bOk = true;
1684cdf0e10cSrcweir                 }
1685cdf0e10cSrcweir             }
1686cdf0e10cSrcweir         }
1687cdf0e10cSrcweir         break;
1688cdf0e10cSrcweir     }
1689cdf0e10cSrcweir     case OWN_ATTR_GRAFURL:
1690cdf0e10cSrcweir     {
1691cdf0e10cSrcweir         OUString aURL;
1692cdf0e10cSrcweir         if( rValue >>= aURL )
1693cdf0e10cSrcweir         {
1694cdf0e10cSrcweir             if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
1695cdf0e10cSrcweir             {
1696cdf0e10cSrcweir                 // graphic manager url
1697cdf0e10cSrcweir                 aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
1698cdf0e10cSrcweir                 String aTmpStr(aURL);
1699cdf0e10cSrcweir                 ByteString aUniqueID( aTmpStr, RTL_TEXTENCODING_UTF8 );
1700cdf0e10cSrcweir                 GraphicObject aGrafObj( aUniqueID );
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir                 // #101808# since loading a graphic can cause a reschedule of the office
1703cdf0e10cSrcweir                 //          it is possible that our shape is removed while where in this
1704cdf0e10cSrcweir                 //          method.
1705cdf0e10cSrcweir                 if( mpObj.is() )
1706cdf0e10cSrcweir                 {
1707cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink();
1708cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj );
1709cdf0e10cSrcweir                 }
1710cdf0e10cSrcweir             }
1711cdf0e10cSrcweir             else if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
1712cdf0e10cSrcweir             {
1713cdf0e10cSrcweir                 // normal link
1714cdf0e10cSrcweir                 String              aFilterName;
1715cdf0e10cSrcweir                 const SfxFilter*    pSfxFilter = NULL;
1716cdf0e10cSrcweir                 SfxMedium           aSfxMedium( aURL, STREAM_READ | STREAM_SHARE_DENYNONE, sal_False );
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir                 SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir                 if( !pSfxFilter )
1721cdf0e10cSrcweir                 {
1722cdf0e10cSrcweir                     INetURLObject aURLObj( aURL );
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir                     if( aURLObj.GetProtocol() == INET_PROT_NOT_VALID )
1725cdf0e10cSrcweir                     {
1726cdf0e10cSrcweir                         String aValidURL;
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir                         if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) )
1729cdf0e10cSrcweir                             aURLObj = INetURLObject( aValidURL );
1730cdf0e10cSrcweir                     }
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir                     if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID )
1733cdf0e10cSrcweir                     {
1734cdf0e10cSrcweir                         GraphicFilter* pGrfFilter = GraphicFilter::GetGraphicFilter();
1735cdf0e10cSrcweir                         aFilterName = pGrfFilter->GetImportFormatName( pGrfFilter->GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
1736cdf0e10cSrcweir                     }
1737cdf0e10cSrcweir                 }
1738cdf0e10cSrcweir                 else
1739cdf0e10cSrcweir                     aFilterName = pSfxFilter->GetFilterName();
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir                 // #101808# since loading a graphic can cause a reschedule of the office
1742cdf0e10cSrcweir                 //          it is possible that our shape is removed while where in this
1743cdf0e10cSrcweir                 //          method.
1744cdf0e10cSrcweir                 if( mpObj.is() )
1745cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, aFilterName );
1746cdf0e10cSrcweir 
1747cdf0e10cSrcweir             }
1748cdf0e10cSrcweir             bOk = true;
1749cdf0e10cSrcweir         }
1750cdf0e10cSrcweir         break;
1751cdf0e10cSrcweir     }
1752cdf0e10cSrcweir 
1753cdf0e10cSrcweir     case OWN_ATTR_GRAFSTREAMURL:
1754cdf0e10cSrcweir     {
1755cdf0e10cSrcweir         OUString aStreamURL;
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir         if( rValue >>= aStreamURL )
1758cdf0e10cSrcweir         {
1759cdf0e10cSrcweir             if( aStreamURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
1760cdf0e10cSrcweir                 aStreamURL = OUString();
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir             if( mpObj.is() )
1763cdf0e10cSrcweir             {
1764cdf0e10cSrcweir                 static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
1765cdf0e10cSrcweir                 static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut();
1766cdf0e10cSrcweir             }
1767cdf0e10cSrcweir             bOk = true;
1768cdf0e10cSrcweir         }
1769cdf0e10cSrcweir         break;
1770cdf0e10cSrcweir     }
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir     case OWN_ATTR_VALUE_GRAPHIC:
1773cdf0e10cSrcweir     {
1774cdf0e10cSrcweir         Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
1775cdf0e10cSrcweir         if( xGraphic.is() )
1776cdf0e10cSrcweir         {
1777cdf0e10cSrcweir             static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
1778cdf0e10cSrcweir             bOk = true;
1779cdf0e10cSrcweir         }
1780cdf0e10cSrcweir         break;
1781cdf0e10cSrcweir     }
1782cdf0e10cSrcweir     default:
1783cdf0e10cSrcweir         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1784cdf0e10cSrcweir     }
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir     if( !bOk )
1787cdf0e10cSrcweir         throw lang::IllegalArgumentException();
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir     if( mpModel )
1790cdf0e10cSrcweir         mpModel->SetChanged();
1791cdf0e10cSrcweir 
1792cdf0e10cSrcweir     return true;
1793cdf0e10cSrcweir }
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir //----------------------------------------------------------------------
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir bool SvxGraphicObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1798cdf0e10cSrcweir {
1799cdf0e10cSrcweir     switch( pProperty->nWID )
1800cdf0e10cSrcweir     {
1801cdf0e10cSrcweir     case OWN_ATTR_VALUE_FILLBITMAP:
1802cdf0e10cSrcweir     {
1803cdf0e10cSrcweir         sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1804cdf0e10cSrcweir         const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir         if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
1807cdf0e10cSrcweir         {
1808cdf0e10cSrcweir             // Objekt in eine Bitmap packen
1809cdf0e10cSrcweir             Reference< ::com::sun::star::awt::XBitmap >  xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
1810cdf0e10cSrcweir             rValue <<= xBitmap;
1811cdf0e10cSrcweir         }
1812cdf0e10cSrcweir         else
1813cdf0e10cSrcweir         {
1814cdf0e10cSrcweir             SvMemoryStream aDestStrm( 65535, 65535 );
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir             ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False );
1817cdf0e10cSrcweir             const uno::Sequence<sal_Int8> aSeq(
1818cdf0e10cSrcweir                 static_cast< const sal_Int8* >(aDestStrm.GetData()),
1819cdf0e10cSrcweir                 aDestStrm.GetEndOfData());
1820cdf0e10cSrcweir             rValue <<= aSeq;
1821cdf0e10cSrcweir         }
1822cdf0e10cSrcweir         if ( bSwapped )
1823cdf0e10cSrcweir             static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1824cdf0e10cSrcweir         break;
1825cdf0e10cSrcweir     }
1826cdf0e10cSrcweir 
1827cdf0e10cSrcweir     case OWN_ATTR_GRAFURL:
1828cdf0e10cSrcweir     {
1829cdf0e10cSrcweir         if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() )
1830cdf0e10cSrcweir         {
1831cdf0e10cSrcweir             rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() );
1832cdf0e10cSrcweir         }
1833cdf0e10cSrcweir         else
1834cdf0e10cSrcweir         {
1835cdf0e10cSrcweir             sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1836cdf0e10cSrcweir             const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
1837cdf0e10cSrcweir             OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
1838cdf0e10cSrcweir             aURL += OUString::createFromAscii( rGrafObj.GetUniqueID().GetBuffer() );
1839cdf0e10cSrcweir             rValue <<= aURL;
1840cdf0e10cSrcweir             if ( bSwapped )
1841cdf0e10cSrcweir                 static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1842cdf0e10cSrcweir         }
1843cdf0e10cSrcweir         break;
1844cdf0e10cSrcweir     }
1845cdf0e10cSrcweir 
1846*ddde725dSArmin Le Grand     case OWN_ATTR_REPLACEMENTGRAFURL:
1847*ddde725dSArmin Le Grand     {
1848*ddde725dSArmin Le Grand         const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(mpObj.get())->GetReplacementGraphicObject();
1849*ddde725dSArmin Le Grand 
1850*ddde725dSArmin Le Grand         if(pGrafObj)
1851*ddde725dSArmin Le Grand         {
1852*ddde725dSArmin Le Grand             OUString aURL(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
1853*ddde725dSArmin Le Grand             aURL += OUString::createFromAscii(pGrafObj->GetUniqueID().GetBuffer());
1854*ddde725dSArmin Le Grand             rValue <<= aURL;
1855*ddde725dSArmin Le Grand         }
1856*ddde725dSArmin Le Grand 
1857*ddde725dSArmin Le Grand         break;
1858*ddde725dSArmin Le Grand     }
1859*ddde725dSArmin Le Grand 
1860cdf0e10cSrcweir     case OWN_ATTR_GRAFSTREAMURL:
1861cdf0e10cSrcweir     {
1862cdf0e10cSrcweir         const OUString  aStreamURL( ( (SdrGrafObj*) mpObj.get() )->GetGrafStreamURL() );
1863cdf0e10cSrcweir         if( aStreamURL.getLength() )
1864cdf0e10cSrcweir             rValue <<= aStreamURL;
1865cdf0e10cSrcweir         break;
1866cdf0e10cSrcweir     }
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir     case OWN_ATTR_VALUE_GRAPHIC:
1869cdf0e10cSrcweir     {
1870cdf0e10cSrcweir         sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1871cdf0e10cSrcweir         Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
1872cdf0e10cSrcweir         rValue <<= xGraphic;
1873cdf0e10cSrcweir         if ( bSwapped )
1874cdf0e10cSrcweir             static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1875cdf0e10cSrcweir         break;
1876cdf0e10cSrcweir     }
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir     case OWN_ATTR_GRAPHIC_STREAM:
1879cdf0e10cSrcweir     {
1880cdf0e10cSrcweir         rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
1881cdf0e10cSrcweir         break;
1882cdf0e10cSrcweir     }
1883cdf0e10cSrcweir     default:
1884cdf0e10cSrcweir         return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
1885cdf0e10cSrcweir     }
1886cdf0e10cSrcweir 
1887cdf0e10cSrcweir     return true;
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw()
1893cdf0e10cSrcweir : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CAPTION), aSvxMapProvider.GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) )
1894cdf0e10cSrcweir {
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir SvxShapeCaption::~SvxShapeCaption() throw()
1898cdf0e10cSrcweir {
1899cdf0e10cSrcweir }
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir /***********************************************************************
1902cdf0e10cSrcweir * class SvxCustomShape                                                   *
1903cdf0e10cSrcweir ***********************************************************************/
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir SvxCustomShape::SvxCustomShape( SdrObject* pObj )  throw() :
1906cdf0e10cSrcweir     SvxShapeText( pObj, aSvxMapProvider.GetMap( SVXMAP_CUSTOMSHAPE ), aSvxMapProvider.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) )
1907cdf0e10cSrcweir {
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir 
1910cdf0e10cSrcweir //----------------------------------------------------------------------
1911cdf0e10cSrcweir SvxCustomShape::~SvxCustomShape() throw()
1912cdf0e10cSrcweir {
1913cdf0e10cSrcweir }
1914cdf0e10cSrcweir 
1915cdf0e10cSrcweir //----------------------------------------------------------------------
1916cdf0e10cSrcweir 
1917cdf0e10cSrcweir void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir     SvxShapeText::Create( pNewObj, pNewPage );
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir //----------------------------------------------------------------------
1923cdf0e10cSrcweir 
1924cdf0e10cSrcweir uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType )
1925cdf0e10cSrcweir     throw(uno::RuntimeException)
1926cdf0e10cSrcweir {
1927cdf0e10cSrcweir     return SvxShapeText::queryInterface( rType );
1928cdf0e10cSrcweir }
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType )
1931cdf0e10cSrcweir     throw(uno::RuntimeException)
1932cdf0e10cSrcweir {
1933cdf0e10cSrcweir     ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType );
1934cdf0e10cSrcweir     if ( !aReturn.hasValue() )
1935cdf0e10cSrcweir         aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) );
1936cdf0e10cSrcweir     return aReturn;
1937cdf0e10cSrcweir }
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir void SAL_CALL SvxCustomShape::acquire() throw ( )
1940cdf0e10cSrcweir {
1941cdf0e10cSrcweir     SvxShapeText::acquire();
1942cdf0e10cSrcweir }
1943cdf0e10cSrcweir 
1944cdf0e10cSrcweir void SAL_CALL SvxCustomShape::release() throw ( )
1945cdf0e10cSrcweir {
1946cdf0e10cSrcweir     SvxShapeText::release();
1947cdf0e10cSrcweir }
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir //----------------------------------------------------------------------
1950cdf0e10cSrcweir 
1951cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes()
1952cdf0e10cSrcweir     throw (uno::RuntimeException)
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir     return SvxShapeText::getTypes();
1955cdf0e10cSrcweir }
1956cdf0e10cSrcweir 
1957cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
1958cdf0e10cSrcweir     throw (uno::RuntimeException)
1959cdf0e10cSrcweir {
1960cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aId;
1961cdf0e10cSrcweir     if( aId.getLength() == 0 )
1962cdf0e10cSrcweir     {
1963cdf0e10cSrcweir         aId.realloc( 16 );
1964cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
1965cdf0e10cSrcweir     }
1966cdf0e10cSrcweir     return aId;
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir // ::com::sun::star::drawing::XShape
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir //----------------------------------------------------------------------
1972cdf0e10cSrcweir OUString SAL_CALL SvxCustomShape::getShapeType()
1973cdf0e10cSrcweir     throw( uno::RuntimeException )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir     return SvxShape::getShapeType();
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir //------------------------------------------------------------------1----
1979cdf0e10cSrcweir awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException)
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1982cdf0e10cSrcweir     if ( mpModel && mpObj.is() )
1983cdf0e10cSrcweir     {
1984cdf0e10cSrcweir         SdrAShapeObjGeoData aCustomShapeGeoData;
1985cdf0e10cSrcweir         ((SdrObjCustomShape*)mpObj.get())->SaveGeoData( aCustomShapeGeoData );
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir         sal_Bool bMirroredX = sal_False;
1988cdf0e10cSrcweir         sal_Bool bMirroredY = sal_False;
1989cdf0e10cSrcweir 
1990cdf0e10cSrcweir         if ( mpObj.is() )
1991cdf0e10cSrcweir         {
1992cdf0e10cSrcweir             bMirroredX = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredX() );
1993cdf0e10cSrcweir             bMirroredY = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredY() );
1994cdf0e10cSrcweir         }
1995cdf0e10cSrcweir         // get aRect, this is the unrotated snaprect
1996cdf0e10cSrcweir         Rectangle aRect(((SdrObjCustomShape*)mpObj.get())->GetLogicRect());
1997cdf0e10cSrcweir         Rectangle aRectangle( aRect );
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir         if ( bMirroredX || bMirroredY )
2000cdf0e10cSrcweir         {   // we have to retrieve the unmirrored rect
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir             GeoStat aNewGeo( aCustomShapeGeoData.aGeo );
2003cdf0e10cSrcweir             if ( bMirroredX )
2004cdf0e10cSrcweir             {
2005cdf0e10cSrcweir                 Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
2006cdf0e10cSrcweir                 Rectangle aBoundRect( aPol.GetBoundRect() );
2007cdf0e10cSrcweir 
2008cdf0e10cSrcweir                 Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
2009cdf0e10cSrcweir                 Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
2010cdf0e10cSrcweir                 sal_uInt16 i;
2011cdf0e10cSrcweir                 sal_uInt16 nPntAnz=aPol.GetSize();
2012cdf0e10cSrcweir                 for (i=0; i<nPntAnz; i++)
2013cdf0e10cSrcweir                 {
2014cdf0e10cSrcweir                     MirrorPoint(aPol[i],aRef1,aRef2);
2015cdf0e10cSrcweir                 }
2016cdf0e10cSrcweir                 // Polygon wenden und etwas schieben
2017cdf0e10cSrcweir                 Polygon aPol0(aPol);
2018cdf0e10cSrcweir                 aPol[0]=aPol0[1];
2019cdf0e10cSrcweir                 aPol[1]=aPol0[0];
2020cdf0e10cSrcweir                 aPol[2]=aPol0[3];
2021cdf0e10cSrcweir                 aPol[3]=aPol0[2];
2022cdf0e10cSrcweir                 aPol[4]=aPol0[1];
2023cdf0e10cSrcweir                 Poly2Rect(aPol,aRectangle,aNewGeo);
2024cdf0e10cSrcweir             }
2025cdf0e10cSrcweir             if ( bMirroredY )
2026cdf0e10cSrcweir             {
2027cdf0e10cSrcweir                 Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
2028cdf0e10cSrcweir                 Rectangle aBoundRect( aPol.GetBoundRect() );
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir                 Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
2031cdf0e10cSrcweir                 Point aRef2( aRef1.X() + 1000, aRef1.Y() );
2032cdf0e10cSrcweir                 sal_uInt16 i;
2033cdf0e10cSrcweir                 sal_uInt16 nPntAnz=aPol.GetSize();
2034cdf0e10cSrcweir                 for (i=0; i<nPntAnz; i++)
2035cdf0e10cSrcweir                 {
2036cdf0e10cSrcweir                     MirrorPoint(aPol[i],aRef1,aRef2);
2037cdf0e10cSrcweir                 }
2038cdf0e10cSrcweir                 // Polygon wenden und etwas schieben
2039cdf0e10cSrcweir                 Polygon aPol0(aPol);
2040cdf0e10cSrcweir                 aPol[0]=aPol0[1];
2041cdf0e10cSrcweir                 aPol[1]=aPol0[0];
2042cdf0e10cSrcweir                 aPol[2]=aPol0[3];
2043cdf0e10cSrcweir                 aPol[3]=aPol0[2];
2044cdf0e10cSrcweir                 aPol[4]=aPol0[1];
2045cdf0e10cSrcweir                 Poly2Rect( aPol, aRectangle, aNewGeo );
2046cdf0e10cSrcweir             }
2047cdf0e10cSrcweir         }
2048cdf0e10cSrcweir         Point aPt( aRectangle.TopLeft() );
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir         if( mpModel->IsWriter() )
2051cdf0e10cSrcweir             aPt -= mpObj->GetAnchorPos();
2052cdf0e10cSrcweir 
2053cdf0e10cSrcweir         ForceMetricTo100th_mm(aPt);
2054cdf0e10cSrcweir         return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
2055cdf0e10cSrcweir     }
2056cdf0e10cSrcweir     else
2057cdf0e10cSrcweir         return SvxShape::getPosition();
2058cdf0e10cSrcweir }
2059cdf0e10cSrcweir 
2060cdf0e10cSrcweir //----------------------------------------------------------------------
2061cdf0e10cSrcweir void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
2062cdf0e10cSrcweir {
2063cdf0e10cSrcweir     SvxShapeText::setPosition(Position);
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir 
2066cdf0e10cSrcweir //----------------------------------------------------------------------
2067cdf0e10cSrcweir 
2068cdf0e10cSrcweir awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException)
2069cdf0e10cSrcweir {
2070cdf0e10cSrcweir     return SvxShapeText::getSize();
2071cdf0e10cSrcweir }
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir //----------------------------------------------------------------------
2074cdf0e10cSrcweir void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize )
2075cdf0e10cSrcweir     throw(beans::PropertyVetoException, uno::RuntimeException)
2076cdf0e10cSrcweir {
2077cdf0e10cSrcweir     SvxShapeText::setSize( rSize );
2078cdf0e10cSrcweir }
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir //----------------------------------------------------------------------
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir //----------------------------------------------------------------------
2083cdf0e10cSrcweir void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
2084cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
2085cdf0e10cSrcweir {
2086cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
2087cdf0e10cSrcweir     SdrObject* pObject = mpObj.get();
2088cdf0e10cSrcweir 
2089cdf0e10cSrcweir     sal_Bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) );
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir     sal_Bool bMirroredX = sal_False;
2092cdf0e10cSrcweir     sal_Bool bMirroredY = sal_False;
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir     if ( bCustomShapeGeometry )
2095cdf0e10cSrcweir     {
2096cdf0e10cSrcweir         bMirroredX = ( ((SdrObjCustomShape*)pObject)->IsMirroredX() );
2097cdf0e10cSrcweir         bMirroredY = ( ((SdrObjCustomShape*)pObject)->IsMirroredY() );
2098cdf0e10cSrcweir     }
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir     SvxShape::setPropertyValue( aPropertyName, aValue );
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir     if ( bCustomShapeGeometry )
2103cdf0e10cSrcweir     {
2104cdf0e10cSrcweir         ((SdrObjCustomShape*)pObject)->MergeDefaultAttributes(0);
2105cdf0e10cSrcweir         Rectangle aRect( pObject->GetSnapRect() );
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir         // #i38892#
2108cdf0e10cSrcweir         bool bNeedsMirrorX = ((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX;
2109cdf0e10cSrcweir         bool bNeedsMirrorY = ((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY;
2110cdf0e10cSrcweir 
2111cdf0e10cSrcweir         boost::scoped_ptr< SdrGluePointList > pListCopy;
2112cdf0e10cSrcweir         if( bNeedsMirrorX || bNeedsMirrorY )
2113cdf0e10cSrcweir         {
2114cdf0e10cSrcweir             const SdrGluePointList* pList = pObject->GetGluePointList();
2115cdf0e10cSrcweir             if( pList )
2116cdf0e10cSrcweir                 pListCopy.reset( new SdrGluePointList(*pList) );
2117cdf0e10cSrcweir         }
2118cdf0e10cSrcweir 
2119cdf0e10cSrcweir         if ( bNeedsMirrorX )
2120cdf0e10cSrcweir         {
2121cdf0e10cSrcweir             Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
2122cdf0e10cSrcweir             Point aBottom( aTop.X(), aTop.Y() + 1000 );
2123cdf0e10cSrcweir             pObject->NbcMirror( aTop, aBottom );
2124cdf0e10cSrcweir             // NbcMirroring is flipping the current mirror state,
2125cdf0e10cSrcweir             // so we have to set the correct state again
2126cdf0e10cSrcweir             ((SdrObjCustomShape*)pObject)->SetMirroredX( bMirroredX ? sal_False : sal_True );
2127cdf0e10cSrcweir         }
2128cdf0e10cSrcweir         if ( bNeedsMirrorY )
2129cdf0e10cSrcweir         {
2130cdf0e10cSrcweir             Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
2131cdf0e10cSrcweir             Point aRight( aLeft.X() + 1000, aLeft.Y() );
2132cdf0e10cSrcweir             pObject->NbcMirror( aLeft, aRight );
2133cdf0e10cSrcweir             // NbcMirroring is flipping the current mirror state,
2134cdf0e10cSrcweir             // so we have to set the correct state again
2135cdf0e10cSrcweir             ((SdrObjCustomShape*)pObject)->SetMirroredY( bMirroredY ? sal_False : sal_True );
2136cdf0e10cSrcweir         }
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir         if( pListCopy )
2139cdf0e10cSrcweir         {
2140cdf0e10cSrcweir             SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
2141cdf0e10cSrcweir             if(pNewList)
2142cdf0e10cSrcweir                 *pNewList = *pListCopy;
2143cdf0e10cSrcweir         }
2144cdf0e10cSrcweir     }
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir bool SvxCustomShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir     switch( pProperty->nWID )
2150cdf0e10cSrcweir     {
2151cdf0e10cSrcweir     case SDRATTR_ROTATEANGLE:
2152cdf0e10cSrcweir     {
2153cdf0e10cSrcweir         double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
2154cdf0e10cSrcweir         fAngle *= 100;
2155cdf0e10cSrcweir         rValue <<= (sal_Int32)fAngle;
2156cdf0e10cSrcweir         return true;
2157cdf0e10cSrcweir     }
2158cdf0e10cSrcweir     default:
2159cdf0e10cSrcweir         return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
2160cdf0e10cSrcweir     }
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir //----------------------------------------------------------------------
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir void SvxCustomShape::createCustomShapeDefaults( const rtl::OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException)
2165cdf0e10cSrcweir {
2166cdf0e10cSrcweir     ((SdrObjCustomShape*)mpObj.get())->MergeDefaultAttributes( &rValueType );
2167cdf0e10cSrcweir }
2168