1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/document/EventObject.hpp>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <osl/mutex.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <comphelper/classids.hxx>
25 #include <comphelper/serviceinfohelper.hxx>
27 #include <sfx2/objsh.hxx>
28 #include <svx/svdpool.hxx>
29 #include <svx/svdobj.hxx>
30 #include <svx/svdoole2.hxx>
31 #include <svx/svdpage.hxx>
32 #include <svx/svdmodel.hxx>
33 #include <svx/svdview.hxx>
34 #include <svx/svdpagv.hxx>
35 #include <svx/unopage.hxx>
36 #include "shapeimpl.hxx"
37 #include "svx/globl3d.hxx"
38 #include <svx/polysc3d.hxx>
39 #include <svx/unoprov.hxx>
40 #include <svx/svdopath.hxx>
41 #include "svx/unoapi.hxx"
42 #include <svx/svdomeas.hxx>
43 #include <svx/extrud3d.hxx>
44 #include <svx/lathe3d.hxx>
45 #include <vcl/svapp.hxx>
46 #include <tools/diagnose_ex.h>
48 using namespace ::cppu
;
49 using namespace ::com::sun::star
;
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::container
;
53 using namespace ::com::sun::star::drawing
;
55 #define INTERFACE_TYPE( xint ) \
56 ::getCppuType((const Reference< xint >*)0)
58 /**********************************************************************
60 **********************************************************************/
62 UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage
);
64 SvxDrawPage::SvxDrawPage( SdrPage
* pInPage
) throw()
65 : mrBHelper( getMutex() )
69 DBG_CTOR(SvxDrawPage
,NULL
);
70 // Am Broadcaster anmelden
72 mpModel
= mpPage
->GetModel();
74 StartListening( *mpModel
);
77 // Erzeugen der (hidden) ::com::sun::star::sdbcx::View
78 mpView
= new SdrView( mpModel
);
80 mpView
->SetDesignMode(sal_True
);
83 //----------------------------------------------------------------------
84 SvxDrawPage::~SvxDrawPage() throw()
86 DBG_ASSERT( mrBHelper
.bDisposed
, "SvxDrawPage must be disposed!" );
87 if( !mrBHelper
.bDisposed
)
92 DBG_DTOR(SvxDrawPage
,NULL
);
95 //----------------------------------------------------------------------
98 void SvxDrawPage::release() throw()
100 OWeakAggObject::release();
104 void SvxDrawPage::disposing() throw()
108 EndListening( *mpModel
);
120 //----------------------------------------------------------------------
122 //----------------------------------------------------------------------
124 void SvxDrawPage::dispose()
125 throw(::com::sun::star::uno::RuntimeException
)
127 SolarMutexGuard aSolarGuard
;
129 // An frequently programming error is to release the last
130 // reference to this object in the disposing message.
131 // Make it rubust, hold a self Reference.
132 uno::Reference
< lang::XComponent
> xSelf( this );
134 // Guard dispose against multible threading
135 // Remark: It is an error to call dispose more than once
136 bool bDoDispose
= false;
138 osl::MutexGuard
aGuard( mrBHelper
.rMutex
);
139 if( !mrBHelper
.bDisposed
&& !mrBHelper
.bInDispose
)
141 // only one call go into this section
142 mrBHelper
.bInDispose
= sal_True
;
147 // Do not hold the mutex because we are broadcasting
150 // Create an event with this as sender
153 uno::Reference
< uno::XInterface
> xSource( uno::Reference
< uno::XInterface
>::query( (lang::XComponent
*)this ) );
154 ::com::sun::star::document::EventObject aEvt
;
155 aEvt
.Source
= xSource
;
156 // inform all listeners to release this object
157 // The listener container are automaticly cleared
158 mrBHelper
.aLC
.disposeAndClear( aEvt
);
159 // notify subclasses to do their dispose
162 catch(const ::com::sun::star::uno::Exception
&)
164 // catch exception and throw again but signal that
165 // the object was disposed. Dispose should be called
167 mrBHelper
.bDisposed
= sal_True
;
168 mrBHelper
.bInDispose
= sal_False
;
172 // the values bDispose and bInDisposing must set in this order.
173 // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
174 mrBHelper
.bDisposed
= sal_True
;
175 mrBHelper
.bInDispose
= sal_False
;
180 //----------------------------------------------------------------------
182 void SAL_CALL
SvxDrawPage::addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
184 SolarMutexGuard aGuard
;
187 throw lang::DisposedException();
189 mrBHelper
.addListener( ::getCppuType( &aListener
) , aListener
);
192 //----------------------------------------------------------------------
194 void SAL_CALL
SvxDrawPage::removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
196 SolarMutexGuard aGuard
;
199 throw lang::DisposedException();
201 mrBHelper
.removeListener( ::getCppuType( &aListener
) , aListener
);
204 //----------------------------------------------------------------------
206 //----------------------------------------------------------------------
208 void SvxDrawPage::Notify( SfxBroadcaster
&, const SfxHint
& /*rHint*/ )
212 //----------------------------------------------------------------------
213 // ::com::sun::star::drawing::XShapes
214 //----------------------------------------------------------------------
216 void SAL_CALL
SvxDrawPage::add( const uno::Reference
< drawing::XShape
>& xShape
)
217 throw( uno::RuntimeException
)
219 SolarMutexGuard aGuard
;
221 if ( ( mpModel
== NULL
) || ( mpPage
== NULL
) )
222 throw lang::DisposedException();
224 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
229 SdrObject
*pObj
= pShape
->GetSdrObject();
233 pObj
= CreateSdrObject( xShape
);
234 ENSURE_OR_RETURN_VOID( pObj
!= NULL
, "SvxDrawPage::add: no SdrObject was created!" );
236 else if ( !pObj
->IsInserted() )
238 pObj
->SetModel(mpModel
);
239 mpPage
->InsertObject( pObj
);
242 pShape
->Create( pObj
, this );
243 OSL_ENSURE( pShape
->GetSdrObject() == pObj
, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
245 if ( !pObj
->IsInserted() )
247 pObj
->SetModel(mpModel
);
248 mpPage
->InsertObject( pObj
);
251 mpModel
->SetChanged();
254 //----------------------------------------------------------------------
255 void SAL_CALL
SvxDrawPage::remove( const Reference
< drawing::XShape
>& xShape
)
256 throw( uno::RuntimeException
)
258 SolarMutexGuard aGuard
;
260 if( (mpModel
== 0) || (mpPage
== 0) )
261 throw lang::DisposedException();
263 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
267 SdrObject
* pObj
= pShape
->GetSdrObject();
270 // SdrObject aus der Page loeschen
271 sal_uInt32 nCount
= mpPage
->GetObjCount();
272 for( sal_uInt32 nNum
= 0; nNum
< nCount
; nNum
++ )
274 if(mpPage
->GetObj(nNum
) == pObj
)
276 OSL_VERIFY( mpPage
->RemoveObject( nNum
) == pObj
);
277 SdrObject::Free( pObj
);
285 mpModel
->SetChanged();
288 //----------------------------------------------------------------------
289 // ::com::sun::star::container::XIndexAccess
290 //----------------------------------------------------------------------
292 sal_Int32 SAL_CALL
SvxDrawPage::getCount()
293 throw( uno::RuntimeException
)
295 SolarMutexGuard aGuard
;
297 if( (mpModel
== 0) || (mpPage
== 0) )
298 throw lang::DisposedException();
300 return( (sal_Int32
) mpPage
->GetObjCount() );
303 //----------------------------------------------------------------------
304 uno::Any SAL_CALL
SvxDrawPage::getByIndex( sal_Int32 Index
)
305 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
307 SolarMutexGuard aGuard
;
309 if( (mpModel
== 0) || (mpPage
== 0) )
310 throw lang::DisposedException();
312 if ( Index
< 0 || Index
>= (sal_Int32
)mpPage
->GetObjCount() )
313 throw lang::IndexOutOfBoundsException();
315 SdrObject
* pObj
= mpPage
->GetObj( Index
);
317 throw uno::RuntimeException();
320 return makeAny(Reference
< drawing::XShape
>( pObj
->getUnoShape(), uno::UNO_QUERY
));
324 //----------------------------------------------------------------------
325 // ::com::sun::star::container::XElementAccess
326 //----------------------------------------------------------------------
328 uno::Type SAL_CALL
SvxDrawPage::getElementType()
329 throw( uno::RuntimeException
)
331 return INTERFACE_TYPE( drawing::XShape
);
334 //----------------------------------------------------------------------
335 sal_Bool SAL_CALL
SvxDrawPage::hasElements()
336 throw( uno::RuntimeException
)
338 SolarMutexGuard aGuard
;
340 if( (mpModel
== 0) || (mpPage
== 0) )
341 throw lang::DisposedException();
343 return mpPage
&& mpPage
->GetObjCount()>0;
348 void lcl_markSdrObjectOfShape( const Reference
< drawing::XShape
>& _rxShape
, SdrView
& _rView
, SdrPageView
& _rPageView
)
350 SvxShape
* pShape
= SvxShape::getImplementation( _rxShape
);
354 SdrObject
* pObj
= pShape
->GetSdrObject();
358 _rView
.MarkObj( pObj
, &_rPageView
);
362 //----------------------------------------------------------------------
363 // ACHTUNG: _SelectObjectsInView selektiert die ::com::sun::star::drawing::Shapes nur in der angegebennen
364 // SdrPageView. Dies mu� nicht die sichtbare SdrPageView sein.
365 //----------------------------------------------------------------------
366 void SvxDrawPage::_SelectObjectsInView( const Reference
< drawing::XShapes
> & aShapes
, SdrPageView
* pPageView
) throw ()
368 DBG_ASSERT(pPageView
,"SdrPageView ist NULL! [CL]");
369 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
371 if(pPageView
!=NULL
&& mpView
!=NULL
)
373 mpView
->UnmarkAllObj( pPageView
);
375 long nCount
= aShapes
->getCount();
376 for( long i
= 0; i
< nCount
; i
++ )
378 uno::Any
aAny( aShapes
->getByIndex(i
) );
379 Reference
< drawing::XShape
> xShape
;
380 if( aAny
>>= xShape
)
381 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
386 //----------------------------------------------------------------------
387 // ACHTUNG: _SelectObjectInView selektiert das Shape *nur* in der angegebennen
388 // SdrPageView. Dies mu� nicht die sichtbare SdrPageView sein.
389 //----------------------------------------------------------------------
390 void SvxDrawPage::_SelectObjectInView( const Reference
< drawing::XShape
> & xShape
, SdrPageView
* pPageView
) throw()
392 DBG_ASSERT(pPageView
,"SdrPageView ist NULL! [CL]");
393 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
395 if(pPageView
!=NULL
&& mpView
!= NULL
)
397 mpView
->UnmarkAllObj( pPageView
);
398 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
402 //----------------------------------------------------------------------
403 Reference
< drawing::XShapeGroup
> SAL_CALL
SvxDrawPage::group( const Reference
< drawing::XShapes
>& xShapes
)
404 throw( uno::RuntimeException
)
406 SolarMutexGuard aGuard
;
408 if( (mpModel
== 0) || (mpPage
== 0) )
409 throw lang::DisposedException();
411 DBG_ASSERT(mpPage
,"SdrPage ist NULL! [CL]");
412 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
414 Reference
< ::com::sun::star::drawing::XShapeGroup
> xShapeGroup
;
415 if(mpPage
==NULL
||mpView
==NULL
||!xShapes
.is())
418 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
420 _SelectObjectsInView( xShapes
, pPageView
);
422 mpView
->GroupMarked();
424 mpView
->AdjustMarkHdl();
425 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
426 if( rMarkList
.GetMarkCount() == 1 )
428 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
430 xShapeGroup
= Reference
< drawing::XShapeGroup
>::query( pObj
->getUnoShape() );
433 mpView
->HideSdrPage();
436 mpModel
->SetChanged();
441 //----------------------------------------------------------------------
442 void SAL_CALL
SvxDrawPage::ungroup( const Reference
< drawing::XShapeGroup
>& aGroup
)
443 throw( uno::RuntimeException
)
445 SolarMutexGuard aGuard
;
447 if( (mpModel
== 0) || (mpPage
== 0) )
448 throw lang::DisposedException();
450 DBG_ASSERT(mpPage
,"SdrPage ist NULL! [CL]");
451 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
453 if(mpPage
==NULL
||mpView
==NULL
||!aGroup
.is())
456 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
458 Reference
< drawing::XShape
> xShape( aGroup
, UNO_QUERY
);
459 _SelectObjectInView( xShape
, pPageView
);
460 mpView
->UnGroupMarked();
462 mpView
->HideSdrPage();
465 mpModel
->SetChanged();
468 //----------------------------------------------------------------------
469 SdrObject
*SvxDrawPage::_CreateSdrObject( const Reference
< drawing::XShape
> & xShape
) throw()
472 sal_uInt32 nInventor
;
474 GetTypeAndInventor( nType
, nInventor
, xShape
->getShapeType() );
475 SdrObject
* pNewObj
= 0;
479 awt::Size aSize
= xShape
->getSize();
482 awt::Point aPos
= xShape
->getPosition();
483 Rectangle
aRect( Point( aPos
.X
, aPos
.Y
), Size( aSize
.Width
, aSize
.Height
) );
486 if( nInventor
== SdrInventor
)
492 pNewObj
= new SdrMeasureObj( aRect
.TopLeft(), aRect
.BottomRight() );
497 basegfx::B2DPolygon aPoly
;
498 aPoly
.append(basegfx::B2DPoint(aRect
.Left(), aRect
.Top()));
499 aPoly
.append(basegfx::B2DPoint(aRect
.Right(), aRect
.Bottom()));
500 pNewObj
= new SdrPathObj(OBJ_LINE
, basegfx::B2DPolyPolygon(aPoly
));
506 if( pNewObj
== NULL
)
507 pNewObj
= SdrObjFactory::MakeNewObject( nInventor
, nType
, mpPage
);
511 pNewObj
->SetSnapRect(aRect
);
513 if( pNewObj
->ISA(E3dPolyScene
))
515 // Szene initialisieren
516 E3dScene
* pScene
= (E3dScene
*)pNewObj
;
518 double fW
= (double)aSize
.Width
;
519 double fH
= (double)aSize
.Height
;
521 Camera3D
aCam(pScene
->GetCamera());
522 aCam
.SetAutoAdjustProjection(sal_False
);
523 aCam
.SetViewWindow(- fW
/ 2, - fH
/ 2, fW
, fH
);
524 basegfx::B3DPoint aLookAt
;
525 basegfx::B3DPoint
aCamPos(0.0, 0.0, 10000.0);
526 aCam
.SetPosAndLookAt(aCamPos
, aLookAt
);
527 aCam
.SetFocalLength(100.0);
528 aCam
.SetDefaults(aCamPos
, aLookAt
, 10000.0);
529 pScene
->SetCamera(aCam
);
531 pScene
->SetRectsDirty();
533 else if(pNewObj
->ISA(E3dExtrudeObj
))
535 E3dExtrudeObj
* pObj
= (E3dExtrudeObj
*)pNewObj
;
536 basegfx::B2DPolygon aNewPolygon
;
537 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
538 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
539 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
540 aNewPolygon
.setClosed(true);
541 pObj
->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon
));
543 // #107245# pObj->SetExtrudeCharacterMode(sal_True);
544 pObj
->SetMergedItem(Svx3DCharacterModeItem(sal_True
));
546 else if(pNewObj
->ISA(E3dLatheObj
))
548 E3dLatheObj
* pObj
= (E3dLatheObj
*)pNewObj
;
549 basegfx::B2DPolygon aNewPolygon
;
550 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
551 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
552 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
553 aNewPolygon
.setClosed(true);
554 pObj
->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon
));
556 // #107245# pObj->SetLatheCharacterMode(sal_True);
557 pObj
->SetMergedItem(Svx3DCharacterModeItem(sal_True
));
565 //----------------------------------------------------------------------
566 void SvxDrawPage::GetTypeAndInventor( sal_uInt16
& rType
, sal_uInt32
& rInventor
, const OUString
& aName
) const throw()
568 sal_uInt32 nTempType
= UHashMap::getId( aName
);
570 if( nTempType
== UHASHMAP_NOTFOUND
)
572 if( aName
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) ||
573 aName
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TableShape")) )
575 rInventor
= SdrInventor
;
578 else if ( aName
== "com.sun.star.presentation.MediaShape" )
580 rInventor
= SdrInventor
;
584 else if(nTempType
& E3D_INVENTOR_FLAG
)
586 rInventor
= E3dInventor
;
587 rType
= (sal_uInt16
)(nTempType
& ~E3D_INVENTOR_FLAG
);
591 rInventor
= SdrInventor
;
592 rType
= (sal_uInt16
)nTempType
;
597 case OBJ_OLE2_PLUGIN
:
598 case OBJ_OLE2_APPLET
:
605 //----------------------------------------------------------------------
606 SvxShape
* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType
, sal_uInt32 nInventor
, SdrObject
*pObj
, SvxDrawPage
*mpPage
) throw()
608 SvxShape
* pRet
= NULL
;
616 case E3D_POLYSCENE_ID
:
617 pRet
= new Svx3DSceneObject( pObj
, mpPage
);
619 case E3D_CUBEOBJ_ID
:
620 pRet
= new Svx3DCubeObject( pObj
);
622 case E3D_SPHEREOBJ_ID
:
623 pRet
= new Svx3DSphereObject( pObj
);
625 case E3D_LATHEOBJ_ID
:
626 pRet
= new Svx3DLatheObject( pObj
);
628 case E3D_EXTRUDEOBJ_ID
:
629 pRet
= new Svx3DExtrudeObject( pObj
);
631 case E3D_POLYGONOBJ_ID
:
632 pRet
= new Svx3DPolygonObject( pObj
);
634 default: // unbekanntes 3D-Objekt auf der Page
635 pRet
= new SvxShape( pObj
);
647 pRet
= new SvxShapeGroup( pObj
, mpPage
);
650 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_LINE
);
653 pRet
= new SvxShapeRect( pObj
);
659 pRet
= new SvxShapeCircle( pObj
);
662 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_POLY
);
665 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PLIN
);
669 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_PATHLINE
);
673 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_PATHFILL
);
676 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_FREELINE
);
679 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_FREEFILL
);
682 pRet
= new SvxShapeCaption( pObj
);
685 case OBJ_OUTLINETEXT
:
687 pRet
= new SvxShapeText( pObj
);
690 pRet
= new SvxGraphicObject( pObj
);
693 pRet
= new SvxFrameShape( pObj
);
695 case OBJ_OLE2_APPLET
:
696 pRet
= new SvxAppletShape( pObj
);
698 case OBJ_OLE2_PLUGIN
:
699 pRet
= new SvxPluginShape( pObj
);
703 if( pObj
&& !pObj
->IsEmptyPresObj() && mpPage
)
705 SdrPage
* pSdrPage
= mpPage
->GetSdrPage();
708 SdrModel
* pSdrModel
= pSdrPage
->GetModel();
711 ::comphelper::IEmbeddedHelper
*pPersist
= pSdrModel
->GetPersist();
714 uno::Reference
< embed::XEmbeddedObject
> xObject
= pPersist
->getEmbeddedObjectContainer().
715 GetEmbeddedObject( static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() );
717 // TODO CL->KA: Why is this not working anymore?
720 SvGlobalName
aClassId( xObject
->getClassID() );
722 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
723 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
724 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
726 if( aPluginClassId
== aClassId
)
728 pRet
= new SvxPluginShape( pObj
);
729 nType
= OBJ_OLE2_PLUGIN
;
731 else if( aAppletClassId
== aClassId
)
733 pRet
= new SvxAppletShape( pObj
);
734 nType
= OBJ_OLE2_APPLET
;
736 else if( aIFrameClassId
== aClassId
)
738 pRet
= new SvxFrameShape( pObj
);
748 SvxUnoPropertyMapProvider
& rSvxMapProvider
= getSvxMapProvider();
749 pRet
= new SvxOle2Shape( pObj
, rSvxMapProvider
.GetMap(SVXMAP_OLE2
), rSvxMapProvider
.GetPropertySet(SVXMAP_OLE2
, SdrObject::GetGlobalDrawObjectItemPool()) );
754 pRet
= new SvxShapeConnector( pObj
);
757 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PATHPOLY
);
760 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PATHPLIN
);
764 SvxUnoPropertyMapProvider
& rSvxMapProvider
= getSvxMapProvider();
765 pRet
= new SvxShape( pObj
, rSvxMapProvider
.GetMap(SVXMAP_PAGE
), rSvxMapProvider
.GetPropertySet(SVXMAP_PAGE
, SdrObject::GetGlobalDrawObjectItemPool()) );
769 pRet
= new SvxShapeDimensioning( pObj
);
774 pRet
= new SvxShapeControl( pObj
);
776 case OBJ_CUSTOMSHAPE
:
777 pRet
= new SvxCustomShape( pObj
);
780 pRet
= new SvxMediaShape( pObj
);
783 pRet
= new SvxTableShape( pObj
);
785 default: // unbekanntes 2D-Objekt auf der Page
786 OSL_FAIL("Nicht implementierter Starone-Shape erzeugt! [CL]");
787 pRet
= new SvxShapeText( pObj
);
792 default: // Unbekannter Inventor
794 OSL_FAIL("AW: Unknown Inventor in SvxDrawPage::_CreateShape()");
801 sal_uInt32 nObjId
= nType
;
803 if( nInventor
== E3dInventor
)
804 nObjId
|= E3D_INVENTOR_FLAG
;
808 case OBJ_CCUT
: // Kreisabschnitt
809 case OBJ_CARC
: // Kreisbogen
810 case OBJ_SECT
: // Kreissektor
814 case E3D_SCENE_ID
| E3D_INVENTOR_FLAG
:
815 nObjId
= E3D_POLYSCENE_ID
| E3D_INVENTOR_FLAG
;
819 case OBJ_OUTLINETEXT
:
824 pRet
->setShapeKind(nObjId
);
830 //----------------------------------------------------------------------
831 Reference
< drawing::XShape
> SvxDrawPage::_CreateShape( SdrObject
*pObj
) const throw()
833 Reference
< drawing::XShape
> xShape( CreateShapeByTypeAndInventor(pObj
->GetObjIdentifier(),
834 pObj
->GetObjInventor(),
836 (SvxDrawPage
*)this));
840 //----------------------------------------------------------------------
841 SdrObject
*SvxDrawPage::CreateSdrObject( const Reference
< drawing::XShape
> & xShape
) throw()
843 SdrObject
* pObj
= _CreateSdrObject( xShape
);
846 pObj
->SetModel(mpModel
);
847 if ( !pObj
->IsInserted() && !pObj
->IsDoNotInsertIntoPageAutomatically() )
848 mpPage
->InsertObject( pObj
);
854 //----------------------------------------------------------------------
855 // ::com::sun::star::lang::XServiceInfo
856 //----------------------------------------------------------------------
857 OUString SAL_CALL
SvxDrawPage::getImplementationName() throw( uno::RuntimeException
)
859 return OUString("SvxDrawPage");
862 sal_Bool SAL_CALL
SvxDrawPage::supportsService( const OUString
& ServiceName
)
863 throw(::com::sun::star::uno::RuntimeException
)
865 return comphelper::ServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
868 uno::Sequence
< OUString
> SAL_CALL
SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException
)
870 uno::Sequence
< OUString
> aSeq( 1 );
871 aSeq
.getArray()[0] = OUString("com.sun.star.drawing.ShapeCollection" );
875 SvxShape
* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType
, sal_uInt32 nInventor
) throw()
877 return SvxDrawPage::CreateShapeByTypeAndInventor( nType
, nInventor
);
880 void SvxDrawPage::ChangeModel( SdrModel
* pNewModel
)
882 if( pNewModel
!= mpModel
)
885 EndListening( *mpModel
);
888 StartListening( *pNewModel
);
895 mpView
= new SdrView( mpModel
);
897 mpView
->SetDesignMode(sal_True
);
902 /** returns a StarOffice API wrapper for the given SdrPage */
903 uno::Reference
< drawing::XDrawPage
> GetXDrawPageForSdrPage( SdrPage
* pPage
) throw ()
907 uno::Reference
< drawing::XDrawPage
> xDrawPage( pPage
->getUnoPage(), uno::UNO_QUERY
);
912 return uno::Reference
< drawing::XDrawPage
>();
915 /** returns the SdrObject from the given StarOffice API wrapper */
916 SdrPage
* GetSdrPageFromXDrawPage( uno::Reference
< drawing::XDrawPage
> xDrawPage
) throw()
920 SvxDrawPage
* pDrawPage
= SvxDrawPage::getImplementation( xDrawPage
);
924 return pDrawPage
->GetSdrPage();
931 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */