LibreOffice Module svx (master) 1
unopage.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <config_features.h>
21
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>
32
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"
45#include <svx/dialmgr.hxx>
46#include <svx/svdobjkind.hxx>
47#include <svx/unoprov.hxx>
48#include <svx/unoapi.hxx>
49#include <extrud3d.hxx>
50#include <svx/lathe3d.hxx>
51#include <svx/scene3d.hxx>
52#include <vcl/svapp.hxx>
54#include <tools/globname.hxx>
55#include <sal/log.hxx>
56
57using namespace ::cppu;
58using namespace ::com::sun::star;
59using namespace ::com::sun::star::uno;
60using namespace ::com::sun::star::lang;
61using namespace ::com::sun::star::container;
62using namespace ::com::sun::star::drawing;
63
65
66SvxDrawPage::SvxDrawPage(SdrPage* pInPage) // TTTT should be reference
67: mrBHelper(m_aMutex)
68 ,mpPage(pInPage)
69 ,mpModel(&pInPage->getSdrModelFromSdrPage()) // register at broadcaster
70 ,mpView(new SdrView(pInPage->getSdrModelFromSdrPage())) // create (hidden) view
71{
72 mpView->SetDesignMode();
73}
74
76{
77 if( !mrBHelper.bDisposed )
78 {
79 assert(!"SvxDrawPage must be disposed!");
80 acquire();
81 dispose();
82 }
83}
84
85// XInterface
86void SvxDrawPage::release() noexcept
87{
88 OWeakAggObject::release();
89}
90
91// XComponent
93{
94 if( mpModel )
95 {
96 mpModel = nullptr;
97 }
98
99 mpView.reset();
100 mpPage = nullptr;
101}
102
103// XComponent
105{
106 SolarMutexGuard aSolarGuard;
107
108 // An frequently programming error is to release the last
109 // reference to this object in the disposing message.
110 // Make it robust, hold a self Reference.
111 uno::Reference< lang::XComponent > xSelf( this );
112
113 // Guard dispose against multiple threading
114 // Remark: It is an error to call dispose more than once
115 bool bDoDispose = false;
116 {
117 osl::MutexGuard aGuard( mrBHelper.rMutex );
119 {
120 // only one call go into this section
121 mrBHelper.bInDispose = true;
122 bDoDispose = true;
123 }
124 }
125
126 // Do not hold the mutex because we are broadcasting
127 if( !bDoDispose )
128 return;
129
130 // Create an event with this as sender
131 try
132 {
133 uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( static_cast<lang::XComponent *>(this) ) );
134 css::document::EventObject aEvt;
135 aEvt.Source = xSource;
136 // inform all listeners to release this object
137 // The listener container are automatically cleared
138 mrBHelper.aLC.disposeAndClear( aEvt );
139 // notify subclasses to do their dispose
140 disposing();
141 }
142 catch(const css::uno::Exception&)
143 {
144 // catch exception and throw again but signal that
145 // the object was disposed. Dispose should be called
146 // only once.
147 osl::MutexGuard aGuard( mrBHelper.rMutex );
148 mrBHelper.bDisposed = true;
149 mrBHelper.bInDispose = false;
150 throw;
151 }
152
153 osl::MutexGuard aGuard( mrBHelper.rMutex );
154 mrBHelper.bDisposed = true;
155 mrBHelper.bInDispose = false;
156
157}
158
159void SAL_CALL SvxDrawPage::addEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener )
160{
161 SolarMutexGuard aGuard;
162
163 if( mpModel == nullptr )
164 throw lang::DisposedException();
165
166 mrBHelper.addListener( cppu::UnoType<decltype(aListener)>::get() , aListener );
167}
168
169void SAL_CALL SvxDrawPage::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener )
170{
171 SolarMutexGuard aGuard;
172
173 if( mpModel == nullptr )
174 throw lang::DisposedException();
175
176 mrBHelper.removeListener( cppu::UnoType<decltype(aListener)>::get() , aListener );
177}
178
179void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape )
180{
181 SolarMutexGuard aGuard;
182
183 if ( ( mpModel == nullptr ) || ( mpPage == nullptr ) )
184 throw lang::DisposedException();
185
186 SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
187
188 if( nullptr == pShape )
189 {
190 assert(false && "adding a non-SvxShape to a page?");
191 return;
192 }
193
195 bool bNeededToClone(false);
196
197 if(pObj && &pObj->getSdrModelFromSdrObject() != &mpPage->getSdrModelFromSdrPage())
198 {
199 // TTTT UNO API tries to add an existing SvxShape to this SvxDrawPage,
200 // but these use different SdrModels. It was possible before to completely
201 // 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
202 // stuff), but is no longer. We need to Clone the SdrObject to the target model
203 // and ::Create a new SvxShape (set SdrObject there, take over values, ...)
204 rtl::Reference<SdrObject> pClonedSdrShape(pObj->CloneSdrObject(mpPage->getSdrModelFromSdrPage()));
205 pObj->setUnoShape(nullptr);
206 pClonedSdrShape->setUnoShape(pShape);
207 // pShape->InvalidateSdrObject();
208 // pShape->Create(pClonedSdrShape, this);
209 pObj = pClonedSdrShape;
210 bNeededToClone = true;
211 }
212
213 if(!pObj)
214 {
215 pObj = CreateSdrObject( xShape );
216 ENSURE_OR_RETURN_VOID( pObj != nullptr, "SvxDrawPage::add: no SdrObject was created!" );
217 }
218 else if ( !pObj->IsInserted() )
219 {
220 mpPage->InsertObject( pObj.get() );
221
222 if(bNeededToClone)
223 {
224 // TTTT Unfortunately in SdrObject::SetPage (see there) the
225 // xShape/UnoShape at the newly cloned SDrObject is *removed* again,
226 // so re-set it here, the caller *may need it* (e.g. Writer)
227 uno::Reference< drawing::XShape > xShapeCheck(pObj->getWeakUnoShape());
228
229 if( !xShapeCheck.is() )
230 {
231 pObj->setUnoShape(pShape);
232 }
233 }
234 }
235
236 pShape->Create( pObj.get(), this );
237 OSL_ENSURE( pShape->GetSdrObject() == pObj.get(), "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
238
239 if ( !pObj->IsInserted() )
240 {
241 mpPage->InsertObject( pObj.get() );
242 }
243
245}
246
247void SAL_CALL SvxDrawPage::addTop( const uno::Reference< drawing::XShape >& xShape )
248{
249 add(xShape);
250}
251
252void SAL_CALL SvxDrawPage::addBottom( const uno::Reference< drawing::XShape >& xShape )
253{
254 SolarMutexGuard aGuard;
255
256 if ( ( mpModel == nullptr ) || ( mpPage == nullptr ) )
257 throw lang::DisposedException();
258
259 SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
260
261 if( nullptr == pShape )
262 {
263 assert(false && "adding a non-SvxShape to a page?");
264 return;
265 }
266
268
269 if(!pObj)
270 {
271 pObj = CreateSdrObject( xShape, true );
272 ENSURE_OR_RETURN_VOID( pObj != nullptr, "SvxDrawPage::add: no SdrObject was created!" );
273 }
274 else if ( !pObj->IsInserted() )
275 {
276 mpPage->InsertObject( pObj.get(), 0 );
277 }
278
279 pShape->Create( pObj.get(), this );
280 OSL_ENSURE( pShape->GetSdrObject() == pObj.get(), "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
281
282 if ( !pObj->IsInserted() )
283 {
284 mpPage->InsertObject( pObj.get(), 0 );
285 }
286
288}
289
290void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape )
291{
292 SolarMutexGuard aGuard;
293
294 if( (mpModel == nullptr) || (mpPage == nullptr) )
295 throw lang::DisposedException();
296
298 if (!pObj)
299 return;
300
301 // remove SdrObject from page
302 const size_t nCount = mpPage->GetObjCount();
303 for( size_t nNum = 0; nNum < nCount; ++nNum )
304 {
305 if(mpPage->GetObj(nNum) == pObj)
306 {
307 const bool bUndoEnabled = mpModel->IsUndoEnabled();
308
309 if (bUndoEnabled)
310 {
311 mpModel->BegUndo(SvxResId(STR_EditDelete),
313
315 }
316
317 OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
318
319 if (bUndoEnabled)
320 mpModel->EndUndo();
321
322 break;
323 }
324 }
325
327}
328
329void SvxDrawPage::sort( const css::uno::Sequence< sal_Int32 >& sortOrder )
330{
331 SolarMutexGuard aGuard;
332
333 if ((mpModel == nullptr) || (mpPage == nullptr))
334 throw lang::DisposedException();
335
336 auto newOrder = comphelper::sequenceToContainer<std::vector<sal_Int32>>(sortOrder);
337 mpPage->sort(newOrder);
338}
339
340// css::container::XIndexAccess
341sal_Int32 SAL_CALL SvxDrawPage::getCount()
342{
343 SolarMutexGuard aGuard;
344
345 if( (mpModel == nullptr) || (mpPage == nullptr) )
346 throw lang::DisposedException();
347
348 return static_cast<sal_Int32>( mpPage->GetObjCount() );
349}
350
352{
353 SolarMutexGuard aGuard;
354
355 if( (mpModel == nullptr) || (mpPage == nullptr) )
356 throw lang::DisposedException("Model or Page was already disposed!");
357
359 throw lang::IndexOutOfBoundsException("Index (" + OUString::number(Index)
360 + ") needs to be a positive integer smaller than the shape count ("
361 + OUString::number(mpPage->GetObjCount()) + ")!");
362
363 SdrObject* pObj = mpPage->GetObj( Index );
364 if( pObj == nullptr )
365 throw uno::RuntimeException("Runtime exception thrown while getting a ref to the SdrObject at index: "
366 + OUString::number(Index));
367
368
369 return Any(Reference< drawing::XShape >( pObj->getUnoShape(), uno::UNO_QUERY ));
370}
371
372// css::container::XElementAccess
374{
376}
377
379{
380 SolarMutexGuard aGuard;
381
382 if( (mpModel == nullptr) || (mpPage == nullptr) )
383 throw lang::DisposedException();
384
385 return mpPage && mpPage->GetObjCount()>0;
386}
387
388namespace
389{
390 void lcl_markSdrObjectOfShape( const Reference< drawing::XShape >& _rxShape, SdrView& _rView, SdrPageView& _rPageView )
391 {
393 if ( !pObj )
394 return;
395
396 _rView.MarkObj( pObj, &_rPageView );
397 }
398}
399
400// ATTENTION: SelectObjectsInView selects the css::drawing::Shapes
401// only in the given SdrPageView. It hasn't to be the visible SdrPageView.
402void SvxDrawPage::SelectObjectsInView( const Reference< drawing::XShapes > & aShapes, SdrPageView* pPageView ) noexcept
403{
404 SAL_WARN_IF(!pPageView, "svx", "SdrPageView is NULL!");
405 SAL_WARN_IF(!mpView, "svx", "SdrView is NULL!");
406
407 if(pPageView==nullptr || mpView==nullptr)
408 return;
409
410 mpView->UnmarkAllObj( pPageView );
411
412 tools::Long nCount = aShapes->getCount();
413 for( tools::Long i = 0; i < nCount; i++ )
414 {
415 uno::Any aAny( aShapes->getByIndex(i) );
416 Reference< drawing::XShape > xShape;
417 if( aAny >>= xShape )
418 lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView );
419 }
420}
421
422// ATTENTION: SelectObjectInView selects the shape only in the given SdrPageView.
423// It hasn't to be the visible SdrPageView.
424void SvxDrawPage::SelectObjectInView( const Reference< drawing::XShape > & xShape, SdrPageView* pPageView ) noexcept
425{
426 SAL_WARN_IF(!pPageView, "svx", "SdrPageView is NULL!");
427 SAL_WARN_IF(!mpView, "svx", "SdrView is NULL!");
428
429 if(pPageView!=nullptr && mpView != nullptr)
430 {
431 mpView->UnmarkAllObj( pPageView );
432 lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView );
433 }
434}
435
436Reference< drawing::XShapeGroup > SAL_CALL SvxDrawPage::group( const Reference< drawing::XShapes >& xShapes )
437{
438 SolarMutexGuard aGuard;
439
440 if( (mpModel == nullptr) || (mpPage == nullptr) )
441 throw lang::DisposedException();
442
443 SAL_WARN_IF(!mpPage , "svx", "SdrPage is NULL!");
444 SAL_WARN_IF(!mpView, "svx", "SdrView is NULL!");
445
446 Reference< css::drawing::XShapeGroup > xShapeGroup;
447 if(mpPage==nullptr||mpView==nullptr||!xShapes.is())
448 return xShapeGroup;
449
450 SdrPageView* pPageView = mpView->ShowSdrPage( mpPage );
451
452 SelectObjectsInView( xShapes, pPageView );
453
454 mpView->GroupMarked();
455
456 mpView->AdjustMarkHdl();
457 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
458 if( rMarkList.GetMarkCount() == 1 )
459 {
460 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
461 if( pObj )
462 xShapeGroup.set( pObj->getUnoShape(), UNO_QUERY );
463 }
464
465 mpView->HideSdrPage();
466
467 if( mpModel )
469
470 return xShapeGroup;
471}
472
473void SAL_CALL SvxDrawPage::ungroup( const Reference< drawing::XShapeGroup >& aGroup )
474{
475 SolarMutexGuard aGuard;
476
477 if( (mpModel == nullptr) || (mpPage == nullptr) )
478 throw lang::DisposedException();
479
480 SAL_WARN_IF(!mpPage, "svx", "SdrPage is NULL!");
481 SAL_WARN_IF(!mpView, "svx", "SdrView is NULL!");
482
483 if(mpPage==nullptr||mpView==nullptr||!aGroup.is())
484 return;
485
486 SdrPageView* pPageView = mpView->ShowSdrPage( mpPage );
487
488 SelectObjectInView( aGroup, pPageView );
489 mpView->UnGroupMarked();
490
491 mpView->HideSdrPage();
492
493 if( mpModel )
495}
496
497rtl::Reference<SdrObject> SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xShape)
498{
500 SdrInventor nInventor;
501
502 GetTypeAndInventor( nType, nInventor, xShape->getShapeType() );
503 if (nType == SdrObjKind::NONE)
504 return nullptr;
505
506 awt::Size aSize = xShape->getSize();
507 aSize.Width += 1;
508 aSize.Height += 1;
509 awt::Point aPos = xShape->getPosition();
510 tools::Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
511
513 *mpModel,
514 nInventor,
515 nType,
516 &aRect);
517
518 if (!pNewObj)
519 return nullptr;
520
522 {
523 auto pScene = static_cast<E3dScene* >(pNewObj.get());
524 // initialise scene
525
526 double fW = static_cast<double>(aSize.Width);
527 double fH = static_cast<double>(aSize.Height);
528
529 Camera3D aCam(pScene->GetCamera());
530 aCam.SetAutoAdjustProjection(false);
531 aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
532 basegfx::B3DPoint aLookAt;
533 basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
534 aCam.SetPosAndLookAt(aCamPos, aLookAt);
535 aCam.SetFocalLength(100.0);
536 pScene->SetCamera(aCam);
537
538 pScene->SetBoundAndSnapRectsDirty();
539 }
541 {
542 auto pObj = static_cast<E3dExtrudeObj* >(pNewObj.get());
543 basegfx::B2DPolygon aNewPolygon;
544 aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
545 aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
546 aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
547 aNewPolygon.setClosed(true);
548 pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
549
550 // #107245# pObj->SetExtrudeCharacterMode(sal_True);
552 }
553 else if(nType == SdrObjKind::E3D_Lathe)
554 {
555 auto pLatheObj = static_cast<E3dLatheObj* >(pNewObj.get());
556 basegfx::B2DPolygon aNewPolygon;
557 aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
558 aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
559 aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
560 aNewPolygon.setClosed(true);
561 pLatheObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
562
563 // #107245# pObj->SetLatheCharacterMode(sal_True);
564 pLatheObj->SetMergedItem(Svx3DCharacterModeItem(true));
565 }
566
567 return pNewObj;
568}
569
570void SvxDrawPage::GetTypeAndInventor( SdrObjKind& rType, SdrInventor& rInventor, const OUString& aName ) noexcept
571{
572 std::optional<SdrObjKind> nTempType = UHashMap::getId( aName );
573
574 if( !nTempType )
575 {
576 if( aName == "com.sun.star.drawing.TableShape" ||
577 aName == "com.sun.star.presentation.TableShape" )
578 {
579 rInventor = SdrInventor::Default;
580 rType = SdrObjKind::Table;
581 }
582#if HAVE_FEATURE_AVMEDIA
583 else if ( aName == "com.sun.star.presentation.MediaShape" )
584 {
585 rInventor = SdrInventor::Default;
586 rType = SdrObjKind::Media;
587 }
588#endif
589 }
590 else if( IsInventorE3D(*nTempType) )
591 {
592 rInventor = SdrInventor::E3d;
593 rType = *nTempType;
594 }
595 else
596 {
597 rInventor = SdrInventor::Default;
598 rType = *nTempType;
599
600 switch( rType )
601 {
605 rType = SdrObjKind::OLE2;
606 break;
607 default:
608 break;
609 }
610 }
611}
612
614{
616
617 switch( nInventor )
618 {
619 case SdrInventor::E3d:
620 {
621 switch( nType )
622 {
624 pRet = new Svx3DSceneObject( pObj, mpPage );
625 break;
627 pRet = new Svx3DCubeObject( pObj );
628 break;
630 pRet = new Svx3DSphereObject( pObj );
631 break;
633 pRet = new Svx3DLatheObject( pObj );
634 break;
636 pRet = new Svx3DExtrudeObject( pObj );
637 break;
639 pRet = new Svx3DPolygonObject( pObj );
640 break;
641 default: // unknown 3D-object on page
642 assert(false && "the IsInventor3D function must be wrong");
643 pRet = new SvxShape( pObj );
644 break;
645 }
646 break;
647 }
649 {
650 switch( nType )
651 {
653 pRet = new SvxShapeGroup( pObj, mpPage );
654 break;
655 case SdrObjKind::Line:
656 pRet = new SvxShapePolyPolygon( pObj );
657 break;
659 pRet = new SvxShapeRect( pObj );
660 break;
665 pRet = new SvxShapeCircle( pObj );
666 break;
668 pRet = new SvxShapePolyPolygon( pObj );
669 break;
671 pRet = new SvxShapePolyPolygon( pObj );
672 break;
674 pRet = new SvxShapePolyPolygon( pObj );
675 break;
677 pRet = new SvxShapePolyPolygon( pObj );
678 break;
680 pRet = new SvxShapePolyPolygon( pObj );
681 break;
683 pRet = new SvxShapePolyPolygon( pObj );
684 break;
686 pRet = new SvxShapeCaption( pObj );
687 break;
690 case SdrObjKind::Text:
691 pRet = new SvxShapeText( pObj );
692 break;
694 pRet = new SvxGraphicObject( pObj );
695 break;
697 pRet = new SvxFrameShape( pObj );
698 break;
700 pRet = new SvxAppletShape( pObj );
701 break;
703 pRet = new SvxPluginShape( pObj );
704 break;
705 case SdrObjKind::OLE2:
706 {
707 if( pObj && !pObj->IsEmptyPresObj() && mpPage )
708 {
709 SdrPage* pSdrPage = mpPage->GetSdrPage();
710 if( pSdrPage )
711 {
712 SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage());
713 ::comphelper::IEmbeddedHelper *pPersist = rSdrModel.GetPersist();
714
715 if( pPersist )
716 {
717 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
718 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
719
720 // TODO CL->KA: Why is this not working anymore?
721 if( xObject.is() )
722 {
723 SvGlobalName aClassId( xObject->getClassID() );
724
725 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
726 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
727 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
728
729 if( aPluginClassId == aClassId )
730 {
731 pRet = new SvxPluginShape( pObj );
733 }
734 else if( aAppletClassId == aClassId )
735 {
736 pRet = new SvxAppletShape( pObj );
738 }
739 else if( aIFrameClassId == aClassId )
740 {
741 pRet = new SvxFrameShape( pObj );
743 }
744 }
745 }
746 }
747 }
748 if( pRet == nullptr )
749 {
750 SvxUnoPropertyMapProvider& rSvxMapProvider = getSvxMapProvider();
751 pRet = new SvxOle2Shape( pObj, rSvxMapProvider.GetMap(SVXMAP_OLE2), rSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) );
752 }
753 }
754 break;
755 case SdrObjKind::Edge:
756 pRet = new SvxShapeConnector( pObj );
757 break;
759 pRet = new SvxShapePolyPolygon( pObj );
760 break;
762 pRet = new SvxShapePolyPolygon( pObj );
763 break;
764 case SdrObjKind::Page:
765 {
766 SvxUnoPropertyMapProvider& rSvxMapProvider = getSvxMapProvider();
767 pRet = new SvxShape( pObj, rSvxMapProvider.GetMap(SVXMAP_PAGE), rSvxMapProvider.GetPropertySet(SVXMAP_PAGE, SdrObject::GetGlobalDrawObjectItemPool()) );
768 }
769 break;
771 pRet = new SvxShapeDimensioning( pObj );
772 break;
773 case SdrObjKind::UNO:
774 pRet = new SvxShapeControl( pObj );
775 break;
777 pRet = new SvxCustomShape( pObj );
778 break;
780 pRet = new SvxMediaShape( pObj, referer );
781 break;
783 pRet = new SvxTableShape( pObj );
784 break;
785 default: // unknown 2D-object on page
786 assert(false && "Not implemented Starone-Shape created");
787 pRet = new SvxShapeText( pObj );
788 break;
789 }
790 break;
791 }
792 default: // unknown inventor
793 {
794 assert(false && "Unknown Inventor in SvxDrawPage::CreateShape()");
795 break;
796 }
797 }
798
799 if(pRet)
800 {
801 SdrObjKind nObjId = nType;
802
803 switch(nObjId)
804 {
805 case SdrObjKind::CircleCut: // segment of circle
806 case SdrObjKind::CircleArc: // arc of circle
807 case SdrObjKind::CircleSection: // sector
809 break;
810
813 nObjId = SdrObjKind::Text;
814 break;
815 default: ;
816 }
817
818 pRet->setShapeKind(nObjId);
819 }
820
821 return pRet;
822}
823
824Reference< drawing::XShape > SvxDrawPage::CreateShape( SdrObject *pObj ) const
825{
826 Reference< drawing::XShape > xShape( CreateShapeByTypeAndInventor(pObj->GetObjIdentifier(),
827 pObj->GetObjInventor(),
828 pObj,
829 const_cast<SvxDrawPage*>(this)));
830 return xShape;
831}
832
833rtl::Reference<SdrObject> SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape, bool bBeginning ) noexcept
834{
835 rtl::Reference<SdrObject> pObj = CreateSdrObject_( xShape );
836 if( pObj)
837 {
838 if ( !pObj->IsInserted() && !pObj->IsDoNotInsertIntoPageAutomatically() )
839 {
840 if(bBeginning)
841 mpPage->InsertObject( pObj.get(), 0 );
842 else
843 mpPage->InsertObject( pObj.get() );
844 }
845 }
846
847 return pObj;
848}
849
850// css::lang::XServiceInfo
852{
853 return "SvxDrawPage";
854}
855
856sal_Bool SAL_CALL SvxDrawPage::supportsService( const OUString& ServiceName )
857{
858 return cppu::supportsService( this, ServiceName );
859}
860
861uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames()
862{
863 uno::Sequence<OUString> aSeq { "com.sun.star.drawing.ShapeCollection" };
864 return aSeq;
865}
866
868{
869 return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor, nullptr, nullptr, referer );
870}
871
873uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage( SdrPage* pPage ) noexcept
874{
875 if(pPage)
876 {
877 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
878
879 return xDrawPage;
880 }
881
882 return uno::Reference< drawing::XDrawPage >();
883}
884
886SdrPage* GetSdrPageFromXDrawPage( const uno::Reference< drawing::XDrawPage >& xDrawPage ) noexcept
887{
888 if(xDrawPage.is())
889 {
890 SvxDrawPage* pDrawPage = comphelper::getFromUnoTunnel<SvxDrawPage>( xDrawPage );
891
892 if(pDrawPage)
893 {
894 return pDrawPage->GetSdrPage();
895 }
896 assert(false && "non-SvxDrawPage?");
897 }
898
899 return nullptr;
900}
901
902/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
FPDF_PAGE mpPage
void SetAutoAdjustProjection(bool bAdjust)
Definition: camera3d.hxx:62
void SetFocalLength(double fLen)
Definition: camera3d.cxx:172
void SetPosAndLookAt(const basegfx::B3DPoint &rNewPos, const basegfx::B3DPoint &rNewLookAt)
Definition: camera3d.cxx:69
void SetViewWindow(double fX, double fY, double fW, double fH)
Definition: camera3d.cxx:41
size_t GetMarkCount() const
Definition: svdmark.hxx:178
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:230
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1941
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
::comphelper::IEmbeddedHelper * GetPersist() const
Definition: svdmodel.hxx:355
void BegUndo()
Definition: svdmodel.cxx:382
virtual void SetChanged(bool bFlg=true)
Definition: svdmodel.cxx:1143
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdmodel.cxx:516
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
Definition: svdmodel.cxx:1915
bool IsUndoEnabled() const
returns true if undo is currently enabled This returns false if undo was disabled using EnableUndo( f...
Definition: svdmodel.cxx:547
void EndUndo()
Definition: svdmodel.cxx:453
static rtl::Reference< SdrObject > MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
Definition: svdobj.cxx:3279
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:295
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:785
size_t GetObjCount() const
Definition: svdpage.cxx:779
void sort(std::vector< sal_Int32 > &sortOrder)
Definition: svdpage.cxx:581
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
Definition: svdpage.cxx:373
Abstract DrawObject.
Definition: svdobj.hxx:260
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
Definition: unoshape.cxx:4020
static SdrItemPool & GetGlobalDrawObjectItemPool()
Definition: svdobj.cxx:548
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:621
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
Definition: svdobj.cxx:2866
bool IsEmptyPresObj() const
Definition: svdobj.hxx:833
virtual SdrObjKind GetObjIdentifier() const
Definition: svdobj.cxx:626
virtual OUString TakeObjNameSingul() const
Definition: svdobj.cxx:1087
void SetMergedItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1984
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:403
virtual std::unique_ptr< SdrUndoAction > CreateUndoDeleteObject(SdrObject &rObject, bool bOrdNumDirect=false)
Definition: svdundo.cxx:1694
std::unique_ptr< SdrView > mpView
Definition: unopage.hxx:65
SvxDrawPage(SdrPage *pPage)
Definition: unopage.cxx:66
rtl::Reference< SdrObject > CreateSdrObject(const css::uno::Reference< css::drawing::XShape > &xShape, bool bBeginning=false) noexcept
Definition: unopage.cxx:833
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const
Definition: unopage.cxx:824
SdrModel * mpModel
Definition: unopage.hxx:64
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unopage.cxx:179
virtual void SAL_CALL addBottom(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unopage.cxx:252
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unopage.cxx:856
cppu::OBroadcastHelper mrBHelper
Definition: unopage.hxx:61
virtual sal_Int32 SAL_CALL getCount() override
Definition: unopage.cxx:341
virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > &aGroup) override
Definition: unopage.cxx:473
virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unopage.cxx:290
SdrPage * mpPage
Definition: unopage.hxx:63
virtual sal_Bool SAL_CALL hasElements() override
Definition: unopage.cxx:378
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unopage.cxx:169
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: unopage.cxx:351
void SelectObjectsInView(const css::uno::Reference< css::drawing::XShapes > &aShapes, SdrPageView *pPageView) noexcept
Definition: unopage.cxx:402
virtual void SAL_CALL release() noexcept override
Definition: unopage.cxx:86
static void GetTypeAndInventor(SdrObjKind &rType, SdrInventor &rInventor, const OUString &aName) noexcept
Definition: unopage.cxx:570
virtual void SAL_CALL addTop(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unopage.cxx:247
virtual void disposing() noexcept
Definition: unopage.cxx:92
virtual void SAL_CALL sort(const css::uno::Sequence< sal_Int32 > &sortOrder) override
Definition: unopage.cxx:329
SdrPage * GetSdrPage() const
Definition: unopage.hxx:77
virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > &xShapes) override
Definition: unopage.cxx:436
virtual OUString SAL_CALL getImplementationName() override
Definition: unopage.cxx:851
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unopage.cxx:861
static rtl::Reference< SvxShape > CreateShapeByTypeAndInventor(SdrObjKind nType, SdrInventor nInventor, SdrObject *pObj, SvxDrawPage *pPage=nullptr, OUString const &referer=OUString())
Definition: unopage.cxx:613
virtual rtl::Reference< SdrObject > CreateSdrObject_(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: unopage.cxx:497
virtual ~SvxDrawPage() noexcept override
Definition: unopage.cxx:75
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unopage.cxx:159
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unopage.cxx:373
void SelectObjectInView(const css::uno::Reference< css::drawing::XShape > &xShape, SdrPageView *pPageView) noexcept
Definition: unopage.cxx:424
virtual void SAL_CALL dispose() override
Definition: unopage.cxx:104
virtual void Create(SdrObject *pNewOpj, SvxDrawPage *pNewPage)
Definition: unoshape.cxx:361
SdrObject * GetSdrObject() const
Definition: unoshape.hxx:172
SvxUnoPropertyMapProvider.
Definition: unoprov.hxx:84
const SvxItemPropertySet * GetPropertySet(sal_uInt16 nPropertyId, SfxItemPool &rPool)
Definition: unoprov.cxx:924
o3tl::span< const SfxItemPropertyMapEntry > GetMap(sal_uInt16 nPropertyId)
Definition: unoprov.cxx:886
static std::optional< SdrObjKind > getId(const OUString &rCompareString)
Definition: unoprov.cxx:858
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
virtual EmbeddedObjectContainer & getEmbeddedObjectContainer() const=0
css::uno::Type const & get()
#define SO3_PLUGIN_CLASSID
#define SO3_IFRAME_CLASSID
#define SO3_APPLET_CLASSID
int nCount
#define ENSURE_OR_RETURN_VOID(c, m)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
std::mutex m_aMutex
OUString aName
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
long Long
QPRO_FUNC_TYPE nType
SvxUnoPropertyMapProvider & getSvxMapProvider()
Definition: unoprov.cxx:868
UnoViewSharedPtr mpView
void addListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
void removeListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
SdrInventor
Definition: svdobj.hxx:98
constexpr bool IsInventorE3D(SdrObjKind e)
Definition: svdobjkind.hxx:148
SdrObjKind
Definition: svdobjkind.hxx:25
@ Group
abstract object (SdrObject)
@ Measure
object that represents a SdrPage
@ Page
Polyline represented by SdrPathObj.
@ Caption
connector object
@ Media
custom shape
@ PathFill
open Bezier-curve
@ OLE2Applet
table
@ Line
object group
@ Polygon
circle cut
@ Table
media shape
@ FreehandLine
closed Bezier-curve
@ UNO
continuously activated OLE (PlugIn-Frame or similar)
@ PathLine
PolyLine.
@ CustomShape
Universal Network Object packed into SvDraw object.
@ CircleOrEllipse
rectangle (round corners optional)
@ PathPoly
caption object
@ Text
closed free-hand line
@ OLE2
foreign graphic (StarView Graphic)
@ OLEPluginFrame
measurement object
@ Graphic
OutlineText, special text object for StarDraw.
@ CircleCut
circle arc
@ Rectangle
line
@ PathPolyLine
Polygon/PolyPolygon represented by SdrPathObj.
@ CircleSection
circle, ellipse
@ OutlineText
TitleText, special text object for StarDraw.
@ CircleArc
circle section
@ PolyLine
polygon, PolyPolygon
@ Edge
OLE object.
@ TitleText
text object
@ FreehandFill
open free-hand line
unsigned char sal_Bool
UNO3_GETIMPLEMENTATION_IMPL(SvxDrawPage)
uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage(SdrPage *pPage) noexcept
returns a StarOffice API wrapper for the given SdrPage
Definition: unopage.cxx:873
SdrPage * GetSdrPageFromXDrawPage(const uno::Reference< drawing::XDrawPage > &xDrawPage) noexcept
returns the SdrObject from the given StarOffice API wrapper
Definition: unopage.cxx:886
rtl::Reference< SvxShape > CreateSvxShapeByTypeAndInventor(SdrObjKind nType, SdrInventor nInventor, OUString const &referer)
Creates a StarOffice API wrapper with the given type and inventor Deprecated: This will be replaced w...
Definition: unopage.cxx:867
#define SVXMAP_PAGE
Definition: unoprov.hxx:76
#define SVXMAP_OLE2
Definition: unoprov.hxx:67