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/embed/XEmbeddedObject.hpp>
24 #include <com/sun/star/lang/DisposedException.hpp>
25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 #include <o3tl/safeint.hxx>
27 #include <osl/mutex.hxx>
28 #include <comphelper/classids.hxx>
29 #include <comphelper/embeddedobjectcontainer.hxx>
30 #include <comphelper/sequence.hxx>
31 #include <cppuhelper/supportsservice.hxx>
33 #include <svx/svdpool.hxx>
34 #include <svx/svdobj.hxx>
35 #include <svx/svdoole2.hxx>
36 #include <svx/svdpage.hxx>
37 #include <svx/svdmodel.hxx>
38 #include <svx/strings.hrc>
39 #include <svx/svdview.hxx>
40 #include <svx/svdpagv.hxx>
41 #include <svx/svdundo.hxx>
42 #include <svx/unopage.hxx>
43 #include "shapeimpl.hxx"
44 #include <svx/dialmgr.hxx>
45 #include <svx/svdobjkind.hxx>
46 #include <svx/unoprov.hxx>
47 #include <svx/unoapi.hxx>
48 #include <extrud3d.hxx>
49 #include <svx/lathe3d.hxx>
50 #include <svx/scene3d.hxx>
51 #include <vcl/svapp.hxx>
52 #include <tools/diagnose_ex.h>
53 #include <tools/globname.hxx>
54 #include <sal/log.hxx>
56 using namespace ::cppu
;
57 using namespace ::com::sun::star
;
58 using namespace ::com::sun::star::uno
;
59 using namespace ::com::sun::star::lang
;
60 using namespace ::com::sun::star::container
;
61 using namespace ::com::sun::star::drawing
;
63 UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage
);
65 SvxDrawPage::SvxDrawPage(SdrPage
* pInPage
) // TTTT should be reference
68 ,mpModel(&pInPage
->getSdrModelFromSdrPage()) // register at broadcaster
69 ,mpView(new SdrView(pInPage
->getSdrModelFromSdrPage())) // create (hidden) view
71 mpView
->SetDesignMode();
74 SvxDrawPage::~SvxDrawPage() noexcept
76 if( !mrBHelper
.bDisposed
)
78 assert(!"SvxDrawPage must be disposed!");
85 void SvxDrawPage::release() noexcept
87 OWeakAggObject::release();
91 void SvxDrawPage::disposing() noexcept
103 void SvxDrawPage::dispose()
105 SolarMutexGuard aSolarGuard
;
107 // An frequently programming error is to release the last
108 // reference to this object in the disposing message.
109 // Make it robust, hold a self Reference.
110 uno::Reference
< lang::XComponent
> xSelf( this );
112 // Guard dispose against multiple threading
113 // Remark: It is an error to call dispose more than once
114 bool bDoDispose
= false;
116 osl::MutexGuard
aGuard( mrBHelper
.rMutex
);
117 if( !mrBHelper
.bDisposed
&& !mrBHelper
.bInDispose
)
119 // only one call go into this section
120 mrBHelper
.bInDispose
= true;
125 // Do not hold the mutex because we are broadcasting
129 // Create an event with this as sender
132 uno::Reference
< uno::XInterface
> xSource( uno::Reference
< uno::XInterface
>::query( static_cast<lang::XComponent
*>(this) ) );
133 css::document::EventObject aEvt
;
134 aEvt
.Source
= xSource
;
135 // inform all listeners to release this object
136 // The listener container are automatically cleared
137 mrBHelper
.aLC
.disposeAndClear( aEvt
);
138 // notify subclasses to do their dispose
141 catch(const css::uno::Exception
&)
143 // catch exception and throw again but signal that
144 // the object was disposed. Dispose should be called
146 osl::MutexGuard
aGuard( mrBHelper
.rMutex
);
147 mrBHelper
.bDisposed
= true;
148 mrBHelper
.bInDispose
= false;
152 osl::MutexGuard
aGuard( mrBHelper
.rMutex
);
153 mrBHelper
.bDisposed
= true;
154 mrBHelper
.bInDispose
= false;
158 void SAL_CALL
SvxDrawPage::addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
)
160 SolarMutexGuard aGuard
;
162 if( mpModel
== nullptr )
163 throw lang::DisposedException();
165 mrBHelper
.addListener( cppu::UnoType
<decltype(aListener
)>::get() , aListener
);
168 void SAL_CALL
SvxDrawPage::removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
)
170 SolarMutexGuard aGuard
;
172 if( mpModel
== nullptr )
173 throw lang::DisposedException();
175 mrBHelper
.removeListener( cppu::UnoType
<decltype(aListener
)>::get() , aListener
);
178 void SAL_CALL
SvxDrawPage::add( const uno::Reference
< drawing::XShape
>& xShape
)
180 SolarMutexGuard aGuard
;
182 if ( ( mpModel
== nullptr ) || ( mpPage
== nullptr ) )
183 throw lang::DisposedException();
185 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xShape
);
187 if( nullptr == pShape
)
190 SdrObject
*pObj
= pShape
->GetSdrObject();
191 bool bNeededToClone(false);
193 if(nullptr != pObj
&& &pObj
->getSdrModelFromSdrObject() != &mpPage
->getSdrModelFromSdrPage())
195 // TTTT UNO API tries to add an existing SvxShape to this SvxDrawPage,
196 // but these use different SdrModels. It was possible before to completely
197 // 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
198 // stuff), but is no longer. We need to Clone the SdrObject to the target model
199 // and ::Create a new SvxShape (set SdrObject there, take obver values, ...)
200 SdrObject
* pClonedSdrShape(pObj
->CloneSdrObject(mpPage
->getSdrModelFromSdrPage()));
201 pObj
->setUnoShape(nullptr);
202 pClonedSdrShape
->setUnoShape(xShape
);
203 // pShape->InvalidateSdrObject();
204 // pShape->Create(pClonedSdrShape, this);
205 SdrObject::Free(pObj
);
206 pObj
= pClonedSdrShape
;
207 bNeededToClone
= true;
212 pObj
= CreateSdrObject( xShape
);
213 ENSURE_OR_RETURN_VOID( pObj
!= nullptr, "SvxDrawPage::add: no SdrObject was created!" );
215 else if ( !pObj
->IsInserted() )
217 mpPage
->InsertObject( pObj
);
221 // TTTT Unfortunately in SdrObject::SetPage (see there) the
222 // xShape/UnoShape at the newly cloned SDrObject is *removed* again,
223 // so re-set it here, the caller *may need it* (e.g. Writer)
224 uno::Reference
< uno::XInterface
> xShapeCheck(pObj
->getWeakUnoShape());
226 if( !xShapeCheck
.is() )
228 pObj
->setUnoShape(xShape
);
233 pShape
->Create( pObj
, this );
234 OSL_ENSURE( pShape
->GetSdrObject() == pObj
, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
236 if ( !pObj
->IsInserted() )
238 mpPage
->InsertObject( pObj
);
241 mpModel
->SetChanged();
244 void SAL_CALL
SvxDrawPage::addTop( const uno::Reference
< drawing::XShape
>& xShape
)
249 void SAL_CALL
SvxDrawPage::addBottom( const uno::Reference
< drawing::XShape
>& xShape
)
251 SolarMutexGuard aGuard
;
253 if ( ( mpModel
== nullptr ) || ( mpPage
== nullptr ) )
254 throw lang::DisposedException();
256 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xShape
);
258 if( nullptr == pShape
)
261 SdrObject
*pObj
= pShape
->GetSdrObject();
265 pObj
= CreateSdrObject( xShape
, true );
266 ENSURE_OR_RETURN_VOID( pObj
!= nullptr, "SvxDrawPage::add: no SdrObject was created!" );
268 else if ( !pObj
->IsInserted() )
270 mpPage
->InsertObject( pObj
, 0 );
273 pShape
->Create( pObj
, this );
274 OSL_ENSURE( pShape
->GetSdrObject() == pObj
, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
276 if ( !pObj
->IsInserted() )
278 mpPage
->InsertObject( pObj
, 0 );
281 mpModel
->SetChanged();
284 void SAL_CALL
SvxDrawPage::remove( const Reference
< drawing::XShape
>& xShape
)
286 SolarMutexGuard aGuard
;
288 if( (mpModel
== nullptr) || (mpPage
== nullptr) )
289 throw lang::DisposedException();
291 SdrObject
* pObj
= SdrObject::getSdrObjectFromXShape( xShape
);
295 // remove SdrObject from page
296 const size_t nCount
= mpPage
->GetObjCount();
297 for( size_t nNum
= 0; nNum
< nCount
; ++nNum
)
299 if(mpPage
->GetObj(nNum
) == pObj
)
301 const bool bUndoEnabled
= mpModel
->IsUndoEnabled();
305 mpModel
->BegUndo(SvxResId(STR_EditDelete
),
306 pObj
->TakeObjNameSingul(), SdrRepeatFunc::Delete
);
308 mpModel
->AddUndo(mpModel
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj
));
311 OSL_VERIFY( mpPage
->RemoveObject( nNum
) == pObj
);
314 SdrObject::Free(pObj
);
323 mpModel
->SetChanged();
326 void SvxDrawPage::sort( const css::uno::Sequence
< sal_Int32
>& sortOrder
)
328 SolarMutexGuard aGuard
;
330 if ((mpModel
== nullptr) || (mpPage
== nullptr))
331 throw lang::DisposedException();
333 auto newOrder
= comphelper::sequenceToContainer
<std::vector
<sal_Int32
>>(sortOrder
);
334 mpPage
->sort(newOrder
);
337 // css::container::XIndexAccess
338 sal_Int32 SAL_CALL
SvxDrawPage::getCount()
340 SolarMutexGuard aGuard
;
342 if( (mpModel
== nullptr) || (mpPage
== nullptr) )
343 throw lang::DisposedException();
345 return static_cast<sal_Int32
>( mpPage
->GetObjCount() );
348 uno::Any SAL_CALL
SvxDrawPage::getByIndex( sal_Int32 Index
)
350 SolarMutexGuard aGuard
;
352 if( (mpModel
== nullptr) || (mpPage
== nullptr) )
353 throw lang::DisposedException("Model or Page was already disposed!");
355 if ( Index
< 0 || o3tl::make_unsigned(Index
) >= mpPage
->GetObjCount() )
356 throw lang::IndexOutOfBoundsException("Index (" + OUString::number(Index
)
357 + ") needs to be a positive integer smaller than the shape count ("
358 + OUString::number(mpPage
->GetObjCount()) + ")!");
360 SdrObject
* pObj
= mpPage
->GetObj( Index
);
361 if( pObj
== nullptr )
362 throw uno::RuntimeException("Runtime exception thrown while getting a ref to the SdrObject at index: "
363 + OUString::number(Index
));
366 return makeAny(Reference
< drawing::XShape
>( pObj
->getUnoShape(), uno::UNO_QUERY
));
369 // css::container::XElementAccess
370 uno::Type SAL_CALL
SvxDrawPage::getElementType()
372 return cppu::UnoType
<drawing::XShape
>::get();
375 sal_Bool SAL_CALL
SvxDrawPage::hasElements()
377 SolarMutexGuard aGuard
;
379 if( (mpModel
== nullptr) || (mpPage
== nullptr) )
380 throw lang::DisposedException();
382 return mpPage
&& mpPage
->GetObjCount()>0;
387 void lcl_markSdrObjectOfShape( const Reference
< drawing::XShape
>& _rxShape
, SdrView
& _rView
, SdrPageView
& _rPageView
)
389 SdrObject
* pObj
= SdrObject::getSdrObjectFromXShape( _rxShape
);
393 _rView
.MarkObj( pObj
, &_rPageView
);
397 // ATTENTION: SelectObjectsInView selects the css::drawing::Shapes
398 // only in the given SdrPageView. It hasn't to be the visible SdrPageView.
399 void SvxDrawPage::SelectObjectsInView( const Reference
< drawing::XShapes
> & aShapes
, SdrPageView
* pPageView
) noexcept
401 SAL_WARN_IF(!pPageView
, "svx", "SdrPageView is NULL!");
402 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
404 if(pPageView
==nullptr || mpView
==nullptr)
407 mpView
->UnmarkAllObj( pPageView
);
409 tools::Long nCount
= aShapes
->getCount();
410 for( tools::Long i
= 0; i
< nCount
; i
++ )
412 uno::Any
aAny( aShapes
->getByIndex(i
) );
413 Reference
< drawing::XShape
> xShape
;
414 if( aAny
>>= xShape
)
415 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
419 // ATTENTION: SelectObjectInView selects the shape only in the given SdrPageView.
420 // It hasn't to be the visible SdrPageView.
421 void SvxDrawPage::SelectObjectInView( const Reference
< drawing::XShape
> & xShape
, SdrPageView
* pPageView
) noexcept
423 SAL_WARN_IF(!pPageView
, "svx", "SdrPageView is NULL!");
424 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
426 if(pPageView
!=nullptr && mpView
!= nullptr)
428 mpView
->UnmarkAllObj( pPageView
);
429 lcl_markSdrObjectOfShape( xShape
, *mpView
, *pPageView
);
433 Reference
< drawing::XShapeGroup
> SAL_CALL
SvxDrawPage::group( const Reference
< drawing::XShapes
>& xShapes
)
435 SolarMutexGuard aGuard
;
437 if( (mpModel
== nullptr) || (mpPage
== nullptr) )
438 throw lang::DisposedException();
440 SAL_WARN_IF(!mpPage
, "svx", "SdrPage is NULL!");
441 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
443 Reference
< css::drawing::XShapeGroup
> xShapeGroup
;
444 if(mpPage
==nullptr||mpView
==nullptr||!xShapes
.is())
447 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
449 SelectObjectsInView( xShapes
, pPageView
);
451 mpView
->GroupMarked();
453 mpView
->AdjustMarkHdl();
454 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
455 if( rMarkList
.GetMarkCount() == 1 )
457 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
459 xShapeGroup
.set( pObj
->getUnoShape(), UNO_QUERY
);
462 mpView
->HideSdrPage();
465 mpModel
->SetChanged();
470 void SAL_CALL
SvxDrawPage::ungroup( const Reference
< drawing::XShapeGroup
>& aGroup
)
472 SolarMutexGuard aGuard
;
474 if( (mpModel
== nullptr) || (mpPage
== nullptr) )
475 throw lang::DisposedException();
477 SAL_WARN_IF(!mpPage
, "svx", "SdrPage is NULL!");
478 SAL_WARN_IF(!mpView
, "svx", "SdrView is NULL!");
480 if(mpPage
==nullptr||mpView
==nullptr||!aGroup
.is())
483 SdrPageView
* pPageView
= mpView
->ShowSdrPage( mpPage
);
485 SelectObjectInView( aGroup
, pPageView
);
486 mpView
->UnGroupMarked();
488 mpView
->HideSdrPage();
491 mpModel
->SetChanged();
494 SdrObject
* SvxDrawPage::CreateSdrObject_(const Reference
< drawing::XShape
> & xShape
)
496 SdrObjKind nType
= OBJ_NONE
;
497 SdrInventor nInventor
;
499 GetTypeAndInventor( nType
, nInventor
, xShape
->getShapeType() );
503 awt::Size aSize
= xShape
->getSize();
506 awt::Point aPos
= xShape
->getPosition();
507 tools::Rectangle
aRect( Point( aPos
.X
, aPos
.Y
), Size( aSize
.Width
, aSize
.Height
) );
509 SdrObject
* pNewObj
= SdrObjFactory::MakeNewObject(
518 if( auto pScene
= dynamic_cast<E3dScene
* >(pNewObj
) )
522 double fW
= static_cast<double>(aSize
.Width
);
523 double fH
= static_cast<double>(aSize
.Height
);
525 Camera3D
aCam(pScene
->GetCamera());
526 aCam
.SetAutoAdjustProjection(false);
527 aCam
.SetViewWindow(- fW
/ 2, - fH
/ 2, fW
, fH
);
528 basegfx::B3DPoint aLookAt
;
529 basegfx::B3DPoint
aCamPos(0.0, 0.0, 10000.0);
530 aCam
.SetPosAndLookAt(aCamPos
, aLookAt
);
531 aCam
.SetFocalLength(100.0);
532 pScene
->SetCamera(aCam
);
534 pScene
->SetRectsDirty();
536 else if(auto pObj
= dynamic_cast<E3dExtrudeObj
* >(pNewObj
))
538 basegfx::B2DPolygon aNewPolygon
;
539 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
540 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
541 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
542 aNewPolygon
.setClosed(true);
543 pObj
->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon
));
545 // #107245# pObj->SetExtrudeCharacterMode(sal_True);
546 pObj
->SetMergedItem(Svx3DCharacterModeItem(true));
548 else if(auto pLatheObj
= dynamic_cast<E3dLatheObj
* >(pNewObj
))
550 basegfx::B2DPolygon aNewPolygon
;
551 aNewPolygon
.append(basegfx::B2DPoint(0.0, 0.0));
552 aNewPolygon
.append(basegfx::B2DPoint(0.0, 1.0));
553 aNewPolygon
.append(basegfx::B2DPoint(1.0, 0.0));
554 aNewPolygon
.setClosed(true);
555 pLatheObj
->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon
));
557 // #107245# pObj->SetLatheCharacterMode(sal_True);
558 pLatheObj
->SetMergedItem(Svx3DCharacterModeItem(true));
564 void SvxDrawPage::GetTypeAndInventor( SdrObjKind
& rType
, SdrInventor
& rInventor
, const OUString
& aName
) noexcept
566 sal_uInt32 nTempType
= UHashMap::getId( aName
);
568 if( nTempType
== UHASHMAP_NOTFOUND
)
570 if( aName
== "com.sun.star.drawing.TableShape" ||
571 aName
== "com.sun.star.presentation.TableShape" )
573 rInventor
= SdrInventor::Default
;
576 #if HAVE_FEATURE_AVMEDIA
577 else if ( aName
== "com.sun.star.presentation.MediaShape" )
579 rInventor
= SdrInventor::Default
;
584 else if(nTempType
& E3D_INVENTOR_FLAG
)
586 rInventor
= SdrInventor::E3d
;
587 rType
= static_cast<SdrObjKind
>(nTempType
& ~E3D_INVENTOR_FLAG
);
591 rInventor
= SdrInventor::Default
;
592 rType
= static_cast<SdrObjKind
>(nTempType
);
597 case OBJ_OLE2_PLUGIN
:
598 case OBJ_OLE2_APPLET
:
607 rtl::Reference
<SvxShape
> SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType
, SdrInventor nInventor
, SdrObject
*pObj
, SvxDrawPage
*mpPage
, OUString
const & referer
)
609 rtl::Reference
<SvxShape
> pRet
;
613 case SdrInventor::E3d
:
618 pRet
= new Svx3DSceneObject( pObj
, mpPage
);
620 case E3D_CUBEOBJ_ID
:
621 pRet
= new Svx3DCubeObject( pObj
);
623 case E3D_SPHEREOBJ_ID
:
624 pRet
= new Svx3DSphereObject( pObj
);
626 case E3D_LATHEOBJ_ID
:
627 pRet
= new Svx3DLatheObject( pObj
);
629 case E3D_EXTRUDEOBJ_ID
:
630 pRet
= new Svx3DExtrudeObject( pObj
);
632 case E3D_POLYGONOBJ_ID
:
633 pRet
= new Svx3DPolygonObject( pObj
);
635 default: // unknown 3D-object on page
636 pRet
= new SvxShape( pObj
);
641 case SdrInventor::Default
:
646 pRet
= new SvxShapeGroup( pObj
, mpPage
);
649 pRet
= new SvxShapePolyPolygon( pObj
);
652 pRet
= new SvxShapeRect( pObj
);
658 pRet
= new SvxShapeCircle( pObj
);
661 pRet
= new SvxShapePolyPolygon( pObj
);
664 pRet
= new SvxShapePolyPolygon( pObj
);
668 pRet
= new SvxShapePolyPolygon( pObj
);
672 pRet
= new SvxShapePolyPolygon( pObj
);
675 pRet
= new SvxShapePolyPolygon( pObj
);
678 pRet
= new SvxShapePolyPolygon( pObj
);
681 pRet
= new SvxShapeCaption( pObj
);
684 case OBJ_OUTLINETEXT
:
686 pRet
= new SvxShapeText( pObj
);
689 pRet
= new SvxGraphicObject( pObj
);
692 pRet
= new SvxFrameShape( pObj
);
694 case OBJ_OLE2_APPLET
:
695 pRet
= new SvxAppletShape( pObj
);
697 case OBJ_OLE2_PLUGIN
:
698 pRet
= new SvxPluginShape( pObj
);
702 if( pObj
&& !pObj
->IsEmptyPresObj() && mpPage
)
704 SdrPage
* pSdrPage
= mpPage
->GetSdrPage();
707 SdrModel
& rSdrModel(pSdrPage
->getSdrModelFromSdrPage());
708 ::comphelper::IEmbeddedHelper
*pPersist
= rSdrModel
.GetPersist();
712 uno::Reference
< embed::XEmbeddedObject
> xObject
= pPersist
->getEmbeddedObjectContainer().
713 GetEmbeddedObject( static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() );
715 // TODO CL->KA: Why is this not working anymore?
718 SvGlobalName
aClassId( xObject
->getClassID() );
720 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
721 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
722 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
724 if( aPluginClassId
== aClassId
)
726 pRet
= new SvxPluginShape( pObj
);
727 nType
= OBJ_OLE2_PLUGIN
;
729 else if( aAppletClassId
== aClassId
)
731 pRet
= new SvxAppletShape( pObj
);
732 nType
= OBJ_OLE2_APPLET
;
734 else if( aIFrameClassId
== aClassId
)
736 pRet
= new SvxFrameShape( pObj
);
743 if( pRet
== nullptr )
745 SvxUnoPropertyMapProvider
& rSvxMapProvider
= getSvxMapProvider();
746 pRet
= new SvxOle2Shape( pObj
, rSvxMapProvider
.GetMap(SVXMAP_OLE2
), rSvxMapProvider
.GetPropertySet(SVXMAP_OLE2
, SdrObject::GetGlobalDrawObjectItemPool()) );
751 pRet
= new SvxShapeConnector( pObj
);
754 pRet
= new SvxShapePolyPolygon( pObj
);
757 pRet
= new SvxShapePolyPolygon( pObj
);
761 SvxUnoPropertyMapProvider
& rSvxMapProvider
= getSvxMapProvider();
762 pRet
= new SvxShape( pObj
, rSvxMapProvider
.GetMap(SVXMAP_PAGE
), rSvxMapProvider
.GetPropertySet(SVXMAP_PAGE
, SdrObject::GetGlobalDrawObjectItemPool()) );
766 pRet
= new SvxShapeDimensioning( pObj
);
769 pRet
= new SvxShapeControl( pObj
);
771 case OBJ_CUSTOMSHAPE
:
772 pRet
= new SvxCustomShape( pObj
);
775 pRet
= new SvxMediaShape( pObj
, referer
);
778 pRet
= new SvxTableShape( pObj
);
780 default: // unknown 2D-object on page
781 assert(false && "Not implemented Starone-Shape created");
782 pRet
= new SvxShapeText( pObj
);
787 default: // unknown inventor
789 assert(false && "Unknown Inventor in SvxDrawPage::CreateShape()");
796 sal_uInt32 nObjId
= nType
;
798 if( nInventor
== SdrInventor::E3d
)
799 nObjId
|= E3D_INVENTOR_FLAG
;
803 case OBJ_CCUT
: // segment of circle
804 case OBJ_CARC
: // arc of circle
805 case OBJ_SECT
: // sector
810 case OBJ_OUTLINETEXT
:
815 pRet
->setShapeKind(nObjId
);
821 Reference
< drawing::XShape
> SvxDrawPage::CreateShape( SdrObject
*pObj
) const
823 Reference
< drawing::XShape
> xShape( CreateShapeByTypeAndInventor(pObj
->GetObjIdentifier(),
824 pObj
->GetObjInventor(),
826 const_cast<SvxDrawPage
*>(this)));
830 SdrObject
*SvxDrawPage::CreateSdrObject( const Reference
< drawing::XShape
> & xShape
, bool bBeginning
) noexcept
832 SdrObject
* pObj
= CreateSdrObject_( xShape
);
835 if ( !pObj
->IsInserted() && !pObj
->IsDoNotInsertIntoPageAutomatically() )
838 mpPage
->InsertObject( pObj
, 0 );
840 mpPage
->InsertObject( pObj
);
847 // css::lang::XServiceInfo
848 OUString SAL_CALL
SvxDrawPage::getImplementationName()
850 return "SvxDrawPage";
853 sal_Bool SAL_CALL
SvxDrawPage::supportsService( const OUString
& ServiceName
)
855 return cppu::supportsService( this, ServiceName
);
858 uno::Sequence
< OUString
> SAL_CALL
SvxDrawPage::getSupportedServiceNames()
860 uno::Sequence
<OUString
> aSeq
{ "com.sun.star.drawing.ShapeCollection" };
864 rtl::Reference
<SvxShape
> CreateSvxShapeByTypeAndInventor(sal_uInt16 nType
, SdrInventor nInventor
, OUString
const & referer
)
866 return SvxDrawPage::CreateShapeByTypeAndInventor( nType
, nInventor
, nullptr, nullptr, referer
);
869 /** returns a StarOffice API wrapper for the given SdrPage */
870 uno::Reference
< drawing::XDrawPage
> GetXDrawPageForSdrPage( SdrPage
* pPage
) noexcept
874 uno::Reference
< drawing::XDrawPage
> xDrawPage( pPage
->getUnoPage(), uno::UNO_QUERY
);
879 return uno::Reference
< drawing::XDrawPage
>();
882 /** returns the SdrObject from the given StarOffice API wrapper */
883 SdrPage
* GetSdrPageFromXDrawPage( const uno::Reference
< drawing::XDrawPage
>& xDrawPage
) noexcept
887 SvxDrawPage
* pDrawPage
= comphelper::getUnoTunnelImplementation
<SvxDrawPage
>( xDrawPage
);
891 return pDrawPage
->GetSdrPage();
898 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */