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

Generated by: LCOV version 1.10