bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / unoidl / DrawController.cxx
blob44ae57e105450836aa1fb9b25c5920271c85bc2b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <DrawController.hxx>
21 #include <DrawDocShell.hxx>
23 #include <DrawSubController.hxx>
24 #include <sdpage.hxx>
25 #include <ViewShell.hxx>
26 #include <ViewShellBase.hxx>
27 #include <ViewShellManager.hxx>
28 #include <FormShellManager.hxx>
29 #include <Window.hxx>
31 #include <comphelper/processfactory.hxx>
32 #include <comphelper/sequence.hxx>
33 #include <comphelper/servicehelper.hxx>
34 #include <cppuhelper/exc_hlp.hxx>
35 #include <cppuhelper/bootstrap.hxx>
36 #include <cppuhelper/supportsservice.hxx>
37 #include <cppuhelper/typeprovider.hxx>
39 #include <com/sun/star/beans/PropertyAttribute.hpp>
40 #include <com/sun/star/drawing/framework/ConfigurationController.hpp>
41 #include <com/sun/star/drawing/framework/ModuleController.hpp>
42 #include <com/sun/star/drawing/XLayer.hpp>
43 #include <com/sun/star/lang/XInitialization.hpp>
45 #include <slideshow.hxx>
47 #include <sal/log.hxx>
48 #include <svx/fmshell.hxx>
49 #include <vcl/svapp.hxx>
50 #include <vcl/EnumContext.hxx>
51 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
52 #include <tools/diagnose_ex.h>
54 #include <memory>
56 using namespace ::std;
57 using namespace ::cppu;
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::drawing::framework;
61 using vcl::EnumContext;
63 namespace sd {
65 DrawController::DrawController (ViewShellBase& rBase) throw()
66 : DrawControllerInterfaceBase(&rBase),
67 BroadcastHelperOwner(SfxBaseController::m_aMutex),
68 OPropertySetHelper(BroadcastHelperOwner::maBroadcastHelper),
69 m_aSelectionTypeIdentifier(
70 cppu::UnoType<view::XSelectionChangeListener>::get()),
71 mpBase(&rBase),
72 maLastVisArea(),
73 mpCurrentPage(nullptr),
74 mbMasterPageMode(false),
75 mbLayerMode(false),
76 mbDisposing(false),
77 mxSubController(),
78 mxConfigurationController(),
79 mxModuleController()
81 ProvideFrameworkControllers();
84 DrawController::~DrawController() throw()
88 void DrawController::SetSubController (
89 const Reference<drawing::XDrawSubController>& rxSubController)
91 // Update the internal state.
92 mxSubController = rxSubController;
93 mpPropertyArrayHelper.reset();
94 maLastVisArea = ::tools::Rectangle();
96 // Inform listeners about the changed state.
97 FireSelectionChangeListener();
100 // XInterface
102 IMPLEMENT_FORWARD_XINTERFACE2(
103 DrawController,
104 DrawControllerInterfaceBase,
105 OPropertySetHelper);
107 // XTypeProvider
109 Sequence<Type> SAL_CALL DrawController::getTypes()
111 ThrowIfDisposed();
112 // OPropertySetHelper does not provide getTypes, so we have to
113 // implement this method manually and list its three interfaces.
114 OTypeCollection aTypeCollection (
115 cppu::UnoType<beans::XMultiPropertySet>::get(),
116 cppu::UnoType<beans::XFastPropertySet>::get(),
117 cppu::UnoType<beans::XPropertySet>::get());
119 return ::comphelper::concatSequences(
120 SfxBaseController::getTypes(),
121 aTypeCollection.getTypes(),
122 DrawControllerInterfaceBase::getTypes());
125 IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController);
127 // XComponent
129 void SAL_CALL DrawController::dispose()
131 if( mbDisposing )
132 return;
134 SolarMutexGuard aGuard;
136 if( mbDisposing )
137 return;
139 mbDisposing = true;
141 std::shared_ptr<ViewShell> pViewShell;
142 if (mpBase)
143 pViewShell = mpBase->GetMainViewShell();
144 if ( pViewShell )
146 pViewShell->DeactivateCurrentFunction();
147 DrawDocShell* pDocShell = pViewShell->GetDocSh();
148 if ( pDocShell != nullptr )
149 pDocShell->SetDocShellFunction(nullptr);
151 pViewShell.reset();
153 // When the controller has not been detached from its view
154 // shell, i.e. mpViewShell is not NULL, then tell PaneManager
155 // and ViewShellManager to clear the shell stack.
156 if (mxSubController.is() && mpBase!=nullptr)
158 mpBase->DisconnectAllClients();
159 mpBase->GetViewShellManager()->Shutdown();
162 OPropertySetHelper::disposing();
164 DisposeFrameworkControllers();
166 SfxBaseController::dispose();
169 void SAL_CALL DrawController::addEventListener(
170 const Reference<lang::XEventListener >& xListener)
172 ThrowIfDisposed();
173 SfxBaseController::addEventListener( xListener );
176 void SAL_CALL DrawController::removeEventListener (
177 const Reference<lang::XEventListener >& aListener)
179 if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing)
180 SfxBaseController::removeEventListener( aListener );
183 // XController
184 sal_Bool SAL_CALL DrawController::suspend( sal_Bool Suspend )
186 if( Suspend )
188 ViewShellBase* pViewShellBase = GetViewShellBase();
189 if( pViewShellBase )
191 // do not allow suspend if a slideshow needs this controller!
192 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) );
193 if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) )
194 return false;
198 return SfxBaseController::suspend( Suspend );
201 // XServiceInfo
202 OUString SAL_CALL DrawController::getImplementationName( )
204 // Do not throw an exception at the moment. This leads to a crash
205 // under Solaris on reload. See issue i70929 for details.
206 // ThrowIfDisposed();
207 return OUString("DrawController") ;
210 static const char ssServiceName[] = "com.sun.star.drawing.DrawingDocumentDrawView";
212 sal_Bool SAL_CALL DrawController::supportsService (const OUString& rsServiceName)
214 return cppu::supportsService(this, rsServiceName);
217 Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames()
219 ThrowIfDisposed();
220 Sequence<OUString> aSupportedServices { ssServiceName };
221 return aSupportedServices;
224 //------ XSelectionSupplier --------------------------------------------
225 sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
227 ThrowIfDisposed();
228 SolarMutexGuard aGuard;
230 if (mxSubController.is())
231 return mxSubController->select(aSelection);
232 else
233 return false;
236 Any SAL_CALL DrawController::getSelection()
238 ThrowIfDisposed();
239 SolarMutexGuard aGuard;
241 if (mxSubController.is())
242 return mxSubController->getSelection();
243 else
244 return Any();
247 void SAL_CALL DrawController::addSelectionChangeListener(
248 const Reference< view::XSelectionChangeListener >& xListener)
250 if( mbDisposing )
251 throw lang::DisposedException();
253 BroadcastHelperOwner::maBroadcastHelper.addListener (m_aSelectionTypeIdentifier, xListener);
256 void SAL_CALL DrawController::removeSelectionChangeListener(
257 const Reference< view::XSelectionChangeListener >& xListener )
259 if (rBHelper.bDisposed)
260 throw lang::DisposedException();
262 BroadcastHelperOwner::maBroadcastHelper.removeListener (m_aSelectionTypeIdentifier, xListener);
265 //===== lang::XEventListener ================================================
267 void SAL_CALL
268 DrawController::disposing (const lang::EventObject& )
272 //===== view::XSelectionChangeListener ======================================
274 void SAL_CALL
275 DrawController::selectionChanged (const lang::EventObject& rEvent)
277 ThrowIfDisposed();
278 // Have to forward the event to our selection change listeners.
279 OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer(
280 cppu::UnoType<view::XSelectionChangeListener>::get());
281 if (!pListeners)
282 return;
284 // Re-send the event to all of our listeners.
285 OInterfaceIteratorHelper aIterator (*pListeners);
286 while (aIterator.hasMoreElements())
290 view::XSelectionChangeListener* pListener =
291 static_cast<view::XSelectionChangeListener*>(
292 aIterator.next());
293 if (pListener != nullptr)
294 pListener->selectionChanged (rEvent);
296 catch (const RuntimeException&)
302 // XDrawView
304 void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage )
306 ThrowIfDisposed();
307 SolarMutexGuard aGuard;
309 if (mxSubController.is())
310 mxSubController->setCurrentPage(xPage);
313 Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage()
315 ThrowIfDisposed();
316 SolarMutexGuard aGuard;
317 Reference<drawing::XDrawPage> xPage;
319 // Get current page from sub controller.
320 if (mxSubController.is())
321 xPage = mxSubController->getCurrentPage();
323 // When there is not yet a sub controller (during initialization) then fall back
324 // to the current page in mpCurrentPage.
325 if ( ! xPage.is() && mpCurrentPage.is())
326 xPage.set(mpCurrentPage->getUnoPage(), UNO_QUERY);
328 return xPage;
331 void DrawController::FireVisAreaChanged (const ::tools::Rectangle& rVisArea) throw()
333 if( maLastVisArea == rVisArea )
334 return;
336 Any aNewValue;
337 aNewValue <<= awt::Rectangle(
338 rVisArea.Left(),
339 rVisArea.Top(),
340 rVisArea.GetWidth(),
341 rVisArea.GetHeight() );
343 Any aOldValue;
344 aOldValue <<= awt::Rectangle(
345 maLastVisArea.Left(),
346 maLastVisArea.Top(),
347 maLastVisArea.GetWidth(),
348 maLastVisArea.GetHeight() );
350 FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue);
352 maLastVisArea = rVisArea;
355 void DrawController::FireSelectionChangeListener() throw()
357 OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer(
358 m_aSelectionTypeIdentifier);
359 if( !pLC )
360 return;
362 Reference< XInterface > xSource( static_cast<XWeak*>(this) );
363 const lang::EventObject aEvent( xSource );
365 // iterate over all listeners and send events
366 OInterfaceIteratorHelper aIt( *pLC);
367 while( aIt.hasMoreElements() )
371 view::XSelectionChangeListener * pL =
372 static_cast<view::XSelectionChangeListener*>(aIt.next());
373 if (pL != nullptr)
374 pL->selectionChanged( aEvent );
376 catch (const RuntimeException&)
382 void DrawController::FireChangeEditMode (bool bMasterPageMode) throw()
384 if (bMasterPageMode != mbMasterPageMode )
386 FirePropertyChange(
387 PROPERTY_MASTERPAGEMODE,
388 makeAny(bMasterPageMode),
389 makeAny(mbMasterPageMode));
391 mbMasterPageMode = bMasterPageMode;
395 void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
397 if (bLayerMode != mbLayerMode)
399 FirePropertyChange(
400 PROPERTY_LAYERMODE,
401 makeAny(bLayerMode),
402 makeAny(mbLayerMode));
404 mbLayerMode = bLayerMode;
408 void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
410 SdrPage* pCurrentPage = mpCurrentPage.get();
411 if (pNewCurrentPage == pCurrentPage)
412 return;
416 Any aNewValue (
417 makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY)));
419 Any aOldValue;
420 if (pCurrentPage != nullptr)
422 Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY);
423 aOldValue <<= xOldPage;
426 FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
428 mpCurrentPage.reset(pNewCurrentPage);
430 catch (const uno::Exception&)
432 css::uno::Any ex( cppu::getCaughtException() );
433 SAL_WARN("sd", "sd::SdUnoDrawView::FireSwitchCurrentPage(), exception caught: " << exceptionToString(ex));
437 void DrawController::NotifyAccUpdate()
439 sal_Int32 nHandle = PROPERTY_UPDATEACC;
440 Any aNewValue, aOldValue;
441 fire (&nHandle, &aNewValue, &aOldValue, 1, false);
444 void DrawController::fireChangeLayer( css::uno::Reference< css::drawing::XLayer>* pCurrentLayer ) throw()
446 if( pCurrentLayer != mpCurrentLayer )
448 sal_Int32 nHandle = PROPERTY_ACTIVE_LAYER;
450 Any aNewValue (makeAny( *pCurrentLayer) );
452 Any aOldValue ;
454 fire (&nHandle, &aNewValue, &aOldValue, 1, false);
456 mpCurrentLayer = pCurrentLayer;
460 // This method is only called in slide show and outline view
461 //void DrawController::fireSwitchCurrentPage(String pageName ) throw()
462 void DrawController::fireSwitchCurrentPage(sal_Int32 pageIndex ) throw()
464 Any aNewValue;
465 Any aOldValue;
466 //OUString aPageName( pageName );
467 //aNewValue <<= aPageName ;
468 aNewValue <<= pageIndex;
470 // Use new property to handle page change event
471 sal_Int32 nHandles = PROPERTY_PAGE_CHANGE;
472 fire( &nHandles, &aNewValue, &aOldValue, 1, false );
475 void DrawController::FirePropertyChange (
476 sal_Int32 nHandle,
477 const Any& rNewValue,
478 const Any& rOldValue)
482 fire (&nHandle, &rNewValue, &rOldValue, 1, false);
484 catch (const RuntimeException&)
486 // Ignore this exception. Exceptions should be handled in the
487 // fire() function so that all listeners are called. This is
488 // not the case at the moment, so we simply ignore the
489 // exception.
494 void DrawController::BroadcastContextChange() const
496 std::shared_ptr<ViewShell> pViewShell (mpBase->GetMainViewShell());
497 if ( ! pViewShell)
498 return;
500 EnumContext::Context eContext (EnumContext::Context::Unknown);
501 switch (pViewShell->GetShellType())
503 case ViewShell::ST_IMPRESS:
504 case ViewShell::ST_DRAW:
505 if (mbMasterPageMode)
506 eContext = EnumContext::Context::MasterPage;
507 else
508 eContext = EnumContext::Context::DrawPage;
509 break;
511 case ViewShell::ST_NOTES:
512 eContext = EnumContext::Context::NotesPage;
513 break;
515 case ViewShell::ST_HANDOUT:
516 eContext = EnumContext::Context::HandoutPage;
517 break;
519 case ViewShell::ST_OUTLINE:
520 eContext = EnumContext::Context::OutlineText;
521 break;
523 case ViewShell::ST_SLIDE_SORTER:
524 eContext = EnumContext::Context::SlidesorterPage;
525 break;
527 case ViewShell::ST_PRESENTATION:
528 case ViewShell::ST_NONE:
529 default:
530 eContext = EnumContext::Context::Empty;
531 break;
534 ContextChangeEventMultiplexer::NotifyContextChange(mpBase, eContext);
537 void DrawController::ReleaseViewShellBase()
539 DisposeFrameworkControllers();
540 mpBase = nullptr;
543 //===== XControllerManager ==============================================================
545 Reference<XConfigurationController> SAL_CALL
546 DrawController::getConfigurationController()
548 ThrowIfDisposed();
550 return mxConfigurationController;
553 Reference<XModuleController> SAL_CALL
554 DrawController::getModuleController()
556 ThrowIfDisposed();
558 return mxModuleController;
561 //===== XUnoTunnel ============================================================
563 namespace
565 class theDrawControllerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theDrawControllerUnoTunnelId> {};
568 const Sequence<sal_Int8>& DrawController::getUnoTunnelId()
570 return theDrawControllerUnoTunnelId::get().getSeq();
573 sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId)
575 sal_Int64 nResult = 0;
577 if (rId.getLength() == 16
578 && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
580 nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
583 return nResult;
586 //===== Properties ============================================================
588 void DrawController::FillPropertyTable (
589 ::std::vector<beans::Property>& rProperties)
591 rProperties.emplace_back("VisibleArea",
592 PROPERTY_WORKAREA,
593 ::cppu::UnoType< css::awt::Rectangle>::get(),
594 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY);
595 rProperties.emplace_back(
596 "SubController",
597 PROPERTY_SUB_CONTROLLER,
598 cppu::UnoType<drawing::XDrawSubController>::get(),
599 beans::PropertyAttribute::BOUND);
600 rProperties.emplace_back(
601 "CurrentPage",
602 PROPERTY_CURRENTPAGE,
603 cppu::UnoType<drawing::XDrawPage>::get(),
604 beans::PropertyAttribute::BOUND );
605 rProperties.emplace_back("IsLayerMode",
606 PROPERTY_LAYERMODE,
607 cppu::UnoType<bool>::get(),
608 beans::PropertyAttribute::BOUND );
609 rProperties.emplace_back("IsMasterPageMode",
610 PROPERTY_MASTERPAGEMODE,
611 cppu::UnoType<bool>::get(),
612 beans::PropertyAttribute::BOUND );
613 rProperties.emplace_back("ActiveLayer",
614 PROPERTY_ACTIVE_LAYER,
615 cppu::UnoType<drawing::XLayer>::get(),
616 beans::PropertyAttribute::BOUND );
617 rProperties.emplace_back("ZoomValue",
618 PROPERTY_ZOOMVALUE,
619 ::cppu::UnoType<sal_Int16>::get(),
620 beans::PropertyAttribute::BOUND );
621 rProperties.emplace_back("ZoomType",
622 PROPERTY_ZOOMTYPE,
623 ::cppu::UnoType<sal_Int16>::get(),
624 beans::PropertyAttribute::BOUND );
625 rProperties.emplace_back("ViewOffset",
626 PROPERTY_VIEWOFFSET,
627 ::cppu::UnoType< css::awt::Point>::get(),
628 beans::PropertyAttribute::BOUND );
629 rProperties.emplace_back("DrawViewMode",
630 PROPERTY_DRAWVIEWMODE,
631 ::cppu::UnoType< css::awt::Point>::get(),
632 beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID );
633 // add new property to update current page's acc information
634 rProperties.emplace_back( "UpdateAcc",
635 PROPERTY_UPDATEACC,
636 ::cppu::UnoType<sal_Int16>::get(),
637 beans::PropertyAttribute::BOUND );
638 rProperties.emplace_back( "PageChange",
639 PROPERTY_PAGE_CHANGE,
640 ::cppu::UnoType<sal_Int16>::get(),
641 beans::PropertyAttribute::BOUND );
644 IPropertyArrayHelper & DrawController::getInfoHelper()
646 SolarMutexGuard aGuard;
648 if (mpPropertyArrayHelper == nullptr)
650 ::std::vector<beans::Property> aProperties;
651 FillPropertyTable(aProperties);
652 mpPropertyArrayHelper.reset(new OPropertyArrayHelper(comphelper::containerToSequence(aProperties), false));
655 return *mpPropertyArrayHelper;
658 Reference < beans::XPropertySetInfo > DrawController::getPropertySetInfo()
660 SolarMutexGuard aGuard;
662 static Reference < beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
663 return xInfo;
666 uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form )
668 SolarMutexGuard aGuard;
670 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
671 SdrView* pSdrView = mpBase->GetDrawView();
672 std::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
673 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : nullptr;
675 uno::Reference< form::runtime::XFormController > xController;
676 if ( pFormShell && pSdrView && pWindow )
677 xController = FmFormShell::GetFormController( Form, *pSdrView, *pWindow );
678 return xController;
681 sal_Bool SAL_CALL DrawController::isFormDesignMode( )
683 SolarMutexGuard aGuard;
685 bool bIsDesignMode = true;
687 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
688 if ( pFormShell )
689 bIsDesignMode = pFormShell->IsDesignMode();
691 return bIsDesignMode;
694 void SAL_CALL DrawController::setFormDesignMode( sal_Bool DesignMode )
696 SolarMutexGuard aGuard;
698 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
699 if ( pFormShell )
700 pFormShell->SetDesignMode( DesignMode );
703 uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel )
705 SolarMutexGuard aGuard;
707 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
708 SdrView* pSdrView = mpBase->GetDrawView();
709 std::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
710 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : nullptr;
712 uno::Reference< awt::XControl > xControl;
713 if ( pFormShell && pSdrView && pWindow )
714 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl );
715 return xControl;
718 sal_Bool DrawController::convertFastPropertyValue (
719 Any & rConvertedValue,
720 Any & rOldValue,
721 sal_Int32 nHandle,
722 const Any& rValue)
724 bool bResult = false;
726 if (nHandle == PROPERTY_SUB_CONTROLLER)
728 rOldValue <<= mxSubController;
729 rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY);
730 bResult = (rOldValue != rConvertedValue);
732 else if (mxSubController.is())
734 rConvertedValue = rValue;
737 rOldValue = mxSubController->getFastPropertyValue(nHandle);
738 bResult = (rOldValue != rConvertedValue);
740 catch (const beans::UnknownPropertyException&)
742 // The property is unknown and thus an illegal argument to this method.
743 throw css::lang::IllegalArgumentException();
747 return bResult;
750 void DrawController::setFastPropertyValue_NoBroadcast (
751 sal_Int32 nHandle,
752 const Any& rValue)
754 SolarMutexGuard aGuard;
755 if (nHandle == PROPERTY_SUB_CONTROLLER)
756 SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY));
757 else if (mxSubController.is())
758 mxSubController->setFastPropertyValue(nHandle, rValue);
761 void DrawController::getFastPropertyValue (
762 Any & rRet,
763 sal_Int32 nHandle ) const
765 SolarMutexGuard aGuard;
767 switch( nHandle )
769 case PROPERTY_WORKAREA:
770 rRet <<= awt::Rectangle(
771 maLastVisArea.Left(),
772 maLastVisArea.Top(),
773 maLastVisArea.GetWidth(),
774 maLastVisArea.GetHeight());
775 break;
777 case PROPERTY_SUB_CONTROLLER:
778 rRet <<= mxSubController;
779 break;
781 default:
782 if (mxSubController.is())
783 rRet = mxSubController->getFastPropertyValue(nHandle);
784 break;
788 void DrawController::ProvideFrameworkControllers()
790 SolarMutexGuard aGuard;
793 Reference<XController> xController (this);
794 const Reference<XComponentContext> xContext (
795 ::comphelper::getProcessComponentContext() );
796 mxConfigurationController = ConfigurationController::create(
797 xContext,
798 xController);
799 mxModuleController = ModuleController::create(
800 xContext,
801 xController);
803 catch (const RuntimeException&)
805 mxConfigurationController = nullptr;
806 mxModuleController = nullptr;
810 void DrawController::DisposeFrameworkControllers()
812 Reference<XComponent> xComponent (mxModuleController, UNO_QUERY);
813 if (xComponent.is())
814 xComponent->dispose();
816 xComponent.set(mxConfigurationController, UNO_QUERY);
817 if (xComponent.is())
818 xComponent->dispose();
821 void DrawController::ThrowIfDisposed() const
823 if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing)
825 SAL_WARN("sd", "Calling disposed DrawController object. Throwing exception:");
826 throw lang::DisposedException (
827 "DrawController object has already been disposed",
828 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
832 } // end of namespace sd
834 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */