bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / unoidl / DrawController.cxx
blobe71a0fa4ff39e080289e11dfc4a23168ba4b2496
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 .
21 #include "DrawController.hxx"
22 #include "DrawDocShell.hxx"
24 #include "DrawSubController.hxx"
25 #include "sdpage.hxx"
26 #include "ViewShellBase.hxx"
27 #include "ViewShellManager.hxx"
28 #include "FormShellManager.hxx"
29 #include "Window.hxx"
31 #include <comphelper/anytostring.hxx>
32 #include <comphelper/processfactory.hxx>
33 #include <comphelper/sequence.hxx>
34 #include <comphelper/stl_types.hxx>
35 #include <comphelper/servicehelper.hxx>
36 #include <cppuhelper/exc_hlp.hxx>
37 #include <cppuhelper/bootstrap.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/lang/XInitialization.hpp>
44 #include "slideshow.hxx"
46 #include <svx/fmshell.hxx>
47 #include <osl/mutex.hxx>
48 #include <vcl/svapp.hxx>
49 #include <sfx2/sidebar/EnumContext.hxx>
50 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
52 #include <boost/shared_ptr.hpp>
54 using namespace ::std;
55 using namespace ::cppu;
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::drawing::framework;
59 using ::sfx2::sidebar::EnumContext;
61 namespace sd {
63 DrawController::DrawController (ViewShellBase& rBase) throw()
64 : DrawControllerInterfaceBase(&rBase),
65 BroadcastHelperOwner(SfxBaseController::m_aMutex),
66 OPropertySetHelper( static_cast<OBroadcastHelperVar<
67 OMultiTypeInterfaceContainerHelper,
68 OMultiTypeInterfaceContainerHelper::keyType>& >(
69 BroadcastHelperOwner::maBroadcastHelper)),
70 m_aSelectionTypeIdentifier(
71 ::getCppuType( (Reference<view::XSelectionChangeListener > *)0 )),
72 mpBase(&rBase),
73 maLastVisArea(),
74 mpCurrentPage(NULL),
75 mbMasterPageMode(false),
76 mbLayerMode(false),
77 mbDisposing(false),
78 mpPropertyArrayHelper(NULL),
79 mxSubController(),
80 mxConfigurationController(),
81 mxModuleController()
83 ProvideFrameworkControllers();
89 DrawController::~DrawController (void) throw()
96 void DrawController::SetSubController (
97 const Reference<drawing::XDrawSubController>& rxSubController)
99 // Update the internal state.
100 mxSubController = rxSubController;
101 mpPropertyArrayHelper.reset();
102 maLastVisArea = Rectangle();
104 // Inform listeners about the changed state.
105 FireSelectionChangeListener();
111 // XInterface
113 IMPLEMENT_FORWARD_XINTERFACE2(
114 DrawController,
115 DrawControllerInterfaceBase,
116 OPropertySetHelper);
119 // XTypeProvider
121 Sequence<Type> SAL_CALL DrawController::getTypes (void)
122 throw (::com::sun::star::uno::RuntimeException)
124 ThrowIfDisposed();
125 // OPropertySetHelper does not provide getTypes, so we have to
126 // implement this method manually and list its three interfaces.
127 OTypeCollection aTypeCollection (
128 ::getCppuType (( const Reference<beans::XMultiPropertySet>*)NULL),
129 ::getCppuType (( const Reference<beans::XFastPropertySet>*)NULL),
130 ::getCppuType (( const Reference<beans::XPropertySet>*)NULL));
132 return ::comphelper::concatSequences(
133 SfxBaseController::getTypes(),
134 aTypeCollection.getTypes(),
135 DrawControllerInterfaceBase::getTypes());
138 IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController);
142 // XComponent
145 void SAL_CALL DrawController::dispose (void)
146 throw( RuntimeException )
148 if( !mbDisposing )
150 SolarMutexGuard aGuard;
152 if( !mbDisposing )
154 mbDisposing = true;
156 boost::shared_ptr<ViewShell> pViewShell;
157 if (mpBase)
158 pViewShell = mpBase->GetMainViewShell();
159 if ( pViewShell )
161 pViewShell->DeactivateCurrentFunction();
162 DrawDocShell* pDocShell = pViewShell->GetDocSh();
163 if ( pDocShell != NULL )
164 pDocShell->SetDocShellFunction(0);
166 pViewShell.reset();
168 // When the controller has not been detached from its view
169 // shell, i.e. mpViewShell is not NULL, then tell PaneManager
170 // and ViewShellManager to clear the shell stack.
171 if (mxSubController.is() && mpBase!=NULL)
173 mpBase->DisconnectAllClients();
174 mpBase->GetViewShellManager()->Shutdown();
177 OPropertySetHelper::disposing();
179 DisposeFrameworkControllers();
181 SfxBaseController::dispose();
189 void SAL_CALL DrawController::addEventListener(
190 const Reference<lang::XEventListener >& xListener)
191 throw (RuntimeException)
193 ThrowIfDisposed();
194 SfxBaseController::addEventListener( xListener );
200 void SAL_CALL DrawController::removeEventListener (
201 const Reference<lang::XEventListener >& aListener)
202 throw (RuntimeException)
204 if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing)
205 SfxBaseController::removeEventListener( aListener );
208 // XController
209 ::sal_Bool SAL_CALL DrawController::suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException)
211 if( Suspend )
213 ViewShellBase* pViewShellBase = GetViewShellBase();
214 if( pViewShellBase )
216 // do not allow suspend if a slideshow needs this controller!
217 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) );
218 if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) )
219 return sal_False;
223 return SfxBaseController::suspend( Suspend );
227 // XServiceInfo
229 OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException)
231 // Do not throw an excepetion at the moment. This leads to a crash
232 // under Solaris on relead. See issue i70929 for details.
233 // ThrowIfDisposed();
234 return OUString("DrawController") ;
239 static OUString ssServiceName( "com.sun.star.drawing.DrawingDocumentDrawView");
241 sal_Bool SAL_CALL DrawController::supportsService (
242 const OUString& rsServiceName)
243 throw(RuntimeException)
245 // Do not throw an exception at the moment. This leads to a crash
246 // under Solaris on relead. See issue i70929 for details.
247 // ThrowIfDisposed();
248 return rsServiceName.equals(ssServiceName);
254 Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void)
255 throw(RuntimeException)
257 ThrowIfDisposed();
258 Sequence<OUString> aSupportedServices (1);
259 OUString* pServices = aSupportedServices.getArray();
260 pServices[0] = ssServiceName;
261 return aSupportedServices;
267 //------ XSelectionSupplier --------------------------------------------
269 sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
270 throw(lang::IllegalArgumentException, RuntimeException)
272 ThrowIfDisposed();
273 SolarMutexGuard aGuard;
275 if (mxSubController.is())
276 return mxSubController->select(aSelection);
277 else
278 return false;
284 Any SAL_CALL DrawController::getSelection()
285 throw(RuntimeException)
287 ThrowIfDisposed();
288 SolarMutexGuard aGuard;
290 if (mxSubController.is())
291 return mxSubController->getSelection();
292 else
293 return Any();
299 void SAL_CALL DrawController::addSelectionChangeListener(
300 const Reference< view::XSelectionChangeListener >& xListener)
301 throw(RuntimeException)
303 if( mbDisposing )
304 throw lang::DisposedException();
306 BroadcastHelperOwner::maBroadcastHelper.addListener (m_aSelectionTypeIdentifier, xListener);
312 void SAL_CALL DrawController::removeSelectionChangeListener(
313 const Reference< view::XSelectionChangeListener >& xListener )
314 throw(RuntimeException)
316 if (rBHelper.bDisposed)
317 throw lang::DisposedException();
319 BroadcastHelperOwner::maBroadcastHelper.removeListener (m_aSelectionTypeIdentifier, xListener);
326 //===== lang::XEventListener ================================================
328 void SAL_CALL
329 DrawController::disposing (const lang::EventObject& )
330 throw (uno::RuntimeException)
337 //===== view::XSelectionChangeListener ======================================
339 void SAL_CALL
340 DrawController::selectionChanged (const lang::EventObject& rEvent)
341 throw (uno::RuntimeException)
343 ThrowIfDisposed();
344 // Have to forward the event to our selection change listeners.
345 OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer(
346 ::getCppuType((Reference<view::XSelectionChangeListener>*)0));
347 if (pListeners)
349 // Re-send the event to all of our listeners.
350 OInterfaceIteratorHelper aIterator (*pListeners);
351 while (aIterator.hasMoreElements())
355 view::XSelectionChangeListener* pListener =
356 static_cast<view::XSelectionChangeListener*>(
357 aIterator.next());
358 if (pListener != NULL)
359 pListener->selectionChanged (rEvent);
361 catch (const RuntimeException&)
371 // XDrawView
373 void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage )
374 throw(RuntimeException)
376 ThrowIfDisposed();
377 SolarMutexGuard aGuard;
379 if (mxSubController.is())
380 mxSubController->setCurrentPage(xPage);
386 Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage (void)
387 throw(RuntimeException)
389 ThrowIfDisposed();
390 SolarMutexGuard aGuard;
391 Reference<drawing::XDrawPage> xPage;
393 // Get current page from sub controller.
394 if (mxSubController.is())
395 xPage = mxSubController->getCurrentPage();
397 // When there is not yet a sub controller (during initialization) then fall back
398 // to the current page in mpCurrentPage.
399 if ( ! xPage.is() && mpCurrentPage.is())
400 xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY);
402 return xPage;
408 void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw()
410 if( maLastVisArea != rVisArea )
412 Any aNewValue;
413 aNewValue <<= awt::Rectangle(
414 rVisArea.Left(),
415 rVisArea.Top(),
416 rVisArea.GetWidth(),
417 rVisArea.GetHeight() );
419 Any aOldValue;
420 aOldValue <<= awt::Rectangle(
421 maLastVisArea.Left(),
422 maLastVisArea.Top(),
423 maLastVisArea.GetWidth(),
424 maLastVisArea.GetHeight() );
426 FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue);
428 maLastVisArea = rVisArea;
435 void DrawController::FireSelectionChangeListener() throw()
437 OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer(
438 m_aSelectionTypeIdentifier);
439 if( pLC )
441 Reference< XInterface > xSource( (XWeak*)this );
442 const lang::EventObject aEvent( xSource );
444 // iterate over all listeners and send events
445 OInterfaceIteratorHelper aIt( *pLC);
446 while( aIt.hasMoreElements() )
450 view::XSelectionChangeListener * pL =
451 static_cast<view::XSelectionChangeListener*>(aIt.next());
452 if (pL != NULL)
453 pL->selectionChanged( aEvent );
455 catch (const RuntimeException&)
465 void DrawController::FireChangeEditMode (bool bMasterPageMode) throw()
467 if (bMasterPageMode != mbMasterPageMode )
469 FirePropertyChange(
470 PROPERTY_MASTERPAGEMODE,
471 makeAny(bMasterPageMode),
472 makeAny(mbMasterPageMode));
474 mbMasterPageMode = bMasterPageMode;
481 void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
483 if (bLayerMode != mbLayerMode)
485 FirePropertyChange(
486 PROPERTY_LAYERMODE,
487 makeAny(bLayerMode),
488 makeAny(mbLayerMode));
490 mbLayerMode = bLayerMode;
497 void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
499 SdrPage* pCurrentPage = mpCurrentPage.get();
500 if (pNewCurrentPage != pCurrentPage)
504 Any aNewValue (
505 makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY)));
507 Any aOldValue;
508 if (pCurrentPage != NULL)
510 Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY);
511 aOldValue <<= xOldPage;
514 FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
516 mpCurrentPage.reset(pNewCurrentPage);
518 catch (const uno::Exception&)
520 OSL_FAIL(
521 OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), exception caught: " +
522 OUStringToOString(
523 comphelper::anyToString( cppu::getCaughtException() ),
524 RTL_TEXTENCODING_UTF8 )).getStr() );
532 void DrawController::FirePropertyChange (
533 sal_Int32 nHandle,
534 const Any& rNewValue,
535 const Any& rOldValue)
539 fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False);
541 catch (const RuntimeException&)
543 // Ignore this exception. Exceptions should be handled in the
544 // fire() function so that all listeners are called. This is
545 // not the case at the moment, so we simply ignore the
546 // exception.
554 void DrawController::BroadcastContextChange (void) const
556 ::boost::shared_ptr<ViewShell> pViewShell (mpBase->GetMainViewShell());
557 if ( ! pViewShell)
558 return;
560 EnumContext::Context eContext (EnumContext::Context_Unknown);
561 switch (pViewShell->GetShellType())
563 case ViewShell::ST_IMPRESS:
564 case ViewShell::ST_DRAW:
565 if (mbMasterPageMode)
566 eContext = EnumContext::Context_MasterPage;
567 else
568 eContext = EnumContext::Context_DrawPage;
569 break;
571 case ViewShell::ST_NOTES:
572 eContext = EnumContext::Context_NotesPage;
573 break;
575 case ViewShell::ST_HANDOUT:
576 eContext = EnumContext::Context_HandoutPage;
577 break;
579 case ViewShell::ST_OUTLINE:
580 eContext = EnumContext::Context_OutlineText;
581 break;
583 case ViewShell::ST_SLIDE_SORTER:
584 eContext = EnumContext::Context_SlidesorterPage;
585 break;
587 case ViewShell::ST_PRESENTATION:
588 case ViewShell::ST_NONE:
589 default:
590 eContext = EnumContext::Context_Empty;
591 break;
594 ContextChangeEventMultiplexer::NotifyContextChange(mpBase, eContext);
600 ViewShellBase* DrawController::GetViewShellBase (void)
602 return mpBase;
608 void DrawController::ReleaseViewShellBase (void)
610 DisposeFrameworkControllers();
611 mpBase = NULL;
617 //===== XControllerManager ==============================================================
619 Reference<XConfigurationController> SAL_CALL
620 DrawController::getConfigurationController (void)
621 throw (RuntimeException)
623 ThrowIfDisposed();
625 return mxConfigurationController;
631 Reference<XModuleController> SAL_CALL
632 DrawController::getModuleController (void)
633 throw (RuntimeException)
635 ThrowIfDisposed();
637 return mxModuleController;
643 //===== XUnoTunnel ============================================================
645 namespace
647 class theDrawControllerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theDrawControllerUnoTunnelId> {};
650 const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void)
652 return theDrawControllerUnoTunnelId::get().getSeq();
658 sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId)
659 throw (RuntimeException)
661 sal_Int64 nResult = 0;
663 if (rId.getLength() == 16
664 && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
666 nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
669 return nResult;
675 //===== Properties ============================================================
677 void DrawController::FillPropertyTable (
678 ::std::vector<beans::Property>& rProperties)
680 rProperties.push_back(
681 beans::Property("VisibleArea",
682 PROPERTY_WORKAREA,
683 ::getCppuType((const ::com::sun::star::awt::Rectangle*)0),
684 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY));
685 rProperties.push_back(
686 beans::Property(
687 "SubController",
688 PROPERTY_SUB_CONTROLLER,
689 ::getCppuType((const Reference<drawing::XDrawSubController>*)0),
690 beans::PropertyAttribute::BOUND));
691 rProperties.push_back(
692 beans::Property(
693 "CurrentPage",
694 PROPERTY_CURRENTPAGE,
695 ::getCppuType((const Reference< drawing::XDrawPage > *)0),
696 beans::PropertyAttribute::BOUND ));
697 rProperties.push_back(
698 beans::Property("IsLayerMode",
699 PROPERTY_LAYERMODE,
700 ::getCppuBooleanType(),
701 beans::PropertyAttribute::BOUND ));
702 rProperties.push_back(
703 beans::Property("IsMasterPageMode",
704 PROPERTY_MASTERPAGEMODE,
705 ::getCppuBooleanType(),
706 beans::PropertyAttribute::BOUND ));
707 rProperties.push_back(
708 beans::Property("ActiveLayer",
709 PROPERTY_ACTIVE_LAYER,
710 ::getCppuBooleanType(),
711 beans::PropertyAttribute::BOUND ));
712 rProperties.push_back(
713 beans::Property("ZoomValue",
714 PROPERTY_ZOOMVALUE,
715 ::getCppuType((const sal_Int16*)0),
716 beans::PropertyAttribute::BOUND ));
717 rProperties.push_back(
718 beans::Property("ZoomType",
719 PROPERTY_ZOOMTYPE,
720 ::getCppuType((const sal_Int16*)0),
721 beans::PropertyAttribute::BOUND ));
722 rProperties.push_back(
723 beans::Property("ViewOffset",
724 PROPERTY_VIEWOFFSET,
725 ::getCppuType((const ::com::sun::star::awt::Point*)0),
726 beans::PropertyAttribute::BOUND ));
727 rProperties.push_back(
728 beans::Property("DrawViewMode",
729 PROPERTY_DRAWVIEWMODE,
730 ::getCppuType((const ::com::sun::star::awt::Point*)0),
731 beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID ));
737 IPropertyArrayHelper & DrawController::getInfoHelper()
739 SolarMutexGuard aGuard;
741 if (mpPropertyArrayHelper.get() == NULL)
743 ::std::vector<beans::Property> aProperties;
744 FillPropertyTable (aProperties);
745 Sequence<beans::Property> aPropertySequence (aProperties.size());
746 for (unsigned int i=0; i<aProperties.size(); i++)
747 aPropertySequence[i] = aProperties[i];
748 mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False));
751 return *mpPropertyArrayHelper.get();
757 Reference < beans::XPropertySetInfo > DrawController::getPropertySetInfo()
758 throw ( ::com::sun::star::uno::RuntimeException)
760 SolarMutexGuard aGuard;
762 static Reference < beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
763 return xInfo;
767 uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException)
769 SolarMutexGuard aGuard;
771 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
772 SdrView* pSdrView = mpBase->GetDrawView();
773 ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
774 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
776 uno::Reference< form::runtime::XFormController > xController( NULL );
777 if ( pFormShell && pSdrView && pWindow )
778 xController = pFormShell->GetFormController( Form, *pSdrView, *pWindow );
779 return xController;
782 ::sal_Bool SAL_CALL DrawController::isFormDesignMode( ) throw (uno::RuntimeException)
784 SolarMutexGuard aGuard;
786 sal_Bool bIsDesignMode = sal_True;
788 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
789 if ( pFormShell )
790 bIsDesignMode = pFormShell->IsDesignMode();
792 return bIsDesignMode;
795 void SAL_CALL DrawController::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException)
797 SolarMutexGuard aGuard;
799 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
800 if ( pFormShell )
801 pFormShell->SetDesignMode( _DesignMode );
804 uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException)
806 SolarMutexGuard aGuard;
808 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
809 SdrView* pSdrView = mpBase->GetDrawView();
810 ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
811 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
813 uno::Reference< awt::XControl > xControl( NULL );
814 if ( pFormShell && pSdrView && pWindow )
815 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl );
816 return xControl;
822 sal_Bool DrawController::convertFastPropertyValue (
823 Any & rConvertedValue,
824 Any & rOldValue,
825 sal_Int32 nHandle,
826 const Any& rValue)
827 throw ( com::sun::star::lang::IllegalArgumentException)
829 sal_Bool bResult = sal_False;
831 if (nHandle == PROPERTY_SUB_CONTROLLER)
833 rOldValue <<= mxSubController;
834 rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY);
835 bResult = (rOldValue != rConvertedValue);
837 else if (mxSubController.is())
839 rConvertedValue = rValue;
842 rOldValue = mxSubController->getFastPropertyValue(nHandle);
843 bResult = (rOldValue != rConvertedValue);
845 catch (const beans::UnknownPropertyException&)
847 // The property is unknown and thus an illegal argument to this method.
848 throw com::sun::star::lang::IllegalArgumentException();
852 return bResult;
858 void DrawController::setFastPropertyValue_NoBroadcast (
859 sal_Int32 nHandle,
860 const Any& rValue)
861 throw ( com::sun::star::uno::Exception)
863 SolarMutexGuard aGuard;
864 if (nHandle == PROPERTY_SUB_CONTROLLER)
865 SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY));
866 else if (mxSubController.is())
867 mxSubController->setFastPropertyValue(nHandle, rValue);
873 void DrawController::getFastPropertyValue (
874 Any & rRet,
875 sal_Int32 nHandle ) const
877 SolarMutexGuard aGuard;
879 switch( nHandle )
881 case PROPERTY_WORKAREA:
882 rRet <<= awt::Rectangle(
883 maLastVisArea.Left(),
884 maLastVisArea.Top(),
885 maLastVisArea.GetWidth(),
886 maLastVisArea.GetHeight());
887 break;
889 case PROPERTY_SUB_CONTROLLER:
890 rRet <<= mxSubController;
891 break;
893 default:
894 if (mxSubController.is())
895 rRet = mxSubController->getFastPropertyValue(nHandle);
896 break;
903 //-----------------------------------------------------------------------------
905 void DrawController::ProvideFrameworkControllers (void)
907 SolarMutexGuard aGuard;
910 Reference<XController> xController (this);
911 const Reference<XComponentContext> xContext (
912 ::comphelper::getProcessComponentContext() );
913 mxConfigurationController = ConfigurationController::create(
914 xContext,
915 xController);
916 mxModuleController = ModuleController::create(
917 xContext,
918 xController);
920 catch (const RuntimeException&)
922 mxConfigurationController = NULL;
923 mxModuleController = NULL;
930 void DrawController::DisposeFrameworkControllers (void)
932 Reference<XComponent> xComponent (mxModuleController, UNO_QUERY);
933 if (xComponent.is())
934 xComponent->dispose();
936 xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY);
937 if (xComponent.is())
938 xComponent->dispose();
944 void DrawController::ThrowIfDisposed (void) const
945 throw (::com::sun::star::lang::DisposedException)
947 if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing)
949 OSL_TRACE ("Calling disposed DrawController object. Throwing exception:");
950 throw lang::DisposedException (
951 "DrawController object has already been disposed",
952 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
960 } // end of namespace sd
963 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */