1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unopage.cxx,v $
10 * $Revision: 1.50.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #define _SVX_USE_UNOGLOBALS_
35 #include <com/sun/star/document/EventObject.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <vos/mutex.hxx>
38 #include <osl/mutex.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sot/clsids.hxx>
43 #include <rtl/memory.h>
44 #include <sfx2/objsh.hxx>
46 #include <svx/svdobj.hxx>
47 #include <svx/svdoole2.hxx>
48 #include <svx/svdpage.hxx>
49 #include <svx/svdmodel.hxx>
50 #include <svx/svdview.hxx>
51 #include <svx/svdpagv.hxx>
52 #include <svx/unopage.hxx>
53 #include "shapeimpl.hxx"
54 #include "globl3d.hxx"
55 #include <svx/polysc3d.hxx>
56 #include <svx/unoprov.hxx>
57 #include <svx/svdopath.hxx>
59 #include <svx/svdomeas.hxx>
60 #include <svx/extrud3d.hxx>
61 #include <svx/lathe3d.hxx>
62 #include <vcl/svapp.hxx>
64 using ::rtl::OUString
;
65 using namespace ::vos
;
66 using namespace ::cppu
;
67 using namespace ::com::sun::star
;
68 using namespace ::com::sun::star::uno
;
69 using namespace ::com::sun::star::lang
;
70 using namespace ::com::sun::star::container
;
71 using namespace ::com::sun::star::drawing
;
73 #define INTERFACE_TYPE( xint ) \
74 ::getCppuType((const Reference< xint >*)0)
76 #define QUERYINT( xint ) \
77 if( rType == ::getCppuType((const Reference< xint >*)0) ) \
78 aAny <<= Reference< xint >(this)
80 DECLARE_LIST( SvxDrawPageList
, SvxDrawPage
* )
83 /**********************************************************************
85 **********************************************************************/
87 UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage
);
89 SvxDrawPage::SvxDrawPage( SdrPage
* pInPage
) throw()
90 : mrBHelper( getMutex() )
94 DBG_CTOR(SvxDrawPage
,NULL
);
95 // Am Broadcaster anmelden
97 mpModel
= mpPage
->GetModel();
99 StartListening( *mpModel
);
102 // Erzeugen der (hidden) ::com::sun::star::sdbcx::View
103 mpView
= new SdrView( mpModel
);
105 mpView
->SetDesignMode(sal_True
);
108 //----------------------------------------------------------------------
109 // Ctor fuer SvxDrawPage_NewInstance()
110 //----------------------------------------------------------------------
111 SvxDrawPage::SvxDrawPage() throw()
112 : mrBHelper( getMutex() )
117 DBG_CTOR(SvxDrawPage
,NULL
);
120 //----------------------------------------------------------------------
121 SvxDrawPage::~SvxDrawPage() throw()
123 DBG_ASSERT( mrBHelper
.bDisposed
, "SvxDrawPage must be disposed!" );
124 if( !mrBHelper
.bDisposed
)
129 DBG_DTOR(SvxDrawPage
,NULL
);
132 //----------------------------------------------------------------------
135 void SvxDrawPage::release() throw()
138 uno::Reference< uno::XInterface > x( xDelegator );
141 if (osl_decrementInterlockedCount( &m_refCount ) == 0)
143 if (! mrBHelper.bDisposed)
145 uno::Reference< uno::XInterface > xHoldAlive( (uno::XWeak*)this );
151 catch(::com::sun::star::uno::Exception&)
153 // release should not throw exceptions
156 // only the alive ref holds the object
157 OSL_ASSERT( m_refCount == 1 );
158 // destroy the object if xHoldAlive decrement the refcount to 0
162 // restore the reference count
163 osl_incrementInterlockedCount( &m_refCount );
166 OWeakAggObject::release();
169 //----------------------------------------------------------------------
171 SvxDrawPage
* SvxDrawPage::GetPageForSdrPage( SdrPage
* mpPage
) throw()
173 return getImplementation( mpPage
->getUnoPage() );
177 void SvxDrawPage::disposing() throw()
181 EndListening( *mpModel
);
193 //----------------------------------------------------------------------
195 //----------------------------------------------------------------------
197 void SvxDrawPage::dispose()
198 throw(::com::sun::star::uno::RuntimeException
)
200 OGuard
aSolarGuard( Application::GetSolarMutex() );
202 // An frequently programming error is to release the last
203 // reference to this object in the disposing message.
204 // Make it rubust, hold a self Reference.
205 uno::Reference
< lang::XComponent
> xSelf( this );
207 // Guard dispose against multible threading
208 // Remark: It is an error to call dispose more than once
209 sal_Bool bDoDispose
= sal_False
;
211 osl::MutexGuard
aGuard( mrBHelper
.rMutex
);
212 if( !mrBHelper
.bDisposed
&& !mrBHelper
.bInDispose
)
214 // only one call go into this section
215 mrBHelper
.bInDispose
= sal_True
;
216 bDoDispose
= sal_True
;
220 // Do not hold the mutex because we are broadcasting
223 // Create an event with this as sender
226 uno::Reference
< uno::XInterface
> xSource( uno::Reference
< uno::XInterface
>::query( (lang::XComponent
*)this ) );
227 ::com::sun::star::document::EventObject aEvt
;
228 aEvt
.Source
= xSource
;
229 // inform all listeners to release this object
230 // The listener container are automaticly cleared
231 mrBHelper
.aLC
.disposeAndClear( aEvt
);
232 // notify subclasses to do their dispose
235 catch(::com::sun::star::uno::Exception
& e
)
237 // catch exception and throw again but signal that
238 // the object was disposed. Dispose should be called
240 mrBHelper
.bDisposed
= sal_True
;
241 mrBHelper
.bInDispose
= sal_False
;
245 // the values bDispose and bInDisposing must set in this order.
246 // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
247 mrBHelper
.bDisposed
= sal_True
;
248 mrBHelper
.bInDispose
= sal_False
;
253 //----------------------------------------------------------------------
255 void SAL_CALL
SvxDrawPage::addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
257 OGuard
aGuard( Application::GetSolarMutex() );
260 throw lang::DisposedException();
262 mrBHelper
.addListener( ::getCppuType( &aListener
) , aListener
);
265 //----------------------------------------------------------------------
267 void SAL_CALL
SvxDrawPage::removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
269 OGuard
aGuard( Application::GetSolarMutex() );
272 throw lang::DisposedException();
274 mrBHelper
.removeListener( ::getCppuType( &aListener
) , aListener
);
277 //----------------------------------------------------------------------
279 //----------------------------------------------------------------------
281 void SvxDrawPage::Notify( SfxBroadcaster
&, const SfxHint
& /*rHint*/ )
286 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
289 switch( pSdrHint->GetKind() )
291 case HINT_MODELCLEARED:
302 //----------------------------------------------------------------------
303 // ::com::sun::star::drawing::XShapes
304 //----------------------------------------------------------------------
306 void SAL_CALL
SvxDrawPage::add( const uno::Reference
< drawing::XShape
>& xShape
)
307 throw( uno::RuntimeException
)
309 OGuard
aGuard( Application::GetSolarMutex() );
311 if( (mpModel
== 0) || (mpPage
== 0) )
312 throw lang::DisposedException();
314 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
319 SdrObject
*pObj
= pShape
->GetSdrObject();
323 pObj
= CreateSdrObject( xShape
);
325 else if ( !pObj
->IsInserted() )
327 pObj
->SetModel(mpModel
);
328 mpPage
->InsertObject( pObj
);
335 pShape
->Create( pObj
, this );
338 mpModel
->SetChanged();
341 //----------------------------------------------------------------------
342 void SAL_CALL
SvxDrawPage::remove( const Reference
< drawing::XShape
>& xShape
)
343 throw( uno::RuntimeException
)
345 OGuard
aGuard( Application::GetSolarMutex() );
347 if( (mpModel
== 0) || (mpPage
== 0) )
348 throw lang::DisposedException();
350 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
354 SdrObject
* pObj
= pShape
->GetSdrObject();
357 // SdrObject aus der Page loeschen
358 sal_uInt32 nCount
= mpPage
->GetObjCount();
359 for( sal_uInt32 nNum
= 0; nNum
< nCount
; nNum
++ )
361 if(mpPage
->GetObj(nNum
) == pObj
)
363 OSL_VERIFY( mpPage
->RemoveObject( nNum
) == pObj
);
364 SdrObject::Free( pObj
);
372 mpModel
->SetChanged();
375 //----------------------------------------------------------------------
376 // ::com::sun::star::container::XIndexAccess
377 //----------------------------------------------------------------------
379 sal_Int32 SAL_CALL
SvxDrawPage::getCount()
380 throw( uno::RuntimeException
)
382 OGuard
aGuard( Application::GetSolarMutex() );
384 if( (mpModel
== 0) || (mpPage
== 0) )
385 throw lang::DisposedException();
387 return( (sal_Int32
) mpPage
->GetObjCount() );
390 //----------------------------------------------------------------------
391 uno::Any SAL_CALL
SvxDrawPage::getByIndex( sal_Int32 Index
)
392 throw( lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
394 OGuard
aGuard( Application::GetSolarMutex() );
396 if( (mpModel
== 0) || (mpPage
== 0) )
397 throw lang::DisposedException();
399 if ( Index
< 0 || Index
>= (sal_Int32
)mpPage
->GetObjCount() )
400 throw lang::IndexOutOfBoundsException();
402 SdrObject
* pObj
= mpPage
->GetObj( Index
);
404 throw uno::RuntimeException();
407 return makeAny(Reference
< drawing::XShape
>( pObj
->getUnoShape(), uno::UNO_QUERY
));
411 //----------------------------------------------------------------------
412 // ::com::sun::star::container::XElementAccess
413 //----------------------------------------------------------------------
415 uno::Type SAL_CALL
SvxDrawPage::getElementType()
416 throw( uno::RuntimeException
)
418 return INTERFACE_TYPE( drawing::XShape
);
421 //----------------------------------------------------------------------
422 sal_Bool SAL_CALL
SvxDrawPage::hasElements()
423 throw( uno::RuntimeException
)
425 OGuard
aGuard( Application::GetSolarMutex() );
427 if( (mpModel
== 0) || (mpPage
== 0) )
428 throw lang::DisposedException();
430 return mpPage
&& mpPage
->GetObjCount()>0;
435 void lcl_markSdrObjectOfShape( const Reference
< drawing::XShape
>& _rxShape
, SdrView
& _rView
, SdrPageView
& _rPageView
)
437 SvxShape
* pShape
= SvxShape::getImplementation( _rxShape
);
441 SdrObject
* pObj
= pShape
->GetSdrObject();
445 _rView
.MarkObj( pObj
, &_rPageView
);
449 //----------------------------------------------------------------------
450 // ACHTUNG: _SelectObjectsInView selektiert die ::com::sun::star::drawing::Shapes nur in der angegebennen
451 // SdrPageView. Dies muß nicht die sichtbare SdrPageView sein.
452 //----------------------------------------------------------------------
453 void SvxDrawPage::_SelectObjectsInView( const Reference
< drawing::XShapes
> & aShapes
, SdrPageView
* pPageView
) throw ()
455 DBG_ASSERT(pPageView
,"SdrPageView ist NULL! [CL]");
456 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
458 if(pPageView
!=NULL
&& mpView
!=NULL
)
460 mpView
->UnmarkAllObj( pPageView
);
462 long nCount
= aShapes
->getCount();
463 for( long i
= 0; i
< nCount
; i
++ )
465 uno::Any
aAny( aShapes
->getByIndex(i
) );
466 Reference
< drawing::XShape
> xShape
;
467 if( aAny
>>= xShape
)
468 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
473 //----------------------------------------------------------------------
474 // ACHTUNG: _SelectObjectInView selektiert das Shape *nur* in der angegebennen
475 // SdrPageView. Dies muß nicht die sichtbare SdrPageView sein.
476 //----------------------------------------------------------------------
477 void SvxDrawPage::_SelectObjectInView( const Reference
< drawing::XShape
> & xShape
, SdrPageView
* pPageView
) throw()
479 DBG_ASSERT(pPageView
,"SdrPageView ist NULL! [CL]");
480 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
482 if(pPageView
!=NULL
&& mpView
!= NULL
)
484 mpView
->UnmarkAllObj( pPageView
);
485 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
489 //----------------------------------------------------------------------
490 Reference
< drawing::XShapeGroup
> SAL_CALL
SvxDrawPage::group( const Reference
< drawing::XShapes
>& xShapes
)
491 throw( uno::RuntimeException
)
493 OGuard
aGuard( Application::GetSolarMutex() );
495 if( (mpModel
== 0) || (mpPage
== 0) )
496 throw lang::DisposedException();
498 DBG_ASSERT(mpPage
,"SdrPage ist NULL! [CL]");
499 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
501 Reference
< ::com::sun::star::drawing::XShapeGroup
> xShapeGroup
;
502 if(mpPage
==NULL
||mpView
==NULL
||!xShapes
.is())
505 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
507 _SelectObjectsInView( xShapes
, pPageView
);
509 mpView
->GroupMarked();
511 mpView
->AdjustMarkHdl();
512 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
513 if( rMarkList
.GetMarkCount() == 1 )
515 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
517 xShapeGroup
= Reference
< drawing::XShapeGroup
>::query( pObj
->getUnoShape() );
520 mpView
->HideSdrPage();
523 mpModel
->SetChanged();
528 //----------------------------------------------------------------------
529 void SAL_CALL
SvxDrawPage::ungroup( const Reference
< drawing::XShapeGroup
>& aGroup
)
530 throw( uno::RuntimeException
)
532 OGuard
aGuard( Application::GetSolarMutex() );
534 if( (mpModel
== 0) || (mpPage
== 0) )
535 throw lang::DisposedException();
537 DBG_ASSERT(mpPage
,"SdrPage ist NULL! [CL]");
538 DBG_ASSERT(mpView
, "SdrView ist NULL! [CL]");
540 if(mpPage
==NULL
||mpView
==NULL
||!aGroup
.is())
543 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
545 Reference
< drawing::XShape
> xShape( aGroup
, UNO_QUERY
);
546 _SelectObjectInView( xShape
, pPageView
);
547 mpView
->UnGroupMarked();
549 mpView
->HideSdrPage();
552 mpModel
->SetChanged();
555 //----------------------------------------------------------------------
556 SdrObject
*SvxDrawPage::_CreateSdrObject( const Reference
< drawing::XShape
> & xShape
) throw()
559 sal_uInt32 nInventor
;
561 GetTypeAndInventor( nType
, nInventor
, xShape
->getShapeType() );
562 SdrObject
* pNewObj
= 0;
566 awt::Size aSize
= xShape
->getSize();
569 awt::Point aPos
= xShape
->getPosition();
570 Rectangle
aRect( Point( aPos
.X
, aPos
.Y
), Size( aSize
.Width
, aSize
.Height
) );
573 if( nInventor
== SdrInventor
)
579 pNewObj
= new SdrMeasureObj( aRect
.TopLeft(), aRect
.BottomRight() );
584 basegfx::B2DPolygon aPoly
;
585 aPoly
.append(basegfx::B2DPoint(aRect
.Left(), aRect
.Top()));
586 aPoly
.append(basegfx::B2DPoint(aRect
.Right(), aRect
.Bottom()));
587 pNewObj
= new SdrPathObj(OBJ_LINE
, basegfx::B2DPolyPolygon(aPoly
));
593 if( pNewObj
== NULL
)
594 pNewObj
= SdrObjFactory::MakeNewObject( nInventor
, nType
, mpPage
);
598 pNewObj
->SetSnapRect(aRect
);
600 if( pNewObj
->ISA(E3dPolyScene
))
602 // Szene initialisieren
603 E3dScene
* pScene
= (E3dScene
*)pNewObj
;
605 double fW
= (double)aSize
.Width
;
606 double fH
= (double)aSize
.Height
;
608 Camera3D
aCam(pScene
->GetCamera());
609 aCam
.SetAutoAdjustProjection(sal_False
);
610 aCam
.SetViewWindow(- fW
/ 2, - fH
/ 2, fW
, fH
);
611 basegfx::B3DPoint aLookAt
;
612 basegfx::B3DPoint
aCamPos(0.0, 0.0, 10000.0);
613 aCam
.SetPosAndLookAt(aCamPos
, aLookAt
);
614 aCam
.SetFocalLength(100.0);
615 aCam
.SetDefaults(aCamPos
, aLookAt
, 10000.0);
616 pScene
->SetCamera(aCam
);
618 pScene
->SetRectsDirty();
620 else if(pNewObj
->ISA(E3dExtrudeObj
))
622 E3dExtrudeObj
* pObj
= (E3dExtrudeObj
*)pNewObj
;
623 basegfx::B2DPolygon aNewPolygon
;
624 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
625 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
626 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
627 aNewPolygon
.setClosed(true);
628 pObj
->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon
));
630 // #107245# pObj->SetExtrudeCharacterMode(TRUE);
631 pObj
->SetMergedItem(Svx3DCharacterModeItem(sal_True
));
633 else if(pNewObj
->ISA(E3dLatheObj
))
635 E3dLatheObj
* pObj
= (E3dLatheObj
*)pNewObj
;
636 basegfx::B2DPolygon aNewPolygon
;
637 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
638 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
639 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
640 aNewPolygon
.setClosed(true);
641 pObj
->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon
));
643 // #107245# pObj->SetLatheCharacterMode(TRUE);
644 pObj
->SetMergedItem(Svx3DCharacterModeItem(sal_True
));
652 //----------------------------------------------------------------------
653 void SvxDrawPage::GetTypeAndInventor( sal_uInt16
& rType
, sal_uInt32
& rInventor
, const OUString
& aName
) const throw()
655 sal_uInt32 nTempType
= aSdrShapeIdentifierMap
.getId( aName
);
657 if( nTempType
== UHASHMAP_NOTFOUND
)
659 if( aName
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) )
661 rInventor
= SdrInventor
;
665 else if(nTempType
& E3D_INVENTOR_FLAG
)
667 rInventor
= E3dInventor
;
668 rType
= (sal_uInt16
)(nTempType
& ~E3D_INVENTOR_FLAG
);
672 rInventor
= SdrInventor
;
673 rType
= (sal_uInt16
)nTempType
;
678 case OBJ_OLE2_PLUGIN
:
679 case OBJ_OLE2_APPLET
:
686 //----------------------------------------------------------------------
687 SvxShape
* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType
, sal_uInt32 nInventor
, SdrObject
*pObj
, SvxDrawPage
*mpPage
) throw()
689 SvxShape
* pRet
= NULL
;
697 case E3D_POLYSCENE_ID
:
698 pRet
= new Svx3DSceneObject( pObj
, mpPage
);
700 case E3D_CUBEOBJ_ID
:
701 pRet
= new Svx3DCubeObject( pObj
);
703 case E3D_SPHEREOBJ_ID
:
704 pRet
= new Svx3DSphereObject( pObj
);
706 case E3D_LATHEOBJ_ID
:
707 pRet
= new Svx3DLatheObject( pObj
);
709 case E3D_EXTRUDEOBJ_ID
:
710 pRet
= new Svx3DExtrudeObject( pObj
);
712 case E3D_POLYGONOBJ_ID
:
713 pRet
= new Svx3DPolygonObject( pObj
);
715 default: // unbekanntes 3D-Objekt auf der Page
716 pRet
= new SvxShape( pObj
);
728 pRet
= new SvxShapeGroup( pObj
, mpPage
);
731 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_LINE
);
734 pRet
= new SvxShapeRect( pObj
);
740 pRet
= new SvxShapeCircle( pObj
);
743 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_POLY
);
746 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PLIN
);
750 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_PATHLINE
);
754 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_PATHFILL
);
757 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_FREELINE
);
760 pRet
= new SvxShapePolyPolygonBezier( pObj
, PolygonKind_FREEFILL
);
763 pRet
= new SvxShapeCaption( pObj
);
766 case OBJ_OUTLINETEXT
:
768 pRet
= new SvxShapeText( pObj
);
771 pRet
= new SvxGraphicObject( pObj
);
774 pRet
= new SvxFrameShape( pObj
);
776 case OBJ_OLE2_APPLET
:
777 pRet
= new SvxAppletShape( pObj
);
779 case OBJ_OLE2_PLUGIN
:
780 pRet
= new SvxPluginShape( pObj
);
784 if( pObj
&& !pObj
->IsEmptyPresObj() && mpPage
)
786 SdrPage
* pSdrPage
= mpPage
->GetSdrPage();
789 SdrModel
* pSdrModel
= pSdrPage
->GetModel();
792 ::comphelper::IEmbeddedHelper
*pPersist
= pSdrModel
->GetPersist();
795 uno::Reference
< embed::XEmbeddedObject
> xObject
= pPersist
->getEmbeddedObjectContainer().
796 GetEmbeddedObject( static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() );
798 // TODO CL->KA: Why is this not working anymore?
801 SvGlobalName
aClassId( xObject
->getClassID() );
803 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
804 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
805 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
807 if( aPluginClassId
== aClassId
)
809 pRet
= new SvxPluginShape( pObj
);
810 nType
= OBJ_OLE2_PLUGIN
;
812 else if( aAppletClassId
== aClassId
)
814 pRet
= new SvxAppletShape( pObj
);
815 nType
= OBJ_OLE2_APPLET
;
817 else if( aIFrameClassId
== aClassId
)
819 pRet
= new SvxFrameShape( pObj
);
829 pRet
= new SvxOle2Shape( pObj
, aSvxMapProvider
.GetMap(SVXMAP_OLE2
), aSvxMapProvider
.GetPropertySet(SVXMAP_OLE2
) );
834 pRet
= new SvxShapeConnector( pObj
);
837 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PATHPOLY
);
840 pRet
= new SvxShapePolyPolygon( pObj
, PolygonKind_PATHPLIN
);
843 pRet
= new SvxShape( pObj
, aSvxMapProvider
.GetMap(SVXMAP_PAGE
), aSvxMapProvider
.GetPropertySet(SVXMAP_PAGE
) );
846 pRet
= new SvxShapeDimensioning( pObj
);
851 pRet
= new SvxShapeControl( pObj
);
853 case OBJ_CUSTOMSHAPE
:
854 pRet
= new SvxCustomShape( pObj
);
857 pRet
= new SvxMediaShape( pObj
);
860 pRet
= new SvxTableShape( pObj
);
862 default: // unbekanntes 2D-Objekt auf der Page
863 DBG_ERROR("Nicht implementierter Starone-Shape erzeugt! [CL]");
864 pRet
= new SvxShapeText( pObj
);
869 default: // Unbekannter Inventor
871 DBG_ERROR("AW: Unknown Inventor in SvxDrawPage::_CreateShape()");
878 sal_uInt32 nObjId
= nType
;
880 if( nInventor
== E3dInventor
)
881 nObjId
|= E3D_INVENTOR_FLAG
;
885 case OBJ_CCUT
: // Kreisabschnitt
886 case OBJ_CARC
: // Kreisbogen
887 case OBJ_SECT
: // Kreissektor
891 case E3D_SCENE_ID
| E3D_INVENTOR_FLAG
:
892 nObjId
= E3D_POLYSCENE_ID
| E3D_INVENTOR_FLAG
;
896 case OBJ_OUTLINETEXT
:
901 pRet
->setShapeKind(nObjId
);
907 //----------------------------------------------------------------------
908 Reference
< drawing::XShape
> SvxDrawPage::_CreateShape( SdrObject
*pObj
) const throw()
910 Reference
< drawing::XShape
> xShape( CreateShapeByTypeAndInventor(pObj
->GetObjIdentifier(),
911 pObj
->GetObjInventor(),
913 (SvxDrawPage
*)this));
917 //----------------------------------------------------------------------
918 SdrObject
*SvxDrawPage::CreateSdrObject( const Reference
< drawing::XShape
> & xShape
) throw()
920 SdrObject
* pObj
= _CreateSdrObject( xShape
);
921 if( pObj
&& !pObj
->IsInserted() )
922 mpPage
->InsertObject( pObj
);
927 //----------------------------------------------------------------------
928 // ::com::sun::star::lang::XServiceInfo
929 //----------------------------------------------------------------------
930 OUString SAL_CALL
SvxDrawPage::getImplementationName() throw( uno::RuntimeException
)
932 return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxDrawPage"));
935 sal_Bool SAL_CALL
SvxDrawPage::supportsService( const OUString
& ServiceName
)
936 throw(::com::sun::star::uno::RuntimeException
)
938 return SvxServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
941 uno::Sequence
< OUString
> SAL_CALL
SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException
)
943 uno::Sequence
< OUString
> aSeq( 1 );
944 aSeq
.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ShapeCollection" ));
948 SvxShape
* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType
, sal_uInt32 nInventor
) throw()
950 return SvxDrawPage::CreateShapeByTypeAndInventor( nType
, nInventor
);
953 void SvxDrawPage::ChangeModel( SdrModel
* pNewModel
)
955 if( pNewModel
!= mpModel
)
958 EndListening( *mpModel
);
961 StartListening( *pNewModel
);
968 mpView
= new SdrView( mpModel
);
970 mpView
->SetDesignMode(sal_True
);
975 /** returns a StarOffice API wrapper for the given SdrPage */
976 uno::Reference
< drawing::XDrawPage
> GetXDrawPageForSdrPage( SdrPage
* pPage
) throw ()
980 uno::Reference
< drawing::XDrawPage
> xDrawPage( pPage
->getUnoPage(), uno::UNO_QUERY
);
985 return uno::Reference
< drawing::XDrawPage
>();
988 /** returns the SdrObject from the given StarOffice API wrapper */
989 SdrPage
* GetSdrPageFromXDrawPage( uno::Reference
< drawing::XDrawPage
> xDrawPage
) throw()
993 SvxDrawPage
* pDrawPage
= SvxDrawPage::getImplementation( xDrawPage
);
997 return pDrawPage
->GetSdrPage();