xref: /trunk/main/svx/source/unodraw/unoshap2.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
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 
SvxShapeGroup(SdrObject * pObj,SvxDrawPage * pDrawPage)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 //----------------------------------------------------------------------
~SvxShapeGroup()103cdf0e10cSrcweir SvxShapeGroup::~SvxShapeGroup() throw()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //----------------------------------------------------------------------
Create(SdrObject * pNewObj,SvxDrawPage * pNewPage)108cdf0e10cSrcweir void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     SvxShape::Create( pNewObj, pNewPage );
111cdf0e10cSrcweir     mxPage = pNewPage;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //----------------------------------------------------------------------
queryInterface(const uno::Type & rType)115cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType )
116cdf0e10cSrcweir     throw(uno::RuntimeException)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     return SvxShape::queryInterface( rType );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
queryAggregation(const uno::Type & rType)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 
acquire()135cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::acquire() throw ( )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     SvxShape::acquire();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
release()140cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::release() throw ( )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     SvxShape::release();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
getTypes()145cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes()
146cdf0e10cSrcweir     throw (uno::RuntimeException)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     return SvxShape::getTypes();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
getImplementationId()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 //----------------------------------------------------------------------
getShapeType()166cdf0e10cSrcweir OUString SAL_CALL SvxShapeGroup::getShapeType()
167cdf0e10cSrcweir     throw( uno::RuntimeException )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     return SvxShape::getShapeType();
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //------------------------------------------------------------------1----
getPosition()173cdf0e10cSrcweir awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     return SvxShape::getPosition();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir //----------------------------------------------------------------------
setPosition(const awt::Point & Position)179cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     SvxShape::setPosition(Position);
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir //----------------------------------------------------------------------
185cdf0e10cSrcweir 
getSize()186cdf0e10cSrcweir awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     return SvxShape::getSize();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir //----------------------------------------------------------------------
setSize(const awt::Size & rSize)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 //----------------------------------------------------------------------
enterGroup()201cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::enterGroup(  ) throw(uno::RuntimeException)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir     // Todo
204cdf0e10cSrcweir //  pDrView->EnterMarkedGroup();
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir //----------------------------------------------------------------------
leaveGroup()208cdf0e10cSrcweir void SAL_CALL SvxShapeGroup::leaveGroup(  ) throw(uno::RuntimeException)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir     // Todo
211cdf0e10cSrcweir //  pDrView->LeaveOneGroup();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir //----------------------------------------------------------------------
215cdf0e10cSrcweir 
216cdf0e10cSrcweir // XShapes
add(const uno::Reference<drawing::XShape> & xShape)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 //----------------------------------------------------------------------
remove(const uno::Reference<drawing::XShape> & xShape)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 //----------------------------------------------------------------------
getCount()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 //----------------------------------------------------------------------
getByIndex(sal_Int32 Index)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 //----------------------------------------------------------------------
getElementType()353cdf0e10cSrcweir uno::Type SAL_CALL SvxShapeGroup::getElementType() throw( uno::RuntimeException )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     return ::getCppuType(( const Reference< drawing::XShape >*)0);
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir //----------------------------------------------------------------------
hasElements()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 
getSupportedServiceNames()369cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
370cdf0e10cSrcweir     throw(uno::RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir     return SvxShape::getSupportedServiceNames();
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir /***********************************************************************
376cdf0e10cSrcweir *                                                                      *
377cdf0e10cSrcweir ***********************************************************************/
378cdf0e10cSrcweir 
SvxShapeConnector(SdrObject * pObj)379cdf0e10cSrcweir SvxShapeConnector::SvxShapeConnector( SdrObject* pObj )  throw() :
380cdf0e10cSrcweir     SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONNECTOR), aSvxMapProvider.GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxShapeConnector()385cdf0e10cSrcweir SvxShapeConnector::~SvxShapeConnector() throw()
386cdf0e10cSrcweir {
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir //----------------------------------------------------------------------
390cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)391cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType )
392cdf0e10cSrcweir     throw(uno::RuntimeException)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     return SvxShapeText::queryInterface( rType );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
queryAggregation(const uno::Type & rType)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 
acquire()409cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::acquire() throw ( )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir     SvxShapeText::acquire();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
release()414cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::release() throw ( )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir     SvxShapeText::release();
417cdf0e10cSrcweir }
418cdf0e10cSrcweir // XTypeProvider
419cdf0e10cSrcweir 
getTypes()420cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxShapeConnector::getTypes()
421cdf0e10cSrcweir     throw (uno::RuntimeException)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     return SvxShape::getTypes();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
getImplementationId()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 //----------------------------------------------------------------------
getShapeType()441cdf0e10cSrcweir OUString SAL_CALL SvxShapeConnector::getShapeType()
442cdf0e10cSrcweir     throw( uno::RuntimeException )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir     return SvxShapeText::getShapeType();
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir //------------------------------------------------------------------1----
getPosition()448cdf0e10cSrcweir awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir     return SvxShapeText::getPosition();
451cdf0e10cSrcweir }
452cdf0e10cSrcweir 
453cdf0e10cSrcweir //----------------------------------------------------------------------
setPosition(const awt::Point & Position)454cdf0e10cSrcweir void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
455cdf0e10cSrcweir {
456cdf0e10cSrcweir     SvxShapeText::setPosition(Position);
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir //----------------------------------------------------------------------
460cdf0e10cSrcweir 
getSize()461cdf0e10cSrcweir awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException)
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     return SvxShapeText::getSize();
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir //----------------------------------------------------------------------
setSize(const awt::Size & rSize)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 
connectStart(const uno::Reference<drawing::XConnectableShape> & xShape,drawing::ConnectionType)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 //----------------------------------------------------------------------
connectEnd(const uno::Reference<drawing::XConnectableShape> & xShape,drawing::ConnectionType)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 //----------------------------------------------------------------------
disconnectBegin(const uno::Reference<drawing::XConnectableShape> &)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 //----------------------------------------------------------------------
disconnectEnd(const uno::Reference<drawing::XConnectableShape> &)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 //----------------------------------------------------------------------
getSupportedServiceNames()536cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
539cdf0e10cSrcweir }
540cdf0e10cSrcweir 
541cdf0e10cSrcweir /***********************************************************************
542cdf0e10cSrcweir * class SvxShapeControl                                                *
543cdf0e10cSrcweir ***********************************************************************/
DBG_NAME(SvxShapeControl)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 //----------------------------------------------------------------------
~SvxShapeControl()554cdf0e10cSrcweir SvxShapeControl::~SvxShapeControl() throw()
555cdf0e10cSrcweir {
556cdf0e10cSrcweir     DBG_DTOR(SvxShapeControl,NULL);
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir //----------------------------------------------------------------------
queryInterface(const uno::Type & rType)560cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType )
561cdf0e10cSrcweir     throw(uno::RuntimeException)
562cdf0e10cSrcweir {
563cdf0e10cSrcweir     return SvxShapeText::queryInterface( rType );
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
queryAggregation(const uno::Type & rType)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 
acquire()577cdf0e10cSrcweir void SAL_CALL SvxShapeControl::acquire() throw ( )
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     SvxShapeText::acquire();
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
release()582cdf0e10cSrcweir void SAL_CALL SvxShapeControl::release() throw ( )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir     SvxShapeText::release();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir // XTypeProvider
587cdf0e10cSrcweir 
getTypes()588cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxShapeControl::getTypes()
589cdf0e10cSrcweir     throw (uno::RuntimeException)
590cdf0e10cSrcweir {
591cdf0e10cSrcweir     return SvxShape::getTypes();
592cdf0e10cSrcweir }
593cdf0e10cSrcweir 
getImplementationId()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 //----------------------------------------------------------------------
getShapeType()609cdf0e10cSrcweir OUString SAL_CALL SvxShapeControl::getShapeType()
610cdf0e10cSrcweir     throw( uno::RuntimeException )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir     return SvxShapeText::getShapeType();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir //------------------------------------------------------------------1----
getPosition()616cdf0e10cSrcweir awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException)
617cdf0e10cSrcweir {
618cdf0e10cSrcweir     return SvxShapeText::getPosition();
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
621cdf0e10cSrcweir //----------------------------------------------------------------------
setPosition(const awt::Point & Position)622cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
623cdf0e10cSrcweir {
624cdf0e10cSrcweir     SvxShapeText::setPosition(Position);
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir //----------------------------------------------------------------------
628cdf0e10cSrcweir 
getSize()629cdf0e10cSrcweir awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException)
630cdf0e10cSrcweir {
631cdf0e10cSrcweir     return SvxShapeText::getSize();
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir //----------------------------------------------------------------------
setSize(const awt::Size & rSize)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 
getControl()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 //----------------------------------------------------------------------
setControl(const Reference<awt::XControlModel> & xControl)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
getSupportedServiceNames()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") },
7130de526bdSJianyuan Li     //added for exporting OCX control
7140de526bdSJianyuan Li     { MAP_CHAR_LEN("ControlTypeinMSO"), MAP_CHAR_LEN("ControlTypeinMSO") },
7150de526bdSJianyuan Li     { MAP_CHAR_LEN("ObjIDinMSO"), MAP_CHAR_LEN("ObjIDinMSO") },
716cdf0e10cSrcweir     { NULL,0, NULL, 0 }
717cdf0e10cSrcweir };
718cdf0e10cSrcweir 
719cdf0e10cSrcweir namespace
720cdf0e10cSrcweir {
lcl_convertPropertyName(const OUString & rApiName,OUString & rInternalName)721cdf0e10cSrcweir     static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         sal_uInt16 i = 0;
724cdf0e10cSrcweir         while( SvxShapeControlPropertyMapping[i].mpAPIName )
725cdf0e10cSrcweir         {
726cdf0e10cSrcweir             if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 )
727cdf0e10cSrcweir             {
728cdf0e10cSrcweir                 rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US );
729cdf0e10cSrcweir             }
730cdf0e10cSrcweir             ++i;
731cdf0e10cSrcweir         }
732cdf0e10cSrcweir         return rInternalName.getLength() > 0;
733cdf0e10cSrcweir     }
734cdf0e10cSrcweir 
735cdf0e10cSrcweir     struct EnumConversionMap
736cdf0e10cSrcweir     {
737cdf0e10cSrcweir         sal_Int16   nAPIValue;
738cdf0e10cSrcweir         sal_Int16   nFormValue;
739cdf0e10cSrcweir     };
740cdf0e10cSrcweir 
741cdf0e10cSrcweir     EnumConversionMap aMapAdjustToAlign[] =
742cdf0e10cSrcweir     {
743cdf0e10cSrcweir         // note that order matters:
744cdf0e10cSrcweir         // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
745cdf0e10cSrcweir         // and use the first matching entry
746cdf0e10cSrcweir         {style::ParagraphAdjust_LEFT,           (sal_Int16)awt::TextAlign::LEFT},
747cdf0e10cSrcweir         {style::ParagraphAdjust_CENTER,         (sal_Int16)awt::TextAlign::CENTER},
748cdf0e10cSrcweir         {style::ParagraphAdjust_RIGHT,          (sal_Int16)awt::TextAlign::RIGHT},
749cdf0e10cSrcweir         {style::ParagraphAdjust_BLOCK,          (sal_Int16)awt::TextAlign::RIGHT},
750cdf0e10cSrcweir         {style::ParagraphAdjust_STRETCH,        (sal_Int16)awt::TextAlign::LEFT},
751cdf0e10cSrcweir         {-1,-1}
752cdf0e10cSrcweir     };
753cdf0e10cSrcweir 
lcl_mapFormToAPIValue(Any & _rValue,const EnumConversionMap * _pMap)754cdf0e10cSrcweir     static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap )
755cdf0e10cSrcweir     {
756cdf0e10cSrcweir         sal_Int16 nValue = sal_Int16();
757cdf0e10cSrcweir         OSL_VERIFY( _rValue >>= nValue );
758cdf0e10cSrcweir 
759cdf0e10cSrcweir         const EnumConversionMap* pEntry = _pMap;
760cdf0e10cSrcweir         while ( pEntry && ( pEntry->nFormValue != -1 ) )
761cdf0e10cSrcweir         {
762cdf0e10cSrcweir             if ( nValue == pEntry->nFormValue )
763cdf0e10cSrcweir             {
764cdf0e10cSrcweir                 _rValue <<= pEntry->nAPIValue;
765cdf0e10cSrcweir                 return;
766cdf0e10cSrcweir             }
767cdf0e10cSrcweir             ++pEntry;
768cdf0e10cSrcweir         }
769cdf0e10cSrcweir     }
770cdf0e10cSrcweir 
lcl_mapAPIToFormValue(Any & _rValue,const EnumConversionMap * _pMap)771cdf0e10cSrcweir     static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap )
772cdf0e10cSrcweir     {
773cdf0e10cSrcweir         sal_Int32 nValue = 0;
774cdf0e10cSrcweir         OSL_VERIFY( _rValue >>= nValue );
775cdf0e10cSrcweir 
776cdf0e10cSrcweir         const EnumConversionMap* pEntry = _pMap;
777cdf0e10cSrcweir         while ( pEntry && ( pEntry->nAPIValue != -1 ) )
778cdf0e10cSrcweir         {
779cdf0e10cSrcweir             if ( nValue == pEntry->nAPIValue )
780cdf0e10cSrcweir             {
781cdf0e10cSrcweir                 _rValue <<= pEntry->nFormValue;
782cdf0e10cSrcweir                 return;
783cdf0e10cSrcweir             }
784cdf0e10cSrcweir             ++pEntry;
785cdf0e10cSrcweir         }
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir 
lcl_convertTextAlignmentToParaAdjustment(Any & rValue)788cdf0e10cSrcweir     static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue )
789cdf0e10cSrcweir     {
790cdf0e10cSrcweir         lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign );
791cdf0e10cSrcweir     }
792cdf0e10cSrcweir 
lcl_convertParaAdjustmentToTextAlignment(Any & rValue)793cdf0e10cSrcweir     static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue )
794cdf0e10cSrcweir     {
795cdf0e10cSrcweir         lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign );
796cdf0e10cSrcweir     }
797cdf0e10cSrcweir 
convertVerticalAdjustToVerticalAlign(Any & _rValue)798cdf0e10cSrcweir     void convertVerticalAdjustToVerticalAlign( Any& _rValue ) SAL_THROW( ( lang::IllegalArgumentException ) )
799cdf0e10cSrcweir     {
800cdf0e10cSrcweir         if ( !_rValue.hasValue() )
801cdf0e10cSrcweir             return;
802cdf0e10cSrcweir 
803cdf0e10cSrcweir         drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
804cdf0e10cSrcweir         style::VerticalAlignment    eAlign  = style::VerticalAlignment_TOP;
805cdf0e10cSrcweir         if ( !( _rValue >>= eAdjust ) )
806cdf0e10cSrcweir             throw lang::IllegalArgumentException();
807cdf0e10cSrcweir         switch ( eAdjust )
808cdf0e10cSrcweir         {
809cdf0e10cSrcweir         case drawing::TextVerticalAdjust_TOP:    eAlign = style::VerticalAlignment_TOP; break;
810cdf0e10cSrcweir         case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break;
811cdf0e10cSrcweir         default:                                 eAlign = style::VerticalAlignment_MIDDLE; break;
812cdf0e10cSrcweir         }
813cdf0e10cSrcweir         _rValue <<= eAlign;
814cdf0e10cSrcweir     }
815cdf0e10cSrcweir 
convertVerticalAlignToVerticalAdjust(Any & _rValue)816cdf0e10cSrcweir     void convertVerticalAlignToVerticalAdjust( Any& _rValue )
817cdf0e10cSrcweir     {
818cdf0e10cSrcweir         if ( !_rValue.hasValue() )
819cdf0e10cSrcweir             return;
820cdf0e10cSrcweir         style::VerticalAlignment    eAlign  = style::VerticalAlignment_TOP;
821cdf0e10cSrcweir         drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
822cdf0e10cSrcweir         OSL_VERIFY( _rValue >>= eAlign );
823cdf0e10cSrcweir         switch ( eAlign )
824cdf0e10cSrcweir         {
825cdf0e10cSrcweir         case style::VerticalAlignment_TOP:    eAdjust = drawing::TextVerticalAdjust_TOP; break;
826cdf0e10cSrcweir         case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break;
827cdf0e10cSrcweir         default:                              eAdjust = drawing::TextVerticalAdjust_CENTER; break;
828cdf0e10cSrcweir         }
829cdf0e10cSrcweir         _rValue <<= eAdjust;
830cdf0e10cSrcweir     }
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
setPropertyValue(const OUString & aPropertyName,const uno::Any & aValue)833cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
834cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
835cdf0e10cSrcweir {
836cdf0e10cSrcweir     OUString aFormsName;
837cdf0e10cSrcweir     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
838cdf0e10cSrcweir     {
839cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
840cdf0e10cSrcweir         if( xControl.is() )
841cdf0e10cSrcweir         {
842cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
843cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
844cdf0e10cSrcweir             {
845cdf0e10cSrcweir                 uno::Any aConvertedValue( aValue );
846cdf0e10cSrcweir                 if ( aFormsName.equalsAscii( "FontSlant" ) )
847cdf0e10cSrcweir                 {
848cdf0e10cSrcweir                     awt::FontSlant nSlant;
849cdf0e10cSrcweir                     if( !(aValue >>= nSlant ) )
850cdf0e10cSrcweir                         throw lang::IllegalArgumentException();
851cdf0e10cSrcweir                     aConvertedValue <<= (sal_Int16)nSlant;
852cdf0e10cSrcweir                 }
853cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "Align" ) )
854cdf0e10cSrcweir                 {
855cdf0e10cSrcweir                     lcl_convertParaAdjustmentToTextAlignment( aConvertedValue );
856cdf0e10cSrcweir                 }
857cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
858cdf0e10cSrcweir                 {
859cdf0e10cSrcweir                     convertVerticalAdjustToVerticalAlign( aConvertedValue );
860cdf0e10cSrcweir                 }
861cdf0e10cSrcweir 
862cdf0e10cSrcweir                 xControl->setPropertyValue( aFormsName, aConvertedValue );
863cdf0e10cSrcweir             }
864cdf0e10cSrcweir         }
865cdf0e10cSrcweir     }
866cdf0e10cSrcweir     else
867cdf0e10cSrcweir     {
868cdf0e10cSrcweir         SvxShape::setPropertyValue( aPropertyName, aValue );
869cdf0e10cSrcweir     }
870cdf0e10cSrcweir }
871cdf0e10cSrcweir 
getPropertyValue(const OUString & aPropertyName)872cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName )
873cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
874cdf0e10cSrcweir {
875cdf0e10cSrcweir     OUString aFormsName;
876cdf0e10cSrcweir     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
877cdf0e10cSrcweir     {
878cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
879cdf0e10cSrcweir 
880cdf0e10cSrcweir         uno::Any aValue;
881cdf0e10cSrcweir         if( xControl.is() )
882cdf0e10cSrcweir         {
883cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
884cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
885cdf0e10cSrcweir             {
886cdf0e10cSrcweir                 aValue = xControl->getPropertyValue( aFormsName );
887cdf0e10cSrcweir                 if ( aFormsName.equalsAscii( "FontSlant" ) )
888cdf0e10cSrcweir                 {
889cdf0e10cSrcweir                     awt::FontSlant eSlant = awt::FontSlant_NONE;
890cdf0e10cSrcweir                     sal_Int16 nSlant = sal_Int16();
891cdf0e10cSrcweir                     if ( aValue >>= nSlant )
892cdf0e10cSrcweir                     {
893cdf0e10cSrcweir                         eSlant = (awt::FontSlant)nSlant;
894cdf0e10cSrcweir                     }
895cdf0e10cSrcweir                     else
896cdf0e10cSrcweir                     {
897cdf0e10cSrcweir                         OSL_VERIFY( aValue >>= eSlant );
898cdf0e10cSrcweir                     }
899cdf0e10cSrcweir                     aValue <<= eSlant;
900cdf0e10cSrcweir                 }
901cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "Align" ) )
902cdf0e10cSrcweir                 {
903cdf0e10cSrcweir                     lcl_convertTextAlignmentToParaAdjustment( aValue );
904cdf0e10cSrcweir                 }
905cdf0e10cSrcweir                 else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
906cdf0e10cSrcweir                 {
907cdf0e10cSrcweir                     convertVerticalAlignToVerticalAdjust( aValue );
908cdf0e10cSrcweir                 }
909cdf0e10cSrcweir             }
910cdf0e10cSrcweir         }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir         return aValue;
913cdf0e10cSrcweir     }
914cdf0e10cSrcweir     else
915cdf0e10cSrcweir     {
916cdf0e10cSrcweir         return SvxShape::getPropertyValue( aPropertyName );
917cdf0e10cSrcweir     }
918cdf0e10cSrcweir 
919cdf0e10cSrcweir }
920cdf0e10cSrcweir 
921cdf0e10cSrcweir // XPropertyState
getPropertyState(const::rtl::OUString & PropertyName)922cdf0e10cSrcweir beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir     OUString aFormsName;
925cdf0e10cSrcweir     if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
926cdf0e10cSrcweir     {
927cdf0e10cSrcweir         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
928cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
929cdf0e10cSrcweir 
930cdf0e10cSrcweir         if( xControl.is() && xPropSet.is() )
931cdf0e10cSrcweir         {
932cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
933cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
934cdf0e10cSrcweir             {
935cdf0e10cSrcweir                 return xControl->getPropertyState( aFormsName );
936cdf0e10cSrcweir             }
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir         return beans::PropertyState_DEFAULT_VALUE;
940cdf0e10cSrcweir     }
941cdf0e10cSrcweir     else
942cdf0e10cSrcweir     {
943cdf0e10cSrcweir         return SvxShape::getPropertyState( PropertyName );
944cdf0e10cSrcweir     }
945cdf0e10cSrcweir }
946cdf0e10cSrcweir 
setPropertyToDefault(const::rtl::OUString & PropertyName)947cdf0e10cSrcweir void SAL_CALL SvxShapeControl::setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir     OUString aFormsName;
950cdf0e10cSrcweir     if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
951cdf0e10cSrcweir     {
952cdf0e10cSrcweir         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
953cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
954cdf0e10cSrcweir 
955cdf0e10cSrcweir         if( xControl.is() && xPropSet.is() )
956cdf0e10cSrcweir         {
957cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
958cdf0e10cSrcweir             if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
959cdf0e10cSrcweir             {
960cdf0e10cSrcweir                 xControl->setPropertyToDefault( aFormsName );
961cdf0e10cSrcweir             }
962cdf0e10cSrcweir         }
963cdf0e10cSrcweir     }
964cdf0e10cSrcweir     else
965cdf0e10cSrcweir     {
966cdf0e10cSrcweir         SvxShape::setPropertyToDefault( PropertyName );
967cdf0e10cSrcweir     }
968cdf0e10cSrcweir }
969cdf0e10cSrcweir 
getPropertyDefault(const::rtl::OUString & aPropertyName)970cdf0e10cSrcweir uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const ::rtl::OUString& aPropertyName )
971cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
972cdf0e10cSrcweir {
973cdf0e10cSrcweir     OUString aFormsName;
974cdf0e10cSrcweir     if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
975cdf0e10cSrcweir     {
976cdf0e10cSrcweir         uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
977cdf0e10cSrcweir 
978cdf0e10cSrcweir         if( xControl.is() )
979cdf0e10cSrcweir         {
980cdf0e10cSrcweir             Any aDefault( xControl->getPropertyDefault( aFormsName ) );
981cdf0e10cSrcweir             if ( aFormsName.equalsAscii( "FontSlant" ) )
982cdf0e10cSrcweir             {
983cdf0e10cSrcweir                 sal_Int16 nSlant( 0 );
984cdf0e10cSrcweir                 aDefault >>= nSlant;
985cdf0e10cSrcweir                 aDefault <<= (awt::FontSlant)nSlant;
986cdf0e10cSrcweir             }
987cdf0e10cSrcweir             else if ( aFormsName.equalsAscii( "Align" ) )
988cdf0e10cSrcweir             {
989cdf0e10cSrcweir                 lcl_convertTextAlignmentToParaAdjustment( aDefault );
990cdf0e10cSrcweir             }
991cdf0e10cSrcweir             else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
992cdf0e10cSrcweir             {
993cdf0e10cSrcweir                 convertVerticalAlignToVerticalAdjust( aDefault );
994cdf0e10cSrcweir             }
995cdf0e10cSrcweir             return aDefault;
996cdf0e10cSrcweir         }
997cdf0e10cSrcweir 
998cdf0e10cSrcweir         throw beans::UnknownPropertyException();
999cdf0e10cSrcweir     }
1000cdf0e10cSrcweir     else
1001cdf0e10cSrcweir     {
1002cdf0e10cSrcweir         return SvxShape::getPropertyDefault( aPropertyName );
1003cdf0e10cSrcweir     }
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir /***********************************************************************
1008cdf0e10cSrcweir * class SvxShapeDimensioning                                           *
1009cdf0e10cSrcweir ***********************************************************************/
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir //----------------------------------------------------------------------
SvxShapeDimensioning(SdrObject * pObj)1012cdf0e10cSrcweir SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw()
1013cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_DIMENSIONING), aSvxMapProvider.GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) )
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxShapeDimensioning()1018cdf0e10cSrcweir SvxShapeDimensioning::~SvxShapeDimensioning() throw()
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
getSupportedServiceNames()1023cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1026cdf0e10cSrcweir }
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir /***********************************************************************
1029cdf0e10cSrcweir *                                                                      *
1030cdf0e10cSrcweir ***********************************************************************/
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir //----------------------------------------------------------------------
SvxShapeCircle(SdrObject * pObj)1033cdf0e10cSrcweir SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
1034cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CIRCLE), aSvxMapProvider.GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxShapeCircle()1039cdf0e10cSrcweir SvxShapeCircle::~SvxShapeCircle() throw()
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
1044cdf0e10cSrcweir // XServiceInfo
getSupportedServiceNames()1045cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException )
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir /***********************************************************************
1051cdf0e10cSrcweir *                                                                      *
1052cdf0e10cSrcweir ***********************************************************************/
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir #include <svx/svdopath.hxx>
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir //----------------------------------------------------------------------
SvxShapePolyPolygon(SdrObject * pObj,drawing::PolygonKind eNew)1057cdf0e10cSrcweir SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
1058cdf0e10cSrcweir  throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
1059cdf0e10cSrcweir : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGON), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
1060cdf0e10cSrcweir , mePolygonKind( eNew )
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxShapePolyPolygon()1065cdf0e10cSrcweir SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir 
ImplSvxPointSequenceSequenceToB2DPolyPolygon(const drawing::PointSequenceSequence * pOuterSequence)1069cdf0e10cSrcweir basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw()
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir     basegfx::B2DPolyPolygon aRetval;
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir     // Zeiger auf innere sequences holen
1074cdf0e10cSrcweir     const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray();
1075cdf0e10cSrcweir     const drawing::PointSequence* pInnerSeqEnd   = pInnerSequence + pOuterSequence->getLength();
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir     for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence)
1078cdf0e10cSrcweir     {
1079cdf0e10cSrcweir         // Neues Polygon vorbereiten
1080cdf0e10cSrcweir         basegfx::B2DPolygon aNewPolygon;
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir         // Zeiger auf Arrays holen
1083cdf0e10cSrcweir         const awt::Point* pArray    = pInnerSequence->getConstArray();
1084cdf0e10cSrcweir         const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength();
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir         for(;pArray != pArrayEnd;++pArray)
1087cdf0e10cSrcweir         {
1088cdf0e10cSrcweir             aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1089cdf0e10cSrcweir         }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir         // check for closed state flag
1092cdf0e10cSrcweir         basegfx::tools::checkClosed(aNewPolygon);
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir         // Neues Teilpolygon einfuegen
1095cdf0e10cSrcweir         aRetval.append(aNewPolygon);
1096cdf0e10cSrcweir     }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir     return aRetval;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir //----------------------------------------------------------------------
1102cdf0e10cSrcweir 
setPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,const::com::sun::star::uno::Any & rValue)1103cdf0e10cSrcweir 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)
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir     switch( pProperty->nWID )
1106cdf0e10cSrcweir     {
1107cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGON:
1108cdf0e10cSrcweir     {
1109cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ) )
1110cdf0e10cSrcweir         {
1111cdf0e10cSrcweir             basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( (drawing::PointSequenceSequence*)rValue.getValue()));
1112cdf0e10cSrcweir             SetPolygon(aNewPolyPolygon);
1113cdf0e10cSrcweir             return true;
1114cdf0e10cSrcweir         }
1115cdf0e10cSrcweir         break;
1116cdf0e10cSrcweir     }
1117cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1118cdf0e10cSrcweir     {
1119cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0)))
1120cdf0e10cSrcweir         {
1121cdf0e10cSrcweir             if( mpObj.is() )
1122cdf0e10cSrcweir             {
1123cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aNewPolyPolygon;
1124cdf0e10cSrcweir                 basegfx::B2DHomMatrix aNewHomogenMatrix;
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir                 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1127cdf0e10cSrcweir                 aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon((drawing::PointSequenceSequence*)rValue.getValue());
1128cdf0e10cSrcweir                 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1129cdf0e10cSrcweir             }
1130cdf0e10cSrcweir             return true;
1131cdf0e10cSrcweir         }
1132cdf0e10cSrcweir         break;
1133cdf0e10cSrcweir     }
1134cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGON:
1135cdf0e10cSrcweir     {
1136cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ))
1137cdf0e10cSrcweir         {
1138cdf0e10cSrcweir             drawing::PointSequence* pSequence = (drawing::PointSequence*)rValue.getValue();
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir             // Neues Polygon vorbereiten
1141cdf0e10cSrcweir             basegfx::B2DPolygon aNewPolygon;
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir             // Zeiger auf Arrays holen
1144cdf0e10cSrcweir             // Zeiger auf Arrays holen
1145cdf0e10cSrcweir             const awt::Point* pArray    = pSequence->getConstArray();
1146cdf0e10cSrcweir             const awt::Point* pArrayEnd = pArray + pSequence->getLength();
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir             for(;pArray != pArrayEnd;++pArray)
1149cdf0e10cSrcweir             {
1150cdf0e10cSrcweir                 aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1151cdf0e10cSrcweir             }
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir             // check for closed state flag
1154cdf0e10cSrcweir             basegfx::tools::checkClosed(aNewPolygon);
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir             // Polygon setzen
1157cdf0e10cSrcweir             SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon));
1158cdf0e10cSrcweir             return true;
1159cdf0e10cSrcweir         }
1160cdf0e10cSrcweir         break;
1161cdf0e10cSrcweir     }
1162cdf0e10cSrcweir     default:
1163cdf0e10cSrcweir         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1164cdf0e10cSrcweir     }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir     throw lang::IllegalArgumentException();
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir 
B2DPolyPolygonToSvxPointSequenceSequence(const basegfx::B2DPolyPolygon & rPolyPoly,drawing::PointSequenceSequence & rRetval)1169cdf0e10cSrcweir void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval )
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir     if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() )
1172cdf0e10cSrcweir         rRetval.realloc( rPolyPoly.count() );
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir     // Zeiger auf aeussere Arrays holen
1175cdf0e10cSrcweir     drawing::PointSequence* pOuterSequence = rRetval.getArray();
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++)
1178cdf0e10cSrcweir     {
1179cdf0e10cSrcweir         // Einzelpolygon holen
1180cdf0e10cSrcweir         const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(a));
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir         // #i75974# take closed stae into account, the API polygon still uses the old closed definition
1183cdf0e10cSrcweir         // with last/first point are identical (cannot hold information about open polygons with identical
1184cdf0e10cSrcweir         // first and last point, though)
1185cdf0e10cSrcweir         const sal_uInt32 nPointCount(aPoly.count());
1186cdf0e10cSrcweir         const bool bIsClosed(aPoly.isClosed());
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir         // Platz in Arrays schaffen
1189cdf0e10cSrcweir         pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount);
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir         // Pointer auf arrays holen
1192cdf0e10cSrcweir         awt::Point* pInnerSequence = pOuterSequence->getArray();
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir         for(sal_uInt32 b(0L); b < nPointCount; b++)
1195cdf0e10cSrcweir         {
1196cdf0e10cSrcweir             const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1197cdf0e10cSrcweir             *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1198cdf0e10cSrcweir             pInnerSequence++;
1199cdf0e10cSrcweir         }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir         // #i75974# copy first point
1202cdf0e10cSrcweir         if(bIsClosed)
1203cdf0e10cSrcweir         {
1204cdf0e10cSrcweir             *pInnerSequence = *pOuterSequence->getArray();
1205cdf0e10cSrcweir         }
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir         pOuterSequence++;
1208cdf0e10cSrcweir     }
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir //----------------------------------------------------------------------
1212cdf0e10cSrcweir 
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)1213cdf0e10cSrcweir 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)
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir     switch( pProperty->nWID )
1216cdf0e10cSrcweir     {
1217cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGON:
1218cdf0e10cSrcweir     {
1219cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1220cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1221cdf0e10cSrcweir         drawing::PointSequenceSequence aRetval( rPolyPoly.count() );
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir         B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval );
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir         rValue <<= aRetval;
1226cdf0e10cSrcweir         break;
1227cdf0e10cSrcweir     }
1228cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1229cdf0e10cSrcweir     {
1230cdf0e10cSrcweir         // pack a PolyPolygon in struct PolyPolygon
1231cdf0e10cSrcweir         basegfx::B2DPolyPolygon aNewPolyPolygon;
1232cdf0e10cSrcweir         basegfx::B2DHomMatrix aNewHomogenMatrix;
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir         if(mpObj.is())
1235cdf0e10cSrcweir             mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir         drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
1238cdf0e10cSrcweir         B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
1239cdf0e10cSrcweir         rValue <<= aRetval;
1240cdf0e10cSrcweir         break;
1241cdf0e10cSrcweir     }
1242cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGON:
1243cdf0e10cSrcweir     {
1244cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1245cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir         sal_Int32 nCount = 0;
1248cdf0e10cSrcweir         if( rPolyPoly.count() > 0 )
1249cdf0e10cSrcweir             nCount = rPolyPoly.getB2DPolygon(0L).count();
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir         drawing::PointSequence aRetval( nCount );
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir         if( nCount > 0 )
1254cdf0e10cSrcweir         {
1255cdf0e10cSrcweir             // Einzelpolygon holen
1256cdf0e10cSrcweir             const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L));
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir             // Pointer auf arrays holen
1259cdf0e10cSrcweir             awt::Point* pSequence = aRetval.getArray();
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir             for(sal_Int32 b=0;b<nCount;b++)
1262cdf0e10cSrcweir             {
1263cdf0e10cSrcweir                 const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1264cdf0e10cSrcweir                 *pSequence++ = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1265cdf0e10cSrcweir             }
1266cdf0e10cSrcweir         }
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir         rValue <<= aRetval;
1269cdf0e10cSrcweir         break;
1270cdf0e10cSrcweir     }
1271cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGONKIND:
1272cdf0e10cSrcweir     {
1273cdf0e10cSrcweir         rValue <<= GetPolygonKind();
1274cdf0e10cSrcweir         break;
1275cdf0e10cSrcweir     }
1276cdf0e10cSrcweir     default:
1277cdf0e10cSrcweir         return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1278cdf0e10cSrcweir     }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir     return true;
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir //----------------------------------------------------------------------
GetPolygonKind() const1284cdf0e10cSrcweir drawing::PolygonKind SvxShapePolyPolygon::GetPolygonKind() const throw()
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir     return mePolygonKind;
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir //----------------------------------------------------------------------
SetPolygon(const basegfx::B2DPolyPolygon & rNew)1290cdf0e10cSrcweir void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir     if(mpObj.is())
1295cdf0e10cSrcweir         ((SdrPathObj*)mpObj.get())->SetPathPoly(rNew);
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir //----------------------------------------------------------------------
GetPolygon() const1299cdf0e10cSrcweir basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir     if(mpObj.is())
1304cdf0e10cSrcweir     {
1305cdf0e10cSrcweir         return ((SdrPathObj*)mpObj.get())->GetPathPoly();
1306cdf0e10cSrcweir     }
1307cdf0e10cSrcweir     else
1308cdf0e10cSrcweir     {
1309cdf0e10cSrcweir         return basegfx::B2DPolyPolygon();
1310cdf0e10cSrcweir     }
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
getSupportedServiceNames()1314cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException )
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir /***********************************************************************
1320cdf0e10cSrcweir * class SvxShapePolyPolygonBezier                                      *
1321cdf0e10cSrcweir ***********************************************************************/
1322cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
1323cdf0e10cSrcweir #include <com/sun/star/drawing/FlagSequence.hpp>
1324cdf0e10cSrcweir //----------------------------------------------------------------------
SvxShapePolyPolygonBezier(SdrObject * pObj,drawing::PolygonKind eNew)1325cdf0e10cSrcweir SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw()
1326cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGONBEZIER), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) )
1327cdf0e10cSrcweir ,   mePolygonKind( eNew )
1328cdf0e10cSrcweir {
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxShapePolyPolygonBezier()1332cdf0e10cSrcweir SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw()
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir 
SvxConvertPolyPolygonBezierToB2DPolyPolygon(const drawing::PolyPolygonBezierCoords * pSourcePolyPolygon)1336cdf0e10cSrcweir basegfx::B2DPolyPolygon SvxConvertPolyPolygonBezierToB2DPolyPolygon(const drawing::PolyPolygonBezierCoords* pSourcePolyPolygon)
1337cdf0e10cSrcweir     throw( IllegalArgumentException )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir     const sal_Int32 nOuterSequenceCount(pSourcePolyPolygon->Coordinates.getLength());
1340cdf0e10cSrcweir     basegfx::B2DPolyPolygon aNewPolyPolygon;
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir     if(pSourcePolyPolygon->Flags.getLength() != nOuterSequenceCount)
1343cdf0e10cSrcweir     {
1344cdf0e10cSrcweir         throw IllegalArgumentException();
1345cdf0e10cSrcweir     }
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir     // get pointers to inner sequence
1348cdf0e10cSrcweir     const drawing::PointSequence* pInnerSequence = pSourcePolyPolygon->Coordinates.getConstArray();
1349cdf0e10cSrcweir     const drawing::FlagSequence* pInnerSequenceFlags = pSourcePolyPolygon->Flags.getConstArray();
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir     for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
1352cdf0e10cSrcweir     {
1353cdf0e10cSrcweir         const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir         if(pInnerSequenceFlags->getLength() != nInnerSequenceCount)
1356cdf0e10cSrcweir         {
1357cdf0e10cSrcweir             throw IllegalArgumentException();
1358cdf0e10cSrcweir         }
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir         // prepare new polygon
1361cdf0e10cSrcweir         basegfx::B2DPolygon aNewPolygon;
1362cdf0e10cSrcweir         const awt::Point* pArray = pInnerSequence->getConstArray();
1363cdf0e10cSrcweir         const drawing::PolygonFlags* pArrayFlags = pInnerSequenceFlags->getConstArray();
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir         // get first point and flag
1366cdf0e10cSrcweir         basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y); pArray++;
1367cdf0e10cSrcweir         XPolyFlags ePolyFlag((XPolyFlags)((sal_uInt16)*pArrayFlags)); pArrayFlags++;
1368cdf0e10cSrcweir         basegfx::B2DPoint aControlA;
1369cdf0e10cSrcweir         basegfx::B2DPoint aControlB;
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir         // first point is not allowed to be a control point
1372cdf0e10cSrcweir         if(XPOLY_CONTROL == ePolyFlag)
1373cdf0e10cSrcweir         {
1374cdf0e10cSrcweir             throw IllegalArgumentException();
1375cdf0e10cSrcweir         }
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir         // add first point as start point
1378cdf0e10cSrcweir         aNewPolygon.append(aNewCoordinatePair);
1379cdf0e10cSrcweir 
1380cdf0e10cSrcweir         for(sal_Int32 b(1); b < nInnerSequenceCount;)
1381cdf0e10cSrcweir         {
1382cdf0e10cSrcweir             // prepare loop
1383cdf0e10cSrcweir             bool bControlA(false);
1384cdf0e10cSrcweir             bool bControlB(false);
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir             // get next point and flag
1387cdf0e10cSrcweir             aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
1388cdf0e10cSrcweir             ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
1389cdf0e10cSrcweir             pArray++; pArrayFlags++; b++;
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir             if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag)
1392cdf0e10cSrcweir             {
1393cdf0e10cSrcweir                 aControlA = aNewCoordinatePair;
1394cdf0e10cSrcweir                 bControlA = true;
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir                 // get next point and flag
1397cdf0e10cSrcweir                 aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
1398cdf0e10cSrcweir                 ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
1399cdf0e10cSrcweir                 pArray++; pArrayFlags++; b++;
1400cdf0e10cSrcweir             }
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir             if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag)
1403cdf0e10cSrcweir             {
1404cdf0e10cSrcweir                 aControlB = aNewCoordinatePair;
1405cdf0e10cSrcweir                 bControlB = true;
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir                 // get next point and flag
1408cdf0e10cSrcweir                 aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
1409cdf0e10cSrcweir                 ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
1410cdf0e10cSrcweir                 pArray++; pArrayFlags++; b++;
1411cdf0e10cSrcweir             }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir             // two or no control points are consumed, another one would be an error.
1414cdf0e10cSrcweir             // It's also an error if only one control point was read
1415cdf0e10cSrcweir             if(XPOLY_CONTROL == ePolyFlag || bControlA != bControlB)
1416cdf0e10cSrcweir             {
1417cdf0e10cSrcweir                 throw IllegalArgumentException();
1418cdf0e10cSrcweir             }
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir             // the previous writes used the B2DPolyPoygon -> PolyPolygon converter
1421cdf0e10cSrcweir             // which did not create minimal PolyPolygons, but created all control points
1422cdf0e10cSrcweir             // as null vectors (identical points). Because of the former P(CA)(CB)-norm of
1423cdf0e10cSrcweir             // B2DPolygon and it's unused sign of being the zero-vector and CA and CB being
1424cdf0e10cSrcweir             // relative to P, an empty edge was exported as P == CA == CB. Luckily, the new
1425cdf0e10cSrcweir             // export format can be read without errors by the old OOo-versions, so we need only
1426cdf0e10cSrcweir             // to correct here at read and do not need to export a wrong but compatible version
1427cdf0e10cSrcweir             // for the future.
1428cdf0e10cSrcweir             if(bControlA
1429cdf0e10cSrcweir                 && aControlA.equal(aControlB)
1430cdf0e10cSrcweir                 && aControlA.equal(aNewPolygon.getB2DPoint(aNewPolygon.count() - 1)))
1431cdf0e10cSrcweir             {
1432cdf0e10cSrcweir                 bControlA = bControlB = false;
1433cdf0e10cSrcweir             }
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir             if(bControlA)
1436cdf0e10cSrcweir             {
1437cdf0e10cSrcweir                 // add bezier edge
1438cdf0e10cSrcweir                 aNewPolygon.appendBezierSegment(aControlA, aControlB, aNewCoordinatePair);
1439cdf0e10cSrcweir             }
1440cdf0e10cSrcweir             else
1441cdf0e10cSrcweir             {
1442cdf0e10cSrcweir                 // add edge
1443cdf0e10cSrcweir                 aNewPolygon.append(aNewCoordinatePair);
1444cdf0e10cSrcweir             }
1445cdf0e10cSrcweir         }
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir         // next sequence
1448cdf0e10cSrcweir         pInnerSequence++;
1449cdf0e10cSrcweir         pInnerSequenceFlags++;
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir         // #i72807# API import uses old line start/end-equal definition for closed,
1452cdf0e10cSrcweir         // so we need to correct this to closed state here
1453cdf0e10cSrcweir         basegfx::tools::checkClosed(aNewPolygon);
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir         // add new subpolygon
1456cdf0e10cSrcweir         aNewPolyPolygon.append(aNewPolygon);
1457cdf0e10cSrcweir     }
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir     return aNewPolyPolygon;
1460cdf0e10cSrcweir }
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir //----------------------------------------------------------------------
1463cdf0e10cSrcweir 
setPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,const::com::sun::star::uno::Any & rValue)1464cdf0e10cSrcweir 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)
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir     switch( pProperty->nWID )
1467cdf0e10cSrcweir     {
1468cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1469cdf0e10cSrcweir     {
1470cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0) ) )
1471cdf0e10cSrcweir         {
1472cdf0e10cSrcweir             basegfx::B2DPolyPolygon aNewPolyPolygon(SvxConvertPolyPolygonBezierToB2DPolyPolygon( (drawing::PolyPolygonBezierCoords*)rValue.getValue()));
1473cdf0e10cSrcweir             SetPolygon(aNewPolyPolygon);
1474cdf0e10cSrcweir             return true;
1475cdf0e10cSrcweir         }
1476cdf0e10cSrcweir         break;
1477cdf0e10cSrcweir     }
1478cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1479cdf0e10cSrcweir     {
1480cdf0e10cSrcweir         if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0)) )
1481cdf0e10cSrcweir         {
1482cdf0e10cSrcweir             if( mpObj.is() )
1483cdf0e10cSrcweir             {
1484cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aNewPolyPolygon;
1485cdf0e10cSrcweir                 basegfx::B2DHomMatrix aNewHomogenMatrix;
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir                 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1488cdf0e10cSrcweir                 aNewPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon((drawing::PolyPolygonBezierCoords*)rValue.getValue());
1489cdf0e10cSrcweir                 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1490cdf0e10cSrcweir             }
1491cdf0e10cSrcweir             return true;
1492cdf0e10cSrcweir         }
1493cdf0e10cSrcweir         break;
1494cdf0e10cSrcweir     }
1495cdf0e10cSrcweir     default:
1496cdf0e10cSrcweir         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1497cdf0e10cSrcweir     }
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir     throw IllegalArgumentException();
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir 
SvxConvertB2DPolyPolygonToPolyPolygonBezier(const basegfx::B2DPolyPolygon & rPolyPoly,drawing::PolyPolygonBezierCoords & rRetval)1502cdf0e10cSrcweir void SvxConvertB2DPolyPolygonToPolyPolygonBezier( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PolyPolygonBezierCoords& rRetval )
1503cdf0e10cSrcweir {
1504cdf0e10cSrcweir     // use PolyPolygon converter as base. Since PolyPolygonBezierCoords uses
1505cdf0e10cSrcweir     // integer coordinates, this is no precision loss at all.
1506cdf0e10cSrcweir     const PolyPolygon aPolyPoly(rPolyPoly);
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir     // Polygone innerhalb vrobereiten
1509cdf0e10cSrcweir     rRetval.Coordinates.realloc((sal_Int32)aPolyPoly.Count());
1510cdf0e10cSrcweir     rRetval.Flags.realloc((sal_Int32)aPolyPoly.Count());
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir     // Zeiger auf aeussere Arrays holen
1513cdf0e10cSrcweir     drawing::PointSequence* pOuterSequence = rRetval.Coordinates.getArray();
1514cdf0e10cSrcweir     drawing::FlagSequence*  pOuterFlags = rRetval.Flags.getArray();
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir     for(sal_uInt16 a=0;a<aPolyPoly.Count();a++)
1517cdf0e10cSrcweir     {
1518cdf0e10cSrcweir         // Einzelpolygon holen
1519cdf0e10cSrcweir         const Polygon& rPoly = aPolyPoly[a];
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir         // Platz in Arrays schaffen
1522cdf0e10cSrcweir         pOuterSequence->realloc((sal_Int32)rPoly.GetSize());
1523cdf0e10cSrcweir         pOuterFlags->realloc((sal_Int32)rPoly.GetSize());
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir         // Pointer auf arrays holen
1526cdf0e10cSrcweir         awt::Point* pInnerSequence = pOuterSequence->getArray();
1527cdf0e10cSrcweir         drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir         for(sal_uInt16 b=0;b<rPoly.GetSize();b++)
1530cdf0e10cSrcweir         {
1531cdf0e10cSrcweir             *pInnerSequence++ = awt::Point( rPoly[b].X(), rPoly[b].Y() );
1532cdf0e10cSrcweir             *pInnerFlags++ = (drawing::PolygonFlags)((sal_uInt16)rPoly.GetFlags(b));
1533cdf0e10cSrcweir         }
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir         pOuterSequence++;
1536cdf0e10cSrcweir         pOuterFlags++;
1537cdf0e10cSrcweir     }
1538cdf0e10cSrcweir }
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir //----------------------------------------------------------------------
1541cdf0e10cSrcweir 
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)1542cdf0e10cSrcweir 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)
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir     switch( pProperty->nWID )
1545cdf0e10cSrcweir     {
1546cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1547cdf0e10cSrcweir     {
1548cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1549cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1550cdf0e10cSrcweir         drawing::PolyPolygonBezierCoords aRetval;
1551cdf0e10cSrcweir         SvxConvertB2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval );
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir         rValue <<= aRetval;
1554cdf0e10cSrcweir         break;
1555cdf0e10cSrcweir     }
1556cdf0e10cSrcweir     case OWN_ATTR_BASE_GEOMETRY:
1557cdf0e10cSrcweir     {
1558cdf0e10cSrcweir         // PolyPolygon in eine struct PolyPolygon packen
1559cdf0e10cSrcweir         basegfx::B2DPolyPolygon aNewPolyPolygon;
1560cdf0e10cSrcweir         basegfx::B2DHomMatrix aNewHomogenMatrix;
1561cdf0e10cSrcweir         mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1562cdf0e10cSrcweir         drawing::PolyPolygonBezierCoords aRetval;
1563cdf0e10cSrcweir         SvxConvertB2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir         rValue <<= aRetval;
1566cdf0e10cSrcweir         break;
1567cdf0e10cSrcweir     }
1568cdf0e10cSrcweir     case OWN_ATTR_VALUE_POLYGONKIND:
1569cdf0e10cSrcweir     {
1570cdf0e10cSrcweir         rValue <<= mePolygonKind;
1571cdf0e10cSrcweir         break;
1572cdf0e10cSrcweir     }
1573cdf0e10cSrcweir     default:
1574cdf0e10cSrcweir         return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1575cdf0e10cSrcweir     }
1576cdf0e10cSrcweir     return true;
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir //----------------------------------------------------------------------
GetPolygonKind() const1580cdf0e10cSrcweir drawing::PolygonKind SvxShapePolyPolygonBezier::GetPolygonKind() const throw()
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir     return mePolygonKind;
1583cdf0e10cSrcweir }
1584cdf0e10cSrcweir 
1585cdf0e10cSrcweir //----------------------------------------------------------------------
SetPolygon(const basegfx::B2DPolyPolygon & rNew)1586cdf0e10cSrcweir void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
1587cdf0e10cSrcweir {
1588cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir     if(mpObj.is())
1591cdf0e10cSrcweir         static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir //----------------------------------------------------------------------
GetPolygon() const1595cdf0e10cSrcweir basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
1596cdf0e10cSrcweir {
1597cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir     if(mpObj.is())
1600cdf0e10cSrcweir     {
1601cdf0e10cSrcweir         return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
1602cdf0e10cSrcweir     }
1603cdf0e10cSrcweir     else
1604cdf0e10cSrcweir     {
1605cdf0e10cSrcweir         return basegfx::B2DPolyPolygon();
1606cdf0e10cSrcweir     }
1607cdf0e10cSrcweir }
1608cdf0e10cSrcweir 
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
getSupportedServiceNames()1611cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException )
1612cdf0e10cSrcweir {
1613cdf0e10cSrcweir     return SvxShapeText::getSupportedServiceNames();
1614cdf0e10cSrcweir }
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir /***********************************************************************
1617cdf0e10cSrcweir * class SvxGraphicObject                                               *
1618cdf0e10cSrcweir ***********************************************************************/
1619cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
1620cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
1621cdf0e10cSrcweir #include <svx/svdograf.hxx>
1622cdf0e10cSrcweir #ifndef SVX_LIGHT
1623cdf0e10cSrcweir #ifndef _SFXDOCFILE_HXX
1624cdf0e10cSrcweir #include <sfx2/docfile.hxx>
1625cdf0e10cSrcweir #endif
16261b9d1397SArrigo Marchiori #include <sfx2/linkmgr.hxx>
1627cdf0e10cSrcweir #include <sfx2/app.hxx>
1628cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
1629cdf0e10cSrcweir #endif
1630cdf0e10cSrcweir 
1631b63233d8Sdamjan #include "toolkit/helper/vclunohelper.hxx"
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir //----------------------------------------------------------------------
SvxGraphicObject(SdrObject * pObj)1634cdf0e10cSrcweir SvxGraphicObject::SvxGraphicObject( SdrObject* pObj ) throw()
1635cdf0e10cSrcweir :   SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_GRAPHICOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
1636cdf0e10cSrcweir {
1637cdf0e10cSrcweir }
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxGraphicObject()1640cdf0e10cSrcweir SvxGraphicObject::~SvxGraphicObject() throw()
1641cdf0e10cSrcweir {
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir //----------------------------------------------------------------------
1645cdf0e10cSrcweir 
setPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,const::com::sun::star::uno::Any & rValue)1646cdf0e10cSrcweir 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)
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir     bool bOk = false;
1649cdf0e10cSrcweir     switch( pProperty->nWID )
1650cdf0e10cSrcweir     {
1651cdf0e10cSrcweir     case OWN_ATTR_VALUE_FILLBITMAP:
1652cdf0e10cSrcweir     {
1653cdf0e10cSrcweir         if( rValue.getValue() )
1654cdf0e10cSrcweir         {
1655cdf0e10cSrcweir             if( rValue.getValueType() == ::getCppuType(( const uno::Sequence< sal_Int8 >*)0) )
1656cdf0e10cSrcweir             {
1657cdf0e10cSrcweir                 uno::Sequence<sal_Int8>* pSeq( (uno::Sequence<sal_Int8>*)rValue.getValue() );
1658cdf0e10cSrcweir                 SvMemoryStream  aMemStm;
1659cdf0e10cSrcweir                 Graphic         aGraphic;
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir                 aMemStm.SetBuffer( (char*)pSeq->getConstArray(), pSeq->getLength(), sal_False, pSeq->getLength() );
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir                 if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
1664cdf0e10cSrcweir                 {
1665cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
1666cdf0e10cSrcweir                     bOk = true;
1667cdf0e10cSrcweir                 }
1668cdf0e10cSrcweir             }
1669cdf0e10cSrcweir         }
1670cdf0e10cSrcweir         else if( (rValue.getValueType() == awt::XBitmap::static_type()) || (rValue.getValueType() == graphic::XGraphic::static_type()))
1671cdf0e10cSrcweir         {
1672cdf0e10cSrcweir             Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY );
1673cdf0e10cSrcweir             if( xGraphic.is() )
1674cdf0e10cSrcweir             {
1675cdf0e10cSrcweir                 ((SdrGrafObj*)mpObj.get())->SetGraphic(Graphic(xGraphic));
1676cdf0e10cSrcweir                 bOk = true;
1677cdf0e10cSrcweir             }
1678cdf0e10cSrcweir             else
1679cdf0e10cSrcweir             {
1680cdf0e10cSrcweir                 // Bitmap in das Objekt packen
1681cdf0e10cSrcweir                 Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
1682cdf0e10cSrcweir                 if( xBmp.is() )
1683cdf0e10cSrcweir                 {
1684cdf0e10cSrcweir                     // Bitmap einsetzen
1685cdf0e10cSrcweir                     Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp ));
1686cdf0e10cSrcweir                     ((SdrGrafObj*)mpObj.get())->SetGraphic(aGraphic);
1687cdf0e10cSrcweir                     bOk = true;
1688cdf0e10cSrcweir                 }
1689cdf0e10cSrcweir             }
1690cdf0e10cSrcweir         }
1691cdf0e10cSrcweir         break;
1692cdf0e10cSrcweir     }
1693cdf0e10cSrcweir     case OWN_ATTR_GRAFURL:
1694cdf0e10cSrcweir     {
1695cdf0e10cSrcweir         OUString aURL;
1696cdf0e10cSrcweir         if( rValue >>= aURL )
1697cdf0e10cSrcweir         {
1698cdf0e10cSrcweir             if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
1699cdf0e10cSrcweir             {
1700cdf0e10cSrcweir                 // graphic manager url
1701cdf0e10cSrcweir                 aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
1702cdf0e10cSrcweir                 String aTmpStr(aURL);
1703cdf0e10cSrcweir                 ByteString aUniqueID( aTmpStr, RTL_TEXTENCODING_UTF8 );
1704cdf0e10cSrcweir                 GraphicObject aGrafObj( aUniqueID );
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir                 // #101808# since loading a graphic can cause a reschedule of the office
1707cdf0e10cSrcweir                 //          it is possible that our shape is removed while where in this
1708cdf0e10cSrcweir                 //          method.
1709cdf0e10cSrcweir                 if( mpObj.is() )
1710cdf0e10cSrcweir                 {
1711cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink();
1712cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj );
1713cdf0e10cSrcweir                 }
1714cdf0e10cSrcweir             }
1715cdf0e10cSrcweir             else if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
1716cdf0e10cSrcweir             {
1717cdf0e10cSrcweir                 // normal link
1718cdf0e10cSrcweir                 String              aFilterName;
1719cdf0e10cSrcweir                 const SfxFilter*    pSfxFilter = NULL;
1720cdf0e10cSrcweir                 SfxMedium           aSfxMedium( aURL, STREAM_READ | STREAM_SHARE_DENYNONE, sal_False );
1721cdf0e10cSrcweir 
17221b9d1397SArrigo Marchiori                 // SfxFilterMatcher::GuessFilter() may ``taste'' linked files, so we must be sure we are authorized to access them
17231b9d1397SArrigo Marchiori                 sfx2::LinkManager *linkManager = NULL;
17241b9d1397SArrigo Marchiori                 if (mpModel) {
17251b9d1397SArrigo Marchiori                     linkManager = mpModel->GetLinkManager();
17261b9d1397SArrigo Marchiori                 }
1727*671443b4SArrigo Marchiori                 if ( ( linkManager == NULL ) ||
1728*671443b4SArrigo Marchiori                      ( !linkManager->urlIsVendor( aURL ) && linkManager->GetUserAllowsLinkUpdate( SFX_APP()->GetTopWindow() ) ) ) {
1729cdf0e10cSrcweir                     SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
17301b9d1397SArrigo Marchiori                 }
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir                 if( !pSfxFilter )
1733cdf0e10cSrcweir                 {
1734cdf0e10cSrcweir                     INetURLObject aURLObj( aURL );
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir                     if( aURLObj.GetProtocol() == INET_PROT_NOT_VALID )
1737cdf0e10cSrcweir                     {
1738cdf0e10cSrcweir                         String aValidURL;
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir                         if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) )
1741cdf0e10cSrcweir                             aURLObj = INetURLObject( aValidURL );
1742cdf0e10cSrcweir                     }
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir                     if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID )
1745cdf0e10cSrcweir                     {
1746cdf0e10cSrcweir                         GraphicFilter* pGrfFilter = GraphicFilter::GetGraphicFilter();
1747cdf0e10cSrcweir                         aFilterName = pGrfFilter->GetImportFormatName( pGrfFilter->GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
1748cdf0e10cSrcweir                     }
1749cdf0e10cSrcweir                 }
1750cdf0e10cSrcweir                 else
1751cdf0e10cSrcweir                     aFilterName = pSfxFilter->GetFilterName();
1752cdf0e10cSrcweir 
1753cdf0e10cSrcweir                 // #101808# since loading a graphic can cause a reschedule of the office
1754cdf0e10cSrcweir                 //          it is possible that our shape is removed while where in this
1755cdf0e10cSrcweir                 //          method.
1756cdf0e10cSrcweir                 if( mpObj.is() )
1757cdf0e10cSrcweir                     static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, aFilterName );
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir             }
1760cdf0e10cSrcweir             bOk = true;
1761cdf0e10cSrcweir         }
1762cdf0e10cSrcweir         break;
1763cdf0e10cSrcweir     }
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir     case OWN_ATTR_GRAFSTREAMURL:
1766cdf0e10cSrcweir     {
1767cdf0e10cSrcweir         OUString aStreamURL;
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir         if( rValue >>= aStreamURL )
1770cdf0e10cSrcweir         {
1771cdf0e10cSrcweir             if( aStreamURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
1772cdf0e10cSrcweir                 aStreamURL = OUString();
1773cdf0e10cSrcweir 
1774cdf0e10cSrcweir             if( mpObj.is() )
1775cdf0e10cSrcweir             {
1776cdf0e10cSrcweir                 static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
1777cdf0e10cSrcweir                 static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut();
1778cdf0e10cSrcweir             }
1779cdf0e10cSrcweir             bOk = true;
1780cdf0e10cSrcweir         }
1781cdf0e10cSrcweir         break;
1782cdf0e10cSrcweir     }
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir     case OWN_ATTR_VALUE_GRAPHIC:
1785cdf0e10cSrcweir     {
1786cdf0e10cSrcweir         Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
1787cdf0e10cSrcweir         if( xGraphic.is() )
1788cdf0e10cSrcweir         {
1789cdf0e10cSrcweir             static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
1790cdf0e10cSrcweir             bOk = true;
1791cdf0e10cSrcweir         }
1792cdf0e10cSrcweir         break;
1793cdf0e10cSrcweir     }
1794cdf0e10cSrcweir     default:
1795cdf0e10cSrcweir         return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1796cdf0e10cSrcweir     }
1797cdf0e10cSrcweir 
1798cdf0e10cSrcweir     if( !bOk )
1799cdf0e10cSrcweir         throw lang::IllegalArgumentException();
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir     if( mpModel )
1802cdf0e10cSrcweir         mpModel->SetChanged();
1803cdf0e10cSrcweir 
1804cdf0e10cSrcweir     return true;
1805cdf0e10cSrcweir }
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir //----------------------------------------------------------------------
1808cdf0e10cSrcweir 
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)1809cdf0e10cSrcweir 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)
1810cdf0e10cSrcweir {
1811cdf0e10cSrcweir     switch( pProperty->nWID )
1812cdf0e10cSrcweir     {
1813cdf0e10cSrcweir     case OWN_ATTR_VALUE_FILLBITMAP:
1814cdf0e10cSrcweir     {
1815cdf0e10cSrcweir         sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1816cdf0e10cSrcweir         const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir         if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
1819cdf0e10cSrcweir         {
1820cdf0e10cSrcweir             // Objekt in eine Bitmap packen
1821cdf0e10cSrcweir             Reference< ::com::sun::star::awt::XBitmap >  xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
1822cdf0e10cSrcweir             rValue <<= xBitmap;
1823cdf0e10cSrcweir         }
1824cdf0e10cSrcweir         else
1825cdf0e10cSrcweir         {
1826cdf0e10cSrcweir             SvMemoryStream aDestStrm( 65535, 65535 );
1827cdf0e10cSrcweir 
1828cdf0e10cSrcweir             ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False );
1829cdf0e10cSrcweir             const uno::Sequence<sal_Int8> aSeq(
1830cdf0e10cSrcweir                 static_cast< const sal_Int8* >(aDestStrm.GetData()),
1831cdf0e10cSrcweir                 aDestStrm.GetEndOfData());
1832cdf0e10cSrcweir             rValue <<= aSeq;
1833cdf0e10cSrcweir         }
1834cdf0e10cSrcweir         if ( bSwapped )
1835cdf0e10cSrcweir             static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1836cdf0e10cSrcweir         break;
1837cdf0e10cSrcweir     }
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir     case OWN_ATTR_GRAFURL:
1840cdf0e10cSrcweir     {
1841cdf0e10cSrcweir         if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() )
1842cdf0e10cSrcweir         {
1843cdf0e10cSrcweir             rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() );
1844cdf0e10cSrcweir         }
1845cdf0e10cSrcweir         else
1846cdf0e10cSrcweir         {
1847cdf0e10cSrcweir             sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1848cdf0e10cSrcweir             const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
1849cdf0e10cSrcweir             OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
1850cdf0e10cSrcweir             aURL += OUString::createFromAscii( rGrafObj.GetUniqueID().GetBuffer() );
1851cdf0e10cSrcweir             rValue <<= aURL;
1852cdf0e10cSrcweir             if ( bSwapped )
1853cdf0e10cSrcweir                 static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1854cdf0e10cSrcweir         }
1855cdf0e10cSrcweir         break;
1856cdf0e10cSrcweir     }
1857cdf0e10cSrcweir 
1858ddde725dSArmin Le Grand     case OWN_ATTR_REPLACEMENTGRAFURL:
1859ddde725dSArmin Le Grand     {
1860ddde725dSArmin Le Grand         const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(mpObj.get())->GetReplacementGraphicObject();
1861ddde725dSArmin Le Grand 
1862ddde725dSArmin Le Grand         if(pGrafObj)
1863ddde725dSArmin Le Grand         {
1864ddde725dSArmin Le Grand             OUString aURL(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
1865ddde725dSArmin Le Grand             aURL += OUString::createFromAscii(pGrafObj->GetUniqueID().GetBuffer());
1866ddde725dSArmin Le Grand             rValue <<= aURL;
1867ddde725dSArmin Le Grand         }
1868ddde725dSArmin Le Grand 
1869ddde725dSArmin Le Grand         break;
1870ddde725dSArmin Le Grand     }
1871ddde725dSArmin Le Grand 
1872cdf0e10cSrcweir     case OWN_ATTR_GRAFSTREAMURL:
1873cdf0e10cSrcweir     {
1874cdf0e10cSrcweir         const OUString  aStreamURL( ( (SdrGrafObj*) mpObj.get() )->GetGrafStreamURL() );
1875cdf0e10cSrcweir         if( aStreamURL.getLength() )
1876cdf0e10cSrcweir             rValue <<= aStreamURL;
1877cdf0e10cSrcweir         break;
1878cdf0e10cSrcweir     }
1879cdf0e10cSrcweir 
1880cdf0e10cSrcweir     case OWN_ATTR_VALUE_GRAPHIC:
1881cdf0e10cSrcweir     {
1882cdf0e10cSrcweir         sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1883cdf0e10cSrcweir         Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
1884cdf0e10cSrcweir         rValue <<= xGraphic;
1885cdf0e10cSrcweir         if ( bSwapped )
1886cdf0e10cSrcweir             static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1887cdf0e10cSrcweir         break;
1888cdf0e10cSrcweir     }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir     case OWN_ATTR_GRAPHIC_STREAM:
1891cdf0e10cSrcweir     {
1892cdf0e10cSrcweir         rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
1893cdf0e10cSrcweir         break;
1894cdf0e10cSrcweir     }
1895cdf0e10cSrcweir     default:
1896cdf0e10cSrcweir         return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
1897cdf0e10cSrcweir     }
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir     return true;
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
1903cdf0e10cSrcweir 
SvxShapeCaption(SdrObject * pObj)1904cdf0e10cSrcweir SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw()
1905cdf0e10cSrcweir : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CAPTION), aSvxMapProvider.GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) )
1906cdf0e10cSrcweir {
1907cdf0e10cSrcweir }
1908cdf0e10cSrcweir 
~SvxShapeCaption()1909cdf0e10cSrcweir SvxShapeCaption::~SvxShapeCaption() throw()
1910cdf0e10cSrcweir {
1911cdf0e10cSrcweir }
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir /***********************************************************************
1914cdf0e10cSrcweir * class SvxCustomShape                                                   *
1915cdf0e10cSrcweir ***********************************************************************/
1916cdf0e10cSrcweir 
SvxCustomShape(SdrObject * pObj)1917cdf0e10cSrcweir SvxCustomShape::SvxCustomShape( SdrObject* pObj )  throw() :
1918cdf0e10cSrcweir     SvxShapeText( pObj, aSvxMapProvider.GetMap( SVXMAP_CUSTOMSHAPE ), aSvxMapProvider.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) )
1919cdf0e10cSrcweir {
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir //----------------------------------------------------------------------
~SvxCustomShape()1923cdf0e10cSrcweir SvxCustomShape::~SvxCustomShape() throw()
1924cdf0e10cSrcweir {
1925cdf0e10cSrcweir }
1926cdf0e10cSrcweir 
1927cdf0e10cSrcweir //----------------------------------------------------------------------
1928cdf0e10cSrcweir 
Create(SdrObject * pNewObj,SvxDrawPage * pNewPage)1929cdf0e10cSrcweir void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
1930cdf0e10cSrcweir {
1931cdf0e10cSrcweir     SvxShapeText::Create( pNewObj, pNewPage );
1932cdf0e10cSrcweir }
1933cdf0e10cSrcweir 
1934cdf0e10cSrcweir //----------------------------------------------------------------------
1935cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)1936cdf0e10cSrcweir uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType )
1937cdf0e10cSrcweir     throw(uno::RuntimeException)
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir     return SvxShapeText::queryInterface( rType );
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir 
queryAggregation(const uno::Type & rType)1942cdf0e10cSrcweir uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType )
1943cdf0e10cSrcweir     throw(uno::RuntimeException)
1944cdf0e10cSrcweir {
1945cdf0e10cSrcweir     ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType );
1946cdf0e10cSrcweir     if ( !aReturn.hasValue() )
1947cdf0e10cSrcweir         aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) );
1948cdf0e10cSrcweir     return aReturn;
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir 
acquire()1951cdf0e10cSrcweir void SAL_CALL SvxCustomShape::acquire() throw ( )
1952cdf0e10cSrcweir {
1953cdf0e10cSrcweir     SvxShapeText::acquire();
1954cdf0e10cSrcweir }
1955cdf0e10cSrcweir 
release()1956cdf0e10cSrcweir void SAL_CALL SvxCustomShape::release() throw ( )
1957cdf0e10cSrcweir {
1958cdf0e10cSrcweir     SvxShapeText::release();
1959cdf0e10cSrcweir }
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir //----------------------------------------------------------------------
1962cdf0e10cSrcweir 
getTypes()1963cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes()
1964cdf0e10cSrcweir     throw (uno::RuntimeException)
1965cdf0e10cSrcweir {
1966cdf0e10cSrcweir     return SvxShapeText::getTypes();
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
getImplementationId()1969cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
1970cdf0e10cSrcweir     throw (uno::RuntimeException)
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aId;
1973cdf0e10cSrcweir     if( aId.getLength() == 0 )
1974cdf0e10cSrcweir     {
1975cdf0e10cSrcweir         aId.realloc( 16 );
1976cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
1977cdf0e10cSrcweir     }
1978cdf0e10cSrcweir     return aId;
1979cdf0e10cSrcweir }
1980cdf0e10cSrcweir 
1981cdf0e10cSrcweir // ::com::sun::star::drawing::XShape
1982cdf0e10cSrcweir 
1983cdf0e10cSrcweir //----------------------------------------------------------------------
getShapeType()1984cdf0e10cSrcweir OUString SAL_CALL SvxCustomShape::getShapeType()
1985cdf0e10cSrcweir     throw( uno::RuntimeException )
1986cdf0e10cSrcweir {
1987cdf0e10cSrcweir     return SvxShape::getShapeType();
1988cdf0e10cSrcweir }
1989cdf0e10cSrcweir 
1990cdf0e10cSrcweir //------------------------------------------------------------------1----
getPosition()1991cdf0e10cSrcweir awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException)
1992cdf0e10cSrcweir {
1993cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
1994cdf0e10cSrcweir     if ( mpModel && mpObj.is() )
1995cdf0e10cSrcweir     {
1996cdf0e10cSrcweir         SdrAShapeObjGeoData aCustomShapeGeoData;
1997cdf0e10cSrcweir         ((SdrObjCustomShape*)mpObj.get())->SaveGeoData( aCustomShapeGeoData );
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir         sal_Bool bMirroredX = sal_False;
2000cdf0e10cSrcweir         sal_Bool bMirroredY = sal_False;
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir         if ( mpObj.is() )
2003cdf0e10cSrcweir         {
2004cdf0e10cSrcweir             bMirroredX = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredX() );
2005cdf0e10cSrcweir             bMirroredY = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredY() );
2006cdf0e10cSrcweir         }
2007cdf0e10cSrcweir         // get aRect, this is the unrotated snaprect
2008cdf0e10cSrcweir         Rectangle aRect(((SdrObjCustomShape*)mpObj.get())->GetLogicRect());
2009cdf0e10cSrcweir         Rectangle aRectangle( aRect );
2010cdf0e10cSrcweir 
2011cdf0e10cSrcweir         if ( bMirroredX || bMirroredY )
2012cdf0e10cSrcweir         {   // we have to retrieve the unmirrored rect
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir             GeoStat aNewGeo( aCustomShapeGeoData.aGeo );
2015cdf0e10cSrcweir             if ( bMirroredX )
2016cdf0e10cSrcweir             {
2017cdf0e10cSrcweir                 Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
2018cdf0e10cSrcweir                 Rectangle aBoundRect( aPol.GetBoundRect() );
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir                 Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
2021cdf0e10cSrcweir                 Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
2022cdf0e10cSrcweir                 sal_uInt16 i;
2023cdf0e10cSrcweir                 sal_uInt16 nPntAnz=aPol.GetSize();
2024cdf0e10cSrcweir                 for (i=0; i<nPntAnz; i++)
2025cdf0e10cSrcweir                 {
2026cdf0e10cSrcweir                     MirrorPoint(aPol[i],aRef1,aRef2);
2027cdf0e10cSrcweir                 }
2028cdf0e10cSrcweir                 // Polygon wenden und etwas schieben
2029cdf0e10cSrcweir                 Polygon aPol0(aPol);
2030cdf0e10cSrcweir                 aPol[0]=aPol0[1];
2031cdf0e10cSrcweir                 aPol[1]=aPol0[0];
2032cdf0e10cSrcweir                 aPol[2]=aPol0[3];
2033cdf0e10cSrcweir                 aPol[3]=aPol0[2];
2034cdf0e10cSrcweir                 aPol[4]=aPol0[1];
2035cdf0e10cSrcweir                 Poly2Rect(aPol,aRectangle,aNewGeo);
2036cdf0e10cSrcweir             }
2037cdf0e10cSrcweir             if ( bMirroredY )
2038cdf0e10cSrcweir             {
2039cdf0e10cSrcweir                 Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
2040cdf0e10cSrcweir                 Rectangle aBoundRect( aPol.GetBoundRect() );
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir                 Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
2043cdf0e10cSrcweir                 Point aRef2( aRef1.X() + 1000, aRef1.Y() );
2044cdf0e10cSrcweir                 sal_uInt16 i;
2045cdf0e10cSrcweir                 sal_uInt16 nPntAnz=aPol.GetSize();
2046cdf0e10cSrcweir                 for (i=0; i<nPntAnz; i++)
2047cdf0e10cSrcweir                 {
2048cdf0e10cSrcweir                     MirrorPoint(aPol[i],aRef1,aRef2);
2049cdf0e10cSrcweir                 }
2050cdf0e10cSrcweir                 // Polygon wenden und etwas schieben
2051cdf0e10cSrcweir                 Polygon aPol0(aPol);
2052cdf0e10cSrcweir                 aPol[0]=aPol0[1];
2053cdf0e10cSrcweir                 aPol[1]=aPol0[0];
2054cdf0e10cSrcweir                 aPol[2]=aPol0[3];
2055cdf0e10cSrcweir                 aPol[3]=aPol0[2];
2056cdf0e10cSrcweir                 aPol[4]=aPol0[1];
2057cdf0e10cSrcweir                 Poly2Rect( aPol, aRectangle, aNewGeo );
2058cdf0e10cSrcweir             }
2059cdf0e10cSrcweir         }
2060cdf0e10cSrcweir         Point aPt( aRectangle.TopLeft() );
2061cdf0e10cSrcweir 
2062cdf0e10cSrcweir         if( mpModel->IsWriter() )
2063cdf0e10cSrcweir             aPt -= mpObj->GetAnchorPos();
2064cdf0e10cSrcweir 
2065cdf0e10cSrcweir         ForceMetricTo100th_mm(aPt);
2066cdf0e10cSrcweir         return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
2067cdf0e10cSrcweir     }
2068cdf0e10cSrcweir     else
2069cdf0e10cSrcweir         return SvxShape::getPosition();
2070cdf0e10cSrcweir }
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir //----------------------------------------------------------------------
setPosition(const awt::Point & Position)2073cdf0e10cSrcweir void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
2074cdf0e10cSrcweir {
2075cdf0e10cSrcweir     SvxShapeText::setPosition(Position);
2076cdf0e10cSrcweir }
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir //----------------------------------------------------------------------
2079cdf0e10cSrcweir 
getSize()2080cdf0e10cSrcweir awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException)
2081cdf0e10cSrcweir {
2082cdf0e10cSrcweir     return SvxShapeText::getSize();
2083cdf0e10cSrcweir }
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir //----------------------------------------------------------------------
setSize(const awt::Size & rSize)2086cdf0e10cSrcweir void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize )
2087cdf0e10cSrcweir     throw(beans::PropertyVetoException, uno::RuntimeException)
2088cdf0e10cSrcweir {
2089cdf0e10cSrcweir     SvxShapeText::setSize( rSize );
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir //----------------------------------------------------------------------
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir //----------------------------------------------------------------------
setPropertyValue(const OUString & aPropertyName,const uno::Any & aValue)2095cdf0e10cSrcweir void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
2096cdf0e10cSrcweir     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
2097cdf0e10cSrcweir {
2098cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
2099cdf0e10cSrcweir     SdrObject* pObject = mpObj.get();
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir     sal_Bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) );
2102cdf0e10cSrcweir 
2103cdf0e10cSrcweir     sal_Bool bMirroredX = sal_False;
2104cdf0e10cSrcweir     sal_Bool bMirroredY = sal_False;
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir     if ( bCustomShapeGeometry )
2107cdf0e10cSrcweir     {
2108cdf0e10cSrcweir         bMirroredX = ( ((SdrObjCustomShape*)pObject)->IsMirroredX() );
2109cdf0e10cSrcweir         bMirroredY = ( ((SdrObjCustomShape*)pObject)->IsMirroredY() );
2110cdf0e10cSrcweir     }
2111cdf0e10cSrcweir 
2112cdf0e10cSrcweir     SvxShape::setPropertyValue( aPropertyName, aValue );
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir     if ( bCustomShapeGeometry )
2115cdf0e10cSrcweir     {
2116cdf0e10cSrcweir         ((SdrObjCustomShape*)pObject)->MergeDefaultAttributes(0);
2117cdf0e10cSrcweir         Rectangle aRect( pObject->GetSnapRect() );
2118cdf0e10cSrcweir 
2119cdf0e10cSrcweir         // #i38892#
2120cdf0e10cSrcweir         bool bNeedsMirrorX = ((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX;
2121cdf0e10cSrcweir         bool bNeedsMirrorY = ((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY;
2122cdf0e10cSrcweir 
2123cdf0e10cSrcweir         boost::scoped_ptr< SdrGluePointList > pListCopy;
2124cdf0e10cSrcweir         if( bNeedsMirrorX || bNeedsMirrorY )
2125cdf0e10cSrcweir         {
2126cdf0e10cSrcweir             const SdrGluePointList* pList = pObject->GetGluePointList();
2127cdf0e10cSrcweir             if( pList )
2128cdf0e10cSrcweir                 pListCopy.reset( new SdrGluePointList(*pList) );
2129cdf0e10cSrcweir         }
2130cdf0e10cSrcweir 
2131cdf0e10cSrcweir         if ( bNeedsMirrorX )
2132cdf0e10cSrcweir         {
2133cdf0e10cSrcweir             Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
2134cdf0e10cSrcweir             Point aBottom( aTop.X(), aTop.Y() + 1000 );
2135cdf0e10cSrcweir             pObject->NbcMirror( aTop, aBottom );
2136cdf0e10cSrcweir             // NbcMirroring is flipping the current mirror state,
2137cdf0e10cSrcweir             // so we have to set the correct state again
2138cdf0e10cSrcweir             ((SdrObjCustomShape*)pObject)->SetMirroredX( bMirroredX ? sal_False : sal_True );
2139cdf0e10cSrcweir         }
2140cdf0e10cSrcweir         if ( bNeedsMirrorY )
2141cdf0e10cSrcweir         {
2142cdf0e10cSrcweir             Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
2143cdf0e10cSrcweir             Point aRight( aLeft.X() + 1000, aLeft.Y() );
2144cdf0e10cSrcweir             pObject->NbcMirror( aLeft, aRight );
2145cdf0e10cSrcweir             // NbcMirroring is flipping the current mirror state,
2146cdf0e10cSrcweir             // so we have to set the correct state again
2147cdf0e10cSrcweir             ((SdrObjCustomShape*)pObject)->SetMirroredY( bMirroredY ? sal_False : sal_True );
2148cdf0e10cSrcweir         }
2149cdf0e10cSrcweir 
2150cdf0e10cSrcweir         if( pListCopy )
2151cdf0e10cSrcweir         {
2152cdf0e10cSrcweir             SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
2153cdf0e10cSrcweir             if(pNewList)
2154cdf0e10cSrcweir                 *pNewList = *pListCopy;
2155cdf0e10cSrcweir         }
2156cdf0e10cSrcweir     }
2157cdf0e10cSrcweir }
2158cdf0e10cSrcweir 
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)2159cdf0e10cSrcweir 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)
2160cdf0e10cSrcweir {
2161cdf0e10cSrcweir     switch( pProperty->nWID )
2162cdf0e10cSrcweir     {
2163cdf0e10cSrcweir     case SDRATTR_ROTATEANGLE:
2164cdf0e10cSrcweir     {
2165cdf0e10cSrcweir         double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
2166cdf0e10cSrcweir         fAngle *= 100;
2167cdf0e10cSrcweir         rValue <<= (sal_Int32)fAngle;
2168cdf0e10cSrcweir         return true;
2169cdf0e10cSrcweir     }
2170cdf0e10cSrcweir     default:
2171cdf0e10cSrcweir         return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
2172cdf0e10cSrcweir     }
2173cdf0e10cSrcweir }
2174cdf0e10cSrcweir //----------------------------------------------------------------------
2175cdf0e10cSrcweir 
createCustomShapeDefaults(const rtl::OUString & rValueType)2176cdf0e10cSrcweir void SvxCustomShape::createCustomShapeDefaults( const rtl::OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException)
2177cdf0e10cSrcweir {
2178cdf0e10cSrcweir     ((SdrObjCustomShape*)mpObj.get())->MergeDefaultAttributes( &rValueType );
2179cdf0e10cSrcweir }
2180