LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - DrawController.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 212 323 65.6 %
Date: 2012-08-25 Functions: 37 51 72.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 178 563 31.6 %

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

Generated by: LCOV version 1.10