LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - DrawController.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 375 0.0 %
Date: 2014-04-14 Functions: 0 55 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      21             : #include "DrawController.hxx"
      22             : #include "DrawDocShell.hxx"
      23             : 
      24             : #include "DrawSubController.hxx"
      25             : #include "sdpage.hxx"
      26             : #include "ViewShellBase.hxx"
      27             : #include "ViewShellManager.hxx"
      28             : #include "FormShellManager.hxx"
      29             : #include "Window.hxx"
      30             : 
      31             : #include <comphelper/anytostring.hxx>
      32             : #include <comphelper/processfactory.hxx>
      33             : #include <comphelper/sequence.hxx>
      34             : #include <comphelper/servicehelper.hxx>
      35             : #include <cppuhelper/exc_hlp.hxx>
      36             : #include <cppuhelper/bootstrap.hxx>
      37             : #include <cppuhelper/supportsservice.hxx>
      38             : 
      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>
      43             : 
      44             : #include "slideshow.hxx"
      45             : 
      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>
      51             : 
      52             : #include <boost/shared_ptr.hpp>
      53             : 
      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;
      60             : 
      61             : namespace sd {
      62             : 
      63           0 : 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           0 :         ::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           0 :       mxModuleController()
      82             : {
      83           0 :     ProvideFrameworkControllers();
      84           0 : }
      85             : 
      86             : 
      87             : 
      88             : 
      89           0 : DrawController::~DrawController (void) throw()
      90             : {
      91           0 : }
      92             : 
      93             : 
      94             : 
      95             : 
      96           0 : void DrawController::SetSubController (
      97             :     const Reference<drawing::XDrawSubController>& rxSubController)
      98             : {
      99             :     // Update the internal state.
     100           0 :     mxSubController = rxSubController;
     101           0 :     mpPropertyArrayHelper.reset();
     102           0 :     maLastVisArea = Rectangle();
     103             : 
     104             :     // Inform listeners about the changed state.
     105           0 :     FireSelectionChangeListener();
     106           0 : }
     107             : 
     108             : 
     109             : 
     110             : 
     111             : // XInterface
     112             : 
     113           0 : IMPLEMENT_FORWARD_XINTERFACE2(
     114             :     DrawController,
     115             :     DrawControllerInterfaceBase,
     116             :     OPropertySetHelper);
     117             : 
     118             : 
     119             : // XTypeProvider
     120             : 
     121           0 : Sequence<Type> SAL_CALL DrawController::getTypes (void)
     122             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     123             : {
     124           0 :     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           0 :         ::getCppuType (( const Reference<beans::XMultiPropertySet>*)NULL),
     129           0 :         ::getCppuType (( const Reference<beans::XFastPropertySet>*)NULL),
     130           0 :         ::getCppuType (( const Reference<beans::XPropertySet>*)NULL));
     131             : 
     132             :     return ::comphelper::concatSequences(
     133             :         SfxBaseController::getTypes(),
     134             :         aTypeCollection.getTypes(),
     135           0 :         DrawControllerInterfaceBase::getTypes());
     136             : }
     137             : 
     138           0 : IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController);
     139             : 
     140             : 
     141             : 
     142             : // XComponent
     143             : 
     144             : 
     145           0 : void SAL_CALL DrawController::dispose (void)
     146             :     throw( RuntimeException, std::exception )
     147             : {
     148           0 :     if( !mbDisposing )
     149             :     {
     150           0 :         SolarMutexGuard aGuard;
     151             : 
     152           0 :         if( !mbDisposing )
     153             :         {
     154           0 :             mbDisposing = true;
     155             : 
     156           0 :             boost::shared_ptr<ViewShell> pViewShell;
     157           0 :             if (mpBase)
     158           0 :                 pViewShell = mpBase->GetMainViewShell();
     159           0 :             if ( pViewShell )
     160             :             {
     161           0 :                 pViewShell->DeactivateCurrentFunction();
     162           0 :                 DrawDocShell* pDocShell = pViewShell->GetDocSh();
     163           0 :                 if ( pDocShell != NULL )
     164           0 :                     pDocShell->SetDocShellFunction(0);
     165             :             }
     166           0 :             pViewShell.reset();
     167             : 
     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           0 :             if (mxSubController.is() && mpBase!=NULL)
     172             :             {
     173           0 :                 mpBase->DisconnectAllClients();
     174           0 :                 mpBase->GetViewShellManager()->Shutdown();
     175             :             }
     176             : 
     177           0 :             OPropertySetHelper::disposing();
     178             : 
     179           0 :             DisposeFrameworkControllers();
     180             : 
     181           0 :             SfxBaseController::dispose();
     182           0 :         }
     183             :     }
     184           0 : }
     185             : 
     186             : 
     187             : 
     188             : 
     189           0 : void SAL_CALL DrawController::addEventListener(
     190             :     const Reference<lang::XEventListener >& xListener)
     191             :     throw (RuntimeException, std::exception)
     192             : {
     193           0 :     ThrowIfDisposed();
     194           0 :     SfxBaseController::addEventListener( xListener );
     195           0 : }
     196             : 
     197             : 
     198             : 
     199             : 
     200           0 : void SAL_CALL DrawController::removeEventListener (
     201             :     const Reference<lang::XEventListener >& aListener)
     202             :     throw (RuntimeException, std::exception)
     203             : {
     204           0 :     if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing)
     205           0 :         SfxBaseController::removeEventListener( aListener );
     206           0 : }
     207             : 
     208             : // XController
     209           0 : sal_Bool SAL_CALL DrawController::suspend( sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     210             : {
     211           0 :     if( Suspend )
     212             :     {
     213           0 :         ViewShellBase* pViewShellBase = GetViewShellBase();
     214           0 :         if( pViewShellBase )
     215             :         {
     216             :             // do not allow suspend if a slideshow needs this controller!
     217           0 :             rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) );
     218           0 :             if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) )
     219           0 :                 return sal_False;
     220             :         }
     221             :     }
     222             : 
     223           0 :     return SfxBaseController::suspend( Suspend );
     224             : }
     225             : 
     226             : // XServiceInfo
     227           0 : OUString SAL_CALL DrawController::getImplementationName(  ) throw(RuntimeException, std::exception)
     228             : {
     229             :     // Do not throw an excepetion at the moment.  This leads to a crash
     230             :     // under Solaris on relead.  See issue i70929 for details.
     231             :     //    ThrowIfDisposed();
     232           0 :     return OUString("DrawController") ;
     233             : }
     234             : 
     235           0 : static OUString ssServiceName( "com.sun.star.drawing.DrawingDocumentDrawView");
     236             : 
     237           0 : sal_Bool SAL_CALL DrawController::supportsService (const OUString& rsServiceName)
     238             :     throw(RuntimeException, std::exception)
     239             : {
     240           0 :     return cppu::supportsService(this, rsServiceName);
     241             : }
     242             : 
     243           0 : Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void)
     244             :     throw(RuntimeException, std::exception)
     245             : {
     246           0 :     ThrowIfDisposed();
     247           0 :     Sequence<OUString> aSupportedServices (1);
     248           0 :     OUString* pServices = aSupportedServices.getArray();
     249           0 :     pServices[0] = ssServiceName;
     250           0 :     return aSupportedServices;
     251             : }
     252             : 
     253             : //------ XSelectionSupplier --------------------------------------------
     254           0 : sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
     255             :     throw(lang::IllegalArgumentException, RuntimeException, std::exception)
     256             : {
     257           0 :     ThrowIfDisposed();
     258           0 :     SolarMutexGuard aGuard;
     259             : 
     260           0 :     if (mxSubController.is())
     261           0 :         return mxSubController->select(aSelection);
     262             :     else
     263           0 :         return false;
     264             : }
     265             : 
     266             : 
     267             : 
     268             : 
     269           0 : Any SAL_CALL DrawController::getSelection()
     270             :     throw(RuntimeException, std::exception)
     271             : {
     272           0 :     ThrowIfDisposed();
     273           0 :     SolarMutexGuard aGuard;
     274             : 
     275           0 :     if (mxSubController.is())
     276           0 :         return mxSubController->getSelection();
     277             :     else
     278           0 :         return Any();
     279             : }
     280             : 
     281             : 
     282             : 
     283             : 
     284           0 : void SAL_CALL DrawController::addSelectionChangeListener(
     285             :     const Reference< view::XSelectionChangeListener >& xListener)
     286             :     throw(RuntimeException, std::exception)
     287             : {
     288           0 :     if( mbDisposing )
     289           0 :         throw lang::DisposedException();
     290             : 
     291           0 :     BroadcastHelperOwner::maBroadcastHelper.addListener (m_aSelectionTypeIdentifier, xListener);
     292           0 : }
     293             : 
     294             : 
     295             : 
     296             : 
     297           0 : void SAL_CALL DrawController::removeSelectionChangeListener(
     298             :     const Reference< view::XSelectionChangeListener >& xListener )
     299             :     throw(RuntimeException, std::exception)
     300             : {
     301           0 :     if (rBHelper.bDisposed)
     302           0 :         throw lang::DisposedException();
     303             : 
     304           0 :     BroadcastHelperOwner::maBroadcastHelper.removeListener (m_aSelectionTypeIdentifier, xListener);
     305           0 : }
     306             : 
     307             : 
     308             : 
     309             : 
     310             : 
     311             : //=====  lang::XEventListener  ================================================
     312             : 
     313             : void SAL_CALL
     314           0 :     DrawController::disposing (const lang::EventObject& )
     315             :     throw (uno::RuntimeException, std::exception)
     316             : {
     317           0 : }
     318             : 
     319             : 
     320             : 
     321             : 
     322             : //=====  view::XSelectionChangeListener  ======================================
     323             : 
     324             : void  SAL_CALL
     325           0 :     DrawController::selectionChanged (const lang::EventObject& rEvent)
     326             :         throw (uno::RuntimeException, std::exception)
     327             : {
     328           0 :     ThrowIfDisposed();
     329             :     // Have to forward the event to our selection change listeners.
     330             :     OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer(
     331           0 :         ::getCppuType((Reference<view::XSelectionChangeListener>*)0));
     332           0 :     if (pListeners)
     333             :     {
     334             :         // Re-send the event to all of our listeners.
     335           0 :         OInterfaceIteratorHelper aIterator (*pListeners);
     336           0 :         while (aIterator.hasMoreElements())
     337             :         {
     338             :             try
     339             :             {
     340             :                 view::XSelectionChangeListener* pListener =
     341             :                     static_cast<view::XSelectionChangeListener*>(
     342           0 :                         aIterator.next());
     343           0 :                 if (pListener != NULL)
     344           0 :                     pListener->selectionChanged (rEvent);
     345             :             }
     346           0 :             catch (const RuntimeException&)
     347             :             {
     348             :             }
     349           0 :         }
     350             :     }
     351           0 : }
     352             : 
     353             : 
     354             : 
     355             : 
     356             : // XDrawView
     357             : 
     358           0 : void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage )
     359             :     throw(RuntimeException, std::exception)
     360             : {
     361           0 :     ThrowIfDisposed();
     362           0 :     SolarMutexGuard aGuard;
     363             : 
     364           0 :     if (mxSubController.is())
     365           0 :         mxSubController->setCurrentPage(xPage);
     366           0 : }
     367             : 
     368             : 
     369             : 
     370             : 
     371           0 : Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage (void)
     372             :     throw(RuntimeException, std::exception)
     373             : {
     374           0 :     ThrowIfDisposed();
     375           0 :     SolarMutexGuard aGuard;
     376           0 :     Reference<drawing::XDrawPage> xPage;
     377             : 
     378             :     // Get current page from sub controller.
     379           0 :     if (mxSubController.is())
     380           0 :         xPage = mxSubController->getCurrentPage();
     381             : 
     382             :     // When there is not yet a sub controller (during initialization) then fall back
     383             :     // to the current page in mpCurrentPage.
     384           0 :     if ( ! xPage.is() && mpCurrentPage.is())
     385           0 :         xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY);
     386             : 
     387           0 :     return xPage;
     388             : }
     389             : 
     390             : 
     391             : 
     392             : 
     393           0 : void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw()
     394             : {
     395           0 :     if( maLastVisArea != rVisArea )
     396             :     {
     397           0 :         Any aNewValue;
     398           0 :         aNewValue <<= awt::Rectangle(
     399           0 :             rVisArea.Left(),
     400           0 :             rVisArea.Top(),
     401           0 :             rVisArea.GetWidth(),
     402           0 :             rVisArea.GetHeight() );
     403             : 
     404           0 :         Any aOldValue;
     405           0 :         aOldValue <<= awt::Rectangle(
     406           0 :             maLastVisArea.Left(),
     407           0 :             maLastVisArea.Top(),
     408           0 :             maLastVisArea.GetWidth(),
     409           0 :             maLastVisArea.GetHeight() );
     410             : 
     411           0 :         FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue);
     412             : 
     413           0 :         maLastVisArea = rVisArea;
     414             :     }
     415           0 : }
     416             : 
     417             : 
     418             : 
     419             : 
     420           0 : void DrawController::FireSelectionChangeListener() throw()
     421             : {
     422             :     OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer(
     423           0 :         m_aSelectionTypeIdentifier);
     424           0 :     if( pLC )
     425             :     {
     426           0 :         Reference< XInterface > xSource( (XWeak*)this );
     427           0 :         const lang::EventObject aEvent( xSource );
     428             : 
     429             :         // iterate over all listeners and send events
     430           0 :         OInterfaceIteratorHelper aIt( *pLC);
     431           0 :         while( aIt.hasMoreElements() )
     432             :         {
     433             :             try
     434             :             {
     435             :                 view::XSelectionChangeListener * pL =
     436           0 :                     static_cast<view::XSelectionChangeListener*>(aIt.next());
     437           0 :                 if (pL != NULL)
     438           0 :                     pL->selectionChanged( aEvent );
     439             :             }
     440           0 :             catch (const RuntimeException&)
     441             :             {
     442             :             }
     443           0 :         }
     444             :     }
     445           0 : }
     446             : 
     447             : 
     448             : 
     449             : 
     450           0 : void DrawController::FireChangeEditMode (bool bMasterPageMode) throw()
     451             : {
     452           0 :     if (bMasterPageMode != mbMasterPageMode )
     453             :     {
     454             :         FirePropertyChange(
     455             :             PROPERTY_MASTERPAGEMODE,
     456             :             makeAny(bMasterPageMode),
     457           0 :             makeAny(mbMasterPageMode));
     458             : 
     459           0 :         mbMasterPageMode = bMasterPageMode;
     460             :     }
     461           0 : }
     462             : 
     463             : 
     464             : 
     465             : 
     466           0 : void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
     467             : {
     468           0 :     if (bLayerMode != mbLayerMode)
     469             :     {
     470             :         FirePropertyChange(
     471             :             PROPERTY_LAYERMODE,
     472             :             makeAny(bLayerMode),
     473           0 :             makeAny(mbLayerMode));
     474             : 
     475           0 :         mbLayerMode = bLayerMode;
     476             :     }
     477           0 : }
     478             : 
     479             : 
     480             : 
     481             : 
     482           0 : void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
     483             : {
     484           0 :     SdrPage* pCurrentPage  = mpCurrentPage.get();
     485           0 :     if (pNewCurrentPage != pCurrentPage)
     486             :     {
     487             :         try
     488             :         {
     489             :             Any aNewValue (
     490           0 :                 makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY)));
     491             : 
     492           0 :             Any aOldValue;
     493           0 :             if (pCurrentPage != NULL)
     494             :             {
     495           0 :                 Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY);
     496           0 :                 aOldValue <<= xOldPage;
     497             :             }
     498             : 
     499           0 :             FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
     500             : 
     501           0 :             mpCurrentPage.reset(pNewCurrentPage);
     502             :         }
     503           0 :         catch (const uno::Exception&)
     504             :         {
     505             :             OSL_FAIL(
     506             :                 OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), exception caught: " +
     507             :                     OUStringToOString(
     508             :                         comphelper::anyToString( cppu::getCaughtException() ),
     509             :                         RTL_TEXTENCODING_UTF8 )).getStr() );
     510             :         }
     511             :     }
     512           0 : }
     513             : 
     514           0 : void DrawController::NotifyAccUpdate()
     515             : {
     516           0 :     sal_Int32 nHandle = PROPERTY_UPDATEACC;
     517           0 :     Any aNewValue, aOldValue;
     518           0 :     fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False);
     519           0 : }
     520             : 
     521           0 : void DrawController::fireChangeLayer( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer>* pCurrentLayer ) throw()
     522             : {
     523           0 :     if( pCurrentLayer != mpCurrentLayer )
     524             :     {
     525           0 :         sal_Int32 nHandle = PROPERTY_ACTIVE_LAYER;
     526             : 
     527           0 :         Any aNewValue (makeAny( *pCurrentLayer) );
     528             : 
     529           0 :         Any aOldValue ;
     530             : 
     531           0 :         fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False);
     532             : 
     533           0 :         mpCurrentLayer = pCurrentLayer;
     534             :     }
     535           0 : }
     536             : 
     537             : // This method is only called in slide show and outline view
     538             : //void DrawController::fireSwitchCurrentPage(String pageName ) throw()
     539           0 : void DrawController::fireSwitchCurrentPage(sal_Int32 pageIndex ) throw()
     540             : {
     541           0 :         Any aNewValue;
     542           0 :         Any aOldValue;
     543             :         //OUString aPageName(  pageName );
     544             :         //aNewValue <<= aPageName ;
     545           0 :         aNewValue <<= pageIndex;
     546             : 
     547             :         // Use new property to handle page change event
     548           0 :         sal_Int32 nHandles = PROPERTY_PAGE_CHANGE;
     549           0 :         fire( &nHandles, &aNewValue, &aOldValue, 1, sal_False );
     550           0 : }
     551             : 
     552           0 : void DrawController::FirePropertyChange (
     553             :     sal_Int32 nHandle,
     554             :     const Any& rNewValue,
     555             :     const Any& rOldValue)
     556             : {
     557             :     try
     558             :     {
     559           0 :         fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False);
     560             :     }
     561           0 :     catch (const RuntimeException&)
     562             :     {
     563             :         // Ignore this exception.  Exceptions should be handled in the
     564             :         // fire() function so that all listeners are called.  This is
     565             :         // not the case at the moment, so we simply ignore the
     566             :         // exception.
     567             :     }
     568             : 
     569           0 : }
     570             : 
     571             : 
     572             : 
     573             : 
     574           0 : void DrawController::BroadcastContextChange (void) const
     575             : {
     576           0 :     ::boost::shared_ptr<ViewShell> pViewShell (mpBase->GetMainViewShell());
     577           0 :     if ( ! pViewShell)
     578           0 :         return;
     579             : 
     580           0 :     EnumContext::Context eContext (EnumContext::Context_Unknown);
     581           0 :     switch (pViewShell->GetShellType())
     582             :     {
     583             :         case ViewShell::ST_IMPRESS:
     584             :         case ViewShell::ST_DRAW:
     585           0 :             if (mbMasterPageMode)
     586           0 :                 eContext = EnumContext::Context_MasterPage;
     587             :             else
     588           0 :                 eContext = EnumContext::Context_DrawPage;
     589           0 :             break;
     590             : 
     591             :         case ViewShell::ST_NOTES:
     592           0 :             eContext = EnumContext::Context_NotesPage;
     593           0 :             break;
     594             : 
     595             :         case ViewShell::ST_HANDOUT:
     596           0 :             eContext = EnumContext::Context_HandoutPage;
     597           0 :             break;
     598             : 
     599             :         case ViewShell::ST_OUTLINE:
     600           0 :             eContext = EnumContext::Context_OutlineText;
     601           0 :             break;
     602             : 
     603             :         case ViewShell::ST_SLIDE_SORTER:
     604           0 :             eContext = EnumContext::Context_SlidesorterPage;
     605           0 :             break;
     606             : 
     607             :         case ViewShell::ST_PRESENTATION:
     608             :         case ViewShell::ST_NONE:
     609             :         default:
     610           0 :             eContext = EnumContext::Context_Empty;
     611           0 :             break;
     612             :     }
     613             : 
     614           0 :     ContextChangeEventMultiplexer::NotifyContextChange(mpBase, eContext);
     615             : }
     616             : 
     617             : 
     618             : 
     619             : 
     620           0 : ViewShellBase* DrawController::GetViewShellBase (void)
     621             : {
     622           0 :     return mpBase;
     623             : }
     624             : 
     625             : 
     626             : 
     627             : 
     628           0 : void DrawController::ReleaseViewShellBase (void)
     629             : {
     630           0 :     DisposeFrameworkControllers();
     631           0 :     mpBase = NULL;
     632           0 : }
     633             : 
     634             : 
     635             : 
     636             : 
     637             : //===== XControllerManager ==============================================================
     638             : 
     639             : Reference<XConfigurationController> SAL_CALL
     640           0 :     DrawController::getConfigurationController (void)
     641             :     throw (RuntimeException, std::exception)
     642             : {
     643           0 :     ThrowIfDisposed();
     644             : 
     645           0 :     return mxConfigurationController;
     646             : }
     647             : 
     648             : 
     649             : 
     650             : 
     651             : Reference<XModuleController> SAL_CALL
     652           0 :     DrawController::getModuleController (void)
     653             :     throw (RuntimeException, std::exception)
     654             : {
     655           0 :     ThrowIfDisposed();
     656             : 
     657           0 :     return mxModuleController;
     658             : }
     659             : 
     660             : 
     661             : 
     662             : 
     663             : //===== XUnoTunnel ============================================================
     664             : 
     665             : namespace
     666             : {
     667             :     class theDrawControllerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theDrawControllerUnoTunnelId> {};
     668             : }
     669             : 
     670           0 : const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void)
     671             : {
     672           0 :     return theDrawControllerUnoTunnelId::get().getSeq();
     673             : }
     674             : 
     675             : 
     676             : 
     677             : 
     678           0 : sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId)
     679             :     throw (RuntimeException, std::exception)
     680             : {
     681           0 :     sal_Int64 nResult = 0;
     682             : 
     683           0 :     if (rId.getLength() == 16
     684           0 :         && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
     685             :     {
     686           0 :         nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
     687             :     }
     688             : 
     689           0 :     return nResult;
     690             : }
     691             : 
     692             : 
     693             : 
     694             : 
     695             : //===== Properties ============================================================
     696             : 
     697           0 : void DrawController::FillPropertyTable (
     698             :     ::std::vector<beans::Property>& rProperties)
     699             : {
     700             :     rProperties.push_back(
     701             :         beans::Property("VisibleArea",
     702             :             PROPERTY_WORKAREA,
     703           0 :             ::getCppuType((const ::com::sun::star::awt::Rectangle*)0),
     704           0 :             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY));
     705             :     rProperties.push_back(
     706             :         beans::Property(
     707             :             "SubController",
     708             :             PROPERTY_SUB_CONTROLLER,
     709           0 :             ::getCppuType((const Reference<drawing::XDrawSubController>*)0),
     710           0 :             beans::PropertyAttribute::BOUND));
     711             :     rProperties.push_back(
     712             :         beans::Property(
     713             :             "CurrentPage",
     714             :             PROPERTY_CURRENTPAGE,
     715           0 :             ::getCppuType((const Reference< drawing::XDrawPage > *)0),
     716           0 :             beans::PropertyAttribute::BOUND ));
     717             :     rProperties.push_back(
     718             :         beans::Property("IsLayerMode",
     719             :             PROPERTY_LAYERMODE,
     720           0 :             ::getCppuBooleanType(),
     721           0 :             beans::PropertyAttribute::BOUND ));
     722             :     rProperties.push_back(
     723             :         beans::Property("IsMasterPageMode",
     724             :             PROPERTY_MASTERPAGEMODE,
     725           0 :             ::getCppuBooleanType(),
     726           0 :             beans::PropertyAttribute::BOUND ));
     727             :     rProperties.push_back(
     728             :         beans::Property("ActiveLayer",
     729             :             PROPERTY_ACTIVE_LAYER,
     730           0 :             ::getCppuType((const Reference< drawing::XLayer > *)0),
     731           0 :             beans::PropertyAttribute::BOUND ));
     732             :     rProperties.push_back(
     733             :         beans::Property("ZoomValue",
     734             :             PROPERTY_ZOOMVALUE,
     735           0 :             ::getCppuType((const sal_Int16*)0),
     736           0 :             beans::PropertyAttribute::BOUND ));
     737             :     rProperties.push_back(
     738             :         beans::Property("ZoomType",
     739             :             PROPERTY_ZOOMTYPE,
     740           0 :             ::getCppuType((const sal_Int16*)0),
     741           0 :             beans::PropertyAttribute::BOUND ));
     742             :     rProperties.push_back(
     743             :         beans::Property("ViewOffset",
     744             :             PROPERTY_VIEWOFFSET,
     745           0 :             ::getCppuType((const ::com::sun::star::awt::Point*)0),
     746           0 :             beans::PropertyAttribute::BOUND ));
     747             :     rProperties.push_back(
     748             :         beans::Property("DrawViewMode",
     749             :             PROPERTY_DRAWVIEWMODE,
     750           0 :             ::getCppuType((const ::com::sun::star::awt::Point*)0),
     751           0 :             beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID ));
     752             :     // add new property to update current page's acc information
     753             :     rProperties.push_back(
     754           0 :         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("UpdateAcc") ),
     755             :             PROPERTY_UPDATEACC,
     756           0 :             ::getCppuType((const sal_Int16*)0),
     757           0 :             beans::PropertyAttribute::BOUND ));
     758             :     rProperties.push_back(
     759           0 :         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("PageChange") ),
     760             :             PROPERTY_PAGE_CHANGE,
     761           0 :             ::getCppuType((const sal_Int16*)0),
     762           0 :             beans::PropertyAttribute::BOUND ));
     763           0 : }
     764             : 
     765             : 
     766             : 
     767             : 
     768           0 : IPropertyArrayHelper & DrawController::getInfoHelper()
     769             : {
     770           0 :     SolarMutexGuard aGuard;
     771             : 
     772           0 :     if (mpPropertyArrayHelper.get() == NULL)
     773             :     {
     774           0 :         ::std::vector<beans::Property> aProperties;
     775           0 :         FillPropertyTable (aProperties);
     776           0 :         Sequence<beans::Property> aPropertySequence (aProperties.size());
     777           0 :         for (unsigned int i=0; i<aProperties.size(); i++)
     778           0 :             aPropertySequence[i] = aProperties[i];
     779           0 :         mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False));
     780             :     }
     781             : 
     782           0 :     return *mpPropertyArrayHelper.get();
     783             : }
     784             : 
     785             : 
     786             : 
     787             : 
     788           0 : Reference < beans::XPropertySetInfo >  DrawController::getPropertySetInfo()
     789             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     790             : {
     791           0 :     SolarMutexGuard aGuard;
     792             : 
     793           0 :     static Reference < beans::XPropertySetInfo >  xInfo( createPropertySetInfo( getInfoHelper() ) );
     794           0 :     return xInfo;
     795             : }
     796             : 
     797             : 
     798           0 : uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException, std::exception)
     799             : {
     800           0 :     SolarMutexGuard aGuard;
     801             : 
     802           0 :     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
     803           0 :     SdrView* pSdrView = mpBase->GetDrawView();
     804           0 :     ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
     805           0 :     ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
     806             : 
     807           0 :     uno::Reference< form::runtime::XFormController > xController( NULL );
     808           0 :     if ( pFormShell && pSdrView && pWindow )
     809           0 :         xController = pFormShell->GetFormController( Form, *pSdrView, *pWindow );
     810           0 :     return xController;
     811             : }
     812             : 
     813           0 : sal_Bool SAL_CALL DrawController::isFormDesignMode(  ) throw (uno::RuntimeException, std::exception)
     814             : {
     815           0 :     SolarMutexGuard aGuard;
     816             : 
     817           0 :     sal_Bool bIsDesignMode = sal_True;
     818             : 
     819           0 :     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
     820           0 :     if ( pFormShell )
     821           0 :         bIsDesignMode = pFormShell->IsDesignMode();
     822             : 
     823           0 :     return bIsDesignMode;
     824             : }
     825             : 
     826           0 : void SAL_CALL DrawController::setFormDesignMode( sal_Bool _DesignMode ) throw (uno::RuntimeException, std::exception)
     827             : {
     828           0 :     SolarMutexGuard aGuard;
     829             : 
     830           0 :     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
     831           0 :     if ( pFormShell )
     832           0 :         pFormShell->SetDesignMode( _DesignMode );
     833           0 : }
     834             : 
     835           0 : uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
     836             : {
     837           0 :     SolarMutexGuard aGuard;
     838             : 
     839           0 :     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
     840           0 :     SdrView* pSdrView = mpBase->GetDrawView();
     841           0 :     ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
     842           0 :     ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
     843             : 
     844           0 :     uno::Reference< awt::XControl > xControl( NULL );
     845           0 :     if ( pFormShell && pSdrView && pWindow )
     846           0 :         pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl );
     847           0 :     return xControl;
     848             : }
     849             : 
     850             : 
     851             : 
     852             : 
     853           0 : sal_Bool DrawController::convertFastPropertyValue (
     854             :     Any & rConvertedValue,
     855             :     Any & rOldValue,
     856             :     sal_Int32 nHandle,
     857             :     const Any& rValue)
     858             :     throw ( com::sun::star::lang::IllegalArgumentException)
     859             : {
     860           0 :     sal_Bool bResult = sal_False;
     861             : 
     862           0 :     if (nHandle == PROPERTY_SUB_CONTROLLER)
     863             :     {
     864           0 :         rOldValue <<= mxSubController;
     865           0 :         rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY);
     866           0 :         bResult = (rOldValue != rConvertedValue);
     867             :     }
     868           0 :     else if (mxSubController.is())
     869             :     {
     870           0 :         rConvertedValue = rValue;
     871             :         try
     872             :         {
     873           0 :             rOldValue = mxSubController->getFastPropertyValue(nHandle);
     874           0 :             bResult = (rOldValue != rConvertedValue);
     875             :         }
     876           0 :         catch (const beans::UnknownPropertyException&)
     877             :         {
     878             :             // The property is unknown and thus an illegal argument to this method.
     879           0 :             throw com::sun::star::lang::IllegalArgumentException();
     880             :         }
     881             :     }
     882             : 
     883           0 :     return bResult;
     884             : }
     885             : 
     886             : 
     887             : 
     888             : 
     889           0 : void DrawController::setFastPropertyValue_NoBroadcast (
     890             :     sal_Int32 nHandle,
     891             :     const Any& rValue)
     892             :     throw ( com::sun::star::uno::Exception, std::exception)
     893             : {
     894           0 :     SolarMutexGuard aGuard;
     895           0 :     if (nHandle == PROPERTY_SUB_CONTROLLER)
     896           0 :         SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY));
     897           0 :     else if (mxSubController.is())
     898           0 :         mxSubController->setFastPropertyValue(nHandle, rValue);
     899           0 : }
     900             : 
     901             : 
     902             : 
     903             : 
     904           0 : void DrawController::getFastPropertyValue (
     905             :     Any & rRet,
     906             :     sal_Int32 nHandle ) const
     907             : {
     908           0 :     SolarMutexGuard aGuard;
     909             : 
     910           0 :     switch( nHandle )
     911             :     {
     912             :         case PROPERTY_WORKAREA:
     913           0 :             rRet <<= awt::Rectangle(
     914           0 :                 maLastVisArea.Left(),
     915           0 :                 maLastVisArea.Top(),
     916           0 :                 maLastVisArea.GetWidth(),
     917           0 :                 maLastVisArea.GetHeight());
     918           0 :             break;
     919             : 
     920             :         case PROPERTY_SUB_CONTROLLER:
     921           0 :             rRet <<= mxSubController;
     922           0 :             break;
     923             : 
     924             :         default:
     925           0 :             if (mxSubController.is())
     926           0 :                 rRet = mxSubController->getFastPropertyValue(nHandle);
     927           0 :             break;
     928           0 :     }
     929           0 : }
     930             : 
     931             : 
     932             : 
     933             : 
     934             : 
     935             : 
     936           0 : void DrawController::ProvideFrameworkControllers (void)
     937             : {
     938           0 :     SolarMutexGuard aGuard;
     939             :     try
     940             :     {
     941           0 :         Reference<XController> xController (this);
     942             :         const Reference<XComponentContext> xContext (
     943           0 :             ::comphelper::getProcessComponentContext() );
     944           0 :         mxConfigurationController = ConfigurationController::create(
     945             :             xContext,
     946           0 :             xController);
     947           0 :         mxModuleController = ModuleController::create(
     948             :             xContext,
     949           0 :             xController);
     950             :     }
     951           0 :     catch (const RuntimeException&)
     952             :     {
     953           0 :         mxConfigurationController = NULL;
     954           0 :         mxModuleController = NULL;
     955           0 :     }
     956           0 : }
     957             : 
     958             : 
     959             : 
     960             : 
     961           0 : void DrawController::DisposeFrameworkControllers (void)
     962             : {
     963           0 :     Reference<XComponent> xComponent (mxModuleController, UNO_QUERY);
     964           0 :     if (xComponent.is())
     965           0 :         xComponent->dispose();
     966             : 
     967           0 :     xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY);
     968           0 :     if (xComponent.is())
     969           0 :         xComponent->dispose();
     970           0 : }
     971             : 
     972             : 
     973             : 
     974             : 
     975           0 : void DrawController::ThrowIfDisposed (void) const
     976             :     throw (::com::sun::star::lang::DisposedException)
     977             : {
     978           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing)
     979             :     {
     980             :         OSL_TRACE ("Calling disposed DrawController object. Throwing exception:");
     981             :         throw lang::DisposedException (
     982             :             "DrawController object has already been disposed",
     983           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     984             :     }
     985           0 : }
     986             : 
     987             : 
     988             : 
     989             : 
     990             : 
     991           0 : } // end of namespace sd
     992             : 
     993             : 
     994             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10