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 <cppuhelper/typeprovider.hxx>
29 #include <com/sun/star/awt/XBitmap.hpp>
30 #include <com/sun/star/awt/Rectangle.hpp>
31 #include <com/sun/star/drawing/CircleKind.hpp>
32 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
33 #include <vcl/svapp.hxx>
34 #include <svl/itemprop.hxx>
35 #include <svtools/fltcall.hxx>
36 #include <vos/mutex.hxx>
37 #include <editeng/unotext.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdoole2.hxx>
40 #include <osl/mutex.hxx>
41 #include <comphelper/extract.hxx>
42 #include "svx/shapepropertynotifier.hxx"
43 #include <comphelper/serviceinfohelper.hxx>
44 #include <toolkit/helper/vclunohelper.hxx>
45 #include <comphelper/serviceinfohelper.hxx>
46 #include <rtl/uuid.h>
47 #include <rtl/memory.h>
48 #include <vcl/gfxlink.hxx>
49 #include <vcl/virdev.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <sfx2/viewsh.hxx>
52 #include "svx/svdopage.hxx"
53 #include "svx/xflbstit.hxx"
54 #include "svx/xflbmtit.hxx"
55 #include "svx/xlnstit.hxx"
56 #include "svx/xlnedit.hxx"
57 #include "svx/svdogrp.hxx"
58 #include "svx/scene3d.hxx"
59 #include "svx/svdmodel.hxx"
60 #include "svx/globl3d.hxx"
61 #include "svx/fmglob.hxx"
62 #include "svx/unopage.hxx"
63 #include "svx/view3d.hxx"
64 #include "svx/unoshape.hxx"
65 #include "svx/svxids.hrc"
66 #include "svx/unoshtxt.hxx"
67 #include "svx/svdpage.hxx"
68 #include "svx/unoshprp.hxx"
69 #include "svx/sxciaitm.hxx" // todo: remove
70 #include "svx/svdograf.hxx"
71 #include "svx/unoapi.hxx"
72 #include "svx/svdomeas.hxx"
73 #include "svx/svdpagv.hxx"
74 #include "svx/svdpool.hxx"
75 #include <tools/shl.hxx> //
76 #include "svx/dialmgr.hxx" // not nice, we need our own resources some day
77 #include "svx/dialogs.hrc" //
78 #include "svx/svdocapt.hxx"
79 #include <svx/obj3d.hxx>
80 #include <tools/diagnose_ex.h>
81 #include "svx/xflftrit.hxx"
82 #include "svx/xtable.hxx"
83 #include "svx/xbtmpit.hxx"
84 #include "svx/xflgrit.hxx"
85 #include "svx/xflhtit.hxx"
86 #include "svx/xlnedit.hxx"
87 #include "svx/xlnstit.hxx"
88 #include "svx/xlndsit.hxx"
89 #include "svx/svdglob.hxx"
90 #include "svx/svdstr.hrc"
91 #include "svx/unomaster.hxx"
92 #include <editeng/outlobj.hxx>
93 #include <basegfx/matrix/b2dhommatrix.hxx>
94 #include <basegfx/matrix/b2dhommatrixtools.hxx>
95 #include <basegfx/polygon/b2dpolypolygontools.hxx>
96
97 #include <vector>
98
99 // #i68523#
100 #include "svx/lathe3d.hxx"
101 #include "svx/extrud3d.hxx"
102 #include "unopolyhelper.hxx"
103
104 #include <comphelper/scopeguard.hxx>
105 #include <boost/bind.hpp>
106
107 using ::rtl::OUString;
108 using namespace ::osl;
109 using namespace ::vos;
110 using namespace ::cppu;
111 using namespace ::com::sun::star;
112 using namespace ::com::sun::star::uno;
113 using namespace ::com::sun::star::lang;
114 using namespace ::com::sun::star::container;
115 using ::svx::PropertyValueProvider;
116 using ::svx::IPropertyValueProvider;
117
118 #define QUERYINT( xint ) \
119 if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
120 aAny <<= uno::Reference< xint >(this)
121
122 class GDIMetaFile;
123 class SvStream;
124 sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
125 FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True );
126
127 uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject );
128
129 /***********************************************************************
130 * class SvxShapeImpl *
131 ***********************************************************************/
132
133 struct SvxShapeImpl
134 {
135 SvxShape& mrAntiImpl;
136 SfxItemSet* mpItemSet;
137 sal_uInt32 mnObjId;
138 SvxShapeMaster* mpMaster;
139 bool mbHasSdrObjectOwnership;
140 bool mbDisposing;
141
142 /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
143 * a SvxShape::Create() call is executed. It is then set to the created
144 * SdrObject so a multiple call to SvxShape::Create() with same SdrObject
145 * is prohibited.
146 */
147 ::tools::WeakReference< SdrObject > mpCreatedObj;
148
149 // for xComponent
150 ::cppu::OInterfaceContainerHelper maDisposeListeners;
151 ::svx::PropertyChangeNotifier maPropertyNotifier;
152
SvxShapeImplSvxShapeImpl153 SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex )
154 :mrAntiImpl( _rAntiImpl )
155 ,mpItemSet( NULL )
156 ,mnObjId( 0 )
157 ,mpMaster( NULL )
158 ,mbHasSdrObjectOwnership( false )
159 ,mbDisposing( false )
160 ,mpCreatedObj()
161 ,maDisposeListeners( _rMutex )
162 ,maPropertyNotifier( _rAntiImpl, _rMutex )
163 {
164 }
165 };
166
167 /**********************************************************************/
168 class ShapePositionProvider : public PropertyValueProvider
169 {
170 public:
ShapePositionProvider(const SvxShapeImpl & _shapeImpl)171 ShapePositionProvider( const SvxShapeImpl& _shapeImpl )
172 :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Position" )
173 {
174 }
175
176 protected:
getCurrentValue(Any & _out_rCurrentValue) const177 virtual void getCurrentValue( Any& _out_rCurrentValue ) const
178 {
179 _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getPosition();
180 }
181 };
182
183 //----------------------------------------------------------------------
184 class ShapeSizeProvider : public PropertyValueProvider
185 {
186 public:
ShapeSizeProvider(const SvxShapeImpl & _shapeImpl)187 ShapeSizeProvider( const SvxShapeImpl& _shapeImpl )
188 :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Size" )
189 {
190 }
191
192 protected:
getCurrentValue(Any & _out_rCurrentValue) const193 virtual void getCurrentValue( Any& _out_rCurrentValue ) const
194 {
195 _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getSize();
196 }
197 };
198
199 /***********************************************************************
200 * class SvxShape *
201 ***********************************************************************/
202
DBG_NAME(SvxShape)203 DBG_NAME(SvxShape)
204
205 SvxShape::SvxShape( SdrObject* pObject ) throw()
206 : maSize(100,100)
207 , mpImpl( new SvxShapeImpl( *this, maMutex ) )
208 , mbIsMultiPropertyCall(false)
209 , mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
210 , maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE))
211 , mpObj(pObject)
212 , mpModel(NULL)
213 , mnLockCount(0)
214 {
215 DBG_CTOR(SvxShape,NULL);
216 impl_construct();
217 }
218
219 //----------------------------------------------------------------------
SvxShape(SdrObject * pObject,const SfxItemPropertyMapEntry * pEntries,const SvxItemPropertySet * pPropertySet)220 SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet ) throw()
221 : maSize(100,100)
222 , mpImpl( new SvxShapeImpl( *this, maMutex ) )
223 , mbIsMultiPropertyCall(false)
224 , mpPropSet(pPropertySet)
225 , maPropMapEntries(pEntries)
226 , mpObj(pObject)
227 , mpModel(NULL)
228 , mnLockCount(0)
229 {
230 DBG_CTOR(SvxShape,NULL);
231 impl_construct();
232 }
233
234 //----------------------------------------------------------------------
SvxShape()235 SvxShape::SvxShape() throw()
236 : maSize(100,100)
237 , mpImpl( new SvxShapeImpl( *this, maMutex ) )
238 , mbIsMultiPropertyCall(false)
239 , mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
240 , maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE))
241 , mpObj(NULL)
242 , mpModel(NULL)
243 , mnLockCount(0)
244 {
245 DBG_CTOR(SvxShape,NULL);
246 impl_construct();
247 }
248
249 //----------------------------------------------------------------------
~SvxShape()250 SvxShape::~SvxShape() throw()
251 {
252 OGuard aGuard( Application::GetSolarMutex() );
253
254 DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" );
255
256 if ( mpModel )
257 EndListening( *mpModel );
258
259 if ( mpImpl->mpMaster )
260 mpImpl->mpMaster->dispose();
261
262 if ( mpObj.is() )
263 mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
264
265 if( HasSdrObjectOwnership() && mpObj.is() )
266 {
267 mpImpl->mbHasSdrObjectOwnership = false;
268 SdrObject* pObject = mpObj.get();
269 SdrObject::Free( pObject );
270 }
271
272 delete mpImpl, mpImpl = NULL;
273
274 DBG_DTOR(SvxShape,NULL);
275 }
276
277 //----------------------------------------------------------------------
278
TakeSdrObjectOwnership()279 void SvxShape::TakeSdrObjectOwnership()
280 {
281 mpImpl->mbHasSdrObjectOwnership = true;
282 }
283
284 //----------------------------------------------------------------------
285
HasSdrObjectOwnership() const286 bool SvxShape::HasSdrObjectOwnership() const
287 {
288 if ( !mpImpl->mbHasSdrObjectOwnership )
289 return false;
290
291 OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
292 return mpObj.is();
293 }
294
295 //----------------------------------------------------------------------
296
setShapeKind(sal_uInt32 nKind)297 void SvxShape::setShapeKind( sal_uInt32 nKind )
298 {
299 mpImpl->mnObjId = nKind;
300 }
301
302 //----------------------------------------------------------------------
303
getShapeKind() const304 sal_uInt32 SvxShape::getShapeKind() const
305 {
306 return mpImpl->mnObjId;
307 }
308
309 //----------------------------------------------------------------------
310
setMaster(SvxShapeMaster * pMaster)311 void SvxShape::setMaster( SvxShapeMaster* pMaster )
312 {
313 mpImpl->mpMaster = pMaster;
314 }
315
getMaster()316 SvxShapeMaster* SvxShape::getMaster()
317 {
318 return mpImpl->mpMaster;
319 }
320
getMaster() const321 const SvxShapeMaster* SvxShape::getMaster() const
322 {
323 return mpImpl->mpMaster;
324 }
325
326 //----------------------------------------------------------------------
327
queryAggregation(const uno::Type & rType)328 uno::Any SAL_CALL SvxShape::queryAggregation( const uno::Type& rType )
329 {
330 if( mpImpl->mpMaster )
331 {
332 uno::Any aAny;
333 if( mpImpl->mpMaster->queryAggregation( rType, aAny ) )
334 return aAny;
335 }
336
337 return SvxShape_UnoImplHelper::queryAggregation(rType);
338 }
339
340 //----------------------------------------------------------------------
getUnoTunnelId()341 const ::com::sun::star::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() throw()
342 {
343 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
344 if( !pSeq )
345 {
346 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
347 if( !pSeq )
348 {
349 static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
350 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
351 pSeq = &aSeq;
352 }
353 }
354 return *pSeq;
355 }
356
357 //----------------------------------------------------------------------
getImplementation(const uno::Reference<uno::XInterface> & xInt)358 SvxShape* SvxShape::getImplementation( const uno::Reference< uno::XInterface >& xInt )
359 {
360 uno::Reference< lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY );
361 if( xUT.is() )
362 return reinterpret_cast<SvxShape*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxShape::getUnoTunnelId())));
363 else
364 return NULL;
365 }
366
367 //----------------------------------------------------------------------
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rId)368 sal_Int64 SAL_CALL SvxShape::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) \
369 {
370 if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) )
371 {
372 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
373 }
374 else
375 {
376 return 0;
377 }
378 }
379
380 //----------------------------------------------------------------------
GetShapeForSdrObj(SdrObject * pObj)381 SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw()
382 {
383 return getImplementation( pObj->getUnoShape() );
384 }
385
386 //----------------------------------------------------------------------
getShapePropertyChangeNotifier()387 ::svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier()
388 {
389 return mpImpl->maPropertyNotifier;
390 }
391
392 //----------------------------------------------------------------------
impl_construct()393 void SvxShape::impl_construct()
394 {
395 mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapePosition,
396 ::svx::PPropertyValueProvider( new ShapePositionProvider( *mpImpl ) ) );
397 mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapeSize,
398 ::svx::PPropertyValueProvider( new ShapeSizeProvider( *mpImpl ) ) );
399
400 if ( mpObj.is() )
401 impl_initFromSdrObject();
402 }
403
404 //----------------------------------------------------------------------
impl_initFromSdrObject()405 void SvxShape::impl_initFromSdrObject()
406 {
407 DBG_TESTSOLARMUTEX();
408 OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
409 if ( !mpObj.is() )
410 return;
411
412 osl_incrementInterlockedCount( &m_refCount );
413 {
414 mpObj->setUnoShape( *this, SdrObject::GrantXShapeAccess() );
415 }
416 osl_decrementInterlockedCount( &m_refCount );
417
418 mpModel = mpObj->GetModel();
419
420 // #i40944#
421 // Do not simply return when no model but do the type corrections
422 // following below.
423 if(mpModel)
424 {
425 StartListening( *mpModel );
426 }
427
428 const sal_uInt32 nInventor = mpObj->GetObjInventor();
429
430 // is it one of ours (svx) ?
431 if( nInventor == SdrInventor || nInventor == E3dInventor || nInventor == FmFormInventor )
432 {
433 if(nInventor == FmFormInventor)
434 {
435 mpImpl->mnObjId = OBJ_UNO;
436 }
437 else
438 {
439 mpImpl->mnObjId = mpObj->GetObjIdentifier();
440 if( nInventor == E3dInventor )
441 mpImpl->mnObjId |= E3D_INVENTOR_FLAG;
442 }
443
444 switch(mpImpl->mnObjId)
445 {
446 case OBJ_CCUT: // Kreisabschnitt
447 case OBJ_CARC: // Kreisbogen
448 case OBJ_SECT: // Kreissektor
449 mpImpl->mnObjId = OBJ_CIRC;
450 break;
451
452 case E3D_SCENE_ID | E3D_INVENTOR_FLAG:
453 mpImpl->mnObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG;
454 break;
455 }
456 }
457 }
458
459 //----------------------------------------------------------------------
Create(SdrObject * pNewObj,SvxDrawPage *)460 void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
461 {
462 DBG_TESTSOLARMUTEX();
463
464 OSL_PRECOND( pNewObj, "SvxShape::Create: invalid new object!" );
465 if ( !pNewObj )
466 return;
467
468 SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get();
469 OSL_ENSURE( ( pCreatedObj == NULL ) || ( pCreatedObj == pNewObj ),
470 "SvxShape::Create: the same shape used for two different objects?! Strange ..." );
471
472 // --> CL, OD 2005-07-19 #i52126# - correct condition
473 if ( pCreatedObj != pNewObj )
474 // <--
475 {
476 DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" );
477 // --> CL, OD 2005-07-19 #i52126#
478 mpImpl->mpCreatedObj = pNewObj;
479 // <--
480
481 if( mpObj.is() && mpObj->GetModel() )
482 {
483 EndListening( *mpObj->GetModel() );
484 }
485
486 mpObj.reset( pNewObj );
487
488 OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" );
489 // this was previously set in impl_initFromSdrObject, but I think it was superfluous
490 // (it definitely was in the other context where it was called, but I strongly suppose
491 // it was also superfluous when called from here)
492 impl_initFromSdrObject();
493
494 ObtainSettingsFromPropertySet( *mpPropSet );
495
496 // save user call
497 SdrObjUserCall* pUser = mpObj->GetUserCall();
498 mpObj->SetUserCall(NULL);
499
500 setPosition( maPosition );
501 setSize( maSize );
502
503 // restore user call after we set the initial size
504 mpObj->SetUserCall( pUser );
505
506 // if this shape was already named, use this name
507 if( maShapeName.getLength() )
508 {
509 mpObj->SetName( maShapeName );
510 maShapeName = OUString();
511 }
512 }
513 }
514
515 //----------------------------------------------------------------------
516
ChangeModel(SdrModel * pNewModel)517 void SvxShape::ChangeModel( SdrModel* pNewModel )
518 {
519 DBG_TESTSOLARMUTEX();
520 if( mpObj.is() && mpObj->GetModel() )
521 {
522 if( mpObj->GetModel() != pNewModel )
523 {
524 EndListening( *mpObj->GetModel() );
525 }
526 }
527
528 // --> CL, OD 2005-07-19 #i52126# - always listen to new model
529 if( pNewModel )
530 {
531 StartListening( *pNewModel );
532 }
533 // <--
534
535 // HACK #i53696# ChangeModel should be virtual, but it isn't. can't change that for 2.0.1
536 SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( this );
537 if( pShapeText )
538 {
539 SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() );
540 if( pTextEditSource )
541 pTextEditSource->ChangeModel( pNewModel );
542 }
543
544 mpModel = pNewModel;
545
546 if( mpImpl->mpMaster )
547 mpImpl->mpMaster->modelChanged( pNewModel );
548 }
549
550 //----------------------------------------------------------------------
551
ForceMetricToItemPoolMetric(Pair & rPoint) const552 void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
553 {
554 DBG_TESTSOLARMUTEX();
555 if(mpModel)
556 {
557 SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
558 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
559 {
560 switch(eMapUnit)
561 {
562 case SFX_MAPUNIT_TWIP :
563 {
564 rPoint.A() = MM_TO_TWIPS(rPoint.A());
565 rPoint.B() = MM_TO_TWIPS(rPoint.B());
566 break;
567 }
568 default:
569 {
570 DBG_ERROR("AW: Missing unit translation to PoolMetric!");
571 }
572 }
573 }
574 }
575 }
576
577 //----------------------------------------------------------------------
578 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon & rPolyPolygon) const579 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
580 {
581 DBG_TESTSOLARMUTEX();
582 if(mpModel)
583 {
584 SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
585 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
586 {
587 switch(eMapUnit)
588 {
589 case SFX_MAPUNIT_TWIP :
590 {
591 basegfx::B2DHomMatrix aTransform;
592 const double fMMToTWIPS(72.0 / 127.0);
593
594 aTransform.scale(fMMToTWIPS, fMMToTWIPS);
595 rPolyPolygon.transform(aTransform);
596 break;
597 }
598 default:
599 {
600 DBG_ERROR("Missing unit translation to PoolMetric!");
601 }
602 }
603 }
604 }
605 }
606 // <--
607
608 //----------------------------------------------------------------------
ForceMetricTo100th_mm(Pair & rPoint) const609 void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
610 {
611 DBG_TESTSOLARMUTEX();
612 SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM;
613 if(mpModel)
614 {
615 eMapUnit = mpModel->GetItemPool().GetMetric(0);
616 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
617 {
618 switch(eMapUnit)
619 {
620 case SFX_MAPUNIT_TWIP :
621 {
622 rPoint.A() = TWIPS_TO_MM(rPoint.A());
623 rPoint.B() = TWIPS_TO_MM(rPoint.B());
624 break;
625 }
626 default:
627 {
628 DBG_ERROR("AW: Missing unit translation to 100th mm!");
629 }
630 }
631 }
632 }
633 }
634
635 //----------------------------------------------------------------------
636 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
ForceMetricTo100th_mm(basegfx::B2DPolyPolygon & rPolyPolygon) const637 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
638 {
639 DBG_TESTSOLARMUTEX();
640 SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM;
641 if(mpModel)
642 {
643 eMapUnit = mpModel->GetItemPool().GetMetric(0);
644 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
645 {
646 switch(eMapUnit)
647 {
648 case SFX_MAPUNIT_TWIP :
649 {
650 basegfx::B2DHomMatrix aTransform;
651 const double fTWIPSToMM(127.0 / 72.0);
652 aTransform.scale(fTWIPSToMM, fTWIPSToMM);
653 rPolyPolygon.transform(aTransform);
654 break;
655 }
656 default:
657 {
658 DBG_ERROR("Missing unit translation to 100th mm!");
659 }
660 }
661 }
662 }
663 }
664 // <--
665 //----------------------------------------------------------------------
666
667
668 //----------------------------------------------------------------------
SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet & rPropSet,SfxItemSet & rSet,uno::Reference<beans::XPropertySet> xSet,const SfxItemPropertyMap * pMap)669 void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet,
670 SfxItemSet& rSet, uno::Reference< beans::XPropertySet > xSet, const SfxItemPropertyMap* pMap )
671 {
672 if(rPropSet.AreThereOwnUsrAnys())
673 {
674 const SfxItemPropertyMap* pSrc = rPropSet.getPropertyMap();
675 PropertyEntryVector_t aSrcPropVector = pSrc->getPropertyEntries();
676 PropertyEntryVector_t::const_iterator aSrcIt = aSrcPropVector.begin();
677 while(aSrcIt != aSrcPropVector.end())
678 {
679 if(aSrcIt->nWID)
680 {
681 uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(aSrcIt->nWID);
682 if(pUsrAny)
683 {
684 // Aequivalenten Eintrag in pDst suchen
685 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aSrcIt->sName );
686 if(pEntry)
687 {
688 // entry found
689 if((pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END) || pEntry->nWID == OWN_ATTR_MISC_OBJ_DECORATIVE)
690 {
691 // Special ID im PropertySet, kann nur direkt am
692 // Objekt gesetzt werden+
693 xSet->setPropertyValue( aSrcIt->sName, *pUsrAny);
694 }
695 else
696 {
697 if(rSet.GetPool()->IsWhich(pEntry->nWID))
698 rSet.Put(rSet.GetPool()->GetDefaultItem(pEntry->nWID));
699 // setzen
700 SvxItemPropertySet_setPropertyValue(rPropSet, pEntry, *pUsrAny, rSet);
701 }
702 }
703 }
704 }
705
706 // next entry
707 ++aSrcIt;
708 }
709 const_cast< SvxItemPropertySet& >(rPropSet).ClearAllUsrAny();
710 }
711 }
712
713
ObtainSettingsFromPropertySet(const SvxItemPropertySet & rPropSet)714 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet)
715 {
716 DBG_TESTSOLARMUTEX();
717 if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel)
718 {
719 SfxItemSet aSet( mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END, 0);
720 Reference< beans::XPropertySet > xShape( (OWeakObject*)this, UNO_QUERY );
721 SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, mpPropSet->getPropertyMap() );
722
723 mpObj->SetMergedItemSetAndBroadcast(aSet);
724
725 mpObj->ApplyNotPersistAttr( aSet );
726 }
727 }
728
729 //----------------------------------------------------------------------
730
GetBitmap(sal_Bool bMetaFile) const731 uno::Any SvxShape::GetBitmap( sal_Bool bMetaFile /* = sal_False */ ) const throw()
732 {
733 DBG_TESTSOLARMUTEX();
734 uno::Any aAny;
735
736 if( !mpObj.is() || mpModel == NULL || !mpObj->IsInserted() || NULL == mpObj->GetPage() )
737 return aAny;
738
739 VirtualDevice aVDev;
740 aVDev.SetMapMode(MapMode(MAP_100TH_MM));
741
742 SdrModel* pModel = mpObj->GetModel();
743 SdrPage* pPage = mpObj->GetPage();
744
745 E3dView* pView = new E3dView( pModel, &aVDev );
746 pView->hideMarkHandles();
747 SdrPageView* pPageView = pView->ShowSdrPage(pPage);
748
749 SdrObject *pTempObj = mpObj.get();
750 pView->MarkObj(pTempObj,pPageView);
751
752 Rectangle aRect(pTempObj->GetCurrentBoundRect());
753 aRect.Justify();
754 Size aSize(aRect.GetSize());
755
756 GDIMetaFile aMtf( pView->GetMarkedObjMetaFile() );
757 if( bMetaFile )
758 {
759 SvMemoryStream aDestStrm( 65535, 65535 );
760 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
761 const uno::Sequence<sal_Int8> aSeq(
762 static_cast< const sal_Int8* >(aDestStrm.GetData()),
763 aDestStrm.GetEndOfData());
764 aAny.setValue( &aSeq, ::getCppuType((const uno::Sequence< sal_Int8 >*)0) );
765 }
766 else
767 {
768 Graphic aGraph(aMtf);
769 aGraph.SetPrefSize(aSize);
770 aGraph.SetPrefMapMode(MAP_100TH_MM);
771
772 Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY );
773 aAny <<= xBmp;
774 }
775
776 pView->UnmarkAll();
777 delete pView;
778
779 return aAny;
780 }
781
782 //----------------------------------------------------------------------
783
getTypes()784 uno::Sequence< uno::Type > SAL_CALL SvxShape::getTypes()
785 {
786 if( mpImpl->mpMaster )
787 {
788 return mpImpl->mpMaster->getTypes();
789 }
790 else
791 {
792 return _getTypes();
793 }
794 }
795
796 //----------------------------------------------------------------------
797
_getTypes()798 uno::Sequence< uno::Type > SAL_CALL SvxShape::_getTypes()
799 {
800 switch( mpImpl->mnObjId )
801 {
802 // shapes without text
803 case OBJ_PAGE:
804 case OBJ_FRAME:
805 case OBJ_OLE2_PLUGIN:
806 case OBJ_OLE2_APPLET:
807 case E3D_CUBEOBJ_ID|E3D_INVENTOR_FLAG:
808 case E3D_SPHEREOBJ_ID|E3D_INVENTOR_FLAG:
809 case E3D_LATHEOBJ_ID|E3D_INVENTOR_FLAG:
810 case E3D_EXTRUDEOBJ_ID|E3D_INVENTOR_FLAG:
811 case E3D_POLYGONOBJ_ID|E3D_INVENTOR_FLAG:
812 case OBJ_MEDIA:
813 {
814 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
815
816 if( aTypeSequence.getLength() == 0 )
817 {
818 // Ready for multithreading; get global mutex for first call of this method only! see before
819 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
820
821 // Control these pointer again ... it can be, that another instance will be faster then these!
822 if( aTypeSequence.getLength() == 0 )
823 {
824 aTypeSequence.realloc( 12 );
825 uno::Type* pTypes = aTypeSequence.getArray();
826
827 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
828 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
829 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
830 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
831 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
832 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
833 *pTypes++ = beans::XMultiPropertyStates::static_type();
834 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
835 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
836 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
837 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
838 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
839 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
840 }
841 }
842 return aTypeSequence;
843 }
844 // group shape
845 case OBJ_GRUP:
846 {
847 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
848
849 if( aTypeSequence.getLength() == 0 )
850 {
851 // Ready for multithreading; get global mutex for first call of this method only! see before
852 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
853
854 // Control these pointer again ... it can be, that another instance will be faster then these!
855 if( aTypeSequence.getLength() == 0 )
856 {
857 aTypeSequence.realloc( 14 );
858 uno::Type* pTypes = aTypeSequence.getArray();
859
860 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
861 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
862 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
863 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
864 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
865 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
866 *pTypes++ = beans::XMultiPropertyStates::static_type();
867 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
868 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
869 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
870 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
871 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
872 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
873 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0);
874 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapeGroup>*)0);
875 }
876 }
877 return aTypeSequence;
878 }
879 // connector shape
880 case OBJ_EDGE:
881 {
882 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
883
884 if( aTypeSequence.getLength() == 0 )
885 {
886 // Ready for multithreading; get global mutex for first call of this method only! see before
887 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
888
889 // Control these pointer again ... it can be, that another instance will be faster then these!
890 if( aTypeSequence.getLength() == 0 )
891 {
892 aTypeSequence.realloc( 17 );
893 uno::Type* pTypes = aTypeSequence.getArray();
894
895 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
896 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
897 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
898 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
899 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
900 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
901 *pTypes++ = beans::XMultiPropertyStates::static_type();
902 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
903 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
904 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
905 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
906 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
907 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
908 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XConnectorShape>*)0);
909 // from SvxUnoTextBase::getTypes()
910 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
911 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
912 *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
913 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
914 }
915 }
916 return aTypeSequence;
917 }
918 // control shape
919 case OBJ_UNO:
920 {
921 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
922
923 if( aTypeSequence.getLength() == 0 )
924 {
925 // Ready for multithreading; get global mutex for first call of this method only! see before
926 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
927
928 // Control these pointer again ... it can be, that another instance will be faster then these!
929 if( aTypeSequence.getLength() == 0 )
930 {
931 aTypeSequence.realloc( 13 );
932 uno::Type* pTypes = aTypeSequence.getArray();
933
934 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
935 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
936 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
937 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
938 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
939 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
940 *pTypes++ = beans::XMultiPropertyStates::static_type();
941 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
942 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
943 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
944 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
945 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
946 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
947 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XControlShape>*)0);
948 }
949 }
950 return aTypeSequence;
951 }
952 // 3d scene shape
953 case E3D_POLYSCENE_ID|E3D_INVENTOR_FLAG:
954 {
955 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
956
957 if( aTypeSequence.getLength() == 0 )
958 {
959 // Ready for multithreading; get global mutex for first call of this method only! see before
960 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
961
962 // Control these pointer again ... it can be, that another instance will be faster then these!
963 if( aTypeSequence.getLength() == 0 )
964 {
965 aTypeSequence.realloc( 13 );
966 uno::Type* pTypes = aTypeSequence.getArray();
967
968 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
969 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
970 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
971 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
972 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
973 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
974 *pTypes++ = beans::XMultiPropertyStates::static_type();
975 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
976 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
977 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
978 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
979 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
980 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
981 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0);
982 }
983 }
984 return aTypeSequence;
985 }
986 case OBJ_CUSTOMSHAPE:
987 {
988 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
989
990 if( aTypeSequence.getLength() == 0 )
991 {
992 // Ready for multithreading; get global mutex for first call of this method only! see before
993 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
994
995 // Control these pointer again ... it can be, that another instance will be faster then these!
996 if( aTypeSequence.getLength() == 0 )
997 {
998 aTypeSequence.realloc( 16 );
999 uno::Type* pTypes = aTypeSequence.getArray();
1000
1001 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
1002 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
1003 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1004 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
1005 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
1006 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
1007 *pTypes++ = beans::XMultiPropertyStates::static_type();
1008 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
1009 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
1010 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
1011 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
1012 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
1013 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
1014 // from SvxUnoTextBase::getTypes()
1015 *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0);
1016 *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
1017 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
1018 *pTypes++ = ::getCppuType(( const uno::Reference< drawing::XEnhancedCustomShapeDefaulter >*)0);
1019 }
1020 }
1021 return aTypeSequence;
1022 }
1023 // shapes with text
1024 case OBJ_RECT:
1025 case OBJ_CIRC:
1026 case OBJ_MEASURE:
1027 case OBJ_LINE:
1028 case OBJ_POLY:
1029 case OBJ_PLIN:
1030 case OBJ_PATHLINE:
1031 case OBJ_PATHFILL:
1032 case OBJ_FREELINE:
1033 case OBJ_FREEFILL:
1034 case OBJ_PATHPOLY:
1035 case OBJ_PATHPLIN:
1036 case OBJ_GRAF:
1037 case OBJ_TEXT:
1038 case OBJ_CAPTION:
1039 case OBJ_TABLE:
1040 case OBJ_OLE2: // #i118485# Moved to shapes with text, was at (shapes without text) before, see above
1041 default:
1042 {
1043 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
1044
1045 if( aTypeSequence.getLength() == 0 )
1046 {
1047 // Ready for multithreading; get global mutex for first call of this method only! see before
1048 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
1049
1050 // Control these pointer again ... it can be, that another instance will be faster then these!
1051 if( aTypeSequence.getLength() == 0 )
1052 {
1053 aTypeSequence.realloc( 16 );
1054 uno::Type* pTypes = aTypeSequence.getArray();
1055
1056 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
1057 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
1058 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
1059 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
1060 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
1061 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
1062 *pTypes++ = beans::XMultiPropertyStates::static_type();
1063 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
1064 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
1065 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
1066 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
1067 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
1068 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
1069 // from SvxUnoTextBase::getTypes()
1070 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
1071 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
1072 *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
1073 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
1074 }
1075 }
1076 return aTypeSequence;
1077 }
1078 }
1079 }
1080
1081 //----------------------------------------------------------------------
1082
getImplementationId()1083 uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
1084 {
1085 static ::cppu::OImplementationId* pID = NULL ;
1086
1087 if ( pID == NULL )
1088 {
1089 // Ready for multithreading; get global mutex for first call of this method only! see before
1090 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
1091
1092 // Control these pointer again ... it can be, that another instance will be faster then these!
1093 if ( pID == NULL )
1094 {
1095 // Create a new static ID ...
1096 static ::cppu::OImplementationId aID( sal_False ) ;
1097 // ... and set his address to static pointer!
1098 pID = &aID ;
1099 }
1100 }
1101
1102 return pID->getImplementationId() ;
1103 }
1104
1105 //----------------------------------------------------------------------
1106
SvxShape_NewInstance()1107 Reference< uno::XInterface > SvxShape_NewInstance()
1108 {
1109 return uno::Reference< uno::XInterface >(static_cast< OWeakObject* >( new SvxShape() ) );
1110 }
1111
1112 //----------------------------------------------------------------------
1113
onUserCall(SdrUserCallType,const Rectangle &)1114 void SvxShape::onUserCall(SdrUserCallType /*_eUserCall*/, const Rectangle& /*_rNewBoundRect*/ )
1115 {
1116 // obsolete, not called anymore
1117 }
1118
1119 //----------------------------------------------------------------------
1120 // SfxListener
1121 //----------------------------------------------------------------------
1122
Notify(SfxBroadcaster &,const SfxHint & rHint)1123 void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
1124 {
1125 DBG_TESTSOLARMUTEX();
1126 if( !mpObj.is() )
1127 return;
1128
1129 // #i55919# HINT_OBJCHG is only interesting if it's for this object
1130
1131 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
1132 if (!pSdrHint || ( /* (pSdrHint->GetKind() != HINT_OBJREMOVED) && */
1133 (pSdrHint->GetKind() != HINT_MODELCLEARED) &&
1134 // #110094#-9 (pSdrHint->GetKind() != HINT_OBJLISTCLEAR) &&
1135 ((pSdrHint->GetKind() != HINT_OBJCHG || pSdrHint->GetObject() != mpObj.get() ))))
1136 return;
1137
1138 uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() );
1139 if( !xSelf.is() )
1140 {
1141 mpObj.reset( NULL );
1142 return;
1143 }
1144
1145 sal_Bool bClearMe = sal_False;
1146
1147 switch( pSdrHint->GetKind() )
1148 {
1149 case HINT_OBJCHG:
1150 {
1151 updateShapeKind();
1152 break;
1153 }
1154 case HINT_MODELCLEARED:
1155 {
1156 bClearMe = sal_True;
1157 mpModel = NULL;
1158 break;
1159 }
1160 default:
1161 break;
1162 };
1163
1164 if( bClearMe )
1165 {
1166 if( !HasSdrObjectOwnership() )
1167 mpObj.reset( NULL );
1168 if ( !mpImpl->mbDisposing )
1169 dispose();
1170 }
1171 }
1172
1173 // XShape
1174
1175 //----------------------------------------------------------------------
1176 // The "*LogicRectHack" functions also existed in sch, and those
1177 // duplicate symbols cause Bad Things To Happen (TM) #i9462#.
1178 // Prefixing with 'svx' and marking static to make sure name collisions
1179 // do not occur.
1180
svx_needLogicRectHack(SdrObject * pObj)1181 static sal_Bool svx_needLogicRectHack( SdrObject* pObj )
1182 {
1183 if( pObj->GetObjInventor() == SdrInventor)
1184 {
1185 switch(pObj->GetObjIdentifier())
1186 {
1187 case OBJ_GRUP:
1188 case OBJ_LINE:
1189 case OBJ_POLY:
1190 case OBJ_PLIN:
1191 case OBJ_PATHLINE:
1192 case OBJ_PATHFILL:
1193 case OBJ_FREELINE:
1194 case OBJ_FREEFILL:
1195 case OBJ_SPLNLINE:
1196 case OBJ_SPLNFILL:
1197 case OBJ_EDGE:
1198 case OBJ_PATHPOLY:
1199 case OBJ_PATHPLIN:
1200 case OBJ_MEASURE:
1201 return sal_True;
1202 }
1203 }
1204 return sal_False;
1205 }
1206
1207 //----------------------------------------------------------------------
1208
svx_getLogicRectHack(SdrObject * pObj)1209 static Rectangle svx_getLogicRectHack( SdrObject* pObj )
1210 {
1211 if(svx_needLogicRectHack(pObj))
1212 {
1213 return pObj->GetSnapRect();
1214 }
1215 else
1216 {
1217 return pObj->GetLogicRect();
1218 }
1219 }
1220
1221 //----------------------------------------------------------------------
1222
svx_setLogicRectHack(SdrObject * pObj,const Rectangle & rRect)1223 static void svx_setLogicRectHack( SdrObject* pObj, const Rectangle& rRect )
1224 {
1225 if(svx_needLogicRectHack(pObj))
1226 {
1227 pObj->SetSnapRect( rRect );
1228 }
1229 else
1230 {
1231 pObj->SetLogicRect( rRect );
1232 }
1233 }
1234
1235 //----------------------------------------------------------------------
1236
getPosition()1237 awt::Point SAL_CALL SvxShape::getPosition()
1238 {
1239 OGuard aGuard( Application::GetSolarMutex() );
1240
1241 if( mpObj.is() && mpModel)
1242 {
1243 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
1244 Point aPt( aRect.Left(), aRect.Top() );
1245
1246 // Position is relativ to anchor, so recalc to absolut position
1247 if( mpModel->IsWriter() )
1248 aPt -= mpObj->GetAnchorPos();
1249
1250 ForceMetricTo100th_mm(aPt);
1251 return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
1252 }
1253 else
1254 {
1255 return maPosition;
1256 }
1257 }
1258
1259 //----------------------------------------------------------------------
setPosition(const awt::Point & Position)1260 void SAL_CALL SvxShape::setPosition( const awt::Point& Position )
1261 {
1262 OGuard aGuard( Application::GetSolarMutex() );
1263
1264 if( mpObj.is() && mpModel )
1265 {
1266 // do NOT move 3D objects, this would change the homogen
1267 // transformation matrix
1268 if(!mpObj->ISA(E3dCompoundObject))
1269 {
1270 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
1271 Point aLocalPos( Position.X, Position.Y );
1272 ForceMetricToItemPoolMetric(aLocalPos);
1273
1274 // Position ist absolut, relativ zum Anker stellen
1275 if( mpModel->IsWriter() )
1276 aLocalPos += mpObj->GetAnchorPos();
1277
1278 long nDX = aLocalPos.X() - aRect.Left();
1279 long nDY = aLocalPos.Y() - aRect.Top();
1280
1281 mpObj->Move( Size( nDX, nDY ) );
1282 mpModel->SetChanged();
1283 }
1284 }
1285
1286 maPosition = Position;
1287 }
1288
1289 //----------------------------------------------------------------------
getSize()1290 awt::Size SAL_CALL SvxShape::getSize()
1291 {
1292 OGuard aGuard( Application::GetSolarMutex() );
1293
1294 if( mpObj.is() && mpModel)
1295 {
1296 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
1297 Size aObjSize( aRect.getWidth(), aRect.getHeight() );
1298 ForceMetricTo100th_mm(aObjSize);
1299 return ::com::sun::star::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() );
1300 }
1301 else
1302 return maSize;
1303 }
1304
1305 //----------------------------------------------------------------------
setSize(const awt::Size & rSize)1306 void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
1307 {
1308 OGuard aGuard( Application::GetSolarMutex() );
1309
1310 if( mpObj.is() && mpModel)
1311 {
1312 // #123539# optimization for 3D chart object generation: do not use UNO
1313 // API commands to get the range, this is too expensive since for 3D
1314 // scenes it may recalculate the whole scene since in AOO this depends
1315 // on the contained geometry (layouted to show all content)
1316 const bool b3DConstruction(dynamic_cast< E3dObject* >(mpObj.get()) && mpModel->isLocked());
1317 Rectangle aRect(
1318 b3DConstruction ?
1319 Rectangle(maPosition.X, maPosition.Y, maSize.Width, maSize.Height) :
1320 svx_getLogicRectHack(mpObj.get()) );
1321 Size aLocalSize( rSize.Width, rSize.Height );
1322 ForceMetricToItemPoolMetric(aLocalSize);
1323
1324 if(mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_MEASURE )
1325 {
1326 Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left());
1327 Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top());
1328 Point aPt = mpObj->GetSnapRect().TopLeft();
1329 mpObj->Resize(aPt,aWdt,aHgt);
1330 }
1331 else
1332 {
1333 //aRect.SetSize(aLocalSize); // this call substract 1 // http://www.openoffice.org/issues/show_bug.cgi?id=83193
1334 if ( !aLocalSize.Width() )
1335 {
1336 aRect.Right() = RECT_EMPTY;
1337 }
1338 else
1339 aRect.setWidth(aLocalSize.Width());
1340 if ( !aLocalSize.Height() )
1341 {
1342 aRect.Bottom() = RECT_EMPTY;
1343 }
1344 else
1345 aRect.setHeight(aLocalSize.Height());
1346
1347 svx_setLogicRectHack( mpObj.get(), aRect );
1348 }
1349
1350 mpModel->SetChanged();
1351 }
1352 maSize = rSize;
1353 }
1354
1355 //----------------------------------------------------------------------
1356
1357 // XNamed
getName()1358 OUString SAL_CALL SvxShape::getName( )
1359 {
1360 OGuard aGuard( Application::GetSolarMutex() );
1361 if( mpObj.is() )
1362 {
1363 return mpObj->GetName();
1364 }
1365 else
1366 {
1367 return maShapeName;
1368 }
1369 }
1370
1371 //----------------------------------------------------------------------
1372
setName(const::rtl::OUString & aName)1373 void SAL_CALL SvxShape::setName( const ::rtl::OUString& aName )
1374 {
1375 OGuard aGuard( Application::GetSolarMutex() );
1376 if( mpObj.is() )
1377 {
1378 mpObj->SetName( aName );
1379 }
1380 else
1381 {
1382 maShapeName = aName;
1383 }
1384 }
1385
1386 // XShapeDescriptor
1387
1388 //----------------------------------------------------------------------
getShapeType()1389 OUString SAL_CALL SvxShape::getShapeType()
1390 {
1391 if( 0 == maShapeType.getLength() )
1392 {
1393 UHashMapEntry* pMap = pSdrShapeIdentifierMap;
1394 while ( ( pMap->nId != mpImpl->mnObjId ) && pMap->aIdentifier.getLength() )
1395 ++pMap;
1396
1397 if ( pMap->aIdentifier.getLength() )
1398 {
1399 return pMap->aIdentifier;
1400 }
1401 else
1402 {
1403 DBG_ERROR("[CL] unknown SdrObjekt identifier");
1404 }
1405 }
1406
1407 return maShapeType;
1408 }
1409
1410 // XComponent
1411
1412 //----------------------------------------------------------------------
dispose()1413 void SAL_CALL SvxShape::dispose()
1414 {
1415 OGuard aGuard( Application::GetSolarMutex() );
1416
1417 if( mpImpl->mbDisposing )
1418 return; // caught a recursion
1419
1420 mpImpl->mbDisposing = true;
1421
1422 lang::EventObject aEvt;
1423 aEvt.Source = *(OWeakAggObject*) this;
1424 mpImpl->maDisposeListeners.disposeAndClear(aEvt);
1425 mpImpl->maPropertyNotifier.disposing();
1426
1427 if ( mpObj.is() )
1428 {
1429 bool bFreeSdrObject = false;
1430
1431 if ( mpObj->IsInserted() && mpObj->GetPage() )
1432 {
1433 OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" );
1434 // normally, we are allowed to free the SdrObject only if we have its ownership.
1435 // Why isn't this checked here?
1436
1437 SdrPage* pPage = mpObj->GetPage();
1438 // SdrObject aus der Page loeschen
1439 sal_uInt32 nCount = pPage->GetObjCount();
1440 for ( sal_uInt32 nNum = 0; nNum < nCount; ++nNum )
1441 {
1442 if ( pPage->GetObj( nNum ) == mpObj.get() )
1443 {
1444 OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() );
1445 bFreeSdrObject = true;
1446 break;
1447 }
1448 }
1449 }
1450
1451 mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
1452
1453 if ( bFreeSdrObject )
1454 {
1455 // in case we have the ownership of the SdrObject, a Free
1456 // would do nothing. So ensure the ownership is reset.
1457 mpImpl->mbHasSdrObjectOwnership = false;
1458 SdrObject* pObject = mpObj.get();
1459 SdrObject::Free( pObject );
1460 }
1461 }
1462
1463 if( mpModel )
1464 {
1465 EndListening( *mpModel );
1466 mpModel = NULL;
1467 }
1468 }
1469
1470 //----------------------------------------------------------------------
1471
addEventListener(const Reference<lang::XEventListener> & xListener)1472 void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener )
1473 {
1474 mpImpl->maDisposeListeners.addInterface(xListener);
1475 }
1476
1477 //----------------------------------------------------------------------
1478
removeEventListener(const Reference<lang::XEventListener> & aListener)1479 void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener )
1480 {
1481 mpImpl->maDisposeListeners.removeInterface(aListener);
1482 }
1483
1484 // XPropertySet
1485
1486 //----------------------------------------------------------------------
1487
1488 Reference< beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo()1489 SvxShape::getPropertySetInfo()
1490 {
1491 if( mpImpl->mpMaster )
1492 {
1493 return mpImpl->mpMaster->getPropertySetInfo();
1494 }
1495 else
1496 {
1497 return _getPropertySetInfo();
1498 }
1499 }
1500
1501 Reference< beans::XPropertySetInfo > SAL_CALL
_getPropertySetInfo()1502 SvxShape::_getPropertySetInfo()
1503 {
1504 return mpPropSet->getPropertySetInfo();
1505 }
1506
1507 //----------------------------------------------------------------------
1508
addPropertyChangeListener(const OUString & _propertyName,const Reference<beans::XPropertyChangeListener> & _listener)1509 void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener )
1510 {
1511 ::osl::MutexGuard aGuard( maMutex );
1512 mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener );
1513 }
1514
1515 //----------------------------------------------------------------------
1516
removePropertyChangeListener(const OUString & _propertyName,const Reference<beans::XPropertyChangeListener> & _listener)1517 void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener )
1518 {
1519 ::osl::MutexGuard aGuard( maMutex );
1520 mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener );
1521 }
1522
1523 //----------------------------------------------------------------------
1524
addVetoableChangeListener(const OUString &,const Reference<beans::XVetoableChangeListener> &)1525 void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& )
1526 {
1527 OSL_ENSURE( false, "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1528 }
1529
1530 //----------------------------------------------------------------------
1531
removeVetoableChangeListener(const OUString &,const Reference<beans::XVetoableChangeListener> &)1532 void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& )
1533 {
1534 OSL_ENSURE( false, "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1535 }
1536
1537 //----------------------------------------------------------------------
1538
SetFillAttribute(sal_Int32 nWID,const OUString & rName)1539 sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName )
1540 {
1541 SfxItemSet aSet( mpModel->GetItemPool(), (sal_uInt16)nWID, (sal_uInt16)nWID );
1542
1543 if( SetFillAttribute( nWID, rName, aSet, mpModel ) )
1544 {
1545 //mpObj->SetItemSetAndBroadcast(aSet);
1546 mpObj->SetMergedItemSetAndBroadcast(aSet);
1547
1548 return sal_True;
1549 }
1550 else
1551 {
1552 return sal_False;
1553 }
1554 }
1555
1556 //----------------------------------------------------------------------
1557
SetFillAttribute(sal_Int32 nWID,const::rtl::OUString & rName,SfxItemSet & rSet,SdrModel * pModel)1558 sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const ::rtl::OUString& rName, SfxItemSet& rSet, SdrModel* pModel )
1559 {
1560 // check if an item with the given name and which id is inside the models
1561 // pool or the stylesheet pool, if found its puttet in the itemse
1562 if( !SetFillAttribute( nWID, rName, rSet ) )
1563 {
1564 // we did not find such item in one of the pools, so we check
1565 // the property lists that are loaded for the model for items
1566 // that support such.
1567 String aStrName;
1568 SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aStrName );
1569
1570 switch( nWID )
1571 {
1572 case XATTR_FILLBITMAP:
1573 {
1574 XBitmapListSharedPtr aBitmapList = pModel->GetBitmapListFromSdrModel();
1575
1576 if( !aBitmapList.get() )
1577 return sal_False;
1578
1579 long nPos = aBitmapList->GetIndex(aStrName);
1580 if( nPos == -1 )
1581 return sal_False;
1582
1583 XBitmapEntry* pEntry = aBitmapList->GetBitmap( nPos );
1584 XFillBitmapItem aBmpItem;
1585 aBmpItem.SetWhich( XATTR_FILLBITMAP );
1586 aBmpItem.SetName( rName );
1587 aBmpItem.SetGraphicObject(pEntry->GetGraphicObject());
1588 rSet.Put( aBmpItem );
1589 break;
1590 }
1591 case XATTR_FILLGRADIENT:
1592 {
1593 XGradientListSharedPtr aGradientList = pModel->GetGradientListFromSdrModel();
1594
1595 if( !aGradientList.get() )
1596 return sal_False;
1597
1598 long nPos = aGradientList->GetIndex(aStrName);
1599 if( nPos == -1 )
1600 return sal_False;
1601
1602 XGradientEntry* pEntry = aGradientList->GetGradient( nPos );
1603 XFillGradientItem aGrdItem;
1604 aGrdItem.SetWhich( XATTR_FILLGRADIENT );
1605 aGrdItem.SetName( rName );
1606 aGrdItem.SetGradientValue( pEntry->GetGradient() );
1607 rSet.Put( aGrdItem );
1608 break;
1609 }
1610 case XATTR_FILLHATCH:
1611 {
1612 XHatchListSharedPtr aHatchList = pModel->GetHatchListFromSdrModel();
1613
1614 if( !aHatchList.get() )
1615 return sal_False;
1616
1617 long nPos = aHatchList->GetIndex(aStrName);
1618 if( nPos == -1 )
1619 return sal_False;
1620
1621 XHatchEntry* pEntry = aHatchList->GetHatch( nPos );
1622 XFillHatchItem aHatchItem;
1623 aHatchItem.SetWhich( XATTR_FILLHATCH );
1624 aHatchItem.SetName( rName );
1625 aHatchItem.SetHatchValue( pEntry->GetHatch() );
1626 rSet.Put( aHatchItem );
1627 break;
1628 }
1629 case XATTR_LINEEND:
1630 case XATTR_LINESTART:
1631 {
1632 XLineEndListSharedPtr aLineEndList = pModel->GetLineEndListFromSdrModel();
1633
1634 if( !aLineEndList.get() )
1635 return sal_False;
1636
1637 long nPos = aLineEndList->GetIndex(aStrName);
1638 if( nPos == -1 )
1639 return sal_False;
1640
1641 XLineEndEntry* pEntry = aLineEndList->GetLineEnd( nPos );
1642 if( XATTR_LINEEND == nWID )
1643 {
1644 XLineEndItem aLEItem;
1645 aLEItem.SetWhich( XATTR_LINEEND );
1646 aLEItem.SetName( rName );
1647 aLEItem.SetLineEndValue( pEntry->GetLineEnd() );
1648 rSet.Put( aLEItem );
1649 }
1650 else
1651 {
1652 XLineStartItem aLSItem;
1653 aLSItem.SetWhich( XATTR_LINESTART );
1654 aLSItem.SetName( rName );
1655 aLSItem.SetLineStartValue( pEntry->GetLineEnd() );
1656 rSet.Put( aLSItem );
1657 }
1658
1659 break;
1660 }
1661 case XATTR_LINEDASH:
1662 {
1663 XDashListSharedPtr aDashList = pModel->GetDashListFromSdrModel();
1664
1665 if( !aDashList.get() )
1666 return sal_False;
1667
1668 long nPos = aDashList->GetIndex(aStrName);
1669 if( nPos == -1 )
1670 return sal_False;
1671
1672 XDashEntry* pEntry = aDashList->GetDash( nPos );
1673 XLineDashItem aDashItem;
1674 aDashItem.SetWhich( XATTR_LINEDASH );
1675 aDashItem.SetName( rName );
1676 aDashItem.SetDashValue( pEntry->GetDash() );
1677 rSet.Put( aDashItem );
1678 break;
1679 }
1680 default:
1681 return sal_False;
1682 }
1683 }
1684
1685 return sal_True;
1686 }
1687
1688 //----------------------------------------------------------------------
1689
SetFillAttribute(sal_Int32 nWID,const OUString & rName,SfxItemSet & rSet)1690 sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, SfxItemSet& rSet )
1691 {
1692 String aName;
1693 SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aName );
1694
1695 if( aName.Len() == 0 )
1696 {
1697 switch( nWID )
1698 {
1699 case XATTR_LINEEND:
1700 case XATTR_LINESTART:
1701 {
1702 const String aEmpty;
1703 const basegfx::B2DPolyPolygon aEmptyPoly;
1704 if( nWID == XATTR_LINEEND )
1705 rSet.Put( XLineEndItem( aEmpty, aEmptyPoly ) );
1706 else
1707 rSet.Put( XLineStartItem( aEmpty, aEmptyPoly ) );
1708
1709 return sal_True;
1710 }
1711 case XATTR_FILLFLOATTRANSPARENCE:
1712 {
1713 // #85953# Set a disabled XFillFloatTransparenceItem
1714 rSet.Put(XFillFloatTransparenceItem());
1715
1716 return sal_True;
1717 }
1718 }
1719
1720 return sal_False;
1721 }
1722
1723 const SfxItemPool* pPool = rSet.GetPool();
1724
1725 const String aSearchName( aName );
1726 const sal_uInt32 nCount = pPool->GetItemCount2((sal_uInt16)nWID);
1727 const NameOrIndex* pItem;
1728
1729 for( sal_uInt32 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
1730 {
1731 pItem = (NameOrIndex*)pPool->GetItem2((sal_uInt16)nWID, nSurrogate);
1732 if( pItem && ( pItem->GetName() == aSearchName ) )
1733 {
1734 rSet.Put( *pItem );
1735 return sal_True;
1736 }
1737 }
1738
1739 return sal_False;
1740 }
1741
1742 //----------------------------------------------------------------------
1743
setPropertyValue(const OUString & rPropertyName,const uno::Any & rVal)1744 void SAL_CALL SvxShape::setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
1745 {
1746 if( mpImpl->mpMaster )
1747 {
1748 mpImpl->mpMaster->setPropertyValue( rPropertyName, rVal );
1749 }
1750 else
1751 {
1752 _setPropertyValue( rPropertyName, rVal );
1753 }
1754 }
1755
_setPropertyValue(const OUString & rPropertyName,const uno::Any & rVal)1756 void SAL_CALL SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
1757 {
1758 OGuard aGuard( Application::GetSolarMutex() );
1759
1760 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
1761
1762 if( mpObj.is() && mpModel )
1763 {
1764 if( pMap == NULL )
1765 throw beans::UnknownPropertyException();
1766
1767 if( (pMap->nFlags & beans::PropertyAttribute::READONLY ) != 0 )
1768 throw beans::PropertyVetoException();
1769
1770 mpModel->SetChanged();
1771
1772 if(!setPropertyValueImpl( rPropertyName, pMap, rVal ) )
1773 {
1774 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST, "Not persist item not handled!" );
1775 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
1776
1777 sal_Bool bIsNotPersist = pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST && pMap->nWID != SDRATTR_TEXTDIRECTION;
1778
1779 if( pMap->nWID == SDRATTR_ECKENRADIUS )
1780 {
1781 sal_Int32 nCornerRadius = 0;
1782 if( !(rVal >>= nCornerRadius) || (nCornerRadius < 0) || (nCornerRadius > 5000000))
1783 throw IllegalArgumentException();
1784 }
1785
1786 SfxItemSet* pSet;
1787 if( mbIsMultiPropertyCall && !bIsNotPersist )
1788 {
1789 if( mpImpl->mpItemSet == NULL )
1790 {
1791 pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone();
1792 }
1793 else
1794 {
1795 pSet = mpImpl->mpItemSet;
1796 }
1797 }
1798 else
1799 {
1800 pSet = new SfxItemSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
1801 }
1802
1803 if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET )
1804 pSet->Put(mpObj->GetMergedItem(pMap->nWID));
1805
1806 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( *pSet, pMap, rVal, *pSet ))
1807 {
1808 if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET )
1809 {
1810 if(bIsNotPersist)
1811 {
1812 // Not-Persistant Attribute, hole diese extra
1813 mpObj->TakeNotPersistAttr(*pSet, sal_False);
1814 }
1815 }
1816
1817 if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET )
1818 {
1819 // Default aus ItemPool holen
1820 if(mpModel->GetItemPool().IsWhich(pMap->nWID))
1821 pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
1822 }
1823
1824 if( pSet->GetItemState( pMap->nWID ) == SFX_ITEM_SET )
1825 {
1826 SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rVal, *pSet );
1827 }
1828 }
1829
1830 if(bIsNotPersist)
1831 {
1832 // Not-Persist Attribute extra setzen
1833 mpObj->ApplyNotPersistAttr( *pSet );
1834 delete pSet;
1835 }
1836 else
1837 {
1838 // if we have a XMultiProperty call then the item set
1839 // will be set in setPropertyValues later
1840 if( !mbIsMultiPropertyCall )
1841 {
1842 mpObj->SetMergedItemSetAndBroadcast( *pSet );
1843
1844 delete pSet;
1845 }
1846 }
1847 return;
1848 }
1849 }
1850 else
1851 {
1852 // since we have no actual sdr object right now
1853 // remember all properties in a list. These
1854 // properties will be set when the sdr object is
1855 // created
1856
1857 if(pMap && pMap->nWID)
1858 // Fixme: We should throw a UnknownPropertyException here.
1859 // But since this class is aggregated from classes
1860 // that support additional properties that we don't
1861 // know here we silently store *all* properties, even
1862 // if they may be not supported after creation
1863 mpPropSet->setPropertyValue( pMap, rVal );
1864 }
1865 }
1866
1867 //----------------------------------------------------------------------
1868
getPropertyValue(const OUString & PropertyName)1869 uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName )
1870 {
1871 if ( mpImpl->mpMaster )
1872 return mpImpl->mpMaster->getPropertyValue( PropertyName );
1873 else
1874 return _getPropertyValue( PropertyName );
1875 }
1876
1877 //----------------------------------------------------------------------
1878
_getPropertyValue(const OUString & PropertyName)1879 uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
1880 {
1881 OGuard aGuard( Application::GetSolarMutex() );
1882
1883 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1884
1885 uno::Any aAny;
1886 if( mpObj.is() && mpModel )
1887 {
1888 if(pMap == NULL )
1889 throw beans::UnknownPropertyException();
1890
1891 if( !getPropertyValueImpl( PropertyName, pMap, aAny ) )
1892 {
1893 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" );
1894 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
1895
1896 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
1897 aSet.Put(mpObj->GetMergedItem(pMap->nWID));
1898
1899 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
1900 return aAny;
1901
1902 if(!aSet.Count())
1903 {
1904 if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST)
1905 {
1906 // Not-Persistant Attribute, hole diese extra
1907 mpObj->TakeNotPersistAttr(aSet, sal_False);
1908 }
1909 }
1910
1911 if(!aSet.Count())
1912 {
1913 // Default aus ItemPool holen
1914 if(mpModel->GetItemPool().IsWhich(pMap->nWID))
1915 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
1916 }
1917
1918 if(aSet.Count())
1919 aAny = GetAnyForItem( aSet, pMap );
1920 }
1921 }
1922 else
1923 {
1924
1925 // Fixme: we should return default values for OWN_ATTR !
1926
1927 if(pMap && pMap->nWID)
1928 // FixMe: see setPropertyValue
1929 aAny = mpPropSet->getPropertyValue( pMap );
1930
1931 }
1932 return aAny;
1933 }
1934
1935 //----------------------------------------------------------------------
1936
1937 // XMultiPropertySet
setPropertyValues(const::com::sun::star::uno::Sequence<::rtl::OUString> & aPropertyNames,const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> & aValues)1938 void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
1939 {
1940 OGuard aSolarGuard( Application::GetSolarMutex() );
1941
1942 const sal_Int32 nCount = aPropertyNames.getLength();
1943 const OUString* pNames = aPropertyNames.getConstArray();
1944
1945 const uno::Any* pValues = aValues.getConstArray();
1946
1947 // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
1948 // reseted even when an exception is thrown
1949 const ::comphelper::ScopeGuard aGuard( boost::bind( &SvxShape::endSetPropertyValues, this ) );
1950
1951 mbIsMultiPropertyCall = sal_True;
1952
1953 if( mpImpl->mpMaster )
1954 {
1955 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1956 {
1957 try
1958 {
1959 setPropertyValue( *pNames, *pValues );
1960 }
1961 catch( beans::UnknownPropertyException& e )
1962 {
1963 (void)e;
1964 }
1965 catch( uno::Exception& ex )
1966 {
1967 (void)ex;
1968 }
1969 }
1970 }
1971 else
1972 {
1973 uno::Reference< beans::XPropertySet > xSet;
1974 queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet;
1975
1976 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1977 {
1978 try
1979 {
1980 xSet->setPropertyValue( *pNames, *pValues );
1981 }
1982 catch( beans::UnknownPropertyException& e )
1983 {
1984 (void)e;
1985 }
1986 catch( uno::Exception& ex )
1987 {
1988 (void)ex;
1989 }
1990 }
1991 }
1992
1993 if( mpImpl->mpItemSet && mpObj.is() )
1994 mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
1995 }
1996
1997 //----------------------------------------------------------------------
1998
endSetPropertyValues()1999 void SvxShape::endSetPropertyValues()
2000 {
2001 mbIsMultiPropertyCall = sal_False;
2002 if( mpImpl->mpItemSet )
2003 {
2004 delete mpImpl->mpItemSet;
2005 mpImpl->mpItemSet = 0;
2006 }
2007 }
2008
2009 //----------------------------------------------------------------------
2010
getPropertyValues(const::com::sun::star::uno::Sequence<::rtl::OUString> & aPropertyNames)2011 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL SvxShape::getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
2012 {
2013 const sal_Int32 nCount = aPropertyNames.getLength();
2014 const OUString* pNames = aPropertyNames.getConstArray();
2015
2016 uno::Sequence< uno::Any > aRet( nCount );
2017 uno::Any* pValue = aRet.getArray();
2018
2019 if( mpImpl->mpMaster )
2020 {
2021 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
2022 {
2023 try
2024 {
2025 *pValue = getPropertyValue( *pNames );
2026 }
2027 catch( uno::Exception& )
2028 {
2029 DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" );
2030 }
2031 }
2032 }
2033 else
2034 {
2035 uno::Reference< beans::XPropertySet > xSet;
2036 queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet;
2037
2038 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
2039 {
2040 try
2041 {
2042 *pValue = xSet->getPropertyValue( *pNames );
2043 }
2044 catch( uno::Exception& )
2045 {
2046 DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" );
2047 }
2048 }
2049 }
2050
2051 return aRet;
2052 }
2053
addPropertiesChangeListener(const::com::sun::star::uno::Sequence<::rtl::OUString> &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertiesChangeListener> &)2054 void SAL_CALL SvxShape::addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& )
2055 {
2056 }
2057
removePropertiesChangeListener(const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertiesChangeListener> &)2058 void SAL_CALL SvxShape::removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& )
2059 {
2060 }
2061
firePropertiesChangeEvent(const::com::sun::star::uno::Sequence<::rtl::OUString> &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertiesChangeListener> &)2062 void SAL_CALL SvxShape::firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& )
2063 {
2064 }
2065
2066 //----------------------------------------------------------------------
2067
GetAnyForItem(SfxItemSet & aSet,const SfxItemPropertySimpleEntry * pMap) const2068 uno::Any SvxShape::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap ) const
2069 {
2070 DBG_TESTSOLARMUTEX();
2071 uno::Any aAny;
2072
2073 switch(pMap->nWID)
2074 {
2075 case SDRATTR_CIRCSTARTANGLE:
2076 {
2077 const SfxPoolItem* pPoolItem=NULL;
2078 if(aSet.GetItemState(SDRATTR_CIRCSTARTANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET)
2079 {
2080 sal_Int32 nAngle = ((SdrCircStartAngleItem*)pPoolItem)->GetValue();
2081 aAny <<= nAngle;
2082 }
2083 break;
2084 }
2085
2086 case SDRATTR_CIRCENDANGLE:
2087 {
2088 const SfxPoolItem* pPoolItem=NULL;
2089 if (aSet.GetItemState(SDRATTR_CIRCENDANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET)
2090 {
2091 sal_Int32 nAngle = ((SdrCircEndAngleItem*)pPoolItem)->GetValue();
2092 aAny <<= nAngle;
2093 }
2094 break;
2095 }
2096
2097 case SDRATTR_CIRCKIND:
2098 {
2099 if( mpObj->GetObjInventor() == SdrInventor)
2100 {
2101 drawing::CircleKind eKind;
2102 switch(mpObj->GetObjIdentifier())
2103 {
2104 case OBJ_CIRC: // Kreis, Ellipse
2105 eKind = drawing::CircleKind_FULL;
2106 break;
2107 case OBJ_CCUT: // Kreisabschnitt
2108 eKind = drawing::CircleKind_CUT;
2109 break;
2110 case OBJ_CARC: // Kreisbogen
2111 eKind = drawing::CircleKind_ARC;
2112 break;
2113 case OBJ_SECT: // Kreissektor
2114 eKind = drawing::CircleKind_SECTION;
2115 break;
2116 }
2117 aAny <<= eKind;
2118 }
2119 break;
2120 }
2121 default:
2122 {
2123 // Hole Wert aus ItemSet
2124 aAny = SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet );
2125
2126 if( *pMap->pType != aAny.getValueType() )
2127 {
2128 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2129 if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
2130 {
2131 sal_Int32 nValue = 0;
2132 aAny >>= nValue;
2133 aAny <<= (sal_Int16)nValue;
2134 }
2135 else
2136 {
2137 DBG_ERROR("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
2138 }
2139 }
2140
2141 }
2142 }
2143
2144 return aAny;
2145 }
2146
2147 //----------------------------------------------------------------------
2148
2149 // XPropertyState
getPropertyState(const OUString & PropertyName)2150 beans::PropertyState SAL_CALL SvxShape::getPropertyState( const OUString& PropertyName )
2151 {
2152 if( mpImpl->mpMaster )
2153 {
2154 return mpImpl->mpMaster->getPropertyState( PropertyName );
2155 }
2156 else
2157 {
2158 return _getPropertyState( PropertyName );
2159 }
2160 }
2161
_getPropertyState(const OUString & PropertyName)2162 beans::PropertyState SAL_CALL SvxShape::_getPropertyState( const OUString& PropertyName )
2163 {
2164 OGuard aGuard( Application::GetSolarMutex() );
2165
2166 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
2167
2168 if( !mpObj.is() || pMap == NULL )
2169 throw beans::UnknownPropertyException();
2170
2171 beans::PropertyState eState;
2172 if( !getPropertyStateImpl( pMap, eState ) )
2173 {
2174 const SfxItemSet& rSet = mpObj->GetMergedItemSet();
2175
2176 switch( rSet.GetItemState( pMap->nWID, sal_False ) )
2177 {
2178 case SFX_ITEM_READONLY:
2179 case SFX_ITEM_SET:
2180 eState = beans::PropertyState_DIRECT_VALUE;
2181 break;
2182 case SFX_ITEM_DEFAULT:
2183 eState = beans::PropertyState_DEFAULT_VALUE;
2184 break;
2185 // case SFX_ITEM_UNKNOWN:
2186 // case SFX_ITEM_DONTCARE:
2187 // case SFX_ITEM_DISABLED:
2188 default:
2189 eState = beans::PropertyState_AMBIGUOUS_VALUE;
2190 break;
2191 }
2192
2193 // if a item is set, this doesn't mean we want it :)
2194 if( ( beans::PropertyState_DIRECT_VALUE == eState ) )
2195 {
2196 switch( pMap->nWID )
2197 {
2198 // the following items are disabled by changing the
2199 // fill style or the line style. so there is no need
2200 // to export items without names which should be empty
2201 case XATTR_FILLBITMAP:
2202 case XATTR_FILLGRADIENT:
2203 case XATTR_FILLHATCH:
2204 case XATTR_LINEDASH:
2205 {
2206 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
2207 if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
2208 eState = beans::PropertyState_DEFAULT_VALUE;
2209 }
2210 break;
2211
2212 // #i36115#
2213 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
2214 // may be a hard attribute covering the set LineStart of the parent (Style).
2215 // #i37644#
2216 // same is for fill float transparency
2217 case XATTR_LINEEND:
2218 case XATTR_LINESTART:
2219 case XATTR_FILLFLOATTRANSPARENCE:
2220 {
2221 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID);
2222 if( pItem == NULL )
2223 eState = beans::PropertyState_DEFAULT_VALUE;
2224 }
2225 break;
2226 }
2227 }
2228 }
2229 return eState;
2230 }
2231
2232 //----------------------------------------------------------------------
2233
setPropertyValueImpl(const::rtl::OUString &,const SfxItemPropertySimpleEntry * pProperty,const::com::sun::star::uno::Any & rValue)2234 bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue )
2235 {
2236 switch( pProperty->nWID )
2237 {
2238 case OWN_ATTR_CAPTION_POINT:
2239 {
2240 awt::Point aPnt;
2241 if( rValue >>= aPnt )
2242 {
2243 Point aVclPoint( aPnt.X, aPnt.Y );
2244
2245 // #90763# position is relative to top left, make it absolute
2246 basegfx::B2DPolyPolygon aNewPolyPolygon;
2247 basegfx::B2DHomMatrix aNewHomogenMatrix;
2248 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2249
2250 aVclPoint.X() += basegfx::fround(aNewHomogenMatrix.get(0, 2));
2251 aVclPoint.Y() += basegfx::fround(aNewHomogenMatrix.get(1, 2));
2252
2253 // #88657# metric of pool maybe twips (writer)
2254 ForceMetricToItemPoolMetric(aVclPoint);
2255
2256 // #88491# position relative to anchor
2257 if( mpModel->IsWriter() )
2258 {
2259 aVclPoint += mpObj->GetAnchorPos();
2260 }
2261
2262 ((SdrCaptionObj*)mpObj.get())->SetTailPos(aVclPoint);
2263
2264 return true;
2265 }
2266 break;
2267 }
2268 case OWN_ATTR_TRANSFORMATION:
2269 {
2270 drawing::HomogenMatrix3 aMatrix;
2271 if(rValue >>= aMatrix)
2272 {
2273 basegfx::B2DPolyPolygon aNewPolyPolygon;
2274 basegfx::B2DHomMatrix aNewHomogenMatrix;
2275
2276 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2277
2278 aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
2279 aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
2280 aNewHomogenMatrix.set(0, 2, aMatrix.Line1.Column3);
2281 aNewHomogenMatrix.set(1, 0, aMatrix.Line2.Column1);
2282 aNewHomogenMatrix.set(1, 1, aMatrix.Line2.Column2);
2283 aNewHomogenMatrix.set(1, 2, aMatrix.Line2.Column3);
2284 aNewHomogenMatrix.set(2, 0, aMatrix.Line3.Column1);
2285 aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2);
2286 aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3);
2287
2288 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2289 return true;
2290 }
2291 break;
2292 }
2293
2294 case OWN_ATTR_ZORDER:
2295 {
2296 sal_Int32 nNewOrdNum = 0;
2297 if(rValue >>= nNewOrdNum)
2298 {
2299 SdrObjList* pObjList = mpObj->GetObjList();
2300 if( pObjList )
2301 {
2302 #ifdef DBG_UTIL
2303 SdrObject* pCheck =
2304 #endif
2305 pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), (sal_uIntPtr)nNewOrdNum );
2306 DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" );
2307 }
2308 return true;
2309 }
2310 break;
2311 }
2312 case OWN_ATTR_FRAMERECT:
2313 {
2314 awt::Rectangle aUnoRect;
2315 if(rValue >>= aUnoRect)
2316 {
2317 Point aTopLeft( aUnoRect.X, aUnoRect.Y );
2318 Size aObjSize( aUnoRect.Width, aUnoRect.Height );
2319 ForceMetricToItemPoolMetric(aTopLeft);
2320 ForceMetricToItemPoolMetric(aObjSize);
2321 Rectangle aRect;
2322 aRect.SetPos(aTopLeft);
2323 aRect.SetSize(aObjSize);
2324 mpObj->SetSnapRect(aRect);
2325 return true;
2326 }
2327 break;
2328 }
2329 case OWN_ATTR_MIRRORED:
2330 {
2331 sal_Bool bMirror = sal_Bool();
2332 if(rValue >>= bMirror )
2333 {
2334 SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() );
2335 if( pObj )
2336 pObj->SetMirrored(bMirror);
2337 return true;
2338 }
2339 break;
2340 }
2341 case OWN_ATTR_EDGE_START_OBJ:
2342 case OWN_ATTR_EDGE_END_OBJ:
2343 case OWN_ATTR_GLUEID_HEAD:
2344 case OWN_ATTR_GLUEID_TAIL:
2345 case OWN_ATTR_EDGE_START_POS:
2346 case OWN_ATTR_EDGE_END_POS:
2347 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2348 {
2349 SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get());
2350 if(pEdgeObj)
2351 {
2352 switch(pProperty->nWID)
2353 {
2354 case OWN_ATTR_EDGE_START_OBJ:
2355 case OWN_ATTR_EDGE_END_OBJ:
2356 {
2357 Reference< drawing::XShape > xShape;
2358 if( rValue >>= xShape )
2359 {
2360 SdrObject* pNode = GetSdrObjectFromXShape( xShape );
2361 if( pNode )
2362 {
2363 pEdgeObj->ConnectToNode( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, pNode );
2364 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, -1 );
2365 return true;
2366 }
2367 }
2368 break;
2369 }
2370
2371 case OWN_ATTR_EDGE_START_POS:
2372 case OWN_ATTR_EDGE_END_POS:
2373 {
2374 awt::Point aUnoPoint;
2375 if( rValue >>= aUnoPoint )
2376 {
2377 Point aPoint( aUnoPoint.X, aUnoPoint.Y );
2378
2379 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
2380 // perform metric change before applying anchor position,
2381 // because the anchor position is in pool metric.
2382 ForceMetricToItemPoolMetric( aPoint );
2383 // <--
2384 if( mpModel->IsWriter() )
2385 aPoint += mpObj->GetAnchorPos();
2386
2387 pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
2388 return true;
2389 }
2390 break;
2391 }
2392
2393 case OWN_ATTR_GLUEID_HEAD:
2394 case OWN_ATTR_GLUEID_TAIL:
2395 {
2396 sal_Int32 nId = 0;
2397 if( rValue >>= nId )
2398 {
2399 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD, nId );
2400 return true;
2401 }
2402 break;
2403 }
2404 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2405 {
2406 basegfx::B2DPolyPolygon aNewPolyPolygon;
2407
2408 // #123616# be a little bit more flexible regardin gthe data type used
2409 if( rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0))
2410 {
2411 // get polygpon data from PointSequenceSequence
2412 aNewPolyPolygon = basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(
2413 *(const drawing::PointSequenceSequence*)rValue.getValue());
2414 }
2415 else if( rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0))
2416 {
2417 // get polygpon data from PolyPolygonBezierCoords
2418 aNewPolyPolygon = basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
2419 *(const drawing::PolyPolygonBezierCoords*)rValue.getValue());
2420 }
2421
2422 if(aNewPolyPolygon.count())
2423 {
2424 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
2425 ForceMetricToItemPoolMetric( aNewPolyPolygon );
2426 // <--
2427 if( mpModel->IsWriter() )
2428 {
2429 Point aPoint( mpObj->GetAnchorPos() );
2430 aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y()));
2431 }
2432 pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon );
2433 return true;
2434 }
2435 }
2436 }
2437 }
2438 break;
2439 }
2440 case OWN_ATTR_MEASURE_START_POS:
2441 case OWN_ATTR_MEASURE_END_POS:
2442 {
2443 SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get());
2444 awt::Point aUnoPoint;
2445 if(pMeasureObj && ( rValue >>= aUnoPoint ) )
2446 {
2447 Point aPoint( aUnoPoint.X, aUnoPoint.Y );
2448
2449 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
2450 ForceMetricToItemPoolMetric( aPoint );
2451 // <--
2452 if( mpModel->IsWriter() )
2453 aPoint += mpObj->GetAnchorPos();
2454
2455 pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0L : 1L );
2456 pMeasureObj->SetChanged();
2457 pMeasureObj->BroadcastObjectChange();
2458 return true;
2459 }
2460 break;
2461 }
2462 case OWN_ATTR_FILLBMP_MODE:
2463 {
2464 drawing::BitmapMode eMode;
2465 if(!(rValue >>= eMode) )
2466 {
2467 sal_Int32 nMode = 0;
2468 if(!(rValue >>= nMode))
2469 break;
2470
2471 eMode = (drawing::BitmapMode)nMode;
2472 }
2473 mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
2474 mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
2475 return true;
2476 }
2477
2478 case SDRATTR_LAYERID:
2479 {
2480 sal_Int16 nLayerId = sal_Int16();
2481 if( rValue >>= nLayerId )
2482 {
2483 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID((unsigned char)nLayerId);
2484 if( pLayer )
2485 {
2486 mpObj->SetLayer((unsigned char)nLayerId);
2487 return true;
2488 }
2489 }
2490 break;
2491 }
2492
2493 case SDRATTR_LAYERNAME:
2494 {
2495 OUString aLayerName;
2496 if( rValue >>= aLayerName )
2497 {
2498 const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName, sal_True);
2499 if( pLayer != NULL )
2500 {
2501 mpObj->SetLayer( pLayer->GetID() );
2502 return true;
2503 }
2504 }
2505 break;
2506 }
2507 case SDRATTR_ROTATEANGLE:
2508 {
2509 sal_Int32 nAngle = 0;
2510 if( rValue >>= nAngle )
2511 {
2512 Point aRef1(mpObj->GetSnapRect().Center());
2513 nAngle -= mpObj->GetRotateAngle();
2514 if (nAngle!=0)
2515 {
2516 double nSin=sin(nAngle*nPi180);
2517 double nCos=cos(nAngle*nPi180);
2518 mpObj->Rotate(aRef1,nAngle,nSin,nCos);
2519 }
2520 return true;
2521 }
2522
2523 break;
2524 }
2525
2526 case SDRATTR_SHEARANGLE:
2527 {
2528 sal_Int32 nShear = 0;
2529 if( rValue >>= nShear )
2530 {
2531 nShear -= mpObj->GetShearAngle();
2532 if(nShear != 0 )
2533 {
2534 Point aRef1(mpObj->GetSnapRect().Center());
2535 double nTan=tan(nShear*nPi180);
2536 mpObj->Shear(aRef1,nShear,nTan,sal_False);
2537 return true;
2538 }
2539 }
2540
2541 break;
2542 }
2543
2544 case SDRATTR_OBJMOVEPROTECT:
2545 {
2546 sal_Bool bMoveProtect = sal_Bool();
2547 if( rValue >>= bMoveProtect )
2548 {
2549 mpObj->SetMoveProtect(bMoveProtect);
2550 return true;
2551 }
2552 break;
2553 }
2554 case SDRATTR_OBJECTNAME:
2555 {
2556 OUString aName;
2557 if( rValue >>= aName )
2558 {
2559 mpObj->SetName( aName );
2560 return true;
2561 }
2562 break;
2563 }
2564
2565 // #i68101#
2566 case OWN_ATTR_MISC_OBJ_TITLE:
2567 {
2568 OUString aTitle;
2569 if( rValue >>= aTitle )
2570 {
2571 mpObj->SetTitle( aTitle );
2572 return true;
2573 }
2574 break;
2575 }
2576 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2577 {
2578 OUString aDescription;
2579 if( rValue >>= aDescription )
2580 {
2581 mpObj->SetDescription( aDescription );
2582 return true;
2583 }
2584 break;
2585 }
2586
2587 case OWN_ATTR_MISC_OBJ_DECORATIVE:
2588 {
2589 sal_Bool bDecorative = sal_False;
2590 if( rValue >>= bDecorative )
2591 {
2592 mpObj->SetDecorative( bDecorative );
2593 return true;
2594 }
2595 break;
2596 }
2597
2598 case SDRATTR_OBJPRINTABLE:
2599 {
2600 sal_Bool bPrintable = sal_Bool();
2601 if( rValue >>= bPrintable )
2602 {
2603 mpObj->SetPrintable(bPrintable);
2604 return true;
2605 }
2606 break;
2607 }
2608 case SDRATTR_OBJVISIBLE:
2609 {
2610 sal_Bool bVisible = sal_Bool();
2611 if( rValue >>= bVisible )
2612 {
2613 mpObj->SetVisible(bVisible);
2614 return true;
2615 }
2616 break;
2617 }
2618 case SDRATTR_OBJSIZEPROTECT:
2619 {
2620 sal_Bool bResizeProtect = sal_Bool();
2621 if( rValue >>= bResizeProtect )
2622 {
2623 mpObj->SetResizeProtect(bResizeProtect);
2624 return true;
2625 }
2626 break;
2627 }
2628 case OWN_ATTR_PAGE_NUMBER:
2629 {
2630 sal_Int32 nPageNum = 0;
2631 if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
2632 {
2633 SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get());
2634 if( pPageObj )
2635 {
2636 SdrModel* pModel = pPageObj->GetModel();
2637 SdrPage* pNewPage = 0L;
2638 const sal_uInt16 nDestinationPageNum((sal_uInt16)((nPageNum << 1L) - 1L));
2639
2640 if(pModel)
2641 {
2642 if(nDestinationPageNum < pModel->GetPageCount())
2643 {
2644 pNewPage = pModel->GetPage(nDestinationPageNum);
2645 }
2646 }
2647
2648 pPageObj->SetReferencedPage(pNewPage);
2649 }
2650
2651 return true;
2652 }
2653 break;
2654 }
2655 case XATTR_FILLBITMAP:
2656 case XATTR_FILLGRADIENT:
2657 case XATTR_FILLHATCH:
2658 case XATTR_FILLFLOATTRANSPARENCE:
2659 case XATTR_LINEEND:
2660 case XATTR_LINESTART:
2661 case XATTR_LINEDASH:
2662 {
2663 if( pProperty->nMemberId == MID_NAME )
2664 {
2665 OUString aApiName;
2666 if( rValue >>= aApiName )
2667 {
2668 if( SetFillAttribute( pProperty->nWID, aApiName ) )
2669 return true;
2670 }
2671 break;
2672 }
2673 else
2674 {
2675 return false;
2676 }
2677 }
2678 default:
2679 {
2680 return false;
2681 }
2682 }
2683 throw lang::IllegalArgumentException();
2684 }
2685
2686 //----------------------------------------------------------------------
2687
getPropertyValueImpl(const::rtl::OUString &,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)2688 bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue )
2689 {
2690 switch( pProperty->nWID )
2691 {
2692 /*
2693 case OWN_ATTR_HASLEVELS:
2694 {
2695 rValue <<= SvxTextEditSource::hasLevels( mpObj.get() );
2696 break;
2697 }
2698 */
2699 case OWN_ATTR_CAPTION_POINT:
2700 {
2701 Point aVclPoint = ((SdrCaptionObj*)mpObj.get())->GetTailPos();
2702
2703 // #88491# make pos relative to anchor
2704 if( mpModel->IsWriter() )
2705 {
2706 aVclPoint -= mpObj->GetAnchorPos();
2707 }
2708
2709 // #88657# metric of pool maybe twips (writer)
2710 ForceMetricTo100th_mm(aVclPoint);
2711
2712 // #90763# pos is absolute, make it relative to top left
2713 basegfx::B2DPolyPolygon aNewPolyPolygon;
2714 basegfx::B2DHomMatrix aNewHomogenMatrix;
2715 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2716
2717 aVclPoint.X() -= basegfx::fround(aNewHomogenMatrix.get(0, 2));
2718 aVclPoint.Y() -= basegfx::fround(aNewHomogenMatrix.get(1, 2));
2719
2720 awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() );
2721 rValue <<= aPnt;
2722 break;
2723 }
2724
2725 case OWN_ATTR_TRANSFORMATION:
2726 {
2727 basegfx::B2DPolyPolygon aNewPolyPolygon;
2728 basegfx::B2DHomMatrix aNewHomogenMatrix;
2729 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2730 drawing::HomogenMatrix3 aMatrix;
2731
2732 aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
2733 aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1);
2734 aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2);
2735 aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0);
2736 aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1);
2737 aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2);
2738 aMatrix.Line3.Column1 = aNewHomogenMatrix.get(2, 0);
2739 aMatrix.Line3.Column2 = aNewHomogenMatrix.get(2, 1);
2740 aMatrix.Line3.Column3 = aNewHomogenMatrix.get(2, 2);
2741
2742 rValue <<= aMatrix;
2743
2744 break;
2745 }
2746
2747 case OWN_ATTR_ZORDER:
2748 {
2749 rValue <<= (sal_Int32)mpObj->GetOrdNum();
2750 break;
2751 }
2752
2753 case OWN_ATTR_BITMAP:
2754 {
2755 rValue = GetBitmap();
2756 if(!rValue.hasValue())
2757 throw uno::RuntimeException();
2758
2759 break;
2760 }
2761
2762 case OWN_ATTR_ISFONTWORK:
2763 {
2764 rValue <<= (sal_Bool)(mpObj->ISA(SdrTextObj) && ((SdrTextObj*)mpObj.get())->IsFontwork());
2765 break;
2766 }
2767
2768 case OWN_ATTR_FRAMERECT:
2769 {
2770 Rectangle aRect( mpObj->GetSnapRect() );
2771 Point aTopLeft( aRect.TopLeft() );
2772 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2773 ForceMetricTo100th_mm(aTopLeft);
2774 ForceMetricTo100th_mm(aObjSize);
2775 ::com::sun::star::awt::Rectangle aUnoRect(
2776 aTopLeft.X(), aTopLeft.Y(),
2777 aObjSize.getWidth(), aObjSize.getHeight() );
2778 rValue <<= aUnoRect;
2779 break;
2780 }
2781
2782 case OWN_ATTR_BOUNDRECT:
2783 {
2784 Rectangle aRect( mpObj->GetCurrentBoundRect() );
2785 Point aTopLeft( aRect.TopLeft() );
2786 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2787 ForceMetricTo100th_mm(aTopLeft);
2788 ForceMetricTo100th_mm(aObjSize);
2789 ::com::sun::star::awt::Rectangle aUnoRect(
2790 aTopLeft.X(), aTopLeft.Y(),
2791 aObjSize.getWidth(), aObjSize.getHeight() );
2792 rValue <<= aUnoRect;
2793 break;
2794 }
2795
2796 case OWN_ATTR_LDNAME:
2797 {
2798 OUString aName( mpObj->GetName() );
2799 rValue <<= aName;
2800 break;
2801 }
2802
2803 case OWN_ATTR_LDBITMAP:
2804 {
2805 sal_uInt16 nId;
2806 if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_OLE2 )
2807 {
2808 nId = RID_UNODRAW_OLE2;
2809 }
2810 else if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_GRAF )
2811 {
2812 nId = RID_UNODRAW_GRAPHICS;
2813 }
2814 else
2815 {
2816 nId = RID_UNODRAW_OBJECTS;
2817 }
2818
2819 BitmapEx aBmp( SVX_RES(nId) );
2820 Reference< awt::XBitmap > xBmp( VCLUnoHelper::CreateBitmap( aBmp ) );
2821
2822 rValue <<= xBmp;
2823 break;
2824 }
2825
2826 case OWN_ATTR_MIRRORED:
2827 {
2828 sal_Bool bMirror = sal_False;
2829 if( mpObj.is() && mpObj->ISA(SdrGrafObj) )
2830 bMirror = ((SdrGrafObj*)mpObj.get())->IsMirrored();
2831
2832 rValue <<= bMirror;
2833 }
2834
2835 case OWN_ATTR_EDGE_START_OBJ:
2836 case OWN_ATTR_EDGE_START_POS:
2837 case OWN_ATTR_EDGE_END_POS:
2838 case OWN_ATTR_EDGE_END_OBJ:
2839 case OWN_ATTR_GLUEID_HEAD:
2840 case OWN_ATTR_GLUEID_TAIL:
2841 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2842 {
2843 SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get());
2844 if(pEdgeObj)
2845 {
2846 switch(pProperty->nWID)
2847 {
2848 case OWN_ATTR_EDGE_START_OBJ:
2849 case OWN_ATTR_EDGE_END_OBJ:
2850 {
2851 SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ);
2852 if(pNode)
2853 {
2854 Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) );
2855 if(xShape.is())
2856 rValue <<= xShape;
2857
2858 }
2859 break;
2860 }
2861
2862 case OWN_ATTR_EDGE_START_POS:
2863 case OWN_ATTR_EDGE_END_POS:
2864 {
2865 Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) );
2866 if( mpModel->IsWriter() )
2867 aPoint -= mpObj->GetAnchorPos();
2868
2869 ForceMetricTo100th_mm( aPoint );
2870 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2871
2872 rValue <<= aUnoPoint;
2873 break;
2874 }
2875 case OWN_ATTR_GLUEID_HEAD:
2876 case OWN_ATTR_GLUEID_TAIL:
2877 {
2878 rValue <<= pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD );
2879 break;
2880 }
2881 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2882 {
2883 basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() );
2884 if( mpModel->IsWriter() )
2885 {
2886 Point aPoint( mpObj->GetAnchorPos() );
2887 aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y()));
2888 }
2889 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051
2890 ForceMetricTo100th_mm( aPolyPoly );
2891 // <--
2892 drawing::PolyPolygonBezierCoords aRetval;
2893 SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval);
2894 rValue <<= aRetval;
2895 break;
2896 }
2897 }
2898 }
2899 break;
2900 }
2901
2902 case OWN_ATTR_MEASURE_START_POS:
2903 case OWN_ATTR_MEASURE_END_POS:
2904 {
2905 SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get());
2906 if(pMeasureObj)
2907 {
2908 Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) );
2909 if( mpModel->IsWriter() )
2910 aPoint -= mpObj->GetAnchorPos();
2911
2912 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051
2913 ForceMetricTo100th_mm( aPoint );
2914 // <--
2915 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2916
2917 rValue <<= aUnoPoint;
2918 break;
2919 }
2920 break;
2921 }
2922
2923 case OWN_ATTR_FILLBMP_MODE:
2924 {
2925 const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet();
2926
2927 XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&rObjItemSet.Get(XATTR_FILLBMP_STRETCH);
2928 XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&rObjItemSet.Get(XATTR_FILLBMP_TILE);
2929
2930 if( pTileItem && pTileItem->GetValue() )
2931 {
2932 rValue <<= drawing::BitmapMode_REPEAT;
2933 }
2934 else if( pStretchItem && pStretchItem->GetValue() )
2935 {
2936 rValue <<= drawing::BitmapMode_STRETCH;
2937 }
2938 else
2939 {
2940 rValue <<= drawing::BitmapMode_NO_REPEAT;
2941 }
2942 break;
2943 }
2944 case SDRATTR_LAYERID:
2945 rValue <<= (sal_Int16)mpObj->GetLayer();
2946 break;
2947
2948 case SDRATTR_LAYERNAME:
2949 {
2950 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer());
2951 if( pLayer )
2952 {
2953 OUString aName( pLayer->GetName() );
2954 rValue <<= aName;
2955 }
2956 break;
2957 }
2958
2959 case SDRATTR_ROTATEANGLE:
2960 rValue <<= mpObj->GetRotateAngle();
2961 break;
2962
2963 case SDRATTR_SHEARANGLE:
2964 rValue <<= mpObj->GetShearAngle();
2965 break;
2966
2967 case SDRATTR_OBJMOVEPROTECT:
2968 rValue = uno::makeAny( (sal_Bool) mpObj->IsMoveProtect() );
2969 break;
2970
2971 case SDRATTR_OBJECTNAME:
2972 {
2973 OUString aName( mpObj->GetName() );
2974 rValue <<= aName;
2975 break;
2976 }
2977
2978 // #i68101#
2979 case OWN_ATTR_MISC_OBJ_TITLE:
2980 {
2981 OUString aTitle( mpObj->GetTitle() );
2982 rValue <<= aTitle;
2983 break;
2984 }
2985
2986 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2987 {
2988 OUString aDescription( mpObj->GetDescription() );
2989 rValue <<= aDescription;
2990 break;
2991 }
2992
2993 case OWN_ATTR_MISC_OBJ_DECORATIVE:
2994 rValue <<= static_cast<sal_Bool>( mpObj->IsDecorative() );
2995 break;
2996
2997 case SDRATTR_OBJPRINTABLE:
2998 rValue <<= static_cast<sal_Bool>( mpObj->IsPrintable() );
2999 break;
3000
3001 case SDRATTR_OBJVISIBLE:
3002 rValue <<= static_cast<sal_Bool>( mpObj->IsVisible() );
3003 break;
3004
3005 case SDRATTR_OBJSIZEPROTECT:
3006 rValue <<= static_cast<sal_Bool>( mpObj->IsResizeProtect() );
3007 break;
3008
3009 case OWN_ATTR_PAGE_NUMBER:
3010 {
3011 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get());
3012 if(pPageObj)
3013 {
3014 SdrPage* pPage = pPageObj->GetReferencedPage();
3015 sal_Int32 nPageNumber = (pPage) ? pPage->GetPageNum() : 0L;
3016 nPageNumber++;
3017 nPageNumber >>= 1;
3018 rValue <<= nPageNumber;
3019 }
3020 break;
3021 }
3022
3023 case OWN_ATTR_UINAME_SINGULAR:
3024 {
3025 String aTmp;
3026 mpObj->TakeObjNameSingul( aTmp );
3027 rValue <<= OUString( aTmp );
3028 break;
3029 }
3030
3031 case OWN_ATTR_UINAME_PLURAL:
3032 {
3033 String aTmp;
3034 mpObj->TakeObjNamePlural( aTmp );
3035 rValue <<= OUString( aTmp );
3036 break;
3037 }
3038 case OWN_ATTR_METAFILE:
3039 {
3040 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
3041 if( pObj )
3042 {
3043 Graphic* pGraphic = pObj->GetGraphic();
3044 if( pGraphic )
3045 {
3046 sal_Bool bIsWMF = sal_False;
3047 if ( pGraphic->IsLink() )
3048 {
3049 GfxLink aLnk = pGraphic->GetLink();
3050 if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF )
3051 {
3052 bIsWMF = sal_True;
3053 uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize());
3054 rValue <<= aSeq;
3055 }
3056 }
3057 if ( !bIsWMF )
3058 {
3059 // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
3060 GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
3061 SvMemoryStream aDestStrm( 65535, 65535 );
3062 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
3063 const uno::Sequence<sal_Int8> aSeq(
3064 static_cast< const sal_Int8* >(aDestStrm.GetData()),
3065 aDestStrm.GetEndOfData());
3066 rValue <<= aSeq;
3067 }
3068 }
3069 }
3070 else
3071 {
3072 rValue = GetBitmap( sal_True );
3073 }
3074 break;
3075 }
3076
3077
3078 default:
3079 return false;
3080 }
3081 return true;
3082 }
3083
3084 //----------------------------------------------------------------------
3085
getPropertyStateImpl(const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::beans::PropertyState & rState)3086 bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState )
3087 {
3088 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
3089 {
3090 const SfxItemSet& rSet = mpObj->GetMergedItemSet();
3091
3092 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET ||
3093 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET )
3094 {
3095 rState = beans::PropertyState_DIRECT_VALUE;
3096 }
3097 else
3098 {
3099 rState = beans::PropertyState_AMBIGUOUS_VALUE;
3100 }
3101 }
3102 else if( pProperty->nWID == OWN_ATTR_MISC_OBJ_DECORATIVE )
3103 {
3104 // a default of false must not make every shape export the property
3105 rState = mpObj->IsDecorative() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_DEFAULT_VALUE;
3106 }
3107 else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
3108 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) )
3109 {
3110 rState = beans::PropertyState_DIRECT_VALUE;
3111 }
3112 else
3113 {
3114 return false;
3115 }
3116
3117 return true;
3118 }
3119
3120 //----------------------------------------------------------------------
3121
setPropertyToDefaultImpl(const SfxItemPropertySimpleEntry * pProperty)3122 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty )
3123 {
3124 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
3125 {
3126 mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH );
3127 mpObj->ClearMergedItem( XATTR_FILLBMP_TILE );
3128 return true;
3129 }
3130 else if( pProperty->nWID == OWN_ATTR_MISC_OBJ_DECORATIVE )
3131 {
3132 mpObj->SetDecorative( false );
3133 return true;
3134 }
3135 else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
3136 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST ))
3137 {
3138 return true;
3139 }
3140 else
3141 {
3142 return false;
3143 }
3144 }
3145
3146 //----------------------------------------------------------------------
3147
getPropertyStates(const uno::Sequence<OUString> & aPropertyName)3148 uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
3149 {
3150 const sal_Int32 nCount = aPropertyName.getLength();
3151 const OUString* pNames = aPropertyName.getConstArray();
3152
3153 uno::Sequence< beans::PropertyState > aRet( nCount );
3154 beans::PropertyState* pState = aRet.getArray();
3155
3156 if( mpImpl->mpMaster )
3157 {
3158 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
3159 pState[nIdx] = getPropertyState( pNames[nIdx] );
3160
3161 }
3162 else
3163 {
3164 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
3165 pState[nIdx] = getPropertyState( pNames[nIdx] );
3166 }
3167
3168 return aRet;
3169 }
3170
3171 //----------------------------------------------------------------------
3172
setPropertyToDefault(const OUString & PropertyName)3173 void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName )
3174 {
3175 if( mpImpl->mpMaster )
3176 {
3177 mpImpl->mpMaster->setPropertyToDefault( PropertyName );
3178 }
3179 else
3180 {
3181 _setPropertyToDefault( PropertyName );
3182 }
3183 }
3184
_setPropertyToDefault(const OUString & PropertyName)3185 void SAL_CALL SvxShape::_setPropertyToDefault( const OUString& PropertyName )
3186 {
3187 OGuard aGuard( Application::GetSolarMutex() );
3188
3189 const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName);
3190
3191 if( !mpObj.is() || mpModel == NULL || pProperty == NULL )
3192 throw beans::UnknownPropertyException();
3193
3194 if( !setPropertyToDefaultImpl( pProperty ) )
3195 {
3196 mpObj->ClearMergedItem( pProperty->nWID );
3197 }
3198
3199 mpModel->SetChanged();
3200 }
3201
3202 //----------------------------------------------------------------------
3203
getPropertyDefault(const OUString & aPropertyName)3204 uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName )
3205 {
3206 if( mpImpl->mpMaster )
3207 {
3208 return mpImpl->mpMaster->getPropertyDefault( aPropertyName );
3209 }
3210 else
3211 {
3212 return _getPropertyDefault( aPropertyName );
3213 }
3214 }
3215
_getPropertyDefault(const OUString & aPropertyName)3216 uno::Any SAL_CALL SvxShape::_getPropertyDefault( const OUString& aPropertyName )
3217 {
3218 OGuard aGuard( Application::GetSolarMutex() );
3219
3220 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
3221
3222 if( !mpObj.is() || pMap == NULL || mpModel == NULL )
3223 throw beans::UnknownPropertyException();
3224
3225 if( pMap->nWID == OWN_ATTR_MISC_OBJ_DECORATIVE )
3226 {
3227 return uno::makeAny( sal_False );
3228 }
3229
3230 if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) ||
3231 ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST ))
3232 {
3233 return getPropertyValue( aPropertyName );
3234 }
3235
3236 // Default aus ItemPool holen
3237 if(!mpModel->GetItemPool().IsWhich(pMap->nWID))
3238 throw beans::UnknownPropertyException();
3239
3240 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
3241 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
3242
3243 return GetAnyForItem( aSet, pMap );
3244 }
3245
3246 // XMultiPropertyStates
setAllPropertiesToDefault()3247 void SvxShape::setAllPropertiesToDefault()
3248 {
3249 OGuard aGuard( Application::GetSolarMutex() );
3250
3251 if( !mpObj.is() )
3252 throw lang::DisposedException();
3253 mpObj->ClearMergedItem(); // nWhich == 0 => all
3254
3255 if(mpObj->ISA(SdrGrafObj))
3256 {
3257 // defaults for graphic objects have changed:
3258 mpObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
3259 mpObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) );
3260 }
3261
3262 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
3263 // but needs to be sal_True in svx, pool default (false) in sch. Since sch
3264 // does not load lathe or extrude objects, it is possible to set the items
3265 // here.
3266 // For other solution possibilities, see task description.
3267 if(mpObj->ISA(E3dLatheObj) || mpObj->ISA(E3dExtrudeObj))
3268 {
3269 mpObj->SetMergedItem(Svx3DCharacterModeItem(true));
3270 }
3271
3272 mpModel->SetChanged();
3273 }
3274
setPropertiesToDefault(const uno::Sequence<OUString> & aPropertyNames)3275 void SvxShape::setPropertiesToDefault(
3276 const uno::Sequence<OUString>& aPropertyNames )
3277 {
3278 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
3279 setPropertyToDefault( aPropertyNames[pos] );
3280 }
3281
getPropertyDefaults(const uno::Sequence<OUString> & aPropertyNames)3282 uno::Sequence<uno::Any> SvxShape::getPropertyDefaults(
3283 const uno::Sequence<OUString>& aPropertyNames )
3284 {
3285 ::std::vector<uno::Any> ret;
3286 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
3287 ret.push_back( getPropertyDefault( aPropertyNames[pos] ) );
3288 return uno::Sequence<uno::Any>( &ret[0], ret.size() );
3289 }
3290
3291 //----------------------------------------------------------------------
3292
3293 //----------------------------------------------------------------------
3294 // XServiceInfo
3295 //----------------------------------------------------------------------
getImplementationName()3296 OUString SAL_CALL SvxShape::getImplementationName()
3297 {
3298 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShape") );
3299 return aServiceName;
3300 }
3301
3302 #define STAR_NAMESPACE "com.sun.star."
3303
3304 const char* sUNO_service_style_ParagraphProperties = STAR_NAMESPACE "style.ParagraphProperties";
3305 const char* sUNO_service_style_ParagraphPropertiesComplex = STAR_NAMESPACE "style.ParagraphPropertiesComplex";
3306 const char* sUNO_service_style_ParagraphPropertiesAsian = STAR_NAMESPACE "style.ParagraphPropertiesAsian";
3307 const char* sUNO_service_style_CharacterProperties = STAR_NAMESPACE "style.CharacterProperties";
3308 const char* sUNO_service_style_CharacterPropertiesComplex = STAR_NAMESPACE "style.CharacterPropertiesComplex";
3309 const char* sUNO_service_style_CharacterPropertiesAsian = STAR_NAMESPACE "style.CharacterPropertiesAsian";
3310
3311 const char* sUNO_service_drawing_FillProperties = STAR_NAMESPACE "drawing.FillProperties";
3312 const char* sUNO_service_drawing_TextProperties = STAR_NAMESPACE "drawing.TextProperties";
3313 const char* sUNO_service_drawing_LineProperties = STAR_NAMESPACE "drawing.LineProperties";
3314 const char* sUNO_service_drawing_ConnectorProperties = STAR_NAMESPACE "drawing.ConnectorProperties";
3315 const char* sUNO_service_drawing_MeasureProperties = STAR_NAMESPACE "drawing.MeasureProperties";
3316 const char* sUNO_service_drawing_ShadowProperties = STAR_NAMESPACE "drawing.ShadowProperties";
3317
3318 const char* sUNO_service_drawing_RotationDescriptor = STAR_NAMESPACE "drawing.RotationDescriptor";
3319
3320 const char* sUNO_service_drawing_Text = STAR_NAMESPACE "drawing.Text";
3321 const char* sUNO_service_drawing_GroupShape = STAR_NAMESPACE "drawing.GroupShape";
3322
3323 const char* sUNO_service_drawing_CustomShapeProperties = STAR_NAMESPACE "drawing.CustomShapeProperties";
3324 const char* sUNO_service_drawing_CustomShape = STAR_NAMESPACE "drawing.CustomShape";
3325
3326 const char* sUNO_service_drawing_PolyPolygonDescriptor = STAR_NAMESPACE "drawing.PolyPolygonDescriptor";
3327 const char* sUNO_service_drawing_PolyPolygonBezierDescriptor= STAR_NAMESPACE "drawing.PolyPolygonBezierDescriptor";
3328
3329 const char* sUNO_service_drawing_LineShape = STAR_NAMESPACE "drawing.LineShape";
3330 const char* sUNO_service_drawing_Shape = STAR_NAMESPACE "drawing.Shape";
3331 const char* sUNO_service_drawing_RectangleShape = STAR_NAMESPACE "drawing.RectangleShape";
3332 const char* sUNO_service_drawing_EllipseShape = STAR_NAMESPACE "drawing.EllipseShape";
3333 const char* sUNO_service_drawing_PolyPolygonShape = STAR_NAMESPACE "drawing.PolyPolygonShape";
3334 const char* sUNO_service_drawing_PolyLineShape = STAR_NAMESPACE "drawing.PolyLineShape";
3335 const char* sUNO_service_drawing_OpenBezierShape = STAR_NAMESPACE "drawing.OpenBezierShape";
3336 const char* sUNO_service_drawing_ClosedBezierShape = STAR_NAMESPACE "drawing.ClosedBezierShape";
3337 const char* sUNO_service_drawing_TextShape = STAR_NAMESPACE "drawing.TextShape";
3338 const char* sUNO_service_drawing_GraphicObjectShape = STAR_NAMESPACE "drawing.GraphicObjectShape";
3339 const char* sUNO_service_drawing_OLE2Shape = STAR_NAMESPACE "drawing.OLE2Shape";
3340 const char* sUNO_service_drawing_PageShape = STAR_NAMESPACE "drawing.PageShape";
3341 const char* sUNO_service_drawing_CaptionShape = STAR_NAMESPACE "drawing.CaptionShape";
3342 const char* sUNO_service_drawing_MeasureShape = STAR_NAMESPACE "drawing.MeasureShape";
3343 const char* sUNO_service_drawing_FrameShape = STAR_NAMESPACE "drawing.FrameShape";
3344 const char* sUNO_service_drawing_ControlShape = STAR_NAMESPACE "drawing.ControlShape";
3345 const char* sUNO_service_drawing_ConnectorShape = STAR_NAMESPACE "drawing.ConnectorShape";
3346 const char* sUNO_service_drawing_MediaShape = STAR_NAMESPACE "drawing.MediaShape";
3347
3348
getSupportedServiceNames()3349 uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames()
3350 {
3351 if( mpImpl->mpMaster )
3352 {
3353 return mpImpl->mpMaster->getSupportedServiceNames();
3354 }
3355 else
3356 {
3357 return _getSupportedServiceNames();
3358 }
3359 }
3360
_getSupportedServiceNames()3361 uno::Sequence< OUString > SAL_CALL SvxShape::_getSupportedServiceNames()
3362 {
3363 OGuard aGuard( Application::GetSolarMutex() );
3364
3365 if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor)
3366 {
3367 const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
3368
3369 switch(nIdent)
3370 {
3371 case OBJ_GRUP:
3372 {
3373 static uno::Sequence< OUString > *pSeq = 0;
3374 if( 0 == pSeq )
3375 {
3376 // OGuard aGuard( Application::GetSolarMutex() );
3377 // if( 0 == pSeq )
3378 {
3379 static uno::Sequence< OUString > SvxShape_GroupServices;
3380
3381 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, 2,
3382 sUNO_service_drawing_GroupShape,
3383 sUNO_service_drawing_Shape );
3384
3385 pSeq = &SvxShape_GroupServices;
3386 }
3387 }
3388
3389 return *pSeq;
3390 }
3391 case OBJ_CUSTOMSHAPE:
3392 {
3393 static uno::Sequence< OUString > *pSeq = 0;
3394 if( 0 == pSeq )
3395 {
3396 // OGuard aGuard( Application::GetSolarMutex() );
3397 // if( 0 == pSeq )
3398 {
3399 static uno::Sequence< OUString > SvxShape_CustomShapeServices;
3400
3401 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, 13,
3402 sUNO_service_drawing_CustomShape,
3403 sUNO_service_drawing_Shape,
3404 sUNO_service_drawing_CustomShapeProperties,
3405 sUNO_service_drawing_FillProperties,
3406 sUNO_service_drawing_LineProperties,
3407 sUNO_service_drawing_Text,
3408 sUNO_service_drawing_TextProperties,
3409 sUNO_service_style_ParagraphProperties,
3410 sUNO_service_style_ParagraphPropertiesComplex,
3411 sUNO_service_style_ParagraphPropertiesAsian,
3412 sUNO_service_style_CharacterProperties,
3413 sUNO_service_style_CharacterPropertiesComplex,
3414 sUNO_service_style_CharacterPropertiesAsian,
3415 sUNO_service_drawing_ShadowProperties,
3416 sUNO_service_drawing_RotationDescriptor);
3417 pSeq = &SvxShape_CustomShapeServices;
3418 }
3419 }
3420 return *pSeq;
3421 }
3422 case OBJ_LINE:
3423 {
3424 static uno::Sequence< OUString > *pSeq = 0;
3425 if( 0 == pSeq )
3426 {
3427 // OGuard aGuard( Application::GetSolarMutex() );
3428 // if( 0 == pSeq )
3429 {
3430 static uno::Sequence< OUString > SvxShape_LineServices;
3431
3432 comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices,14,
3433 sUNO_service_drawing_LineShape,
3434
3435 sUNO_service_drawing_Shape,
3436 sUNO_service_drawing_LineProperties,
3437
3438 sUNO_service_drawing_Text,
3439 sUNO_service_drawing_TextProperties,
3440 sUNO_service_style_ParagraphProperties,
3441 sUNO_service_style_ParagraphPropertiesComplex,
3442 sUNO_service_style_ParagraphPropertiesAsian,
3443 sUNO_service_style_CharacterProperties,
3444 sUNO_service_style_CharacterPropertiesComplex,
3445 sUNO_service_style_CharacterPropertiesAsian,
3446
3447 sUNO_service_drawing_PolyPolygonDescriptor,
3448 sUNO_service_drawing_ShadowProperties,
3449 sUNO_service_drawing_RotationDescriptor);
3450
3451 pSeq = &SvxShape_LineServices;
3452 }
3453 }
3454 return *pSeq;
3455 }
3456
3457 case OBJ_RECT:
3458 {
3459 static uno::Sequence< OUString > *pSeq = 0;
3460 if( 0 == pSeq )
3461 {
3462 // OGuard aGuard( Application::GetSolarMutex() );
3463 // if( 0 == pSeq )
3464 {
3465 static uno::Sequence< OUString > SvxShape_RectServices;
3466
3467 comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices,14,
3468 sUNO_service_drawing_RectangleShape,
3469
3470 sUNO_service_drawing_Shape,
3471 sUNO_service_drawing_FillProperties,
3472 sUNO_service_drawing_LineProperties,
3473 sUNO_service_drawing_Text,
3474 sUNO_service_drawing_TextProperties,
3475 sUNO_service_style_ParagraphProperties,
3476 sUNO_service_style_ParagraphPropertiesComplex,
3477 sUNO_service_style_ParagraphPropertiesAsian,
3478 sUNO_service_style_CharacterProperties,
3479 sUNO_service_style_CharacterPropertiesComplex,
3480 sUNO_service_style_CharacterPropertiesAsian,
3481
3482 sUNO_service_drawing_ShadowProperties,
3483 sUNO_service_drawing_RotationDescriptor);
3484 pSeq = &SvxShape_RectServices;
3485 }
3486
3487 }
3488 return *pSeq;
3489 }
3490
3491 case OBJ_CIRC:
3492 case OBJ_SECT:
3493 case OBJ_CARC:
3494 case OBJ_CCUT:
3495 {
3496 static uno::Sequence< OUString > *pSeq = 0;
3497 if( 0 == pSeq )
3498 {
3499 // OGuard aGuard( Application::GetSolarMutex() );
3500 // if( 0 == pSeq )
3501 {
3502 static uno::Sequence< OUString > SvxShape_CircServices;
3503
3504 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices,14,
3505 sUNO_service_drawing_EllipseShape,
3506
3507 sUNO_service_drawing_Shape,
3508 sUNO_service_drawing_FillProperties,
3509 sUNO_service_drawing_LineProperties,
3510
3511 sUNO_service_drawing_Text,
3512 sUNO_service_drawing_TextProperties,
3513 sUNO_service_style_ParagraphProperties,
3514 sUNO_service_style_ParagraphPropertiesComplex,
3515 sUNO_service_style_ParagraphPropertiesAsian,
3516 sUNO_service_style_CharacterProperties,
3517 sUNO_service_style_CharacterPropertiesComplex,
3518 sUNO_service_style_CharacterPropertiesAsian,
3519
3520 sUNO_service_drawing_ShadowProperties,
3521 sUNO_service_drawing_RotationDescriptor);
3522
3523 pSeq = &SvxShape_CircServices;
3524 }
3525 }
3526
3527 return *pSeq;
3528 }
3529
3530 case OBJ_PATHPLIN:
3531 case OBJ_PLIN:
3532 {
3533 static uno::Sequence< OUString > *pSeq = 0;
3534 if( 0 == pSeq )
3535 {
3536 // OGuard aGuard( Application::GetSolarMutex() );
3537 // if( 0 == pSeq )
3538 {
3539 static uno::Sequence< OUString > SvxShape_PathServices;
3540 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices,14,
3541 sUNO_service_drawing_PolyLineShape,
3542
3543 sUNO_service_drawing_Shape,
3544 sUNO_service_drawing_LineProperties,
3545
3546 sUNO_service_drawing_PolyPolygonDescriptor,
3547
3548 sUNO_service_drawing_Text,
3549 sUNO_service_drawing_TextProperties,
3550 sUNO_service_style_ParagraphProperties,
3551 sUNO_service_style_ParagraphPropertiesComplex,
3552 sUNO_service_style_ParagraphPropertiesAsian,
3553 sUNO_service_style_CharacterProperties,
3554 sUNO_service_style_CharacterPropertiesComplex,
3555 sUNO_service_style_CharacterPropertiesAsian,
3556
3557 sUNO_service_drawing_ShadowProperties,
3558 sUNO_service_drawing_RotationDescriptor);
3559 pSeq = &SvxShape_PathServices;
3560 }
3561 }
3562 return *pSeq;
3563 }
3564
3565 case OBJ_PATHPOLY:
3566 case OBJ_POLY:
3567 {
3568 static uno::Sequence< OUString > *pSeq = 0;
3569 if( 0 == pSeq )
3570 {
3571 // OGuard aGuard( Application::GetSolarMutex() );
3572 // if( 0 == pSeq )
3573 {
3574 static uno::Sequence< OUString > SvxShape_PolyServices;
3575 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices,15,
3576 sUNO_service_drawing_PolyPolygonShape,
3577
3578 sUNO_service_drawing_Shape,
3579 sUNO_service_drawing_LineProperties,
3580 sUNO_service_drawing_FillProperties,
3581
3582 sUNO_service_drawing_PolyPolygonDescriptor,
3583
3584 sUNO_service_drawing_Text,
3585 sUNO_service_drawing_TextProperties,
3586 sUNO_service_style_ParagraphProperties,
3587 sUNO_service_style_ParagraphPropertiesComplex,
3588 sUNO_service_style_ParagraphPropertiesAsian,
3589 sUNO_service_style_CharacterProperties,
3590 sUNO_service_style_CharacterPropertiesComplex,
3591 sUNO_service_style_CharacterPropertiesAsian,
3592
3593 sUNO_service_drawing_ShadowProperties,
3594 sUNO_service_drawing_RotationDescriptor);
3595
3596 pSeq = &SvxShape_PolyServices;
3597 }
3598 }
3599 return *pSeq;
3600 }
3601
3602 case OBJ_FREELINE:
3603 case OBJ_PATHLINE:
3604 {
3605 static uno::Sequence< OUString > *pSeq = 0;
3606 if( 0 == pSeq )
3607 {
3608 // OGuard aGuard( Application::GetSolarMutex() );
3609 // if( 0 == pSeq )
3610 {
3611 static uno::Sequence< OUString > SvxShape_FreeLineServices;
3612
3613 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices,15,
3614 sUNO_service_drawing_OpenBezierShape,
3615
3616 sUNO_service_drawing_Shape,
3617 sUNO_service_drawing_LineProperties,
3618 sUNO_service_drawing_FillProperties,
3619
3620 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3621
3622 sUNO_service_drawing_Text,
3623 sUNO_service_drawing_TextProperties,
3624 sUNO_service_style_ParagraphProperties,
3625 sUNO_service_style_ParagraphPropertiesComplex,
3626 sUNO_service_style_ParagraphPropertiesAsian,
3627 sUNO_service_style_CharacterProperties,
3628 sUNO_service_style_CharacterPropertiesComplex,
3629 sUNO_service_style_CharacterPropertiesAsian,
3630
3631 sUNO_service_drawing_ShadowProperties,
3632 sUNO_service_drawing_RotationDescriptor);
3633
3634 pSeq = &SvxShape_FreeLineServices;
3635 }
3636 }
3637
3638 return *pSeq;
3639 }
3640
3641 case OBJ_FREEFILL:
3642 case OBJ_PATHFILL:
3643 {
3644 static uno::Sequence< OUString > *pSeq = 0;
3645 if( 0 == pSeq )
3646 {
3647 // OGuard aGuard( Application::GetSolarMutex() );
3648 // if( 0 == pSeq )
3649 {
3650 static uno::Sequence< OUString > SvxShape_FreeFillServices;
3651 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices,15,
3652 sUNO_service_drawing_ClosedBezierShape,
3653
3654 sUNO_service_drawing_Shape,
3655 sUNO_service_drawing_LineProperties,
3656 sUNO_service_drawing_FillProperties,
3657
3658 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3659
3660 sUNO_service_drawing_Text,
3661 sUNO_service_drawing_TextProperties,
3662 sUNO_service_style_ParagraphProperties,
3663 sUNO_service_style_ParagraphPropertiesComplex,
3664 sUNO_service_style_ParagraphPropertiesAsian,
3665 sUNO_service_style_CharacterProperties,
3666 sUNO_service_style_CharacterPropertiesComplex,
3667 sUNO_service_style_CharacterPropertiesAsian,
3668
3669 sUNO_service_drawing_ShadowProperties,
3670 sUNO_service_drawing_RotationDescriptor);
3671
3672 pSeq = &SvxShape_FreeFillServices;
3673 }
3674 }
3675 return *pSeq;
3676 }
3677
3678 case OBJ_OUTLINETEXT:
3679 case OBJ_TITLETEXT:
3680 case OBJ_TEXT:
3681 {
3682 static uno::Sequence< OUString > *pSeq = 0;
3683 if( 0 == pSeq )
3684 {
3685 // OGuard aGuard( Application::GetSolarMutex() );
3686 // if( 0 == pSeq )
3687 {
3688 static uno::Sequence< OUString > SvxShape_TextServices;
3689 comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices,14,
3690 sUNO_service_drawing_TextShape,
3691
3692 sUNO_service_drawing_Shape,
3693 sUNO_service_drawing_FillProperties,
3694 sUNO_service_drawing_LineProperties,
3695
3696 sUNO_service_drawing_Text,
3697 sUNO_service_drawing_TextProperties,
3698 sUNO_service_style_ParagraphProperties,
3699 sUNO_service_style_ParagraphPropertiesComplex,
3700 sUNO_service_style_ParagraphPropertiesAsian,
3701 sUNO_service_style_CharacterProperties,
3702 sUNO_service_style_CharacterPropertiesComplex,
3703 sUNO_service_style_CharacterPropertiesAsian,
3704
3705 sUNO_service_drawing_ShadowProperties,
3706 sUNO_service_drawing_RotationDescriptor);
3707
3708 pSeq = &SvxShape_TextServices;
3709 }
3710 }
3711 return *pSeq;
3712 }
3713
3714 case OBJ_GRAF:
3715 {
3716 static uno::Sequence< OUString > *pSeq = 0;
3717 if( 0 == pSeq )
3718 {
3719 // OGuard aGuard( Application::GetSolarMutex() );
3720 // if( 0 == pSeq )
3721 {
3722 static uno::Sequence< OUString > SvxShape_GrafServices;
3723 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, 12,
3724 sUNO_service_drawing_GraphicObjectShape,
3725
3726 sUNO_service_drawing_Shape,
3727
3728 sUNO_service_drawing_Text,
3729 sUNO_service_drawing_TextProperties,
3730 sUNO_service_style_ParagraphProperties,
3731 sUNO_service_style_ParagraphPropertiesComplex,
3732 sUNO_service_style_ParagraphPropertiesAsian,
3733 sUNO_service_style_CharacterProperties,
3734 sUNO_service_style_CharacterPropertiesComplex,
3735 sUNO_service_style_CharacterPropertiesAsian,
3736
3737 sUNO_service_drawing_ShadowProperties,
3738 sUNO_service_drawing_RotationDescriptor);
3739
3740 pSeq = &SvxShape_GrafServices;
3741 }
3742 }
3743 return *pSeq;
3744 }
3745
3746 case OBJ_OLE2:
3747 {
3748 static uno::Sequence< OUString > *pSeq = 0;
3749 if( 0 == pSeq )
3750 {
3751 // OGuard aGuard( Application::GetSolarMutex() );
3752 // if( 0 == pSeq )
3753 {
3754 static uno::Sequence< OUString > SvxShape_Ole2Services;
3755
3756 comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, 2,
3757 sUNO_service_drawing_OLE2Shape,
3758 sUNO_service_drawing_Shape,
3759
3760 // #i118485# Added Text, Shadow and Rotation
3761 sUNO_service_drawing_Text,
3762 sUNO_service_drawing_TextProperties,
3763 sUNO_service_style_ParagraphProperties,
3764 sUNO_service_style_ParagraphPropertiesComplex,
3765 sUNO_service_style_ParagraphPropertiesAsian,
3766 sUNO_service_style_CharacterProperties,
3767 sUNO_service_style_CharacterPropertiesComplex,
3768 sUNO_service_style_CharacterPropertiesAsian,
3769
3770 sUNO_service_drawing_ShadowProperties,
3771 sUNO_service_drawing_RotationDescriptor);
3772
3773 pSeq = &SvxShape_Ole2Services;
3774 }
3775 }
3776 return *pSeq;
3777 }
3778
3779 case OBJ_CAPTION:
3780 {
3781 static uno::Sequence< OUString > *pSeq = 0;
3782 if( 0 == pSeq )
3783 {
3784 // OGuard aGuard( Application::GetSolarMutex() );
3785 // if( 0 == pSeq )
3786 {
3787 static uno::Sequence< OUString > SvxShape_CaptionServices;
3788
3789 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices,14,
3790 sUNO_service_drawing_CaptionShape,
3791
3792 sUNO_service_drawing_Shape,
3793 sUNO_service_drawing_FillProperties,
3794 sUNO_service_drawing_LineProperties,
3795
3796 sUNO_service_drawing_Text,
3797 sUNO_service_drawing_TextProperties,
3798 sUNO_service_style_ParagraphProperties,
3799 sUNO_service_style_ParagraphPropertiesComplex,
3800 sUNO_service_style_ParagraphPropertiesAsian,
3801 sUNO_service_style_CharacterProperties,
3802 sUNO_service_style_CharacterPropertiesComplex,
3803 sUNO_service_style_CharacterPropertiesAsian,
3804
3805 sUNO_service_drawing_ShadowProperties,
3806 sUNO_service_drawing_RotationDescriptor);
3807
3808 pSeq = &SvxShape_CaptionServices;
3809 }
3810 }
3811
3812 return *pSeq;
3813 }
3814
3815 case OBJ_PAGE:
3816 {
3817 static uno::Sequence< OUString > *pSeq = 0;
3818 if( 0 == pSeq )
3819 {
3820 // OGuard aGuard( Application::GetSolarMutex() );
3821 // if( 0 == pSeq )
3822 {
3823 static uno::Sequence< OUString > SvxShape_PageServices;
3824
3825 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, 2,
3826 sUNO_service_drawing_PageShape,
3827 sUNO_service_drawing_Shape );
3828
3829 pSeq = &SvxShape_PageServices;
3830 }
3831 }
3832
3833 return *pSeq;
3834 }
3835
3836 case OBJ_MEASURE:
3837 {
3838 static uno::Sequence< OUString > *pSeq = 0;
3839 if( 0 == pSeq )
3840 {
3841 // OGuard aGuard( Application::GetSolarMutex() );
3842 // if( 0 == pSeq )
3843 {
3844 static uno::Sequence< OUString > SvxShape_MeasureServices;
3845 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices,15,
3846 sUNO_service_drawing_MeasureShape,
3847
3848 sUNO_service_drawing_MeasureProperties,
3849
3850 sUNO_service_drawing_Shape,
3851 sUNO_service_drawing_LineProperties,
3852
3853 sUNO_service_drawing_Text,
3854 sUNO_service_drawing_TextProperties,
3855 sUNO_service_style_ParagraphProperties,
3856 sUNO_service_style_ParagraphPropertiesComplex,
3857 sUNO_service_style_ParagraphPropertiesAsian,
3858 sUNO_service_style_CharacterProperties,
3859 sUNO_service_style_CharacterPropertiesComplex,
3860 sUNO_service_style_CharacterPropertiesAsian,
3861
3862 sUNO_service_drawing_PolyPolygonDescriptor,
3863 sUNO_service_drawing_ShadowProperties,
3864 sUNO_service_drawing_RotationDescriptor);
3865
3866 pSeq = &SvxShape_MeasureServices;
3867 }
3868 }
3869
3870 return *pSeq;
3871 }
3872
3873 case OBJ_FRAME:
3874 {
3875 static uno::Sequence< OUString > *pSeq = 0;
3876 if( 0 == pSeq )
3877 {
3878 // OGuard aGuard( Application::GetSolarMutex() );
3879 // if( 0 == pSeq )
3880 {
3881 static uno::Sequence< OUString > SvxShape_FrameServices;
3882
3883 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, 2,
3884 sUNO_service_drawing_FrameShape,
3885 sUNO_service_drawing_Shape );
3886
3887 pSeq = &SvxShape_FrameServices;
3888 }
3889 }
3890
3891 return *pSeq;
3892 }
3893
3894 case OBJ_UNO:
3895 {
3896 static uno::Sequence< OUString > *pSeq = 0;
3897 if( 0 == pSeq )
3898 {
3899 // OGuard _aGuard( Application::GetSolarMutex() );
3900 // if( 0 == pSeq )
3901 {
3902 static uno::Sequence< OUString > SvxShape_UnoServices;
3903 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
3904 sUNO_service_drawing_ControlShape,
3905 sUNO_service_drawing_Shape );
3906
3907 pSeq = &SvxShape_UnoServices;
3908 }
3909 }
3910 return *pSeq;
3911 }
3912
3913 case OBJ_EDGE:
3914 {
3915 static uno::Sequence< OUString > *pSeq = 0;
3916 if( 0 == pSeq )
3917 {
3918 // OGuard aGuard( Application::GetSolarMutex() );
3919 // if( 0 == pSeq )
3920 {
3921 static uno::Sequence< OUString > SvxShape_EdgeServices;
3922
3923 comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices,15,
3924 sUNO_service_drawing_ConnectorShape,
3925 sUNO_service_drawing_ConnectorProperties,
3926
3927 sUNO_service_drawing_Shape,
3928 sUNO_service_drawing_LineProperties,
3929
3930 sUNO_service_drawing_Text,
3931 sUNO_service_drawing_TextProperties,
3932 sUNO_service_style_ParagraphProperties,
3933 sUNO_service_style_ParagraphPropertiesComplex,
3934 sUNO_service_style_ParagraphPropertiesAsian,
3935 sUNO_service_style_CharacterProperties,
3936 sUNO_service_style_CharacterPropertiesComplex,
3937 sUNO_service_style_CharacterPropertiesAsian,
3938
3939 sUNO_service_drawing_PolyPolygonDescriptor,
3940 sUNO_service_drawing_ShadowProperties,
3941 sUNO_service_drawing_RotationDescriptor);
3942
3943 pSeq = &SvxShape_EdgeServices;
3944 }
3945 }
3946 return *pSeq;
3947 }
3948 case OBJ_MEDIA:
3949 {
3950 static uno::Sequence< OUString > *pSeq = 0;
3951 if( 0 == pSeq )
3952 {
3953 // OGuard aGuard( Application::GetSolarMutex() );
3954 // if( 0 == pSeq )
3955 {
3956 static uno::Sequence< OUString > SvxShape_MediaServices;
3957
3958 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, 2,
3959 sUNO_service_drawing_MediaShape,
3960 sUNO_service_drawing_Shape);
3961
3962 pSeq = &SvxShape_MediaServices;
3963 }
3964 }
3965 return *pSeq;
3966 }
3967 }
3968 }
3969 else if( mpObj.is() && mpObj->GetObjInventor() == FmFormInventor)
3970 {
3971 #if OSL_DEBUG_LEVEL > 0
3972 const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
3973 OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: FmFormInventor, but no UNO object?" );
3974 #endif
3975 static uno::Sequence< OUString > *pSeq = 0;
3976 if( 0 == pSeq )
3977 {
3978 // OGuard aGuard( Application::GetSolarMutex() );
3979 // if( 0 == pSeq )
3980 {
3981 static uno::Sequence< OUString > SvxShape_UnoServices;
3982 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
3983 sUNO_service_drawing_ControlShape,
3984 sUNO_service_drawing_Shape );
3985
3986 pSeq = &SvxShape_UnoServices;
3987 }
3988 }
3989 return *pSeq;
3990 }
3991 OSL_ENSURE( false, "SvxShape::_getSupportedServiceNames: could not determine object type!" );
3992 uno::Sequence< OUString > aSeq;
3993 return aSeq;
3994 }
3995
3996 //----------------------------------------------------------------------
supportsService(const OUString & ServiceName)3997 sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName )
3998 {
3999 Sequence< OUString > SupportedServices( getSupportedServiceNames() );
4000 const ::rtl::OUString * pArray = SupportedServices.getConstArray();
4001 const sal_Int32 nCount = SupportedServices.getLength();
4002 sal_Int32 i;
4003 for( i = 0; i < nCount; i++ )
4004 if( *pArray++ == ServiceName )
4005 return sal_True;
4006 return sal_False;
4007 }
4008
4009 //----------------------------------------------------------------------
4010
4011 // XGluePointsSupplier
getGluePoints()4012 uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints()
4013 {
4014 OGuard aGuard( Application::GetSolarMutex() );
4015 uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints );
4016
4017 if( mpObj.is() && !xGluePoints.is() )
4018 {
4019 uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY );
4020 mxGluePoints = xGluePoints = xNew;
4021 }
4022
4023 return xGluePoints;
4024 }
4025
4026 //----------------------------------------------------------------------
4027
4028 // XChild
getParent()4029 uno::Reference< uno::XInterface > SAL_CALL SvxShape::getParent( )
4030 {
4031 OGuard aGuard( Application::GetSolarMutex() );
4032
4033 if( mpObj.is() && mpObj->GetObjList() )
4034 {
4035 SdrObjList* pObjList = mpObj->GetObjList();
4036
4037 switch( pObjList->GetListKind() )
4038 {
4039 case SDROBJLIST_GROUPOBJ:
4040 if( pObjList->GetOwnerObj()->ISA( SdrObjGroup ) )
4041 return PTR_CAST( SdrObjGroup, pObjList->GetOwnerObj())->getUnoShape();
4042 else if( pObjList->GetOwnerObj()->ISA( E3dScene ) )
4043 return PTR_CAST( E3dScene, pObjList->GetOwnerObj())->getUnoShape();
4044 break;
4045 case SDROBJLIST_DRAWPAGE:
4046 case SDROBJLIST_MASTERPAGE:
4047 return PTR_CAST( SdrPage, pObjList )->getUnoPage();
4048 default:
4049 DBG_ERROR( "SvxShape::getParent( ): unexpected SdrObjListKind" );
4050 break;
4051 }
4052 }
4053
4054 uno::Reference< uno::XInterface > xParent;
4055 return xParent;
4056 }
4057
4058 //----------------------------------------------------------------------
4059
setParent(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> &)4060 void SAL_CALL SvxShape::setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& )
4061 {
4062 throw lang::NoSupportException();
4063 }
4064
4065 //----------------------------------------------------------------------
4066
4067 /** called from the XActionLockable interface methods on initial locking */
lock()4068 void SvxShape::lock()
4069 {
4070 }
4071
4072 //----------------------------------------------------------------------
4073
4074 /** called from the XActionLockable interface methods on final unlock */
unlock()4075 void SvxShape::unlock()
4076 {
4077 }
4078
4079 //----------------------------------------------------------------------
4080
4081 // XActionLockable
isActionLocked()4082 sal_Bool SAL_CALL SvxShape::isActionLocked( )
4083 {
4084 OGuard aGuard( Application::GetSolarMutex() );
4085
4086 return mnLockCount != 0;
4087 }
4088
4089 //----------------------------------------------------------------------
4090
addActionLock()4091 void SAL_CALL SvxShape::addActionLock( )
4092 {
4093 OGuard aGuard( Application::GetSolarMutex() );
4094
4095 DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" );
4096 mnLockCount++;
4097
4098 if( mnLockCount == 1 )
4099 lock();
4100 }
4101
4102 //----------------------------------------------------------------------
4103
removeActionLock()4104 void SAL_CALL SvxShape::removeActionLock( )
4105 {
4106 OGuard aGuard( Application::GetSolarMutex() );
4107
4108 DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" );
4109 mnLockCount--;
4110
4111 if( mnLockCount == 0 )
4112 unlock();
4113 }
4114
4115 //----------------------------------------------------------------------
4116
setActionLocks(sal_Int16 nLock)4117 void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock )
4118 {
4119 OGuard aGuard( Application::GetSolarMutex() );
4120
4121 if( (mnLockCount == 0) && (nLock != 0) )
4122 unlock();
4123
4124 if( (mnLockCount != 0) && (nLock == 0) )
4125 lock();
4126
4127 mnLockCount = (sal_uInt16)nLock;
4128 }
4129
4130 //----------------------------------------------------------------------
4131
resetActionLocks()4132 sal_Int16 SAL_CALL SvxShape::resetActionLocks( )
4133 {
4134 OGuard aGuard( Application::GetSolarMutex() );
4135
4136 if( mnLockCount != 0 )
4137 unlock();
4138
4139 sal_Int16 nOldLocks = (sal_Int16)mnLockCount;
4140 mnLockCount = 0;
4141
4142 return nOldLocks;
4143 }
4144
4145 //----------------------------------------------------------------------
4146
4147 /** since polygon shapes can change theire kind during editing, we have
4148 to recheck it here.
4149 Circle shapes also change theire kind, but theire all treated equal
4150 so no update is necessary.
4151 */
updateShapeKind()4152 void SvxShape::updateShapeKind()
4153 {
4154 switch( mpImpl->mnObjId )
4155 {
4156 case OBJ_LINE:
4157 case OBJ_POLY:
4158 case OBJ_PLIN:
4159 case OBJ_PATHLINE:
4160 case OBJ_PATHFILL:
4161 case OBJ_FREELINE:
4162 case OBJ_FREEFILL:
4163 case OBJ_PATHPOLY:
4164 case OBJ_PATHPLIN:
4165 {
4166 const sal_uInt32 nId = mpObj->GetObjIdentifier();
4167
4168 if( nId != mpImpl->mnObjId )
4169 {
4170 mpImpl->mnObjId = nId;
4171
4172 }
4173 break;
4174 }
4175 };
4176 }
4177
4178 /***********************************************************************
4179 * class SvxShapeText *
4180 ***********************************************************************/
SvxShapeText()4181 SvxShapeText::SvxShapeText() throw ()
4182 : SvxShape(NULL, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
4183 {
4184 }
4185
4186 //----------------------------------------------------------------------
SvxShapeText(SdrObject * pObject)4187 SvxShapeText::SvxShapeText( SdrObject* pObject ) throw ()
4188 : SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
4189 {
4190 if( pObject && pObject->GetModel() )
4191 SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) );
4192 }
4193
4194 //----------------------------------------------------------------------
SvxShapeText(SdrObject * pObject,const SfxItemPropertyMapEntry * pPropertyMap,const SvxItemPropertySet * pPropertySet)4195 SvxShapeText::SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw ()
4196 : SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
4197 {
4198 if( pObject && pObject->GetModel() )
4199 SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) );
4200 }
4201
4202 //----------------------------------------------------------------------
~SvxShapeText()4203 SvxShapeText::~SvxShapeText() throw ()
4204 {
4205 // check if only this instance is registered at the ranges
4206 DBG_ASSERT( (NULL == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
4207 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
4208 }
4209
Create(SdrObject * pNewObj,SvxDrawPage * pNewPage)4210 void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
4211 {
4212 if( pNewObj && (NULL == GetEditSource()))
4213 SetEditSource( new SvxTextEditSource( pNewObj, 0, static_cast< uno::XWeak* >(this) ) );
4214
4215 SvxShape::Create( pNewObj, pNewPage );
4216 }
4217
4218 // XInterface
4219 //----------------------------------------------------------------------
queryInterface(const uno::Type & rType)4220 uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType )
4221 {
4222 return SvxShape::queryInterface( rType );
4223 }
4224
4225 //----------------------------------------------------------------------
4226
queryAggregation(const uno::Type & rType)4227 uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType )
4228 {
4229 uno::Any aAny( SvxShape::queryAggregation( rType ) );
4230 if( aAny.hasValue() )
4231 return aAny;
4232
4233 return SvxUnoTextBase::queryAggregation( rType );
4234 }
4235
4236 //----------------------------------------------------------------------
4237
acquire()4238 void SAL_CALL SvxShapeText::acquire() throw()
4239 {
4240 SvxShape::acquire();
4241 }
4242
4243 //----------------------------------------------------------------------
release()4244 void SAL_CALL SvxShapeText::release() throw()
4245 {
4246 SvxShape::release();
4247 }
4248
4249 // XServiceInfo
4250 //----------------------------------------------------------------------
getImplementationName()4251 OUString SAL_CALL SvxShapeText::getImplementationName()
4252 {
4253 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShapeText") );
4254 return aServiceName;
4255 }
4256
4257 //----------------------------------------------------------------------
getSupportedServiceNames()4258 uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames()
4259 {
4260 return SvxShape::getSupportedServiceNames();
4261 }
4262
4263 //----------------------------------------------------------------------
supportsService(const OUString & ServiceName)4264 sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName )
4265 {
4266 return SvxShape::supportsService(ServiceName);
4267 }
4268
4269 // XTypeProvider
4270 //----------------------------------------------------------------------
getTypes()4271 uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes()
4272 {
4273 return SvxShape::getTypes();
4274 }
4275
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rId)4276 sal_Int64 SAL_CALL SvxShapeText::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) \
4277 {
4278 const sal_Int64 nReturn = SvxShape::getSomething( rId );
4279 if( nReturn )
4280 return nReturn;
4281
4282 return SvxUnoTextBase::getSomething( rId );
4283 }
4284
4285 //----------------------------------------------------------------------
getImplementationId()4286 uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId()
4287 {
4288 static ::cppu::OImplementationId* pID = NULL ;
4289
4290 if ( pID == NULL )
4291 {
4292 // Ready for multithreading; get global mutex for first call of this method only! see before
4293 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
4294
4295 // Control these pointer again ... it can be, that another instance will be faster then these!
4296 if ( pID == NULL )
4297 {
4298 // Create a new static ID ...
4299 static ::cppu::OImplementationId aID( sal_False ) ;
4300 // ... and set his address to static pointer!
4301 pID = &aID ;
4302 }
4303 }
4304
4305 return pID->getImplementationId() ;
4306 }
4307
4308 //----------------------------------------------------------------------
4309
4310 /** called from the XActionLockable interface methods on initial locking */
lock()4311 void SvxShapeText::lock()
4312 {
4313 SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource();
4314 if( pEditSource )
4315 pEditSource->lock();
4316 }
4317
4318 //----------------------------------------------------------------------
4319
4320 /** called from the XActionLockable interface methods on final unlock */
unlock()4321 void SvxShapeText::unlock()
4322 {
4323 SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource();
4324 if( pEditSource )
4325 pEditSource->unlock();
4326 }
4327
4328 // ::com::sun::star::text::XTextRange
getStart()4329 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart()
4330 {
4331 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4332 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4333 if( pForwarder )
4334 ::GetSelection( maSelection, pForwarder );
4335 return SvxUnoTextBase::getStart();
4336
4337 }
4338
getEnd()4339 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd()
4340 {
4341 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4342 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4343 if( pForwarder )
4344 ::GetSelection( maSelection, pForwarder );
4345 return SvxUnoTextBase::getEnd();
4346 }
4347
getString()4348 OUString SAL_CALL SvxShapeText::getString()
4349 {
4350 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4351 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4352 if( pForwarder )
4353 ::GetSelection( maSelection, pForwarder );
4354 return SvxUnoTextBase::getString();
4355 }
4356
4357
setString(const OUString & aString)4358 void SAL_CALL SvxShapeText::setString( const OUString& aString )
4359 {
4360 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4361 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4362 if( pForwarder )
4363 ::GetSelection( maSelection, pForwarder );
4364 SvxUnoTextBase::setString( aString );
4365 }
4366
4367 // overide these for special property handling in subcasses. Return true if property is handled
setPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,const::com::sun::star::uno::Any & rValue)4368 bool SvxShapeText::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue )
4369 {
4370 // HACK-fix #99090#
4371 // since SdrTextObj::SetVerticalWriting exchanges
4372 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
4373 // we have to set the textdirection here
4374
4375 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
4376 {
4377 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
4378 if( pTextObj )
4379 {
4380 com::sun::star::text::WritingMode eMode;
4381 if( rValue >>= eMode )
4382 {
4383 pTextObj->SetVerticalWriting( eMode == com::sun::star::text::WritingMode_TB_RL );
4384 }
4385 }
4386 return true;
4387 }
4388 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
4389 }
4390
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)4391 bool SvxShapeText::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue )
4392 {
4393 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
4394 {
4395 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
4396 if( pTextObj && pTextObj->IsVerticalWriting() )
4397 rValue <<= com::sun::star::text::WritingMode_TB_RL;
4398 else
4399 rValue <<= com::sun::star::text::WritingMode_LR_TB;
4400 return true;
4401 }
4402
4403 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
4404 }
4405
getPropertyStateImpl(const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::beans::PropertyState & rState)4406 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState )
4407 {
4408 return SvxShape::getPropertyStateImpl( pProperty, rState );
4409 }
4410
setPropertyToDefaultImpl(const SfxItemPropertySimpleEntry * pProperty)4411 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty )
4412 {
4413 return SvxShape::setPropertyToDefaultImpl( pProperty );
4414 }
4415
4416 /***********************************************************************
4417 * class SvxShapeRect *
4418 ***********************************************************************/
DBG_NAME(SvxShapeRect)4419 DBG_NAME(SvxShapeRect)
4420 SvxShapeRect::SvxShapeRect( SdrObject* pObj ) throw()
4421 : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_SHAPE), aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
4422 {
4423 DBG_CTOR(SvxShapeRect,NULL);
4424 }
4425
~SvxShapeRect()4426 SvxShapeRect::~SvxShapeRect() throw()
4427 {
4428 DBG_DTOR(SvxShapeRect,NULL);
4429 }
4430
queryInterface(const uno::Type & rType)4431 uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType )
4432 {
4433 return SvxShapeText::queryInterface( rType );
4434 }
4435
queryAggregation(const uno::Type & rType)4436 uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType )
4437 {
4438 return SvxShapeText::queryAggregation( rType );
4439 }
4440
acquire()4441 void SAL_CALL SvxShapeRect::acquire() throw()
4442 {
4443 OWeakAggObject::acquire();
4444 }
4445
release()4446 void SAL_CALL SvxShapeRect::release() throw()
4447 {
4448 OWeakAggObject::release();
4449 }
4450 //----------------------------------------------------------------------
4451 // XServiceInfo
4452 //----------------------------------------------------------------------
getSupportedServiceNames(void)4453 uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames(void)
4454 {
4455 return SvxShape::getSupportedServiceNames();
4456 }
4457
4458 /** returns a StarOffice API wrapper for the given SdrObject */
GetXShapeForSdrObject(SdrObject * pObj)4459 uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw ()
4460 {
4461 uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
4462 return xShape;
4463 }
4464
4465 /** returns the SdrObject from the given StarOffice API wrapper */
GetSdrObjectFromXShape(uno::Reference<drawing::XShape> xShape)4466 SdrObject* GetSdrObjectFromXShape( uno::Reference< drawing::XShape > xShape ) throw()
4467 {
4468 SvxShape* pShape = SvxShape::getImplementation( xShape );
4469 return pShape ? pShape->GetSdrObject() : 0;
4470 }
4471
4472 //----------------------------------------------------------------------
4473
getSdrObjectFromXShape(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xInt)4474 SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt )
4475 {
4476 SvxShape* pSvxShape = SvxShape::getImplementation( xInt );
4477 return pSvxShape ? pSvxShape->GetSdrObject() : 0;
4478 }
4479
SvxItemPropertySet_getPropertyValue(const SvxItemPropertySet & rPropSet,const SfxItemPropertySimpleEntry * pMap,const SfxItemSet & rSet)4480 uno::Any SvxItemPropertySet_getPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet )
4481 {
4482 if(!pMap || !pMap->nWID)
4483 return uno::Any();
4484
4485 // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ.
4486 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4487 return rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues );
4488 }
4489
SvxItemPropertySet_setPropertyValue(const SvxItemPropertySet & rPropSet,const SfxItemPropertySimpleEntry * pMap,const uno::Any & rVal,SfxItemSet & rSet)4490 void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet )
4491 {
4492 if(!pMap || !pMap->nWID)
4493 return;
4494
4495 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4496 rPropSet.setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues );
4497 }
4498