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)
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 SDRATTR_OBJPRINTABLE:
2588 {
2589 sal_Bool bPrintable = sal_Bool();
2590 if( rValue >>= bPrintable )
2591 {
2592 mpObj->SetPrintable(bPrintable);
2593 return true;
2594 }
2595 break;
2596 }
2597 case SDRATTR_OBJVISIBLE:
2598 {
2599 sal_Bool bVisible = sal_Bool();
2600 if( rValue >>= bVisible )
2601 {
2602 mpObj->SetVisible(bVisible);
2603 return true;
2604 }
2605 break;
2606 }
2607 case SDRATTR_OBJSIZEPROTECT:
2608 {
2609 sal_Bool bResizeProtect = sal_Bool();
2610 if( rValue >>= bResizeProtect )
2611 {
2612 mpObj->SetResizeProtect(bResizeProtect);
2613 return true;
2614 }
2615 break;
2616 }
2617 case OWN_ATTR_PAGE_NUMBER:
2618 {
2619 sal_Int32 nPageNum = 0;
2620 if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
2621 {
2622 SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get());
2623 if( pPageObj )
2624 {
2625 SdrModel* pModel = pPageObj->GetModel();
2626 SdrPage* pNewPage = 0L;
2627 const sal_uInt16 nDestinationPageNum((sal_uInt16)((nPageNum << 1L) - 1L));
2628
2629 if(pModel)
2630 {
2631 if(nDestinationPageNum < pModel->GetPageCount())
2632 {
2633 pNewPage = pModel->GetPage(nDestinationPageNum);
2634 }
2635 }
2636
2637 pPageObj->SetReferencedPage(pNewPage);
2638 }
2639
2640 return true;
2641 }
2642 break;
2643 }
2644 case XATTR_FILLBITMAP:
2645 case XATTR_FILLGRADIENT:
2646 case XATTR_FILLHATCH:
2647 case XATTR_FILLFLOATTRANSPARENCE:
2648 case XATTR_LINEEND:
2649 case XATTR_LINESTART:
2650 case XATTR_LINEDASH:
2651 {
2652 if( pProperty->nMemberId == MID_NAME )
2653 {
2654 OUString aApiName;
2655 if( rValue >>= aApiName )
2656 {
2657 if( SetFillAttribute( pProperty->nWID, aApiName ) )
2658 return true;
2659 }
2660 break;
2661 }
2662 else
2663 {
2664 return false;
2665 }
2666 }
2667 default:
2668 {
2669 return false;
2670 }
2671 }
2672 throw lang::IllegalArgumentException();
2673 }
2674
2675 //----------------------------------------------------------------------
2676
getPropertyValueImpl(const::rtl::OUString &,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)2677 bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue )
2678 {
2679 switch( pProperty->nWID )
2680 {
2681 /*
2682 case OWN_ATTR_HASLEVELS:
2683 {
2684 rValue <<= SvxTextEditSource::hasLevels( mpObj.get() );
2685 break;
2686 }
2687 */
2688 case OWN_ATTR_CAPTION_POINT:
2689 {
2690 Point aVclPoint = ((SdrCaptionObj*)mpObj.get())->GetTailPos();
2691
2692 // #88491# make pos relative to anchor
2693 if( mpModel->IsWriter() )
2694 {
2695 aVclPoint -= mpObj->GetAnchorPos();
2696 }
2697
2698 // #88657# metric of pool maybe twips (writer)
2699 ForceMetricTo100th_mm(aVclPoint);
2700
2701 // #90763# pos is absolute, make it relative to top left
2702 basegfx::B2DPolyPolygon aNewPolyPolygon;
2703 basegfx::B2DHomMatrix aNewHomogenMatrix;
2704 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2705
2706 aVclPoint.X() -= basegfx::fround(aNewHomogenMatrix.get(0, 2));
2707 aVclPoint.Y() -= basegfx::fround(aNewHomogenMatrix.get(1, 2));
2708
2709 awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() );
2710 rValue <<= aPnt;
2711 break;
2712 }
2713
2714 case OWN_ATTR_TRANSFORMATION:
2715 {
2716 basegfx::B2DPolyPolygon aNewPolyPolygon;
2717 basegfx::B2DHomMatrix aNewHomogenMatrix;
2718 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2719 drawing::HomogenMatrix3 aMatrix;
2720
2721 aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
2722 aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1);
2723 aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2);
2724 aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0);
2725 aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1);
2726 aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2);
2727 aMatrix.Line3.Column1 = aNewHomogenMatrix.get(2, 0);
2728 aMatrix.Line3.Column2 = aNewHomogenMatrix.get(2, 1);
2729 aMatrix.Line3.Column3 = aNewHomogenMatrix.get(2, 2);
2730
2731 rValue <<= aMatrix;
2732
2733 break;
2734 }
2735
2736 case OWN_ATTR_ZORDER:
2737 {
2738 rValue <<= (sal_Int32)mpObj->GetOrdNum();
2739 break;
2740 }
2741
2742 case OWN_ATTR_BITMAP:
2743 {
2744 rValue = GetBitmap();
2745 if(!rValue.hasValue())
2746 throw uno::RuntimeException();
2747
2748 break;
2749 }
2750
2751 case OWN_ATTR_ISFONTWORK:
2752 {
2753 rValue <<= (sal_Bool)(mpObj->ISA(SdrTextObj) && ((SdrTextObj*)mpObj.get())->IsFontwork());
2754 break;
2755 }
2756
2757 case OWN_ATTR_FRAMERECT:
2758 {
2759 Rectangle aRect( mpObj->GetSnapRect() );
2760 Point aTopLeft( aRect.TopLeft() );
2761 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2762 ForceMetricTo100th_mm(aTopLeft);
2763 ForceMetricTo100th_mm(aObjSize);
2764 ::com::sun::star::awt::Rectangle aUnoRect(
2765 aTopLeft.X(), aTopLeft.Y(),
2766 aObjSize.getWidth(), aObjSize.getHeight() );
2767 rValue <<= aUnoRect;
2768 break;
2769 }
2770
2771 case OWN_ATTR_BOUNDRECT:
2772 {
2773 Rectangle aRect( mpObj->GetCurrentBoundRect() );
2774 Point aTopLeft( aRect.TopLeft() );
2775 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2776 ForceMetricTo100th_mm(aTopLeft);
2777 ForceMetricTo100th_mm(aObjSize);
2778 ::com::sun::star::awt::Rectangle aUnoRect(
2779 aTopLeft.X(), aTopLeft.Y(),
2780 aObjSize.getWidth(), aObjSize.getHeight() );
2781 rValue <<= aUnoRect;
2782 break;
2783 }
2784
2785 case OWN_ATTR_LDNAME:
2786 {
2787 OUString aName( mpObj->GetName() );
2788 rValue <<= aName;
2789 break;
2790 }
2791
2792 case OWN_ATTR_LDBITMAP:
2793 {
2794 sal_uInt16 nId;
2795 if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_OLE2 )
2796 {
2797 nId = RID_UNODRAW_OLE2;
2798 }
2799 else if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_GRAF )
2800 {
2801 nId = RID_UNODRAW_GRAPHICS;
2802 }
2803 else
2804 {
2805 nId = RID_UNODRAW_OBJECTS;
2806 }
2807
2808 BitmapEx aBmp( SVX_RES(nId) );
2809 Reference< awt::XBitmap > xBmp( VCLUnoHelper::CreateBitmap( aBmp ) );
2810
2811 rValue <<= xBmp;
2812 break;
2813 }
2814
2815 case OWN_ATTR_MIRRORED:
2816 {
2817 sal_Bool bMirror = sal_False;
2818 if( mpObj.is() && mpObj->ISA(SdrGrafObj) )
2819 bMirror = ((SdrGrafObj*)mpObj.get())->IsMirrored();
2820
2821 rValue <<= bMirror;
2822 }
2823
2824 case OWN_ATTR_EDGE_START_OBJ:
2825 case OWN_ATTR_EDGE_START_POS:
2826 case OWN_ATTR_EDGE_END_POS:
2827 case OWN_ATTR_EDGE_END_OBJ:
2828 case OWN_ATTR_GLUEID_HEAD:
2829 case OWN_ATTR_GLUEID_TAIL:
2830 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2831 {
2832 SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get());
2833 if(pEdgeObj)
2834 {
2835 switch(pProperty->nWID)
2836 {
2837 case OWN_ATTR_EDGE_START_OBJ:
2838 case OWN_ATTR_EDGE_END_OBJ:
2839 {
2840 SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ);
2841 if(pNode)
2842 {
2843 Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) );
2844 if(xShape.is())
2845 rValue <<= xShape;
2846
2847 }
2848 break;
2849 }
2850
2851 case OWN_ATTR_EDGE_START_POS:
2852 case OWN_ATTR_EDGE_END_POS:
2853 {
2854 Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) );
2855 if( mpModel->IsWriter() )
2856 aPoint -= mpObj->GetAnchorPos();
2857
2858 ForceMetricTo100th_mm( aPoint );
2859 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2860
2861 rValue <<= aUnoPoint;
2862 break;
2863 }
2864 case OWN_ATTR_GLUEID_HEAD:
2865 case OWN_ATTR_GLUEID_TAIL:
2866 {
2867 rValue <<= pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD );
2868 break;
2869 }
2870 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2871 {
2872 basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() );
2873 if( mpModel->IsWriter() )
2874 {
2875 Point aPoint( mpObj->GetAnchorPos() );
2876 aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y()));
2877 }
2878 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051
2879 ForceMetricTo100th_mm( aPolyPoly );
2880 // <--
2881 drawing::PolyPolygonBezierCoords aRetval;
2882 SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval);
2883 rValue <<= aRetval;
2884 break;
2885 }
2886 }
2887 }
2888 break;
2889 }
2890
2891 case OWN_ATTR_MEASURE_START_POS:
2892 case OWN_ATTR_MEASURE_END_POS:
2893 {
2894 SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get());
2895 if(pMeasureObj)
2896 {
2897 Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) );
2898 if( mpModel->IsWriter() )
2899 aPoint -= mpObj->GetAnchorPos();
2900
2901 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051
2902 ForceMetricTo100th_mm( aPoint );
2903 // <--
2904 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2905
2906 rValue <<= aUnoPoint;
2907 break;
2908 }
2909 break;
2910 }
2911
2912 case OWN_ATTR_FILLBMP_MODE:
2913 {
2914 const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet();
2915
2916 XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&rObjItemSet.Get(XATTR_FILLBMP_STRETCH);
2917 XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&rObjItemSet.Get(XATTR_FILLBMP_TILE);
2918
2919 if( pTileItem && pTileItem->GetValue() )
2920 {
2921 rValue <<= drawing::BitmapMode_REPEAT;
2922 }
2923 else if( pStretchItem && pStretchItem->GetValue() )
2924 {
2925 rValue <<= drawing::BitmapMode_STRETCH;
2926 }
2927 else
2928 {
2929 rValue <<= drawing::BitmapMode_NO_REPEAT;
2930 }
2931 break;
2932 }
2933 case SDRATTR_LAYERID:
2934 rValue <<= (sal_Int16)mpObj->GetLayer();
2935 break;
2936
2937 case SDRATTR_LAYERNAME:
2938 {
2939 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer());
2940 if( pLayer )
2941 {
2942 OUString aName( pLayer->GetName() );
2943 rValue <<= aName;
2944 }
2945 break;
2946 }
2947
2948 case SDRATTR_ROTATEANGLE:
2949 rValue <<= mpObj->GetRotateAngle();
2950 break;
2951
2952 case SDRATTR_SHEARANGLE:
2953 rValue <<= mpObj->GetShearAngle();
2954 break;
2955
2956 case SDRATTR_OBJMOVEPROTECT:
2957 rValue = uno::makeAny( (sal_Bool) mpObj->IsMoveProtect() );
2958 break;
2959
2960 case SDRATTR_OBJECTNAME:
2961 {
2962 OUString aName( mpObj->GetName() );
2963 rValue <<= aName;
2964 break;
2965 }
2966
2967 // #i68101#
2968 case OWN_ATTR_MISC_OBJ_TITLE:
2969 {
2970 OUString aTitle( mpObj->GetTitle() );
2971 rValue <<= aTitle;
2972 break;
2973 }
2974
2975 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2976 {
2977 OUString aDescription( mpObj->GetDescription() );
2978 rValue <<= aDescription;
2979 break;
2980 }
2981
2982 case SDRATTR_OBJPRINTABLE:
2983 rValue <<= static_cast<sal_Bool>( mpObj->IsPrintable() );
2984 break;
2985
2986 case SDRATTR_OBJVISIBLE:
2987 rValue <<= static_cast<sal_Bool>( mpObj->IsVisible() );
2988 break;
2989
2990 case SDRATTR_OBJSIZEPROTECT:
2991 rValue <<= static_cast<sal_Bool>( mpObj->IsResizeProtect() );
2992 break;
2993
2994 case OWN_ATTR_PAGE_NUMBER:
2995 {
2996 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get());
2997 if(pPageObj)
2998 {
2999 SdrPage* pPage = pPageObj->GetReferencedPage();
3000 sal_Int32 nPageNumber = (pPage) ? pPage->GetPageNum() : 0L;
3001 nPageNumber++;
3002 nPageNumber >>= 1;
3003 rValue <<= nPageNumber;
3004 }
3005 break;
3006 }
3007
3008 case OWN_ATTR_UINAME_SINGULAR:
3009 {
3010 String aTmp;
3011 mpObj->TakeObjNameSingul( aTmp );
3012 rValue <<= OUString( aTmp );
3013 break;
3014 }
3015
3016 case OWN_ATTR_UINAME_PLURAL:
3017 {
3018 String aTmp;
3019 mpObj->TakeObjNamePlural( aTmp );
3020 rValue <<= OUString( aTmp );
3021 break;
3022 }
3023 case OWN_ATTR_METAFILE:
3024 {
3025 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
3026 if( pObj )
3027 {
3028 Graphic* pGraphic = pObj->GetGraphic();
3029 if( pGraphic )
3030 {
3031 sal_Bool bIsWMF = sal_False;
3032 if ( pGraphic->IsLink() )
3033 {
3034 GfxLink aLnk = pGraphic->GetLink();
3035 if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF )
3036 {
3037 bIsWMF = sal_True;
3038 uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize());
3039 rValue <<= aSeq;
3040 }
3041 }
3042 if ( !bIsWMF )
3043 {
3044 // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
3045 GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
3046 SvMemoryStream aDestStrm( 65535, 65535 );
3047 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
3048 const uno::Sequence<sal_Int8> aSeq(
3049 static_cast< const sal_Int8* >(aDestStrm.GetData()),
3050 aDestStrm.GetEndOfData());
3051 rValue <<= aSeq;
3052 }
3053 }
3054 }
3055 else
3056 {
3057 rValue = GetBitmap( sal_True );
3058 }
3059 break;
3060 }
3061
3062
3063 default:
3064 return false;
3065 }
3066 return true;
3067 }
3068
3069 //----------------------------------------------------------------------
3070
getPropertyStateImpl(const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::beans::PropertyState & rState)3071 bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState )
3072 {
3073 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
3074 {
3075 const SfxItemSet& rSet = mpObj->GetMergedItemSet();
3076
3077 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET ||
3078 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET )
3079 {
3080 rState = beans::PropertyState_DIRECT_VALUE;
3081 }
3082 else
3083 {
3084 rState = beans::PropertyState_AMBIGUOUS_VALUE;
3085 }
3086 }
3087 else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
3088 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) )
3089 {
3090 rState = beans::PropertyState_DIRECT_VALUE;
3091 }
3092 else
3093 {
3094 return false;
3095 }
3096
3097 return true;
3098 }
3099
3100 //----------------------------------------------------------------------
3101
setPropertyToDefaultImpl(const SfxItemPropertySimpleEntry * pProperty)3102 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty )
3103 {
3104 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
3105 {
3106 mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH );
3107 mpObj->ClearMergedItem( XATTR_FILLBMP_TILE );
3108 return true;
3109 }
3110 else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
3111 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST ))
3112 {
3113 return true;
3114 }
3115 else
3116 {
3117 return false;
3118 }
3119 }
3120
3121 //----------------------------------------------------------------------
3122
getPropertyStates(const uno::Sequence<OUString> & aPropertyName)3123 uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
3124 {
3125 const sal_Int32 nCount = aPropertyName.getLength();
3126 const OUString* pNames = aPropertyName.getConstArray();
3127
3128 uno::Sequence< beans::PropertyState > aRet( nCount );
3129 beans::PropertyState* pState = aRet.getArray();
3130
3131 if( mpImpl->mpMaster )
3132 {
3133 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
3134 pState[nIdx] = getPropertyState( pNames[nIdx] );
3135
3136 }
3137 else
3138 {
3139 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
3140 pState[nIdx] = getPropertyState( pNames[nIdx] );
3141 }
3142
3143 return aRet;
3144 }
3145
3146 //----------------------------------------------------------------------
3147
setPropertyToDefault(const OUString & PropertyName)3148 void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName )
3149 {
3150 if( mpImpl->mpMaster )
3151 {
3152 mpImpl->mpMaster->setPropertyToDefault( PropertyName );
3153 }
3154 else
3155 {
3156 _setPropertyToDefault( PropertyName );
3157 }
3158 }
3159
_setPropertyToDefault(const OUString & PropertyName)3160 void SAL_CALL SvxShape::_setPropertyToDefault( const OUString& PropertyName )
3161 {
3162 OGuard aGuard( Application::GetSolarMutex() );
3163
3164 const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName);
3165
3166 if( !mpObj.is() || mpModel == NULL || pProperty == NULL )
3167 throw beans::UnknownPropertyException();
3168
3169 if( !setPropertyToDefaultImpl( pProperty ) )
3170 {
3171 mpObj->ClearMergedItem( pProperty->nWID );
3172 }
3173
3174 mpModel->SetChanged();
3175 }
3176
3177 //----------------------------------------------------------------------
3178
getPropertyDefault(const OUString & aPropertyName)3179 uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName )
3180 {
3181 if( mpImpl->mpMaster )
3182 {
3183 return mpImpl->mpMaster->getPropertyDefault( aPropertyName );
3184 }
3185 else
3186 {
3187 return _getPropertyDefault( aPropertyName );
3188 }
3189 }
3190
_getPropertyDefault(const OUString & aPropertyName)3191 uno::Any SAL_CALL SvxShape::_getPropertyDefault( const OUString& aPropertyName )
3192 {
3193 OGuard aGuard( Application::GetSolarMutex() );
3194
3195 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
3196
3197 if( !mpObj.is() || pMap == NULL || mpModel == NULL )
3198 throw beans::UnknownPropertyException();
3199
3200 if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) ||
3201 ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST ))
3202 {
3203 return getPropertyValue( aPropertyName );
3204 }
3205
3206 // Default aus ItemPool holen
3207 if(!mpModel->GetItemPool().IsWhich(pMap->nWID))
3208 throw beans::UnknownPropertyException();
3209
3210 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
3211 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
3212
3213 return GetAnyForItem( aSet, pMap );
3214 }
3215
3216 // XMultiPropertyStates
setAllPropertiesToDefault()3217 void SvxShape::setAllPropertiesToDefault()
3218 {
3219 OGuard aGuard( Application::GetSolarMutex() );
3220
3221 if( !mpObj.is() )
3222 throw lang::DisposedException();
3223 mpObj->ClearMergedItem(); // nWhich == 0 => all
3224
3225 if(mpObj->ISA(SdrGrafObj))
3226 {
3227 // defaults for graphic objects have changed:
3228 mpObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
3229 mpObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) );
3230 }
3231
3232 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
3233 // but needs to be sal_True in svx, pool default (false) in sch. Since sch
3234 // does not load lathe or extrude objects, it is possible to set the items
3235 // here.
3236 // For other solution possibilities, see task description.
3237 if(mpObj->ISA(E3dLatheObj) || mpObj->ISA(E3dExtrudeObj))
3238 {
3239 mpObj->SetMergedItem(Svx3DCharacterModeItem(true));
3240 }
3241
3242 mpModel->SetChanged();
3243 }
3244
setPropertiesToDefault(const uno::Sequence<OUString> & aPropertyNames)3245 void SvxShape::setPropertiesToDefault(
3246 const uno::Sequence<OUString>& aPropertyNames )
3247 {
3248 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
3249 setPropertyToDefault( aPropertyNames[pos] );
3250 }
3251
getPropertyDefaults(const uno::Sequence<OUString> & aPropertyNames)3252 uno::Sequence<uno::Any> SvxShape::getPropertyDefaults(
3253 const uno::Sequence<OUString>& aPropertyNames )
3254 {
3255 ::std::vector<uno::Any> ret;
3256 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
3257 ret.push_back( getPropertyDefault( aPropertyNames[pos] ) );
3258 return uno::Sequence<uno::Any>( &ret[0], ret.size() );
3259 }
3260
3261 //----------------------------------------------------------------------
3262
3263 //----------------------------------------------------------------------
3264 // XServiceInfo
3265 //----------------------------------------------------------------------
getImplementationName()3266 OUString SAL_CALL SvxShape::getImplementationName()
3267 {
3268 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShape") );
3269 return aServiceName;
3270 }
3271
3272 #define STAR_NAMESPACE "com.sun.star."
3273
3274 const char* sUNO_service_style_ParagraphProperties = STAR_NAMESPACE "style.ParagraphProperties";
3275 const char* sUNO_service_style_ParagraphPropertiesComplex = STAR_NAMESPACE "style.ParagraphPropertiesComplex";
3276 const char* sUNO_service_style_ParagraphPropertiesAsian = STAR_NAMESPACE "style.ParagraphPropertiesAsian";
3277 const char* sUNO_service_style_CharacterProperties = STAR_NAMESPACE "style.CharacterProperties";
3278 const char* sUNO_service_style_CharacterPropertiesComplex = STAR_NAMESPACE "style.CharacterPropertiesComplex";
3279 const char* sUNO_service_style_CharacterPropertiesAsian = STAR_NAMESPACE "style.CharacterPropertiesAsian";
3280
3281 const char* sUNO_service_drawing_FillProperties = STAR_NAMESPACE "drawing.FillProperties";
3282 const char* sUNO_service_drawing_TextProperties = STAR_NAMESPACE "drawing.TextProperties";
3283 const char* sUNO_service_drawing_LineProperties = STAR_NAMESPACE "drawing.LineProperties";
3284 const char* sUNO_service_drawing_ConnectorProperties = STAR_NAMESPACE "drawing.ConnectorProperties";
3285 const char* sUNO_service_drawing_MeasureProperties = STAR_NAMESPACE "drawing.MeasureProperties";
3286 const char* sUNO_service_drawing_ShadowProperties = STAR_NAMESPACE "drawing.ShadowProperties";
3287
3288 const char* sUNO_service_drawing_RotationDescriptor = STAR_NAMESPACE "drawing.RotationDescriptor";
3289
3290 const char* sUNO_service_drawing_Text = STAR_NAMESPACE "drawing.Text";
3291 const char* sUNO_service_drawing_GroupShape = STAR_NAMESPACE "drawing.GroupShape";
3292
3293 const char* sUNO_service_drawing_CustomShapeProperties = STAR_NAMESPACE "drawing.CustomShapeProperties";
3294 const char* sUNO_service_drawing_CustomShape = STAR_NAMESPACE "drawing.CustomShape";
3295
3296 const char* sUNO_service_drawing_PolyPolygonDescriptor = STAR_NAMESPACE "drawing.PolyPolygonDescriptor";
3297 const char* sUNO_service_drawing_PolyPolygonBezierDescriptor= STAR_NAMESPACE "drawing.PolyPolygonBezierDescriptor";
3298
3299 const char* sUNO_service_drawing_LineShape = STAR_NAMESPACE "drawing.LineShape";
3300 const char* sUNO_service_drawing_Shape = STAR_NAMESPACE "drawing.Shape";
3301 const char* sUNO_service_drawing_RectangleShape = STAR_NAMESPACE "drawing.RectangleShape";
3302 const char* sUNO_service_drawing_EllipseShape = STAR_NAMESPACE "drawing.EllipseShape";
3303 const char* sUNO_service_drawing_PolyPolygonShape = STAR_NAMESPACE "drawing.PolyPolygonShape";
3304 const char* sUNO_service_drawing_PolyLineShape = STAR_NAMESPACE "drawing.PolyLineShape";
3305 const char* sUNO_service_drawing_OpenBezierShape = STAR_NAMESPACE "drawing.OpenBezierShape";
3306 const char* sUNO_service_drawing_ClosedBezierShape = STAR_NAMESPACE "drawing.ClosedBezierShape";
3307 const char* sUNO_service_drawing_TextShape = STAR_NAMESPACE "drawing.TextShape";
3308 const char* sUNO_service_drawing_GraphicObjectShape = STAR_NAMESPACE "drawing.GraphicObjectShape";
3309 const char* sUNO_service_drawing_OLE2Shape = STAR_NAMESPACE "drawing.OLE2Shape";
3310 const char* sUNO_service_drawing_PageShape = STAR_NAMESPACE "drawing.PageShape";
3311 const char* sUNO_service_drawing_CaptionShape = STAR_NAMESPACE "drawing.CaptionShape";
3312 const char* sUNO_service_drawing_MeasureShape = STAR_NAMESPACE "drawing.MeasureShape";
3313 const char* sUNO_service_drawing_FrameShape = STAR_NAMESPACE "drawing.FrameShape";
3314 const char* sUNO_service_drawing_ControlShape = STAR_NAMESPACE "drawing.ControlShape";
3315 const char* sUNO_service_drawing_ConnectorShape = STAR_NAMESPACE "drawing.ConnectorShape";
3316 const char* sUNO_service_drawing_MediaShape = STAR_NAMESPACE "drawing.MediaShape";
3317
3318
getSupportedServiceNames()3319 uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames()
3320 {
3321 if( mpImpl->mpMaster )
3322 {
3323 return mpImpl->mpMaster->getSupportedServiceNames();
3324 }
3325 else
3326 {
3327 return _getSupportedServiceNames();
3328 }
3329 }
3330
_getSupportedServiceNames()3331 uno::Sequence< OUString > SAL_CALL SvxShape::_getSupportedServiceNames()
3332 {
3333 OGuard aGuard( Application::GetSolarMutex() );
3334
3335 if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor)
3336 {
3337 const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
3338
3339 switch(nIdent)
3340 {
3341 case OBJ_GRUP:
3342 {
3343 static uno::Sequence< OUString > *pSeq = 0;
3344 if( 0 == pSeq )
3345 {
3346 // OGuard aGuard( Application::GetSolarMutex() );
3347 // if( 0 == pSeq )
3348 {
3349 static uno::Sequence< OUString > SvxShape_GroupServices;
3350
3351 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, 2,
3352 sUNO_service_drawing_GroupShape,
3353 sUNO_service_drawing_Shape );
3354
3355 pSeq = &SvxShape_GroupServices;
3356 }
3357 }
3358
3359 return *pSeq;
3360 }
3361 case OBJ_CUSTOMSHAPE:
3362 {
3363 static uno::Sequence< OUString > *pSeq = 0;
3364 if( 0 == pSeq )
3365 {
3366 // OGuard aGuard( Application::GetSolarMutex() );
3367 // if( 0 == pSeq )
3368 {
3369 static uno::Sequence< OUString > SvxShape_CustomShapeServices;
3370
3371 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, 13,
3372 sUNO_service_drawing_CustomShape,
3373 sUNO_service_drawing_Shape,
3374 sUNO_service_drawing_CustomShapeProperties,
3375 sUNO_service_drawing_FillProperties,
3376 sUNO_service_drawing_LineProperties,
3377 sUNO_service_drawing_Text,
3378 sUNO_service_drawing_TextProperties,
3379 sUNO_service_style_ParagraphProperties,
3380 sUNO_service_style_ParagraphPropertiesComplex,
3381 sUNO_service_style_ParagraphPropertiesAsian,
3382 sUNO_service_style_CharacterProperties,
3383 sUNO_service_style_CharacterPropertiesComplex,
3384 sUNO_service_style_CharacterPropertiesAsian,
3385 sUNO_service_drawing_ShadowProperties,
3386 sUNO_service_drawing_RotationDescriptor);
3387 pSeq = &SvxShape_CustomShapeServices;
3388 }
3389 }
3390 return *pSeq;
3391 }
3392 case OBJ_LINE:
3393 {
3394 static uno::Sequence< OUString > *pSeq = 0;
3395 if( 0 == pSeq )
3396 {
3397 // OGuard aGuard( Application::GetSolarMutex() );
3398 // if( 0 == pSeq )
3399 {
3400 static uno::Sequence< OUString > SvxShape_LineServices;
3401
3402 comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices,14,
3403 sUNO_service_drawing_LineShape,
3404
3405 sUNO_service_drawing_Shape,
3406 sUNO_service_drawing_LineProperties,
3407
3408 sUNO_service_drawing_Text,
3409 sUNO_service_drawing_TextProperties,
3410 sUNO_service_style_ParagraphProperties,
3411 sUNO_service_style_ParagraphPropertiesComplex,
3412 sUNO_service_style_ParagraphPropertiesAsian,
3413 sUNO_service_style_CharacterProperties,
3414 sUNO_service_style_CharacterPropertiesComplex,
3415 sUNO_service_style_CharacterPropertiesAsian,
3416
3417 sUNO_service_drawing_PolyPolygonDescriptor,
3418 sUNO_service_drawing_ShadowProperties,
3419 sUNO_service_drawing_RotationDescriptor);
3420
3421 pSeq = &SvxShape_LineServices;
3422 }
3423 }
3424 return *pSeq;
3425 }
3426
3427 case OBJ_RECT:
3428 {
3429 static uno::Sequence< OUString > *pSeq = 0;
3430 if( 0 == pSeq )
3431 {
3432 // OGuard aGuard( Application::GetSolarMutex() );
3433 // if( 0 == pSeq )
3434 {
3435 static uno::Sequence< OUString > SvxShape_RectServices;
3436
3437 comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices,14,
3438 sUNO_service_drawing_RectangleShape,
3439
3440 sUNO_service_drawing_Shape,
3441 sUNO_service_drawing_FillProperties,
3442 sUNO_service_drawing_LineProperties,
3443 sUNO_service_drawing_Text,
3444 sUNO_service_drawing_TextProperties,
3445 sUNO_service_style_ParagraphProperties,
3446 sUNO_service_style_ParagraphPropertiesComplex,
3447 sUNO_service_style_ParagraphPropertiesAsian,
3448 sUNO_service_style_CharacterProperties,
3449 sUNO_service_style_CharacterPropertiesComplex,
3450 sUNO_service_style_CharacterPropertiesAsian,
3451
3452 sUNO_service_drawing_ShadowProperties,
3453 sUNO_service_drawing_RotationDescriptor);
3454 pSeq = &SvxShape_RectServices;
3455 }
3456
3457 }
3458 return *pSeq;
3459 }
3460
3461 case OBJ_CIRC:
3462 case OBJ_SECT:
3463 case OBJ_CARC:
3464 case OBJ_CCUT:
3465 {
3466 static uno::Sequence< OUString > *pSeq = 0;
3467 if( 0 == pSeq )
3468 {
3469 // OGuard aGuard( Application::GetSolarMutex() );
3470 // if( 0 == pSeq )
3471 {
3472 static uno::Sequence< OUString > SvxShape_CircServices;
3473
3474 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices,14,
3475 sUNO_service_drawing_EllipseShape,
3476
3477 sUNO_service_drawing_Shape,
3478 sUNO_service_drawing_FillProperties,
3479 sUNO_service_drawing_LineProperties,
3480
3481 sUNO_service_drawing_Text,
3482 sUNO_service_drawing_TextProperties,
3483 sUNO_service_style_ParagraphProperties,
3484 sUNO_service_style_ParagraphPropertiesComplex,
3485 sUNO_service_style_ParagraphPropertiesAsian,
3486 sUNO_service_style_CharacterProperties,
3487 sUNO_service_style_CharacterPropertiesComplex,
3488 sUNO_service_style_CharacterPropertiesAsian,
3489
3490 sUNO_service_drawing_ShadowProperties,
3491 sUNO_service_drawing_RotationDescriptor);
3492
3493 pSeq = &SvxShape_CircServices;
3494 }
3495 }
3496
3497 return *pSeq;
3498 }
3499
3500 case OBJ_PATHPLIN:
3501 case OBJ_PLIN:
3502 {
3503 static uno::Sequence< OUString > *pSeq = 0;
3504 if( 0 == pSeq )
3505 {
3506 // OGuard aGuard( Application::GetSolarMutex() );
3507 // if( 0 == pSeq )
3508 {
3509 static uno::Sequence< OUString > SvxShape_PathServices;
3510 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices,14,
3511 sUNO_service_drawing_PolyLineShape,
3512
3513 sUNO_service_drawing_Shape,
3514 sUNO_service_drawing_LineProperties,
3515
3516 sUNO_service_drawing_PolyPolygonDescriptor,
3517
3518 sUNO_service_drawing_Text,
3519 sUNO_service_drawing_TextProperties,
3520 sUNO_service_style_ParagraphProperties,
3521 sUNO_service_style_ParagraphPropertiesComplex,
3522 sUNO_service_style_ParagraphPropertiesAsian,
3523 sUNO_service_style_CharacterProperties,
3524 sUNO_service_style_CharacterPropertiesComplex,
3525 sUNO_service_style_CharacterPropertiesAsian,
3526
3527 sUNO_service_drawing_ShadowProperties,
3528 sUNO_service_drawing_RotationDescriptor);
3529 pSeq = &SvxShape_PathServices;
3530 }
3531 }
3532 return *pSeq;
3533 }
3534
3535 case OBJ_PATHPOLY:
3536 case OBJ_POLY:
3537 {
3538 static uno::Sequence< OUString > *pSeq = 0;
3539 if( 0 == pSeq )
3540 {
3541 // OGuard aGuard( Application::GetSolarMutex() );
3542 // if( 0 == pSeq )
3543 {
3544 static uno::Sequence< OUString > SvxShape_PolyServices;
3545 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices,15,
3546 sUNO_service_drawing_PolyPolygonShape,
3547
3548 sUNO_service_drawing_Shape,
3549 sUNO_service_drawing_LineProperties,
3550 sUNO_service_drawing_FillProperties,
3551
3552 sUNO_service_drawing_PolyPolygonDescriptor,
3553
3554 sUNO_service_drawing_Text,
3555 sUNO_service_drawing_TextProperties,
3556 sUNO_service_style_ParagraphProperties,
3557 sUNO_service_style_ParagraphPropertiesComplex,
3558 sUNO_service_style_ParagraphPropertiesAsian,
3559 sUNO_service_style_CharacterProperties,
3560 sUNO_service_style_CharacterPropertiesComplex,
3561 sUNO_service_style_CharacterPropertiesAsian,
3562
3563 sUNO_service_drawing_ShadowProperties,
3564 sUNO_service_drawing_RotationDescriptor);
3565
3566 pSeq = &SvxShape_PolyServices;
3567 }
3568 }
3569 return *pSeq;
3570 }
3571
3572 case OBJ_FREELINE:
3573 case OBJ_PATHLINE:
3574 {
3575 static uno::Sequence< OUString > *pSeq = 0;
3576 if( 0 == pSeq )
3577 {
3578 // OGuard aGuard( Application::GetSolarMutex() );
3579 // if( 0 == pSeq )
3580 {
3581 static uno::Sequence< OUString > SvxShape_FreeLineServices;
3582
3583 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices,15,
3584 sUNO_service_drawing_OpenBezierShape,
3585
3586 sUNO_service_drawing_Shape,
3587 sUNO_service_drawing_LineProperties,
3588 sUNO_service_drawing_FillProperties,
3589
3590 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3591
3592 sUNO_service_drawing_Text,
3593 sUNO_service_drawing_TextProperties,
3594 sUNO_service_style_ParagraphProperties,
3595 sUNO_service_style_ParagraphPropertiesComplex,
3596 sUNO_service_style_ParagraphPropertiesAsian,
3597 sUNO_service_style_CharacterProperties,
3598 sUNO_service_style_CharacterPropertiesComplex,
3599 sUNO_service_style_CharacterPropertiesAsian,
3600
3601 sUNO_service_drawing_ShadowProperties,
3602 sUNO_service_drawing_RotationDescriptor);
3603
3604 pSeq = &SvxShape_FreeLineServices;
3605 }
3606 }
3607
3608 return *pSeq;
3609 }
3610
3611 case OBJ_FREEFILL:
3612 case OBJ_PATHFILL:
3613 {
3614 static uno::Sequence< OUString > *pSeq = 0;
3615 if( 0 == pSeq )
3616 {
3617 // OGuard aGuard( Application::GetSolarMutex() );
3618 // if( 0 == pSeq )
3619 {
3620 static uno::Sequence< OUString > SvxShape_FreeFillServices;
3621 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices,15,
3622 sUNO_service_drawing_ClosedBezierShape,
3623
3624 sUNO_service_drawing_Shape,
3625 sUNO_service_drawing_LineProperties,
3626 sUNO_service_drawing_FillProperties,
3627
3628 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3629
3630 sUNO_service_drawing_Text,
3631 sUNO_service_drawing_TextProperties,
3632 sUNO_service_style_ParagraphProperties,
3633 sUNO_service_style_ParagraphPropertiesComplex,
3634 sUNO_service_style_ParagraphPropertiesAsian,
3635 sUNO_service_style_CharacterProperties,
3636 sUNO_service_style_CharacterPropertiesComplex,
3637 sUNO_service_style_CharacterPropertiesAsian,
3638
3639 sUNO_service_drawing_ShadowProperties,
3640 sUNO_service_drawing_RotationDescriptor);
3641
3642 pSeq = &SvxShape_FreeFillServices;
3643 }
3644 }
3645 return *pSeq;
3646 }
3647
3648 case OBJ_OUTLINETEXT:
3649 case OBJ_TITLETEXT:
3650 case OBJ_TEXT:
3651 {
3652 static uno::Sequence< OUString > *pSeq = 0;
3653 if( 0 == pSeq )
3654 {
3655 // OGuard aGuard( Application::GetSolarMutex() );
3656 // if( 0 == pSeq )
3657 {
3658 static uno::Sequence< OUString > SvxShape_TextServices;
3659 comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices,14,
3660 sUNO_service_drawing_TextShape,
3661
3662 sUNO_service_drawing_Shape,
3663 sUNO_service_drawing_FillProperties,
3664 sUNO_service_drawing_LineProperties,
3665
3666 sUNO_service_drawing_Text,
3667 sUNO_service_drawing_TextProperties,
3668 sUNO_service_style_ParagraphProperties,
3669 sUNO_service_style_ParagraphPropertiesComplex,
3670 sUNO_service_style_ParagraphPropertiesAsian,
3671 sUNO_service_style_CharacterProperties,
3672 sUNO_service_style_CharacterPropertiesComplex,
3673 sUNO_service_style_CharacterPropertiesAsian,
3674
3675 sUNO_service_drawing_ShadowProperties,
3676 sUNO_service_drawing_RotationDescriptor);
3677
3678 pSeq = &SvxShape_TextServices;
3679 }
3680 }
3681 return *pSeq;
3682 }
3683
3684 case OBJ_GRAF:
3685 {
3686 static uno::Sequence< OUString > *pSeq = 0;
3687 if( 0 == pSeq )
3688 {
3689 // OGuard aGuard( Application::GetSolarMutex() );
3690 // if( 0 == pSeq )
3691 {
3692 static uno::Sequence< OUString > SvxShape_GrafServices;
3693 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, 12,
3694 sUNO_service_drawing_GraphicObjectShape,
3695
3696 sUNO_service_drawing_Shape,
3697
3698 sUNO_service_drawing_Text,
3699 sUNO_service_drawing_TextProperties,
3700 sUNO_service_style_ParagraphProperties,
3701 sUNO_service_style_ParagraphPropertiesComplex,
3702 sUNO_service_style_ParagraphPropertiesAsian,
3703 sUNO_service_style_CharacterProperties,
3704 sUNO_service_style_CharacterPropertiesComplex,
3705 sUNO_service_style_CharacterPropertiesAsian,
3706
3707 sUNO_service_drawing_ShadowProperties,
3708 sUNO_service_drawing_RotationDescriptor);
3709
3710 pSeq = &SvxShape_GrafServices;
3711 }
3712 }
3713 return *pSeq;
3714 }
3715
3716 case OBJ_OLE2:
3717 {
3718 static uno::Sequence< OUString > *pSeq = 0;
3719 if( 0 == pSeq )
3720 {
3721 // OGuard aGuard( Application::GetSolarMutex() );
3722 // if( 0 == pSeq )
3723 {
3724 static uno::Sequence< OUString > SvxShape_Ole2Services;
3725
3726 comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, 2,
3727 sUNO_service_drawing_OLE2Shape,
3728 sUNO_service_drawing_Shape,
3729
3730 // #i118485# Added Text, Shadow and Rotation
3731 sUNO_service_drawing_Text,
3732 sUNO_service_drawing_TextProperties,
3733 sUNO_service_style_ParagraphProperties,
3734 sUNO_service_style_ParagraphPropertiesComplex,
3735 sUNO_service_style_ParagraphPropertiesAsian,
3736 sUNO_service_style_CharacterProperties,
3737 sUNO_service_style_CharacterPropertiesComplex,
3738 sUNO_service_style_CharacterPropertiesAsian,
3739
3740 sUNO_service_drawing_ShadowProperties,
3741 sUNO_service_drawing_RotationDescriptor);
3742
3743 pSeq = &SvxShape_Ole2Services;
3744 }
3745 }
3746 return *pSeq;
3747 }
3748
3749 case OBJ_CAPTION:
3750 {
3751 static uno::Sequence< OUString > *pSeq = 0;
3752 if( 0 == pSeq )
3753 {
3754 // OGuard aGuard( Application::GetSolarMutex() );
3755 // if( 0 == pSeq )
3756 {
3757 static uno::Sequence< OUString > SvxShape_CaptionServices;
3758
3759 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices,14,
3760 sUNO_service_drawing_CaptionShape,
3761
3762 sUNO_service_drawing_Shape,
3763 sUNO_service_drawing_FillProperties,
3764 sUNO_service_drawing_LineProperties,
3765
3766 sUNO_service_drawing_Text,
3767 sUNO_service_drawing_TextProperties,
3768 sUNO_service_style_ParagraphProperties,
3769 sUNO_service_style_ParagraphPropertiesComplex,
3770 sUNO_service_style_ParagraphPropertiesAsian,
3771 sUNO_service_style_CharacterProperties,
3772 sUNO_service_style_CharacterPropertiesComplex,
3773 sUNO_service_style_CharacterPropertiesAsian,
3774
3775 sUNO_service_drawing_ShadowProperties,
3776 sUNO_service_drawing_RotationDescriptor);
3777
3778 pSeq = &SvxShape_CaptionServices;
3779 }
3780 }
3781
3782 return *pSeq;
3783 }
3784
3785 case OBJ_PAGE:
3786 {
3787 static uno::Sequence< OUString > *pSeq = 0;
3788 if( 0 == pSeq )
3789 {
3790 // OGuard aGuard( Application::GetSolarMutex() );
3791 // if( 0 == pSeq )
3792 {
3793 static uno::Sequence< OUString > SvxShape_PageServices;
3794
3795 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, 2,
3796 sUNO_service_drawing_PageShape,
3797 sUNO_service_drawing_Shape );
3798
3799 pSeq = &SvxShape_PageServices;
3800 }
3801 }
3802
3803 return *pSeq;
3804 }
3805
3806 case OBJ_MEASURE:
3807 {
3808 static uno::Sequence< OUString > *pSeq = 0;
3809 if( 0 == pSeq )
3810 {
3811 // OGuard aGuard( Application::GetSolarMutex() );
3812 // if( 0 == pSeq )
3813 {
3814 static uno::Sequence< OUString > SvxShape_MeasureServices;
3815 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices,15,
3816 sUNO_service_drawing_MeasureShape,
3817
3818 sUNO_service_drawing_MeasureProperties,
3819
3820 sUNO_service_drawing_Shape,
3821 sUNO_service_drawing_LineProperties,
3822
3823 sUNO_service_drawing_Text,
3824 sUNO_service_drawing_TextProperties,
3825 sUNO_service_style_ParagraphProperties,
3826 sUNO_service_style_ParagraphPropertiesComplex,
3827 sUNO_service_style_ParagraphPropertiesAsian,
3828 sUNO_service_style_CharacterProperties,
3829 sUNO_service_style_CharacterPropertiesComplex,
3830 sUNO_service_style_CharacterPropertiesAsian,
3831
3832 sUNO_service_drawing_PolyPolygonDescriptor,
3833 sUNO_service_drawing_ShadowProperties,
3834 sUNO_service_drawing_RotationDescriptor);
3835
3836 pSeq = &SvxShape_MeasureServices;
3837 }
3838 }
3839
3840 return *pSeq;
3841 }
3842
3843 case OBJ_FRAME:
3844 {
3845 static uno::Sequence< OUString > *pSeq = 0;
3846 if( 0 == pSeq )
3847 {
3848 // OGuard aGuard( Application::GetSolarMutex() );
3849 // if( 0 == pSeq )
3850 {
3851 static uno::Sequence< OUString > SvxShape_FrameServices;
3852
3853 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, 2,
3854 sUNO_service_drawing_FrameShape,
3855 sUNO_service_drawing_Shape );
3856
3857 pSeq = &SvxShape_FrameServices;
3858 }
3859 }
3860
3861 return *pSeq;
3862 }
3863
3864 case OBJ_UNO:
3865 {
3866 static uno::Sequence< OUString > *pSeq = 0;
3867 if( 0 == pSeq )
3868 {
3869 // OGuard _aGuard( Application::GetSolarMutex() );
3870 // if( 0 == pSeq )
3871 {
3872 static uno::Sequence< OUString > SvxShape_UnoServices;
3873 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
3874 sUNO_service_drawing_ControlShape,
3875 sUNO_service_drawing_Shape );
3876
3877 pSeq = &SvxShape_UnoServices;
3878 }
3879 }
3880 return *pSeq;
3881 }
3882
3883 case OBJ_EDGE:
3884 {
3885 static uno::Sequence< OUString > *pSeq = 0;
3886 if( 0 == pSeq )
3887 {
3888 // OGuard aGuard( Application::GetSolarMutex() );
3889 // if( 0 == pSeq )
3890 {
3891 static uno::Sequence< OUString > SvxShape_EdgeServices;
3892
3893 comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices,15,
3894 sUNO_service_drawing_ConnectorShape,
3895 sUNO_service_drawing_ConnectorProperties,
3896
3897 sUNO_service_drawing_Shape,
3898 sUNO_service_drawing_LineProperties,
3899
3900 sUNO_service_drawing_Text,
3901 sUNO_service_drawing_TextProperties,
3902 sUNO_service_style_ParagraphProperties,
3903 sUNO_service_style_ParagraphPropertiesComplex,
3904 sUNO_service_style_ParagraphPropertiesAsian,
3905 sUNO_service_style_CharacterProperties,
3906 sUNO_service_style_CharacterPropertiesComplex,
3907 sUNO_service_style_CharacterPropertiesAsian,
3908
3909 sUNO_service_drawing_PolyPolygonDescriptor,
3910 sUNO_service_drawing_ShadowProperties,
3911 sUNO_service_drawing_RotationDescriptor);
3912
3913 pSeq = &SvxShape_EdgeServices;
3914 }
3915 }
3916 return *pSeq;
3917 }
3918 case OBJ_MEDIA:
3919 {
3920 static uno::Sequence< OUString > *pSeq = 0;
3921 if( 0 == pSeq )
3922 {
3923 // OGuard aGuard( Application::GetSolarMutex() );
3924 // if( 0 == pSeq )
3925 {
3926 static uno::Sequence< OUString > SvxShape_MediaServices;
3927
3928 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, 2,
3929 sUNO_service_drawing_MediaShape,
3930 sUNO_service_drawing_Shape);
3931
3932 pSeq = &SvxShape_MediaServices;
3933 }
3934 }
3935 return *pSeq;
3936 }
3937 }
3938 }
3939 else if( mpObj.is() && mpObj->GetObjInventor() == FmFormInventor)
3940 {
3941 #if OSL_DEBUG_LEVEL > 0
3942 const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
3943 OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: FmFormInventor, but no UNO object?" );
3944 #endif
3945 static uno::Sequence< OUString > *pSeq = 0;
3946 if( 0 == pSeq )
3947 {
3948 // OGuard aGuard( Application::GetSolarMutex() );
3949 // if( 0 == pSeq )
3950 {
3951 static uno::Sequence< OUString > SvxShape_UnoServices;
3952 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
3953 sUNO_service_drawing_ControlShape,
3954 sUNO_service_drawing_Shape );
3955
3956 pSeq = &SvxShape_UnoServices;
3957 }
3958 }
3959 return *pSeq;
3960 }
3961 OSL_ENSURE( false, "SvxShape::_getSupportedServiceNames: could not determine object type!" );
3962 uno::Sequence< OUString > aSeq;
3963 return aSeq;
3964 }
3965
3966 //----------------------------------------------------------------------
supportsService(const OUString & ServiceName)3967 sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName )
3968 {
3969 Sequence< OUString > SupportedServices( getSupportedServiceNames() );
3970 const ::rtl::OUString * pArray = SupportedServices.getConstArray();
3971 const sal_Int32 nCount = SupportedServices.getLength();
3972 sal_Int32 i;
3973 for( i = 0; i < nCount; i++ )
3974 if( *pArray++ == ServiceName )
3975 return sal_True;
3976 return sal_False;
3977 }
3978
3979 //----------------------------------------------------------------------
3980
3981 // XGluePointsSupplier
getGluePoints()3982 uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints()
3983 {
3984 OGuard aGuard( Application::GetSolarMutex() );
3985 uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints );
3986
3987 if( mpObj.is() && !xGluePoints.is() )
3988 {
3989 uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY );
3990 mxGluePoints = xGluePoints = xNew;
3991 }
3992
3993 return xGluePoints;
3994 }
3995
3996 //----------------------------------------------------------------------
3997
3998 // XChild
getParent()3999 uno::Reference< uno::XInterface > SAL_CALL SvxShape::getParent( )
4000 {
4001 OGuard aGuard( Application::GetSolarMutex() );
4002
4003 if( mpObj.is() && mpObj->GetObjList() )
4004 {
4005 SdrObjList* pObjList = mpObj->GetObjList();
4006
4007 switch( pObjList->GetListKind() )
4008 {
4009 case SDROBJLIST_GROUPOBJ:
4010 if( pObjList->GetOwnerObj()->ISA( SdrObjGroup ) )
4011 return PTR_CAST( SdrObjGroup, pObjList->GetOwnerObj())->getUnoShape();
4012 else if( pObjList->GetOwnerObj()->ISA( E3dScene ) )
4013 return PTR_CAST( E3dScene, pObjList->GetOwnerObj())->getUnoShape();
4014 break;
4015 case SDROBJLIST_DRAWPAGE:
4016 case SDROBJLIST_MASTERPAGE:
4017 return PTR_CAST( SdrPage, pObjList )->getUnoPage();
4018 default:
4019 DBG_ERROR( "SvxShape::getParent( ): unexpected SdrObjListKind" );
4020 break;
4021 }
4022 }
4023
4024 uno::Reference< uno::XInterface > xParent;
4025 return xParent;
4026 }
4027
4028 //----------------------------------------------------------------------
4029
setParent(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> &)4030 void SAL_CALL SvxShape::setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& )
4031 {
4032 throw lang::NoSupportException();
4033 }
4034
4035 //----------------------------------------------------------------------
4036
4037 /** called from the XActionLockable interface methods on initial locking */
lock()4038 void SvxShape::lock()
4039 {
4040 }
4041
4042 //----------------------------------------------------------------------
4043
4044 /** called from the XActionLockable interface methods on final unlock */
unlock()4045 void SvxShape::unlock()
4046 {
4047 }
4048
4049 //----------------------------------------------------------------------
4050
4051 // XActionLockable
isActionLocked()4052 sal_Bool SAL_CALL SvxShape::isActionLocked( )
4053 {
4054 OGuard aGuard( Application::GetSolarMutex() );
4055
4056 return mnLockCount != 0;
4057 }
4058
4059 //----------------------------------------------------------------------
4060
addActionLock()4061 void SAL_CALL SvxShape::addActionLock( )
4062 {
4063 OGuard aGuard( Application::GetSolarMutex() );
4064
4065 DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" );
4066 mnLockCount++;
4067
4068 if( mnLockCount == 1 )
4069 lock();
4070 }
4071
4072 //----------------------------------------------------------------------
4073
removeActionLock()4074 void SAL_CALL SvxShape::removeActionLock( )
4075 {
4076 OGuard aGuard( Application::GetSolarMutex() );
4077
4078 DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" );
4079 mnLockCount--;
4080
4081 if( mnLockCount == 0 )
4082 unlock();
4083 }
4084
4085 //----------------------------------------------------------------------
4086
setActionLocks(sal_Int16 nLock)4087 void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock )
4088 {
4089 OGuard aGuard( Application::GetSolarMutex() );
4090
4091 if( (mnLockCount == 0) && (nLock != 0) )
4092 unlock();
4093
4094 if( (mnLockCount != 0) && (nLock == 0) )
4095 lock();
4096
4097 mnLockCount = (sal_uInt16)nLock;
4098 }
4099
4100 //----------------------------------------------------------------------
4101
resetActionLocks()4102 sal_Int16 SAL_CALL SvxShape::resetActionLocks( )
4103 {
4104 OGuard aGuard( Application::GetSolarMutex() );
4105
4106 if( mnLockCount != 0 )
4107 unlock();
4108
4109 sal_Int16 nOldLocks = (sal_Int16)mnLockCount;
4110 mnLockCount = 0;
4111
4112 return nOldLocks;
4113 }
4114
4115 //----------------------------------------------------------------------
4116
4117 /** since polygon shapes can change theire kind during editing, we have
4118 to recheck it here.
4119 Circle shapes also change theire kind, but theire all treated equal
4120 so no update is necessary.
4121 */
updateShapeKind()4122 void SvxShape::updateShapeKind()
4123 {
4124 switch( mpImpl->mnObjId )
4125 {
4126 case OBJ_LINE:
4127 case OBJ_POLY:
4128 case OBJ_PLIN:
4129 case OBJ_PATHLINE:
4130 case OBJ_PATHFILL:
4131 case OBJ_FREELINE:
4132 case OBJ_FREEFILL:
4133 case OBJ_PATHPOLY:
4134 case OBJ_PATHPLIN:
4135 {
4136 const sal_uInt32 nId = mpObj->GetObjIdentifier();
4137
4138 if( nId != mpImpl->mnObjId )
4139 {
4140 mpImpl->mnObjId = nId;
4141
4142 }
4143 break;
4144 }
4145 };
4146 }
4147
4148 /***********************************************************************
4149 * class SvxShapeText *
4150 ***********************************************************************/
SvxShapeText()4151 SvxShapeText::SvxShapeText() throw ()
4152 : SvxShape(NULL, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
4153 {
4154 }
4155
4156 //----------------------------------------------------------------------
SvxShapeText(SdrObject * pObject)4157 SvxShapeText::SvxShapeText( SdrObject* pObject ) throw ()
4158 : SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
4159 {
4160 if( pObject && pObject->GetModel() )
4161 SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) );
4162 }
4163
4164 //----------------------------------------------------------------------
SvxShapeText(SdrObject * pObject,const SfxItemPropertyMapEntry * pPropertyMap,const SvxItemPropertySet * pPropertySet)4165 SvxShapeText::SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw ()
4166 : SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
4167 {
4168 if( pObject && pObject->GetModel() )
4169 SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) );
4170 }
4171
4172 //----------------------------------------------------------------------
~SvxShapeText()4173 SvxShapeText::~SvxShapeText() throw ()
4174 {
4175 // check if only this instance is registered at the ranges
4176 DBG_ASSERT( (NULL == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
4177 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
4178 }
4179
Create(SdrObject * pNewObj,SvxDrawPage * pNewPage)4180 void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
4181 {
4182 if( pNewObj && (NULL == GetEditSource()))
4183 SetEditSource( new SvxTextEditSource( pNewObj, 0, static_cast< uno::XWeak* >(this) ) );
4184
4185 SvxShape::Create( pNewObj, pNewPage );
4186 }
4187
4188 // XInterface
4189 //----------------------------------------------------------------------
queryInterface(const uno::Type & rType)4190 uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType )
4191 {
4192 return SvxShape::queryInterface( rType );
4193 }
4194
4195 //----------------------------------------------------------------------
4196
queryAggregation(const uno::Type & rType)4197 uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType )
4198 {
4199 uno::Any aAny( SvxShape::queryAggregation( rType ) );
4200 if( aAny.hasValue() )
4201 return aAny;
4202
4203 return SvxUnoTextBase::queryAggregation( rType );
4204 }
4205
4206 //----------------------------------------------------------------------
4207
acquire()4208 void SAL_CALL SvxShapeText::acquire() throw()
4209 {
4210 SvxShape::acquire();
4211 }
4212
4213 //----------------------------------------------------------------------
release()4214 void SAL_CALL SvxShapeText::release() throw()
4215 {
4216 SvxShape::release();
4217 }
4218
4219 // XServiceInfo
4220 //----------------------------------------------------------------------
getImplementationName()4221 OUString SAL_CALL SvxShapeText::getImplementationName()
4222 {
4223 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShapeText") );
4224 return aServiceName;
4225 }
4226
4227 //----------------------------------------------------------------------
getSupportedServiceNames()4228 uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames()
4229 {
4230 return SvxShape::getSupportedServiceNames();
4231 }
4232
4233 //----------------------------------------------------------------------
supportsService(const OUString & ServiceName)4234 sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName )
4235 {
4236 return SvxShape::supportsService(ServiceName);
4237 }
4238
4239 // XTypeProvider
4240 //----------------------------------------------------------------------
getTypes()4241 uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes()
4242 {
4243 return SvxShape::getTypes();
4244 }
4245
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rId)4246 sal_Int64 SAL_CALL SvxShapeText::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) \
4247 {
4248 const sal_Int64 nReturn = SvxShape::getSomething( rId );
4249 if( nReturn )
4250 return nReturn;
4251
4252 return SvxUnoTextBase::getSomething( rId );
4253 }
4254
4255 //----------------------------------------------------------------------
getImplementationId()4256 uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId()
4257 {
4258 static ::cppu::OImplementationId* pID = NULL ;
4259
4260 if ( pID == NULL )
4261 {
4262 // Ready for multithreading; get global mutex for first call of this method only! see before
4263 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
4264
4265 // Control these pointer again ... it can be, that another instance will be faster then these!
4266 if ( pID == NULL )
4267 {
4268 // Create a new static ID ...
4269 static ::cppu::OImplementationId aID( sal_False ) ;
4270 // ... and set his address to static pointer!
4271 pID = &aID ;
4272 }
4273 }
4274
4275 return pID->getImplementationId() ;
4276 }
4277
4278 //----------------------------------------------------------------------
4279
4280 /** called from the XActionLockable interface methods on initial locking */
lock()4281 void SvxShapeText::lock()
4282 {
4283 SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource();
4284 if( pEditSource )
4285 pEditSource->lock();
4286 }
4287
4288 //----------------------------------------------------------------------
4289
4290 /** called from the XActionLockable interface methods on final unlock */
unlock()4291 void SvxShapeText::unlock()
4292 {
4293 SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource();
4294 if( pEditSource )
4295 pEditSource->unlock();
4296 }
4297
4298 // ::com::sun::star::text::XTextRange
getStart()4299 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart()
4300 {
4301 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4302 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4303 if( pForwarder )
4304 ::GetSelection( maSelection, pForwarder );
4305 return SvxUnoTextBase::getStart();
4306
4307 }
4308
getEnd()4309 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd()
4310 {
4311 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4312 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4313 if( pForwarder )
4314 ::GetSelection( maSelection, pForwarder );
4315 return SvxUnoTextBase::getEnd();
4316 }
4317
getString()4318 OUString SAL_CALL SvxShapeText::getString()
4319 {
4320 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4321 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4322 if( pForwarder )
4323 ::GetSelection( maSelection, pForwarder );
4324 return SvxUnoTextBase::getString();
4325 }
4326
4327
setString(const OUString & aString)4328 void SAL_CALL SvxShapeText::setString( const OUString& aString )
4329 {
4330 ::vos::OGuard aGuard( Application::GetSolarMutex() );
4331 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4332 if( pForwarder )
4333 ::GetSelection( maSelection, pForwarder );
4334 SvxUnoTextBase::setString( aString );
4335 }
4336
4337 // 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)4338 bool SvxShapeText::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue )
4339 {
4340 // HACK-fix #99090#
4341 // since SdrTextObj::SetVerticalWriting exchanges
4342 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
4343 // we have to set the textdirection here
4344
4345 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
4346 {
4347 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
4348 if( pTextObj )
4349 {
4350 com::sun::star::text::WritingMode eMode;
4351 if( rValue >>= eMode )
4352 {
4353 pTextObj->SetVerticalWriting( eMode == com::sun::star::text::WritingMode_TB_RL );
4354 }
4355 }
4356 return true;
4357 }
4358 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
4359 }
4360
getPropertyValueImpl(const::rtl::OUString & rName,const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::uno::Any & rValue)4361 bool SvxShapeText::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue )
4362 {
4363 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
4364 {
4365 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
4366 if( pTextObj && pTextObj->IsVerticalWriting() )
4367 rValue <<= com::sun::star::text::WritingMode_TB_RL;
4368 else
4369 rValue <<= com::sun::star::text::WritingMode_LR_TB;
4370 return true;
4371 }
4372
4373 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
4374 }
4375
getPropertyStateImpl(const SfxItemPropertySimpleEntry * pProperty,::com::sun::star::beans::PropertyState & rState)4376 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState )
4377 {
4378 return SvxShape::getPropertyStateImpl( pProperty, rState );
4379 }
4380
setPropertyToDefaultImpl(const SfxItemPropertySimpleEntry * pProperty)4381 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty )
4382 {
4383 return SvxShape::setPropertyToDefaultImpl( pProperty );
4384 }
4385
4386 /***********************************************************************
4387 * class SvxShapeRect *
4388 ***********************************************************************/
DBG_NAME(SvxShapeRect)4389 DBG_NAME(SvxShapeRect)
4390 SvxShapeRect::SvxShapeRect( SdrObject* pObj ) throw()
4391 : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_SHAPE), aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
4392 {
4393 DBG_CTOR(SvxShapeRect,NULL);
4394 }
4395
~SvxShapeRect()4396 SvxShapeRect::~SvxShapeRect() throw()
4397 {
4398 DBG_DTOR(SvxShapeRect,NULL);
4399 }
4400
queryInterface(const uno::Type & rType)4401 uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType )
4402 {
4403 return SvxShapeText::queryInterface( rType );
4404 }
4405
queryAggregation(const uno::Type & rType)4406 uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType )
4407 {
4408 return SvxShapeText::queryAggregation( rType );
4409 }
4410
acquire()4411 void SAL_CALL SvxShapeRect::acquire() throw()
4412 {
4413 OWeakAggObject::acquire();
4414 }
4415
release()4416 void SAL_CALL SvxShapeRect::release() throw()
4417 {
4418 OWeakAggObject::release();
4419 }
4420 //----------------------------------------------------------------------
4421 // XServiceInfo
4422 //----------------------------------------------------------------------
getSupportedServiceNames(void)4423 uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames(void)
4424 {
4425 return SvxShape::getSupportedServiceNames();
4426 }
4427
4428 /** returns a StarOffice API wrapper for the given SdrObject */
GetXShapeForSdrObject(SdrObject * pObj)4429 uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw ()
4430 {
4431 uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
4432 return xShape;
4433 }
4434
4435 /** returns the SdrObject from the given StarOffice API wrapper */
GetSdrObjectFromXShape(uno::Reference<drawing::XShape> xShape)4436 SdrObject* GetSdrObjectFromXShape( uno::Reference< drawing::XShape > xShape ) throw()
4437 {
4438 SvxShape* pShape = SvxShape::getImplementation( xShape );
4439 return pShape ? pShape->GetSdrObject() : 0;
4440 }
4441
4442 //----------------------------------------------------------------------
4443
getSdrObjectFromXShape(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xInt)4444 SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt )
4445 {
4446 SvxShape* pSvxShape = SvxShape::getImplementation( xInt );
4447 return pSvxShape ? pSvxShape->GetSdrObject() : 0;
4448 }
4449
SvxItemPropertySet_getPropertyValue(const SvxItemPropertySet & rPropSet,const SfxItemPropertySimpleEntry * pMap,const SfxItemSet & rSet)4450 uno::Any SvxItemPropertySet_getPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet )
4451 {
4452 if(!pMap || !pMap->nWID)
4453 return uno::Any();
4454
4455 // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ.
4456 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4457 return rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues );
4458 }
4459
SvxItemPropertySet_setPropertyValue(const SvxItemPropertySet & rPropSet,const SfxItemPropertySimpleEntry * pMap,const uno::Any & rVal,SfxItemSet & rSet)4460 void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet )
4461 {
4462 if(!pMap || !pMap->nWID)
4463 return;
4464
4465 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4466 rPropSet.setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues );
4467 }
4468