merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / unoidl / DrawController.cxx
blob09f0db0b0f9e717a0d75e245c6eb7fa0d46fde44
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DrawController.cxx,v $
10 * $Revision: 1.27 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawController.hxx"
36 #include "DrawSubController.hxx"
37 #include "sdpage.hxx"
38 #include "ViewShellBase.hxx"
39 #include "ViewShellManager.hxx"
40 #include "FormShellManager.hxx"
41 #include "Window.hxx"
43 #include <comphelper/anytostring.hxx>
44 #include <comphelper/processfactory.hxx>
45 #include <comphelper/sequence.hxx>
46 #include <comphelper/stl_types.hxx>
47 #include <cppuhelper/exc_hlp.hxx>
48 #include <cppuhelper/bootstrap.hxx>
50 #include <com/sun/star/beans/PropertyAttribute.hpp>
51 #include <com/sun/star/drawing/framework/ConfigurationController.hpp>
52 #include <com/sun/star/drawing/framework/ModuleController.hpp>
53 #include <com/sun/star/lang/XInitialization.hpp>
55 #include "slideshow.hxx"
57 #include <svx/fmshell.hxx>
58 #include <vos/mutex.hxx>
59 #include <vcl/svapp.hxx>
61 using namespace ::std;
62 using ::rtl::OUString;
63 using namespace ::cppu;
64 using namespace ::vos;
65 using namespace ::com::sun::star;
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::drawing::framework;
69 namespace {
70 static const ::com::sun::star::uno::Type saComponentTypeIdentifier (
71 ::getCppuType( (Reference<lang::XEventListener > *)0 ));
72 static const ::com::sun::star::uno::Type saSelectionTypeIdentifier (
73 ::getCppuType( (Reference<view::XSelectionChangeListener > *)0 ));
75 } // end of anonymous namespace
77 namespace sd {
79 DrawController::DrawController (ViewShellBase& rBase) throw()
80 : DrawControllerInterfaceBase(&rBase),
81 BroadcastHelperOwner(SfxBaseController::m_aMutex),
82 OPropertySetHelper( static_cast<OBroadcastHelperVar<
83 OMultiTypeInterfaceContainerHelper,
84 OMultiTypeInterfaceContainerHelper::keyType>& >(
85 BroadcastHelperOwner::maBroadcastHelper)),
86 mpBase(&rBase),
87 maLastVisArea(),
88 mpCurrentPage(NULL),
89 mbMasterPageMode(false),
90 mbLayerMode(false),
91 mbDisposing(false),
92 mpPropertyArrayHelper(NULL),
93 mxSubController(),
94 mxConfigurationController(),
95 mxModuleController()
97 ProvideFrameworkControllers();
103 DrawController::~DrawController (void) throw()
110 void DrawController::SetSubController (
111 const Reference<drawing::XDrawSubController>& rxSubController)
113 // Update the internal state.
114 mxSubController = rxSubController;
115 mpPropertyArrayHelper.reset();
116 maLastVisArea = Rectangle();
118 // Inform listeners about the changed state.
119 FireSelectionChangeListener();
125 // XInterface
127 IMPLEMENT_FORWARD_XINTERFACE2(
128 DrawController,
129 DrawControllerInterfaceBase,
130 OPropertySetHelper);
133 // XTypeProvider
135 Sequence<Type> SAL_CALL DrawController::getTypes (void)
136 throw (::com::sun::star::uno::RuntimeException)
138 ThrowIfDisposed();
139 // OPropertySetHelper does not provide getTypes, so we have to
140 // implement this method manually and list its three interfaces.
141 OTypeCollection aTypeCollection (
142 ::getCppuType (( const Reference<beans::XMultiPropertySet>*)NULL),
143 ::getCppuType (( const Reference<beans::XFastPropertySet>*)NULL),
144 ::getCppuType (( const Reference<beans::XPropertySet>*)NULL));
146 return ::comphelper::concatSequences(
147 SfxBaseController::getTypes(),
148 aTypeCollection.getTypes(),
149 DrawControllerInterfaceBase::getTypes());
152 IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController);
156 // XComponent
159 void SAL_CALL DrawController::dispose (void)
160 throw( RuntimeException )
162 if( !mbDisposing )
164 OGuard aGuard( Application::GetSolarMutex() );
166 if( !mbDisposing )
168 mbDisposing = true;
170 // When the controller has not been detached from its view
171 // shell, i.e. mpViewShell is not NULL, then tell PaneManager
172 // and ViewShellManager to clear the shell stack.
173 if (mxSubController.is() && mpBase!=NULL)
175 mpBase->DisconnectAllClients();
176 mpBase->GetViewShellManager()->Shutdown();
179 OPropertySetHelper::disposing();
181 DisposeFrameworkControllers();
183 SfxBaseController::dispose();
191 void SAL_CALL DrawController::addEventListener(
192 const Reference<lang::XEventListener >& xListener)
193 throw (RuntimeException)
195 ThrowIfDisposed();
196 SfxBaseController::addEventListener( xListener );
202 void SAL_CALL DrawController::removeEventListener (
203 const Reference<lang::XEventListener >& aListener)
204 throw (RuntimeException)
206 if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing)
207 SfxBaseController::removeEventListener( aListener );
210 // XController
211 ::sal_Bool SAL_CALL DrawController::suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException)
213 if( Suspend )
215 ViewShellBase* pViewShellBase = GetViewShellBase();
216 if( pViewShellBase )
218 // do not allow suspend if a slideshow needs this controller!
219 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) );
220 if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) )
221 return sal_False;
225 return SfxBaseController::suspend( Suspend );
229 // XServiceInfo
231 OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException)
233 // Do not throw an excepetion at the moment. This leads to a crash
234 // under Solaris on relead. See issue i70929 for details.
235 // ThrowIfDisposed();
236 return OUString( RTL_CONSTASCII_USTRINGPARAM( "DrawController" ) );
241 static OUString ssServiceName (OUString::createFromAscii(
242 "com.sun.star.drawing.DrawingDocumentDrawView"));
244 sal_Bool SAL_CALL DrawController::supportsService (
245 const OUString& rsServiceName)
246 throw(RuntimeException)
248 // Do not throw an excepetion at the moment. This leads to a crash
249 // under Solaris on relead. See issue i70929 for details.
250 // ThrowIfDisposed();
251 return rsServiceName.equals(ssServiceName);
257 Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void)
258 throw(RuntimeException)
260 ThrowIfDisposed();
261 Sequence<OUString> aSupportedServices (1);
262 OUString* pServices = aSupportedServices.getArray();
263 pServices[0] = ssServiceName;
264 return aSupportedServices;
270 //------ XSelectionSupplier --------------------------------------------
272 sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
273 throw(lang::IllegalArgumentException, RuntimeException)
275 ThrowIfDisposed();
276 ::vos::OGuard aGuard (Application::GetSolarMutex());
278 if (mxSubController.is())
279 return mxSubController->select(aSelection);
280 else
281 return false;
287 Any SAL_CALL DrawController::getSelection()
288 throw(RuntimeException)
290 ThrowIfDisposed();
291 ::vos::OGuard aGuard (Application::GetSolarMutex());
293 if (mxSubController.is())
294 return mxSubController->getSelection();
295 else
296 return Any();
302 void SAL_CALL DrawController::addSelectionChangeListener(
303 const Reference< view::XSelectionChangeListener >& xListener)
304 throw(RuntimeException)
306 if( mbDisposing )
307 throw lang::DisposedException();
309 BroadcastHelperOwner::maBroadcastHelper.addListener (saSelectionTypeIdentifier, xListener);
315 void SAL_CALL DrawController::removeSelectionChangeListener(
316 const Reference< view::XSelectionChangeListener >& xListener )
317 throw(RuntimeException)
319 if (rBHelper.bDisposed)
320 throw lang::DisposedException();
322 BroadcastHelperOwner::maBroadcastHelper.removeListener (saSelectionTypeIdentifier, xListener);
329 //===== lang::XEventListener ================================================
331 void SAL_CALL
332 DrawController::disposing (const lang::EventObject& )
333 throw (uno::RuntimeException)
340 //===== view::XSelectionChangeListener ======================================
342 void SAL_CALL
343 DrawController::selectionChanged (const lang::EventObject& rEvent)
344 throw (uno::RuntimeException)
346 ThrowIfDisposed();
347 // Have to forward the event to our selection change listeners.
348 OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer(
349 ::getCppuType((Reference<view::XSelectionChangeListener>*)0));
350 if (pListeners)
352 // Re-send the event to all of our listeners.
353 OInterfaceIteratorHelper aIterator (*pListeners);
354 while (aIterator.hasMoreElements())
358 view::XSelectionChangeListener* pListener =
359 static_cast<view::XSelectionChangeListener*>(
360 aIterator.next());
361 if (pListener != NULL)
362 pListener->selectionChanged (rEvent);
364 catch (RuntimeException aException)
374 ::awt::Rectangle DrawController::GetVisArea (void) const
376 return awt::Rectangle(
377 maLastVisArea.Left(),
378 maLastVisArea.Top(),
379 maLastVisArea.GetWidth(),
380 maLastVisArea.GetHeight());
386 // XDrawView
388 void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage )
389 throw(RuntimeException)
391 ThrowIfDisposed();
392 ::vos::OGuard aGuard (Application::GetSolarMutex());
394 if (mxSubController.is())
395 mxSubController->setCurrentPage(xPage);
401 Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage (void)
402 throw(RuntimeException)
404 ThrowIfDisposed();
405 ::vos::OGuard aGuard( Application::GetSolarMutex() );
406 Reference<drawing::XDrawPage> xPage;
408 // Get current page from sub controller.
409 if (mxSubController.is())
410 xPage = mxSubController->getCurrentPage();
412 // When there is not yet a sub controller (during initialization) then fall back
413 // to the current page in mpCurrentPage.
414 if ( ! xPage.is() && mpCurrentPage.is())
415 xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY);
417 return xPage;
423 void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw()
425 if( maLastVisArea != rVisArea )
427 Any aNewValue;
428 aNewValue <<= awt::Rectangle(
429 rVisArea.Left(),
430 rVisArea.Top(),
431 rVisArea.GetWidth(),
432 rVisArea.GetHeight() );
434 Any aOldValue;
435 aOldValue <<= awt::Rectangle(
436 maLastVisArea.Left(),
437 maLastVisArea.Top(),
438 maLastVisArea.GetWidth(),
439 maLastVisArea.GetHeight() );
441 FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue);
443 maLastVisArea = rVisArea;
450 void DrawController::FireSelectionChangeListener() throw()
452 OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer(
453 saSelectionTypeIdentifier);
454 if( pLC )
456 Reference< XInterface > xSource( (XWeak*)this );
457 const lang::EventObject aEvent( xSource );
459 // Ueber alle Listener iterieren und Events senden
460 OInterfaceIteratorHelper aIt( *pLC);
461 while( aIt.hasMoreElements() )
465 view::XSelectionChangeListener * pL =
466 static_cast<view::XSelectionChangeListener*>(aIt.next());
467 if (pL != NULL)
468 pL->selectionChanged( aEvent );
470 catch (RuntimeException aException)
480 void DrawController::FireChangeEditMode (bool bMasterPageMode) throw()
482 if (bMasterPageMode != mbMasterPageMode )
484 FirePropertyChange(
485 PROPERTY_MASTERPAGEMODE,
486 makeAny(bMasterPageMode),
487 makeAny(mbMasterPageMode));
489 mbMasterPageMode = bMasterPageMode;
496 void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
498 if (bLayerMode != mbLayerMode)
500 FirePropertyChange(
501 PROPERTY_LAYERMODE,
502 makeAny(bLayerMode),
503 makeAny(mbLayerMode));
505 mbLayerMode = bLayerMode;
512 void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
514 SdrPage* pCurrentPage = mpCurrentPage.get();
515 if (pNewCurrentPage != pCurrentPage)
519 Any aNewValue (
520 makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY)));
522 Any aOldValue;
523 if (pCurrentPage != NULL)
525 Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY);
526 aOldValue <<= xOldPage;
529 FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
531 mpCurrentPage.reset(pNewCurrentPage);
533 catch( uno::Exception& e )
535 (void)e;
536 DBG_ERROR(
537 (::rtl::OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), "
538 "exception caught: ") +
539 ::rtl::OUStringToOString(
540 comphelper::anyToString( cppu::getCaughtException() ),
541 RTL_TEXTENCODING_UTF8 )).getStr() );
549 void DrawController::FirePropertyChange (
550 sal_Int32 nHandle,
551 const Any& rNewValue,
552 const Any& rOldValue)
556 fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False);
558 catch (RuntimeException aException)
560 // Ignore this exception. Exceptions should be handled in the
561 // fire() function so that all listeners are called. This is
562 // not the case at the moment, so we simply ignore the
563 // exception.
571 ViewShellBase* DrawController::GetViewShellBase (void)
573 return mpBase;
579 void DrawController::ReleaseViewShellBase (void)
581 DisposeFrameworkControllers();
582 mpBase = NULL;
588 //===== XControllerManager ==============================================================
590 Reference<XConfigurationController> SAL_CALL
591 DrawController::getConfigurationController (void)
592 throw (RuntimeException)
594 ThrowIfDisposed();
596 return mxConfigurationController;
602 Reference<XModuleController> SAL_CALL
603 DrawController::getModuleController (void)
604 throw (RuntimeException)
606 ThrowIfDisposed();
608 return mxModuleController;
614 //===== XUnoTunnel ============================================================
616 const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void)
618 static ::com::sun::star::uno::Sequence<sal_Int8>* pSequence = NULL;
619 if (pSequence == NULL)
621 ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
622 if (pSequence == NULL)
624 static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
625 rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
626 pSequence = &aSequence;
629 return *pSequence;
635 sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId)
636 throw (RuntimeException)
638 sal_Int64 nResult = 0;
640 if (rId.getLength() == 16
641 && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
643 nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
646 return nResult;
652 //===== Properties ============================================================
654 void DrawController::FillPropertyTable (
655 ::std::vector<beans::Property>& rProperties)
657 rProperties.push_back(
658 beans::Property(
659 OUString( RTL_CONSTASCII_USTRINGPARAM("VisibleArea") ),
660 PROPERTY_WORKAREA,
661 ::getCppuType((const ::com::sun::star::awt::Rectangle*)0),
662 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY));
663 rProperties.push_back(
664 beans::Property(
665 OUString( RTL_CONSTASCII_USTRINGPARAM("SubController") ),
666 PROPERTY_SUB_CONTROLLER,
667 ::getCppuType((const Reference<drawing::XDrawSubController>*)0),
668 beans::PropertyAttribute::BOUND));
669 rProperties.push_back(
670 beans::Property(
671 OUString( RTL_CONSTASCII_USTRINGPARAM("CurrentPage") ),
672 PROPERTY_CURRENTPAGE,
673 ::getCppuType((const Reference< drawing::XDrawPage > *)0),
674 beans::PropertyAttribute::BOUND ));
675 rProperties.push_back(
676 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsLayerMode") ),
677 PROPERTY_LAYERMODE,
678 ::getCppuBooleanType(),
679 beans::PropertyAttribute::BOUND ));
680 rProperties.push_back(
681 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode") ),
682 PROPERTY_MASTERPAGEMODE,
683 ::getCppuBooleanType(),
684 beans::PropertyAttribute::BOUND ));
685 rProperties.push_back(
686 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ActiveLayer") ),
687 PROPERTY_ACTIVE_LAYER,
688 ::getCppuBooleanType(),
689 beans::PropertyAttribute::BOUND ));
690 rProperties.push_back(
691 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomValue") ),
692 PROPERTY_ZOOMVALUE,
693 ::getCppuType((const sal_Int16*)0),
694 beans::PropertyAttribute::BOUND ));
695 rProperties.push_back(
696 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomType") ),
697 PROPERTY_ZOOMTYPE,
698 ::getCppuType((const sal_Int16*)0),
699 beans::PropertyAttribute::BOUND ));
700 rProperties.push_back(
701 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOffset") ),
702 PROPERTY_VIEWOFFSET,
703 ::getCppuType((const ::com::sun::star::awt::Point*)0),
704 beans::PropertyAttribute::BOUND ));
710 IPropertyArrayHelper & DrawController::getInfoHelper()
712 OGuard aGuard( Application::GetSolarMutex() );
714 if (mpPropertyArrayHelper.get() == NULL)
716 ::std::vector<beans::Property> aProperties;
717 FillPropertyTable (aProperties);
718 Sequence<beans::Property> aPropertySequence (aProperties.size());
719 for (unsigned int i=0; i<aProperties.size(); i++)
720 aPropertySequence[i] = aProperties[i];
721 mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False));
724 return *mpPropertyArrayHelper.get();
730 Reference < beans::XPropertySetInfo > DrawController::getPropertySetInfo()
731 throw ( ::com::sun::star::uno::RuntimeException)
733 ::vos::OGuard aGuard( Application::GetSolarMutex() );
735 static Reference < beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
736 return xInfo;
740 uno::Reference< form::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException)
742 OGuard aGuard( Application::GetSolarMutex() );
744 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
745 SdrView* pSdrView = mpBase->GetDrawView();
746 ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
747 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
749 uno::Reference< form::XFormController > xController( NULL );
750 if ( pFormShell && pSdrView && pWindow )
751 xController = pFormShell->GetFormController( Form, *pSdrView, *pWindow );
752 return xController;
755 ::sal_Bool SAL_CALL DrawController::isFormDesignMode( ) throw (uno::RuntimeException)
757 OGuard aGuard( Application::GetSolarMutex() );
759 sal_Bool bIsDesignMode = sal_True;
761 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
762 if ( pFormShell )
763 bIsDesignMode = pFormShell->IsDesignMode();
765 return bIsDesignMode;
768 void SAL_CALL DrawController::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException)
770 OGuard aGuard( Application::GetSolarMutex() );
772 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
773 if ( pFormShell )
774 pFormShell->SetDesignMode( _DesignMode );
777 uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException)
779 OGuard aGuard( Application::GetSolarMutex() );
781 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
782 SdrView* pSdrView = mpBase->GetDrawView();
783 ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
784 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
786 uno::Reference< awt::XControl > xControl( NULL );
787 if ( pFormShell && pSdrView && pWindow )
788 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl );
789 return xControl;
795 sal_Bool DrawController::convertFastPropertyValue (
796 Any & rConvertedValue,
797 Any & rOldValue,
798 sal_Int32 nHandle,
799 const Any& rValue)
800 throw ( com::sun::star::lang::IllegalArgumentException)
802 sal_Bool bResult = sal_False;
804 if (nHandle == PROPERTY_SUB_CONTROLLER)
806 rOldValue <<= mxSubController;
807 rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY);
808 bResult = (rOldValue != rConvertedValue);
810 else if (mxSubController.is())
812 rConvertedValue = rValue;
813 rOldValue = mxSubController->getFastPropertyValue(nHandle);
814 bResult = (rOldValue != rConvertedValue);
815 /* bResult = mpSubController->convertFastPropertyValue(
816 rConvertedValue,
817 rOldValue,
818 nHandle,
819 rValue);
823 return bResult;
829 void DrawController::setFastPropertyValue_NoBroadcast (
830 sal_Int32 nHandle,
831 const Any& rValue)
832 throw ( com::sun::star::uno::Exception)
834 OGuard aGuard( Application::GetSolarMutex() );
835 if (nHandle == PROPERTY_SUB_CONTROLLER)
836 SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY));
837 else if (mxSubController.is())
838 mxSubController->setFastPropertyValue(nHandle, rValue);
844 void DrawController::getFastPropertyValue (
845 Any & rRet,
846 sal_Int32 nHandle ) const
848 OGuard aGuard( Application::GetSolarMutex() );
850 switch( nHandle )
852 case PROPERTY_WORKAREA:
853 rRet <<= awt::Rectangle(
854 maLastVisArea.Left(),
855 maLastVisArea.Top(),
856 maLastVisArea.GetWidth(),
857 maLastVisArea.GetHeight());
858 break;
860 case PROPERTY_SUB_CONTROLLER:
861 rRet <<= mxSubController;
862 break;
864 default:
865 if (mxSubController.is())
866 rRet = mxSubController->getFastPropertyValue(nHandle);
867 break;
874 //-----------------------------------------------------------------------------
876 void DrawController::ProvideFrameworkControllers (void)
878 ::vos::OGuard aGuard (Application::GetSolarMutex());
881 Reference<XController> xController (this);
882 const Reference<XComponentContext> xContext (
883 ::comphelper::getProcessComponentContext() );
884 mxConfigurationController = ConfigurationController::create(
885 xContext,
886 xController);
887 mxModuleController = ModuleController::create(
888 xContext,
889 xController);
891 catch (RuntimeException&)
893 mxConfigurationController = NULL;
894 mxModuleController = NULL;
901 void DrawController::DisposeFrameworkControllers (void)
903 Reference<XComponent> xComponent (mxModuleController, UNO_QUERY);
904 if (xComponent.is())
905 xComponent->dispose();
907 xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY);
908 if (xComponent.is())
909 xComponent->dispose();
915 void DrawController::ThrowIfDisposed (void) const
916 throw (::com::sun::star::lang::DisposedException)
918 if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing)
920 OSL_TRACE ("Calling disposed DrawController object. Throwing exception:");
921 throw lang::DisposedException (
922 OUString(RTL_CONSTASCII_USTRINGPARAM(
923 "DrawController object has already been disposed")),
924 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
932 } // end of namespace sd