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