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 <config_features.h>
22 #include <com/sun/star/document/EventObject.hpp>
23 #include <com/sun/star/lang/DisposedException.hpp>
24 #include <osl/mutex.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <comphelper/classids.hxx>
27 #include <cppuhelper/supportsservice.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <svx/svdpool.hxx>
31 #include <svx/svdobj.hxx>
32 #include <svx/svdoole2.hxx>
33 #include <svx/svdpage.hxx>
34 #include <svx/svdmodel.hxx>
35 #include <svx/svdstr.hrc>
36 #include <svx/svdview.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdundo.hxx>
39 #include <svx/unopage.hxx>
40 #include "shapeimpl.hxx"
41 #include "svdglob.hxx"
42 #include "svx/globl3d.hxx"
43 #include <svx/polysc3d.hxx>
44 #include <svx/unoprov.hxx>
45 #include <svx/svdopath.hxx>
46 #include "svx/unoapi.hxx"
47 #include <svx/svdomeas.hxx>
48 #include <svx/extrud3d.hxx>
49 #include <svx/lathe3d.hxx>
50 #include <vcl/svapp.hxx>
51 #include <tools/diagnose_ex.h>
53 using namespace ::cppu
;
54 using namespace ::com::sun::star
;
55 using namespace ::com::sun::star::uno
;
56 using namespace ::com::sun::star::lang
;
57 using namespace ::com::sun::star::container
;
58 using namespace ::com::sun::star::drawing
;
60 #define INTERFACE_TYPE( xint ) \
61 cppu::UnoType<xint>::get()
63 UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage
);
64 SvxDrawPage::SvxDrawPage( SdrPage
* pInPage
) throw()
65 : mrBHelper( getMutex() )
69 // register at broadcaster
71 mpModel
= mpPage
->GetModel();
73 StartListening( *mpModel
);
76 // create (hidden) view
77 mpView
= new SdrView( mpModel
);
78 mpView
->SetDesignMode(true);
81 SvxDrawPage::~SvxDrawPage() throw()
83 if( !mrBHelper
.bDisposed
)
85 SAL_WARN("svx", "SvxDrawPage must be disposed!");
92 void SvxDrawPage::release() throw()
94 OWeakAggObject::release();
98 void SvxDrawPage::disposing() throw()
102 EndListening( *mpModel
);
115 void SvxDrawPage::dispose()
116 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
118 SolarMutexGuard aSolarGuard
;
120 // An frequently programming error is to release the last
121 // reference to this object in the disposing message.
122 // Make it rubust, hold a self Reference.
123 uno::Reference
< lang::XComponent
> xSelf( this );
125 // Guard dispose against multible threading
126 // Remark: It is an error to call dispose more than once
127 bool bDoDispose
= false;
129 osl::MutexGuard
aGuard( mrBHelper
.rMutex
);
130 if( !mrBHelper
.bDisposed
&& !mrBHelper
.bInDispose
)
132 // only one call go into this section
133 mrBHelper
.bInDispose
= sal_True
;
138 // Do not hold the mutex because we are broadcasting
141 // Create an event with this as sender
144 uno::Reference
< uno::XInterface
> xSource( uno::Reference
< uno::XInterface
>::query( (lang::XComponent
*)this ) );
145 ::com::sun::star::document::EventObject aEvt
;
146 aEvt
.Source
= xSource
;
147 // inform all listeners to release this object
148 // The listener container are automatically cleared
149 mrBHelper
.aLC
.disposeAndClear( aEvt
);
150 // notify subclasses to do their dispose
153 catch(const ::com::sun::star::uno::Exception
&)
155 // catch exception and throw again but signal that
156 // the object was disposed. Dispose should be called
158 mrBHelper
.bDisposed
= sal_True
;
159 mrBHelper
.bInDispose
= sal_False
;
163 // the values bDispose and bInDisposing must set in this order.
164 // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
165 mrBHelper
.bDisposed
= sal_True
;
166 mrBHelper
.bInDispose
= sal_False
;
171 void SAL_CALL
SvxDrawPage::addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
173 SolarMutexGuard aGuard
;
176 throw lang::DisposedException();
178 mrBHelper
.addListener( cppu::UnoType
<decltype(aListener
)>::get() , aListener
);
181 void SAL_CALL
SvxDrawPage::removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
183 SolarMutexGuard aGuard
;
186 throw lang::DisposedException();
188 mrBHelper
.removeListener( cppu::UnoType
<decltype(aListener
)>::get() , aListener
);
192 void SvxDrawPage::Notify( SfxBroadcaster
&, const SfxHint
& /*rHint*/ )
196 void SAL_CALL
SvxDrawPage::add( const uno::Reference
< drawing::XShape
>& xShape
)
197 throw( uno::RuntimeException
, std::exception
)
199 SolarMutexGuard aGuard
;
201 if ( ( mpModel
== NULL
) || ( mpPage
== NULL
) )
202 throw lang::DisposedException();
204 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
209 SdrObject
*pObj
= pShape
->GetSdrObject();
213 pObj
= CreateSdrObject( xShape
);
214 ENSURE_OR_RETURN_VOID( pObj
!= NULL
, "SvxDrawPage::add: no SdrObject was created!" );
216 else if ( !pObj
->IsInserted() )
218 pObj
->SetModel(mpModel
);
219 mpPage
->InsertObject( pObj
);
222 pShape
->Create( pObj
, this );
223 OSL_ENSURE( pShape
->GetSdrObject() == pObj
, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
225 if ( !pObj
->IsInserted() )
227 pObj
->SetModel(mpModel
);
228 mpPage
->InsertObject( pObj
);
231 mpModel
->SetChanged();
234 void SAL_CALL
SvxDrawPage::addTop( const uno::Reference
< drawing::XShape
>& xShape
)
235 throw( uno::RuntimeException
, std::exception
)
240 void SAL_CALL
SvxDrawPage::addBottom( const uno::Reference
< drawing::XShape
>& xShape
)
241 throw( uno::RuntimeException
, std::exception
)
243 SolarMutexGuard aGuard
;
245 if ( ( mpModel
== NULL
) || ( mpPage
== NULL
) )
246 throw lang::DisposedException();
248 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
253 SdrObject
*pObj
= pShape
->GetSdrObject();
257 pObj
= CreateSdrObject( xShape
, true );
258 ENSURE_OR_RETURN_VOID( pObj
!= NULL
, "SvxDrawPage::add: no SdrObject was created!" );
260 else if ( !pObj
->IsInserted() )
262 pObj
->SetModel(mpModel
);
263 mpPage
->InsertObject( pObj
, 0 );
266 pShape
->Create( pObj
, this );
267 OSL_ENSURE( pShape
->GetSdrObject() == pObj
, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
269 if ( !pObj
->IsInserted() )
271 pObj
->SetModel(mpModel
);
272 mpPage
->InsertObject( pObj
, 0 );
275 mpModel
->SetChanged();
278 void SAL_CALL
SvxDrawPage::remove( const Reference
< drawing::XShape
>& xShape
)
279 throw (uno::RuntimeException
, std::exception
)
281 SolarMutexGuard aGuard
;
283 if( (mpModel
== 0) || (mpPage
== 0) )
284 throw lang::DisposedException();
286 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
290 SdrObject
* pObj
= pShape
->GetSdrObject();
293 // remove SdrObject from page
294 const size_t nCount
= mpPage
->GetObjCount();
295 for( size_t nNum
= 0; nNum
< nCount
; ++nNum
)
297 if(mpPage
->GetObj(nNum
) == pObj
)
299 const bool bUndoEnabled
= mpModel
->IsUndoEnabled();
303 mpModel
->BegUndo(ImpGetResStr(STR_EditDelete
),
304 pObj
->TakeObjNameSingul(), SDRREPFUNC_OBJ_DELETE
);
306 SdrUndoAction
* pAction
= mpModel
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj
);
307 mpModel
->AddUndo(pAction
);
310 OSL_VERIFY( mpPage
->RemoveObject( nNum
) == pObj
);
313 SdrObject::Free(pObj
);
324 mpModel
->SetChanged();
327 // ::com::sun::star::container::XIndexAccess
328 sal_Int32 SAL_CALL
SvxDrawPage::getCount()
329 throw( uno::RuntimeException
, std::exception
)
331 SolarMutexGuard aGuard
;
333 if( (mpModel
== 0) || (mpPage
== 0) )
334 throw lang::DisposedException();
336 return static_cast<sal_Int32
>( mpPage
->GetObjCount() );
339 uno::Any SAL_CALL
SvxDrawPage::getByIndex( sal_Int32 Index
)
340 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
342 SolarMutexGuard aGuard
;
344 if( (mpModel
== 0) || (mpPage
== 0) )
345 throw lang::DisposedException();
347 if ( Index
< 0 || static_cast<size_t>(Index
) >= mpPage
->GetObjCount() )
348 throw lang::IndexOutOfBoundsException();
350 SdrObject
* pObj
= mpPage
->GetObj( Index
);
352 throw uno::RuntimeException();
355 return makeAny(Reference
< drawing::XShape
>( pObj
->getUnoShape(), uno::UNO_QUERY
));
358 // ::com::sun::star::container::XElementAccess
359 uno::Type SAL_CALL
SvxDrawPage::getElementType()
360 throw( uno::RuntimeException
, std::exception
)
362 return INTERFACE_TYPE( drawing::XShape
);
365 sal_Bool SAL_CALL
SvxDrawPage::hasElements()
366 throw( uno::RuntimeException
, std::exception
)
368 SolarMutexGuard aGuard
;
370 if( (mpModel
== 0) || (mpPage
== 0) )
371 throw lang::DisposedException();
373 return mpPage
&& mpPage
->GetObjCount()>0;
378 void lcl_markSdrObjectOfShape( const Reference
< drawing::XShape
>& _rxShape
, SdrView
& _rView
, SdrPageView
& _rPageView
)
380 SvxShape
* pShape
= SvxShape::getImplementation( _rxShape
);
384 SdrObject
* pObj
= pShape
->GetSdrObject();
388 _rView
.MarkObj( pObj
, &_rPageView
);
392 // ATTENTION: _SelectObjectsInView selects the ::com::sun::star::drawing::Shapes
393 // only in the given SdrPageView. It hasn't to be the visible SdrPageView.
394 void SvxDrawPage::_SelectObjectsInView( const Reference
< drawing::XShapes
> & aShapes
, SdrPageView
* pPageView
) throw ()
396 SAL_WARN_IF(!pPageView
, "svx", "SdrPageView is NULL!");
397 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
399 if(pPageView
!=NULL
&& mpView
!=NULL
)
401 mpView
->UnmarkAllObj( pPageView
);
403 long nCount
= aShapes
->getCount();
404 for( long i
= 0; i
< nCount
; i
++ )
406 uno::Any
aAny( aShapes
->getByIndex(i
) );
407 Reference
< drawing::XShape
> xShape
;
408 if( aAny
>>= xShape
)
409 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
414 // ATTENTION: _SelectObjectInView selects the shape only in the given SdrPageView.
415 // It hasn't to be the visible SdrPageView.
416 void SvxDrawPage::_SelectObjectInView( const Reference
< drawing::XShape
> & xShape
, SdrPageView
* pPageView
) throw()
418 SAL_WARN_IF(!pPageView
, "svx", "SdrPageView is NULL!");
419 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
421 if(pPageView
!=NULL
&& mpView
!= NULL
)
423 mpView
->UnmarkAllObj( pPageView
);
424 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
428 Reference
< drawing::XShapeGroup
> SAL_CALL
SvxDrawPage::group( const Reference
< drawing::XShapes
>& xShapes
)
429 throw( uno::RuntimeException
, std::exception
)
431 SolarMutexGuard aGuard
;
433 if( (mpModel
== 0) || (mpPage
== 0) )
434 throw lang::DisposedException();
436 SAL_WARN_IF(!mpPage
, "svx", "SdrPage is NULL!");
437 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
439 Reference
< ::com::sun::star::drawing::XShapeGroup
> xShapeGroup
;
440 if(mpPage
==NULL
||mpView
==NULL
||!xShapes
.is())
443 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
445 _SelectObjectsInView( xShapes
, pPageView
);
447 mpView
->GroupMarked();
449 mpView
->AdjustMarkHdl();
450 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
451 if( rMarkList
.GetMarkCount() == 1 )
453 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
455 xShapeGroup
= Reference
< drawing::XShapeGroup
>::query( pObj
->getUnoShape() );
458 mpView
->HideSdrPage();
461 mpModel
->SetChanged();
466 void SAL_CALL
SvxDrawPage::ungroup( const Reference
< drawing::XShapeGroup
>& aGroup
)
467 throw( uno::RuntimeException
, std::exception
)
469 SolarMutexGuard aGuard
;
471 if( (mpModel
== 0) || (mpPage
== 0) )
472 throw lang::DisposedException();
474 SAL_WARN_IF(!mpPage
, "svx", "SdrPage is NULL!");
475 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
477 if(mpPage
==NULL
||mpView
==NULL
||!aGroup
.is())
480 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
482 Reference
< drawing::XShape
> xShape( aGroup
, UNO_QUERY
);
483 _SelectObjectInView( xShape
, pPageView
);
484 mpView
->UnGroupMarked();
486 mpView
->HideSdrPage();
489 mpModel
->SetChanged();
492 SdrObject
*SvxDrawPage::_CreateSdrObject(const Reference
< drawing::XShape
> & xShape
)
493 throw (css::uno::RuntimeException
, std::exception
)
495 sal_uInt16 nType
= 0;
496 sal_uInt32 nInventor
= 0;
498 GetTypeAndInventor( nType
, nInventor
, xShape
->getShapeType() );
502 awt::Size aSize
= xShape
->getSize();
505 awt::Point aPos
= xShape
->getPosition();
506 Rectangle
aRect( Point( aPos
.X
, aPos
.Y
), Size( aSize
.Width
, aSize
.Height
) );
508 SdrObject
* pNewObj
= SdrObjFactory::MakeNewObject(nInventor
, nType
, aRect
, mpPage
);
512 if( pNewObj
->ISA(E3dPolyScene
))
515 E3dScene
* pScene
= static_cast<E3dScene
*>(pNewObj
);
517 double fW
= (double)aSize
.Width
;
518 double fH
= (double)aSize
.Height
;
520 Camera3D
aCam(pScene
->GetCamera());
521 aCam
.SetAutoAdjustProjection(false);
522 aCam
.SetViewWindow(- fW
/ 2, - fH
/ 2, fW
, fH
);
523 basegfx::B3DPoint aLookAt
;
524 basegfx::B3DPoint
aCamPos(0.0, 0.0, 10000.0);
525 aCam
.SetPosAndLookAt(aCamPos
, aLookAt
);
526 aCam
.SetFocalLength(100.0);
527 aCam
.SetDefaults(aCamPos
, aLookAt
, 10000.0);
528 pScene
->SetCamera(aCam
);
530 pScene
->SetRectsDirty();
532 else if(pNewObj
->ISA(E3dExtrudeObj
))
534 E3dExtrudeObj
* pObj
= static_cast<E3dExtrudeObj
*>(pNewObj
);
535 basegfx::B2DPolygon aNewPolygon
;
536 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
537 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
538 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
539 aNewPolygon
.setClosed(true);
540 pObj
->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon
));
542 // #107245# pObj->SetExtrudeCharacterMode(sal_True);
543 pObj
->SetMergedItem(Svx3DCharacterModeItem(true));
545 else if(pNewObj
->ISA(E3dLatheObj
))
547 E3dLatheObj
* pObj
= static_cast<E3dLatheObj
*>(pNewObj
);
548 basegfx::B2DPolygon aNewPolygon
;
549 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
550 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
551 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
552 aNewPolygon
.setClosed(true);
553 pObj
->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon
));
555 // #107245# pObj->SetLatheCharacterMode(sal_True);
556 pObj
->SetMergedItem(Svx3DCharacterModeItem(true));
562 void SvxDrawPage::GetTypeAndInventor( sal_uInt16
& rType
, sal_uInt32
& rInventor
, const OUString
& aName
) throw()
564 sal_uInt32 nTempType
= UHashMap::getId( aName
);
566 if( nTempType
== UHASHMAP_NOTFOUND
)
568 if( aName
== "com.sun.star.drawing.TableShape" ||
569 aName
== "com.sun.star.presentation.TableShape" )
571 rInventor
= SdrInventor
;
574 #if HAVE_FEATURE_AVMEDIA
575 else if ( aName
== "com.sun.star.presentation.MediaShape" )
577 rInventor
= SdrInventor
;
582 else if(nTempType
& E3D_INVENTOR_FLAG
)
584 rInventor
= E3dInventor
;
585 rType
= (sal_uInt16
)(nTempType
& ~E3D_INVENTOR_FLAG
);
589 rInventor
= SdrInventor
;
590 rType
= (sal_uInt16
)nTempType
;
595 case OBJ_OLE2_PLUGIN
:
596 case OBJ_OLE2_APPLET
:
603 SvxShape
* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType
, sal_uInt32 nInventor
, SdrObject
*pObj
, SvxDrawPage
*mpPage
, OUString
const & referer
)
604 throw (css::uno::RuntimeException
)
606 SvxShape
* pRet
= NULL
;
614 case E3D_POLYSCENE_ID
:
615 pRet
= new Svx3DSceneObject( pObj
, mpPage
);
617 case E3D_CUBEOBJ_ID
:
618 pRet
= new Svx3DCubeObject( pObj
);
620 case E3D_SPHEREOBJ_ID
:
621 pRet
= new Svx3DSphereObject( pObj
);
623 case E3D_LATHEOBJ_ID
:
624 pRet
= new Svx3DLatheObject( pObj
);
626 case E3D_EXTRUDEOBJ_ID
:
627 pRet
= new Svx3DExtrudeObject( pObj
);
629 case E3D_POLYGONOBJ_ID
:
630 pRet
= new Svx3DPolygonObject( pObj
);
632 default: // unknown 3D-object on page
633 pRet
= new SvxShape( pObj
);
643 pRet
= new SvxShapeGroup( pObj
, mpPage
);
646 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_LINE
);
649 pRet
= new SvxShapeRect( pObj
);
655 pRet
= new SvxShapeCircle( pObj
);
658 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_POLY
);
661 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PLIN
);
665 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_PATHLINE
);
669 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_PATHFILL
);
672 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_FREELINE
);
675 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_FREEFILL
);
678 pRet
= new SvxShapeCaption( pObj
);
681 case OBJ_OUTLINETEXT
:
683 pRet
= new SvxShapeText( pObj
);
686 pRet
= new SvxGraphicObject( pObj
, referer
);
689 pRet
= new SvxFrameShape( pObj
);
691 case OBJ_OLE2_APPLET
:
692 pRet
= new SvxAppletShape( pObj
);
694 case OBJ_OLE2_PLUGIN
:
695 pRet
= new SvxPluginShape( pObj
);
699 if( pObj
&& !pObj
->IsEmptyPresObj() && mpPage
)
701 SdrPage
* pSdrPage
= mpPage
->GetSdrPage();
704 SdrModel
* pSdrModel
= pSdrPage
->GetModel();
707 ::comphelper::IEmbeddedHelper
*pPersist
= pSdrModel
->GetPersist();
710 uno::Reference
< embed::XEmbeddedObject
> xObject
= pPersist
->getEmbeddedObjectContainer().
711 GetEmbeddedObject( static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() );
713 // TODO CL->KA: Why is this not working anymore?
716 SvGlobalName
aClassId( xObject
->getClassID() );
718 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
719 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
720 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
722 if( aPluginClassId
== aClassId
)
724 pRet
= new SvxPluginShape( pObj
);
725 nType
= OBJ_OLE2_PLUGIN
;
727 else if( aAppletClassId
== aClassId
)
729 pRet
= new SvxAppletShape( pObj
);
730 nType
= OBJ_OLE2_APPLET
;
732 else if( aIFrameClassId
== aClassId
)
734 pRet
= new SvxFrameShape( pObj
);
744 SvxUnoPropertyMapProvider
& rSvxMapProvider
= getSvxMapProvider();
745 pRet
= new SvxOle2Shape( pObj
, rSvxMapProvider
.GetMap(SVXMAP_OLE2
), rSvxMapProvider
.GetPropertySet(SVXMAP_OLE2
, SdrObject::GetGlobalDrawObjectItemPool()) );
750 pRet
= new SvxShapeConnector( pObj
);
753 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PATHPOLY
);
756 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PATHPLIN
);
760 SvxUnoPropertyMapProvider
& rSvxMapProvider
= getSvxMapProvider();
761 pRet
= new SvxShape( pObj
, rSvxMapProvider
.GetMap(SVXMAP_PAGE
), rSvxMapProvider
.GetPropertySet(SVXMAP_PAGE
, SdrObject::GetGlobalDrawObjectItemPool()) );
765 pRet
= new SvxShapeDimensioning( pObj
);
768 pRet
= new SvxShapeControl( pObj
);
770 case OBJ_CUSTOMSHAPE
:
771 pRet
= new SvxCustomShape( pObj
);
773 #if HAVE_FEATURE_DESKTOP
775 pRet
= new SvxMediaShape( pObj
, referer
);
779 pRet
= new SvxTableShape( pObj
);
782 pRet
= new SvxOpenGLObject( pObj
);
784 default: // unknown 2D-object on page
785 OSL_FAIL("Not implemented Starone-Shape created! [CL]");
786 pRet
= new SvxShapeText( pObj
);
791 default: // unknown inventor
793 OSL_FAIL("AW: Unknown Inventor in SvxDrawPage::_CreateShape()");
800 sal_uInt32 nObjId
= nType
;
802 if( nInventor
== E3dInventor
)
803 nObjId
|= E3D_INVENTOR_FLAG
;
807 case OBJ_CCUT
: // segment of circle
808 case OBJ_CARC
: // arc of circle
809 case OBJ_SECT
: // sector
813 case E3D_SCENE_ID
| E3D_INVENTOR_FLAG
:
814 nObjId
= E3D_POLYSCENE_ID
| E3D_INVENTOR_FLAG
;
818 case OBJ_OUTLINETEXT
:
823 pRet
->setShapeKind(nObjId
);
829 Reference
< drawing::XShape
> SvxDrawPage::_CreateShape( SdrObject
*pObj
) const
830 throw (css::uno::RuntimeException
, std::exception
)
832 Reference
< drawing::XShape
> xShape( CreateShapeByTypeAndInventor(pObj
->GetObjIdentifier(),
833 pObj
->GetObjInventor(),
835 const_cast<SvxDrawPage
*>(this)));
839 SdrObject
*SvxDrawPage::CreateSdrObject( const Reference
< drawing::XShape
> & xShape
, bool bBeginning
) throw()
841 SdrObject
* pObj
= _CreateSdrObject( xShape
);
844 pObj
->SetModel(mpModel
);
845 if ( !pObj
->IsInserted() && !pObj
->IsDoNotInsertIntoPageAutomatically() )
848 mpPage
->InsertObject( pObj
, 0 );
850 mpPage
->InsertObject( pObj
);
857 // ::com::sun::star::lang::XServiceInfo
858 OUString SAL_CALL
SvxDrawPage::getImplementationName() throw( uno::RuntimeException
, std::exception
)
860 return OUString("SvxDrawPage");
863 sal_Bool SAL_CALL
SvxDrawPage::supportsService( const OUString
& ServiceName
)
864 throw(::com::sun::star::uno::RuntimeException
, std::exception
)
866 return cppu::supportsService( this, ServiceName
);
869 uno::Sequence
< OUString
> SAL_CALL
SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException
, std::exception
)
871 uno::Sequence
< OUString
> aSeq( 1 );
872 aSeq
.getArray()[0] = "com.sun.star.drawing.ShapeCollection";
876 SvxShape
* CreateSvxShapeByTypeAndInventor(sal_uInt16 nType
, sal_uInt32 nInventor
, OUString
const & referer
)
877 throw (css::uno::RuntimeException
, std::exception
)
879 return SvxDrawPage::CreateShapeByTypeAndInventor( nType
, nInventor
, 0, 0, referer
);
882 void SvxDrawPage::ChangeModel( SdrModel
* pNewModel
)
884 if( pNewModel
!= mpModel
)
887 EndListening( *mpModel
);
890 StartListening( *pNewModel
);
897 mpView
= new SdrView( mpModel
);
898 mpView
->SetDesignMode(true);
903 /** returns a StarOffice API wrapper for the given SdrPage */
904 uno::Reference
< drawing::XDrawPage
> GetXDrawPageForSdrPage( SdrPage
* pPage
) throw ()
908 uno::Reference
< drawing::XDrawPage
> xDrawPage( pPage
->getUnoPage(), uno::UNO_QUERY
);
913 return uno::Reference
< drawing::XDrawPage
>();
916 /** returns the SdrObject from the given StarOffice API wrapper */
917 SdrPage
* GetSdrPageFromXDrawPage( uno::Reference
< drawing::XDrawPage
> xDrawPage
) throw()
921 SvxDrawPage
* pDrawPage
= SvxDrawPage::getImplementation( xDrawPage
);
925 return pDrawPage
->GetSdrPage();
932 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */