LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterController.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 518 0.4 %
Date: 2012-08-25 Functions: 2 52 3.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 1081 0.2 %

           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                 :            : #include "PresenterController.hxx"
      30                 :            : 
      31                 :            : #include "PresenterAccessibility.hxx"
      32                 :            : #include "PresenterCanvasHelper.hxx"
      33                 :            : #include "PresenterCurrentSlideObserver.hxx"
      34                 :            : #include "PresenterFrameworkObserver.hxx"
      35                 :            : #include "PresenterHelper.hxx"
      36                 :            : #include "PresenterScreen.hxx"
      37                 :            : #include "PresenterNotesView.hxx"
      38                 :            : #include "PresenterPaintManager.hxx"
      39                 :            : #include "PresenterPaneBase.hxx"
      40                 :            : #include "PresenterPaneContainer.hxx"
      41                 :            : #include "PresenterPaneBorderPainter.hxx"
      42                 :            : #include "PresenterTheme.hxx"
      43                 :            : #include "PresenterViewFactory.hxx"
      44                 :            : #include "PresenterWindowManager.hxx"
      45                 :            : 
      46                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      47                 :            : #include <com/sun/star/accessibility/XAccessible.hpp>
      48                 :            : #include <com/sun/star/awt/Key.hpp>
      49                 :            : #include <com/sun/star/awt/KeyModifier.hpp>
      50                 :            : #include <com/sun/star/awt/MouseButton.hpp>
      51                 :            : #include <com/sun/star/awt/XWindowPeer.hpp>
      52                 :            : #include <com/sun/star/container/XNamed.hpp>
      53                 :            : #include <com/sun/star/drawing/XDrawView.hpp>
      54                 :            : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      55                 :            : #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
      56                 :            : #include <com/sun/star/drawing/framework/ResourceId.hpp>
      57                 :            : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      58                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      59                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      60                 :            : #include <com/sun/star/presentation/XPresentation.hpp>
      61                 :            : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
      62                 :            : #include <com/sun/star/rendering/CompositeOperation.hpp>
      63                 :            : #include <com/sun/star/rendering/TextDirection.hpp>
      64                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      65                 :            : 
      66                 :            : #include <rtl/ustrbuf.hxx>
      67                 :            : 
      68                 :            : using namespace ::com::sun::star;
      69                 :            : using namespace ::com::sun::star::uno;
      70                 :            : using namespace ::com::sun::star::presentation;
      71                 :            : using namespace ::com::sun::star::drawing::framework;
      72                 :            : using ::rtl::OUString;
      73                 :            : using ::rtl::OUStringBuffer;
      74                 :            : 
      75                 :            : namespace {
      76                 :            :     const sal_Int32 ResourceActivationEventType = 0;
      77                 :            :     const sal_Int32 ResourceDeactivationEventType = 1;
      78                 :            :     const sal_Int32 ConfigurationUpdateEndEventType = 2;
      79                 :            : }
      80                 :            : 
      81                 :            : #define A2S(pString) (::rtl::OUString(pString))
      82                 :            : 
      83                 :            : namespace sdext { namespace presenter {
      84                 :            : 
      85                 :          8 : PresenterController::InstanceContainer PresenterController::maInstances;
      86                 :            : 
      87                 :          0 : ::rtl::Reference<PresenterController> PresenterController::Instance (
      88                 :            :     const css::uno::Reference<css::frame::XFrame>& rxFrame)
      89                 :            : {
      90         [ #  # ]:          0 :     InstanceContainer::const_iterator iInstance (maInstances.find(rxFrame));
      91         [ #  # ]:          0 :     if (iInstance != maInstances.end())
      92                 :          0 :         return iInstance->second;
      93                 :            :     else
      94                 :          0 :         return ::rtl::Reference<PresenterController>();
      95                 :            : }
      96                 :            : 
      97                 :          0 : PresenterController::PresenterController (
      98                 :            :     const css::uno::WeakReference<css::lang::XEventListener> &rxScreen,
      99                 :            :     const Reference<XComponentContext>& rxContext,
     100                 :            :     const Reference<frame::XController>& rxController,
     101                 :            :     const Reference<presentation::XSlideShowController>& rxSlideShowController,
     102                 :            :     const rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
     103                 :            :     const Reference<XResourceId>& rxMainPaneId)
     104                 :            :     : PresenterControllerInterfaceBase(m_aMutex),
     105                 :            :       mxScreen(rxScreen),
     106                 :            :       mxComponentContext(rxContext),
     107                 :            :       mxController(rxController),
     108                 :            :       mxConfigurationController(),
     109                 :            :       mxSlideShowController(rxSlideShowController),
     110                 :            :       mxMainPaneId(rxMainPaneId),
     111                 :            :       mpPaneContainer(rpPaneContainer),
     112                 :            :       mnCurrentSlideIndex(-1),
     113                 :            :       mxCurrentSlide(),
     114                 :            :       mxNextSlide(),
     115         [ #  # ]:          0 :       mpWindowManager(new PresenterWindowManager(rxContext,mpPaneContainer,this)),
     116                 :            :       mnWindowBackgroundColor(0x00ffffff),
     117                 :            :       mpTheme(),
     118                 :            :       mxMainWindow(),
     119                 :            :       mpPaneBorderPainter(),
     120                 :          0 :       mpCanvasHelper(new PresenterCanvasHelper()),
     121                 :            :       mxPresenterHelper(),
     122                 :            :       mpPaintManager(),
     123                 :            :       mnPendingSlideNumber(-1),
     124                 :            :       mxUrlTransformer(),
     125                 :            :       mpAccessibleObject(),
     126 [ #  # ][ #  # ]:          0 :       mbIsAccessibilityActive(false)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :            : {
     128                 :            :     OSL_ASSERT(mxController.is());
     129                 :            : 
     130         [ #  # ]:          0 :     if ( ! mxSlideShowController.is())
     131                 :            :         throw new lang::IllegalArgumentException(
     132                 :            :             A2S("missing slide show controller"),
     133                 :            :             static_cast<XWeak*>(this),
     134 [ #  # ][ #  # ]:          0 :             2);
                 [ #  # ]
     135                 :            : 
     136         [ #  # ]:          0 :     new PresenterCurrentSlideObserver(this,rxSlideShowController);
     137                 :            : 
     138                 :            :     // Listen for configuration changes.
     139         [ #  # ]:          0 :     Reference<XControllerManager> xCM (mxController, UNO_QUERY_THROW);
     140 [ #  # ][ #  # ]:          0 :     mxConfigurationController = xCM->getConfigurationController();
                 [ #  # ]
     141         [ #  # ]:          0 :     if (mxConfigurationController.is())
     142                 :            :     {
     143         [ #  # ]:          0 :         mxConfigurationController->addConfigurationChangeListener(
     144                 :            :             this,
     145                 :            :             A2S("ResourceActivation"),
     146 [ #  # ][ #  # ]:          0 :             Any(ResourceActivationEventType));
                 [ #  # ]
     147         [ #  # ]:          0 :         mxConfigurationController->addConfigurationChangeListener(
     148                 :            :             this,
     149                 :            :             A2S("ResourceDeactivation"),
     150 [ #  # ][ #  # ]:          0 :             Any(ResourceDeactivationEventType));
                 [ #  # ]
     151         [ #  # ]:          0 :         mxConfigurationController->addConfigurationChangeListener(
     152                 :            :             this,
     153                 :            :             A2S("ConfigurationUpdateEnd"),
     154 [ #  # ][ #  # ]:          0 :             Any(ConfigurationUpdateEndEventType));
                 [ #  # ]
     155                 :            :     }
     156                 :            : 
     157                 :            :     // Listen for the frame being activated.
     158 [ #  # ][ #  # ]:          0 :     Reference<frame::XFrame> xFrame (mxController->getFrame());
     159         [ #  # ]:          0 :     if (xFrame.is())
     160 [ #  # ][ #  # ]:          0 :         xFrame->addFrameActionListener(this);
                 [ #  # ]
     161                 :            : 
     162                 :            :     // Create the border painter.
     163 [ #  # ][ #  # ]:          0 :     mpPaneBorderPainter = new PresenterPaneBorderPainter(rxContext);
     164         [ #  # ]:          0 :     mpWindowManager->SetPaneBorderPainter(mpPaneBorderPainter);
     165                 :            : 
     166                 :            :     // Create an object that is able to load the bitmaps in a format that is
     167                 :            :     // supported by the canvas.
     168                 :            :     Reference<lang::XMultiComponentFactory> xFactory (
     169 [ #  # ][ #  # ]:          0 :         rxContext->getServiceManager(), UNO_QUERY);
                 [ #  # ]
     170         [ #  # ]:          0 :     if ( ! xFactory.is())
     171                 :          0 :         return;
     172                 :            :     mxPresenterHelper = Reference<drawing::XPresenterHelper>(
     173         [ #  # ]:          0 :         xFactory->createInstanceWithContext(
     174                 :            :             A2S("com.sun.star.drawing.PresenterHelper"),
     175                 :          0 :             rxContext),
     176 [ #  # ][ #  # ]:          0 :         UNO_QUERY_THROW);
                 [ #  # ]
     177                 :            : 
     178         [ #  # ]:          0 :     if (mxSlideShowController.is())
     179                 :            :     {
     180 [ #  # ][ #  # ]:          0 :         mxSlideShowController->activate();
     181         [ #  # ]:          0 :         Reference<beans::XPropertySet> xProperties (mxSlideShowController, UNO_QUERY);
     182         [ #  # ]:          0 :         if (xProperties.is())
     183                 :            :         {
     184                 :            :             Reference<awt::XWindow> xWindow (
     185 [ #  # ][ #  # ]:          0 :                 xProperties->getPropertyValue(A2S("ParentWindow")), UNO_QUERY);
                 [ #  # ]
     186         [ #  # ]:          0 :             if (xWindow.is())
     187 [ #  # ][ #  # ]:          0 :                 xWindow->addKeyListener(this);
                 [ #  # ]
     188                 :          0 :         }
     189                 :            :     }
     190                 :            : 
     191         [ #  # ]:          0 :     UpdateCurrentSlide(0);
     192                 :            : 
     193 [ #  # ][ #  # ]:          0 :     maInstances[mxController->getFrame()] = this;
         [ #  # ][ #  # ]
     194                 :            : 
     195                 :            :     // Create a URLTransformer.
     196         [ #  # ]:          0 :     if (xFactory.is())
     197                 :            :     {
     198 [ #  # ][ #  # ]:          0 :         mxUrlTransformer = Reference<util::XURLTransformer>(util::URLTransformer::create(mxComponentContext));
     199 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     200                 :            : }
     201                 :            : 
     202 [ #  # ][ #  # ]:          0 : PresenterController::~PresenterController (void)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     203                 :            : {
     204         [ #  # ]:          0 : }
     205                 :            : 
     206                 :          0 : void PresenterController::disposing (void)
     207                 :            : {
     208 [ #  # ][ #  # ]:          0 :     maInstances.erase(mxController->getFrame());
                 [ #  # ]
     209                 :            : 
     210         [ #  # ]:          0 :     if (mxMainWindow.is())
     211                 :            :     {
     212 [ #  # ][ #  # ]:          0 :         mxMainWindow->removeKeyListener(this);
                 [ #  # ]
     213 [ #  # ][ #  # ]:          0 :         mxMainWindow->removeFocusListener(this);
                 [ #  # ]
     214 [ #  # ][ #  # ]:          0 :         mxMainWindow->removeMouseListener(this);
                 [ #  # ]
     215 [ #  # ][ #  # ]:          0 :         mxMainWindow->removeMouseMotionListener(this);
                 [ #  # ]
     216         [ #  # ]:          0 :         mxMainWindow = NULL;
     217                 :            :     }
     218         [ #  # ]:          0 :     if (mxConfigurationController.is())
     219 [ #  # ][ #  # ]:          0 :         mxConfigurationController->removeConfigurationChangeListener(this);
                 [ #  # ]
     220                 :            : 
     221                 :            :     Reference<XComponent> xWindowManagerComponent (
     222         [ #  # ]:          0 :         static_cast<XWeak*>(mpWindowManager.get()), UNO_QUERY);
     223         [ #  # ]:          0 :     mpWindowManager = NULL;
     224         [ #  # ]:          0 :     if (xWindowManagerComponent.is())
     225 [ #  # ][ #  # ]:          0 :         xWindowManagerComponent->dispose();
     226                 :            : 
     227         [ #  # ]:          0 :     if (mxController.is())
     228                 :            :     {
     229 [ #  # ][ #  # ]:          0 :         Reference<frame::XFrame> xFrame (mxController->getFrame());
     230         [ #  # ]:          0 :         if (xFrame.is())
     231 [ #  # ][ #  # ]:          0 :             xFrame->removeFrameActionListener(this);
                 [ #  # ]
     232         [ #  # ]:          0 :         mxController = NULL;
     233                 :            :     }
     234                 :            : 
     235         [ #  # ]:          0 :     mxComponentContext = NULL;
     236         [ #  # ]:          0 :     mxConfigurationController = NULL;
     237         [ #  # ]:          0 :     mxSlideShowController = NULL;
     238         [ #  # ]:          0 :     mxMainPaneId = NULL;
     239         [ #  # ]:          0 :     mpPaneContainer = NULL;
     240                 :          0 :     mnCurrentSlideIndex = -1;
     241         [ #  # ]:          0 :     mxCurrentSlide = NULL;
     242         [ #  # ]:          0 :     mxNextSlide = NULL;
     243         [ #  # ]:          0 :     mpTheme.reset();
     244                 :            :     {
     245                 :            :         Reference<lang::XComponent> xComponent (
     246         [ #  # ]:          0 :             static_cast<XWeak*>(mpPaneBorderPainter.get()), UNO_QUERY);
     247         [ #  # ]:          0 :         mpPaneBorderPainter = NULL;
     248         [ #  # ]:          0 :         if (xComponent.is())
     249 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
     250                 :            :     }
     251         [ #  # ]:          0 :     mpCanvasHelper.reset();
     252                 :            :     {
     253         [ #  # ]:          0 :         Reference<lang::XComponent> xComponent (mxPresenterHelper, UNO_QUERY);
     254         [ #  # ]:          0 :         mxPresenterHelper = NULL;
     255         [ #  # ]:          0 :         if (xComponent.is())
     256 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
     257                 :            :     }
     258         [ #  # ]:          0 :     mpPaintManager.reset();
     259                 :          0 :     mnPendingSlideNumber = -1;
     260                 :            :     {
     261         [ #  # ]:          0 :         Reference<lang::XComponent> xComponent (mxUrlTransformer, UNO_QUERY);
     262         [ #  # ]:          0 :         mxUrlTransformer = NULL;
     263         [ #  # ]:          0 :         if (xComponent.is())
     264 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
     265                 :          0 :     }
     266                 :          0 : }
     267                 :            : 
     268                 :          0 : void PresenterController::UpdateCurrentSlide (const sal_Int32 nOffset)
     269                 :            : {
     270                 :          0 :     GetSlides(nOffset);
     271                 :          0 :     UpdatePaneTitles();
     272                 :          0 :     UpdateViews();
     273                 :            : 
     274                 :            :     // Update the accessibility object.
     275         [ #  # ]:          0 :     if (IsAccessibilityActive())
     276                 :            :     {
     277                 :          0 :         sal_Int32 nSlideCount (0);
     278         [ #  # ]:          0 :         Reference<container::XIndexAccess> xIndexAccess(mxSlideShowController, UNO_QUERY);
     279         [ #  # ]:          0 :         if (xIndexAccess.is())
     280 [ #  # ][ #  # ]:          0 :             nSlideCount = xIndexAccess->getCount();
     281         [ #  # ]:          0 :         mpAccessibleObject->NotifyCurrentSlideChange(mnCurrentSlideIndex, nSlideCount);
     282                 :            :     }
     283                 :          0 : }
     284                 :            : 
     285                 :          0 : void PresenterController::GetSlides (const sal_Int32 nOffset)
     286                 :            : {
     287         [ #  # ]:          0 :     if ( ! mxSlideShowController.is())
     288                 :          0 :         return;
     289                 :            : 
     290                 :            :     // Get the current slide from the slide show controller.
     291         [ #  # ]:          0 :     mxCurrentSlide = NULL;
     292         [ #  # ]:          0 :     Reference<container::XIndexAccess> xIndexAccess(mxSlideShowController, UNO_QUERY);
     293                 :          0 :     sal_Int32 nSlideIndex = -1;
     294                 :            :     try
     295                 :            :     {
     296 [ #  # ][ #  # ]:          0 :         nSlideIndex = mxSlideShowController->getCurrentSlideIndex() + nOffset;
     297 [ #  # ][ #  # ]:          0 :         if (mxSlideShowController->isPaused())
                 [ #  # ]
     298                 :          0 :             nSlideIndex = -1;
     299                 :            : 
     300 [ #  # ][ #  # ]:          0 :         if (xIndexAccess.is() && nSlideIndex>=0)
                 [ #  # ]
     301                 :            :         {
     302 [ #  # ][ #  # ]:          0 :             if (nSlideIndex < xIndexAccess->getCount())
                 [ #  # ]
     303                 :            :             {
     304                 :          0 :                 mnCurrentSlideIndex = nSlideIndex;
     305                 :            :                 mxCurrentSlide = Reference<drawing::XDrawPage>(
     306 [ #  # ][ #  # ]:          0 :                     xIndexAccess->getByIndex(nSlideIndex), UNO_QUERY);
         [ #  # ][ #  # ]
                 [ #  # ]
     307                 :            :             }
     308                 :            :         }
     309                 :            :     }
     310         [ #  # ]:          0 :     catch (RuntimeException&)
     311                 :            :     {
     312                 :            :     }
     313                 :            : 
     314                 :            :     // Get the next slide.
     315         [ #  # ]:          0 :     mxNextSlide = NULL;
     316                 :            :     try
     317                 :            :     {
     318 [ #  # ][ #  # ]:          0 :         const sal_Int32 nNextSlideIndex (mxSlideShowController->getNextSlideIndex()+nOffset);
     319         [ #  # ]:          0 :         if (nNextSlideIndex >= 0)
     320                 :            :         {
     321         [ #  # ]:          0 :             if (xIndexAccess.is())
     322                 :            :             {
     323 [ #  # ][ #  # ]:          0 :                 if (nNextSlideIndex < xIndexAccess->getCount())
                 [ #  # ]
     324                 :            :                     mxNextSlide = Reference<drawing::XDrawPage>(
     325 [ #  # ][ #  # ]:          0 :                         xIndexAccess->getByIndex(nNextSlideIndex), UNO_QUERY);
         [ #  # ][ #  # ]
                 [ #  # ]
     326                 :            :             }
     327                 :            :         }
     328                 :            :     }
     329         [ #  # ]:          0 :     catch (RuntimeException&)
     330                 :            :     {
     331                 :          0 :     }
     332                 :            : }
     333                 :            : 
     334                 :          0 : void PresenterController::UpdatePaneTitles (void)
     335                 :            : {
     336         [ #  # ]:          0 :     if ( ! mxSlideShowController.is())
     337                 :          0 :         return;
     338                 :            : 
     339                 :            :     // Get placeholders and their values.
     340                 :          0 :     const OUString sCurrentSlideNumberPlaceholder (A2S("CURRENT_SLIDE_NUMBER"));
     341                 :          0 :     const OUString sCurrentSlideNamePlaceholder (A2S("CURRENT_SLIDE_NAME"));
     342                 :          0 :     const OUString sSlideCountPlaceholder (A2S("SLIDE_COUNT"));
     343                 :            : 
     344                 :            :     // Get string for slide count.
     345                 :          0 :     OUString sSlideCount (A2S("---"));
     346         [ #  # ]:          0 :     Reference<container::XIndexAccess> xIndexAccess(mxSlideShowController, UNO_QUERY);
     347         [ #  # ]:          0 :     if (xIndexAccess.is())
     348 [ #  # ][ #  # ]:          0 :         sSlideCount = OUString::valueOf(xIndexAccess->getCount());
     349                 :            : 
     350                 :            :     // Get string for current slide index.
     351                 :          0 :     OUString sCurrentSlideNumber (OUString::valueOf(mnCurrentSlideIndex + 1));
     352                 :            : 
     353                 :            :     // Get name of the current slide.
     354                 :          0 :     OUString sCurrentSlideName;
     355         [ #  # ]:          0 :     Reference<container::XNamed> xNamedSlide (mxCurrentSlide, UNO_QUERY);
     356         [ #  # ]:          0 :     if (xNamedSlide.is())
     357 [ #  # ][ #  # ]:          0 :         sCurrentSlideName = xNamedSlide->getName();
     358         [ #  # ]:          0 :     Reference<beans::XPropertySet> xSlideProperties (mxCurrentSlide, UNO_QUERY);
     359         [ #  # ]:          0 :     if (xSlideProperties.is())
     360                 :            :     {
     361                 :            :         try
     362                 :            :         {
     363                 :          0 :             OUString sName;
     364 [ #  # ][ #  # ]:          0 :             if (xSlideProperties->getPropertyValue(A2S("LinkDisplayName")) >>= sName)
                 [ #  # ]
     365                 :            :             {
     366                 :            :                 // Find out whether the name of the current slide has been
     367                 :            :                 // automatically created or has been set by the user.
     368         [ #  # ]:          0 :                 if (sName != sCurrentSlideName)
     369                 :          0 :                     sCurrentSlideName = sName;
     370         [ #  # ]:          0 :             }
     371                 :            :         }
     372         [ #  # ]:          0 :         catch (beans::UnknownPropertyException&)
     373                 :            :         {
     374                 :            :         }
     375                 :            :     }
     376                 :            : 
     377                 :            :     // Replace the placeholders with their current values.
     378                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
     379 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
                 [ #  # ]
     380                 :            :     {
     381                 :            :         OSL_ASSERT((*iPane).get() != NULL);
     382                 :            : 
     383                 :          0 :         OUString sTemplate (IsAccessibilityActive()
     384                 :          0 :             ? (*iPane)->msAccessibleTitleTemplate
     385         [ #  # ]:          0 :             : (*iPane)->msTitleTemplate);
     386         [ #  # ]:          0 :         if (sTemplate.isEmpty())
     387                 :          0 :             continue;
     388                 :            : 
     389                 :          0 :         OUStringBuffer sResult;
     390         [ #  # ]:          0 :         sResult.ensureCapacity(sTemplate.getLength());
     391                 :            : 
     392                 :          0 :         sal_Int32 nIndex (0);
     393                 :          0 :         while (true)
     394                 :            :         {
     395                 :          0 :             sal_Int32 nStartIndex = sTemplate.indexOf('%', nIndex);
     396         [ #  # ]:          0 :             if (nStartIndex < 0)
     397                 :            :             {
     398                 :            :                 // Add the remaining part of the string.
     399         [ #  # ]:          0 :                 sResult.append(sTemplate.copy(nIndex, sTemplate.getLength()-nIndex));
     400                 :          0 :                 break;
     401                 :            :             }
     402                 :            :             else
     403                 :            :             {
     404                 :            :                 // Add the part preceding the next %.
     405         [ #  # ]:          0 :                 sResult.append(sTemplate.copy(nIndex, nStartIndex-nIndex));
     406                 :            : 
     407                 :            :                 // Get the placeholder
     408                 :          0 :                 ++nIndex;
     409                 :          0 :                 ++nStartIndex;
     410                 :          0 :                 const sal_Int32 nEndIndex (sTemplate.indexOf('%', nStartIndex+1));
     411                 :          0 :                 const OUString sPlaceholder (sTemplate.copy(nStartIndex, nEndIndex-nStartIndex));
     412                 :          0 :                 nIndex = nEndIndex+1;
     413                 :            : 
     414                 :            :                 // Replace the placeholder with its current value.
     415         [ #  # ]:          0 :                 if (sPlaceholder == sCurrentSlideNumberPlaceholder)
     416         [ #  # ]:          0 :                     sResult.append(sCurrentSlideNumber);
     417         [ #  # ]:          0 :                 else if (sPlaceholder == sCurrentSlideNamePlaceholder)
     418         [ #  # ]:          0 :                     sResult.append(sCurrentSlideName);
     419         [ #  # ]:          0 :                 else if (sPlaceholder == sSlideCountPlaceholder)
     420         [ #  # ]:          0 :                     sResult.append(sSlideCount);
     421                 :            :             }
     422                 :            :         }
     423                 :            : 
     424         [ #  # ]:          0 :         (*iPane)->msTitle = sResult.makeStringAndClear();
     425         [ #  # ]:          0 :         if ((*iPane)->mxPane.is())
     426         [ #  # ]:          0 :             (*iPane)->mxPane->SetTitle((*iPane)->msTitle);
     427         [ #  # ]:          0 :     }
     428                 :            : }
     429                 :            : 
     430                 :          0 : void PresenterController::UpdateViews (void)
     431                 :            : {
     432                 :            :     // Tell all views about the slides they should display.
     433                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
     434 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
                 [ #  # ]
     435                 :            :     {
     436         [ #  # ]:          0 :         Reference<drawing::XDrawView> xDrawView ((*iPane)->mxView, UNO_QUERY);
     437         [ #  # ]:          0 :         if (xDrawView.is())
     438 [ #  # ][ #  # ]:          0 :             xDrawView->setCurrentPage(mxCurrentSlide);
     439                 :          0 :     }
     440                 :          0 : }
     441                 :            : 
     442                 :            : SharedBitmapDescriptor
     443                 :          0 :     PresenterController::GetViewBackground (const ::rtl::OUString& rsViewURL) const
     444                 :            : {
     445         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     446                 :            :     {
     447         [ #  # ]:          0 :         const OUString sStyleName (mpTheme->GetStyleName(rsViewURL));
     448         [ #  # ]:          0 :         return mpTheme->GetBitmap(sStyleName, A2S("Background"));
     449                 :            :     }
     450                 :          0 :     return SharedBitmapDescriptor();
     451                 :            : }
     452                 :            : 
     453                 :            : PresenterTheme::SharedFontDescriptor
     454                 :          0 :     PresenterController::GetViewFont (const ::rtl::OUString& rsViewURL) const
     455                 :            : {
     456         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     457                 :            :     {
     458         [ #  # ]:          0 :         const OUString sStyleName (mpTheme->GetStyleName(rsViewURL));
     459         [ #  # ]:          0 :         return mpTheme->GetFont(sStyleName);
     460                 :            :     }
     461                 :          0 :     return PresenterTheme::SharedFontDescriptor();
     462                 :            : }
     463                 :            : 
     464                 :          0 : ::boost::shared_ptr<PresenterTheme> PresenterController::GetTheme (void) const
     465                 :            : {
     466                 :          0 :     return mpTheme;
     467                 :            : }
     468                 :            : 
     469                 :          0 : ::rtl::Reference<PresenterWindowManager> PresenterController::GetWindowManager (void) const
     470                 :            : {
     471                 :          0 :     return mpWindowManager;
     472                 :            : }
     473                 :            : 
     474                 :            : Reference<presentation::XSlideShowController>
     475                 :          0 :     PresenterController::GetSlideShowController(void) const
     476                 :            : {
     477                 :          0 :     return mxSlideShowController;
     478                 :            : }
     479                 :            : 
     480                 :          0 : rtl::Reference<PresenterPaneContainer> PresenterController::GetPaneContainer (void) const
     481                 :            : {
     482                 :          0 :     return mpPaneContainer;
     483                 :            : }
     484                 :            : 
     485                 :          0 : ::rtl::Reference<PresenterPaneBorderPainter> PresenterController::GetPaneBorderPainter (void) const
     486                 :            : {
     487                 :          0 :     return mpPaneBorderPainter;
     488                 :            : }
     489                 :            : 
     490                 :          0 : ::boost::shared_ptr<PresenterCanvasHelper> PresenterController::GetCanvasHelper (void) const
     491                 :            : {
     492                 :          0 :     return mpCanvasHelper;
     493                 :            : }
     494                 :            : 
     495                 :          0 : Reference<drawing::XPresenterHelper> PresenterController::GetPresenterHelper (void) const
     496                 :            : {
     497                 :          0 :     return mxPresenterHelper;
     498                 :            : }
     499                 :            : 
     500                 :          0 : ::boost::shared_ptr<PresenterPaintManager> PresenterController::GetPaintManager (void) const
     501                 :            : {
     502                 :          0 :     return mpPaintManager;
     503                 :            : }
     504                 :            : 
     505                 :          0 : void PresenterController::ShowView (const OUString& rsViewURL)
     506                 :            : {
     507                 :            :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     508         [ #  # ]:          0 :         mpPaneContainer->FindViewURL(rsViewURL));
     509         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     510                 :            :     {
     511                 :          0 :         pDescriptor->mbIsActive = true;
     512         [ #  # ]:          0 :         mxConfigurationController->requestResourceActivation(
     513                 :          0 :             pDescriptor->mxPaneId,
     514         [ #  # ]:          0 :             ResourceActivationMode_ADD);
     515         [ #  # ]:          0 :         mxConfigurationController->requestResourceActivation(
     516                 :            :             ResourceId::createWithAnchor(
     517                 :            :                 mxComponentContext,
     518                 :            :                 rsViewURL,
     519                 :          0 :                 pDescriptor->mxPaneId),
     520 [ #  # ][ #  # ]:          0 :             ResourceActivationMode_REPLACE);
     521         [ #  # ]:          0 :     }
     522                 :          0 : }
     523                 :            : 
     524                 :          0 : void PresenterController::HideView (const OUString& rsViewURL)
     525                 :            : {
     526                 :            :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     527         [ #  # ]:          0 :         mpPaneContainer->FindViewURL(rsViewURL));
     528         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     529                 :            :     {
     530         [ #  # ]:          0 :         mxConfigurationController->requestResourceDeactivation(
     531                 :            :             ResourceId::createWithAnchor(
     532                 :            :                 mxComponentContext,
     533                 :            :                 rsViewURL,
     534 [ #  # ][ #  # ]:          0 :                 pDescriptor->mxPaneId));
     535         [ #  # ]:          0 :     }
     536                 :          0 : }
     537                 :            : 
     538                 :          0 : void PresenterController::DispatchUnoCommand (const OUString& rsCommand) const
     539                 :            : {
     540         [ #  # ]:          0 :     if ( ! mxUrlTransformer.is())
     541                 :            :         return;
     542                 :            : 
     543                 :          0 :     util::URL aURL;
     544                 :          0 :     aURL.Complete = rsCommand;
     545 [ #  # ][ #  # ]:          0 :     mxUrlTransformer->parseStrict(aURL);
     546                 :            : 
     547         [ #  # ]:          0 :     Reference<frame::XDispatch> xDispatch (GetDispatch(aURL));
     548         [ #  # ]:          0 :     if ( ! xDispatch.is())
     549                 :            :         return;
     550                 :            : 
     551 [ #  # ][ #  # ]:          0 :     xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     552                 :            : }
     553                 :            : 
     554                 :          0 : Reference<css::frame::XDispatch> PresenterController::GetDispatch (const util::URL& rURL) const
     555                 :            : {
     556         [ #  # ]:          0 :     if ( ! mxController.is())
     557         [ #  # ]:          0 :         return NULL;
     558                 :            : 
     559 [ #  # ][ #  # ]:          0 :     Reference<frame::XDispatchProvider> xDispatchProvider (mxController->getFrame(), UNO_QUERY);
                 [ #  # ]
     560         [ #  # ]:          0 :     if ( ! xDispatchProvider.is())
     561         [ #  # ]:          0 :         return NULL;
     562                 :            : 
     563         [ #  # ]:          0 :     return xDispatchProvider->queryDispatch(
     564                 :            :         rURL,
     565                 :            :         OUString(),
     566         [ #  # ]:          0 :         frame::FrameSearchFlag::SELF);
     567                 :            : }
     568                 :            : 
     569                 :          0 : util::URL PresenterController::CreateURLFromString (const ::rtl::OUString& rsURL) const
     570                 :            : {
     571                 :          0 :     util::URL aURL;
     572                 :            : 
     573         [ #  # ]:          0 :     if (mxUrlTransformer.is())
     574                 :            :     {
     575                 :          0 :         aURL.Complete = rsURL;
     576 [ #  # ][ #  # ]:          0 :         mxUrlTransformer->parseStrict(aURL);
     577                 :            :     }
     578                 :            : 
     579                 :          0 :     return aURL;
     580                 :            : }
     581                 :            : 
     582                 :            : Reference<drawing::framework::XConfigurationController>
     583                 :          0 :     PresenterController::GetConfigurationController (void) const
     584                 :            : {
     585                 :          0 :     return mxConfigurationController;
     586                 :            : }
     587                 :            : 
     588                 :          0 : Reference<drawing::XDrawPage> PresenterController::GetCurrentSlide (void) const
     589                 :            : {
     590                 :          0 :     return mxCurrentSlide;
     591                 :            : }
     592                 :            : 
     593                 :          0 : void PresenterController::SetAccessibilityActiveState (const bool bIsActive)
     594                 :            : {
     595         [ #  # ]:          0 :     if ( mbIsAccessibilityActive != bIsActive)
     596                 :            :     {
     597                 :          0 :         mbIsAccessibilityActive = bIsActive;
     598                 :          0 :         UpdatePaneTitles();
     599                 :            :     }
     600                 :          0 : }
     601                 :            : 
     602                 :          0 : bool PresenterController::IsAccessibilityActive (void) const
     603                 :            : {
     604                 :          0 :     return mbIsAccessibilityActive;
     605                 :            : }
     606                 :            : 
     607                 :          0 : void PresenterController::HandleMouseClick (const awt::MouseEvent& rEvent)
     608                 :            : {
     609         [ #  # ]:          0 :     if (mxSlideShowController.is())
     610                 :            :     {
     611      [ #  #  # ]:          0 :         switch (rEvent.Buttons)
     612                 :            :         {
     613                 :            :             case awt::MouseButton::LEFT:
     614         [ #  # ]:          0 :                 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
     615                 :          0 :                     mxSlideShowController->gotoNextSlide();
     616                 :            :                 else
     617                 :          0 :                     mxSlideShowController->gotoNextEffect();
     618                 :          0 :                 break;
     619                 :            : 
     620                 :            :             case awt::MouseButton::RIGHT:
     621                 :          0 :                 mxSlideShowController->gotoPreviousSlide();
     622                 :          0 :                 break;
     623                 :            : 
     624                 :            :             default:
     625                 :            :                 // Other or multiple buttons.
     626                 :          0 :                 break;
     627                 :            :         }
     628                 :            :     }
     629                 :          0 : }
     630                 :            : 
     631                 :          0 : void PresenterController::RequestViews (
     632                 :            :     const bool bIsSlideSorterActive,
     633                 :            :     const bool bIsNotesViewActive,
     634                 :            :     const bool bIsHelpViewActive)
     635                 :            : {
     636                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
     637         [ #  # ]:          0 :     PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
     638 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
                 [ #  # ]
     639                 :            :     {
     640                 :          0 :         bool bActivate (true);
     641                 :          0 :         const OUString sViewURL ((*iPane)->msViewURL);
     642         [ #  # ]:          0 :         if (sViewURL == PresenterViewFactory::msNotesViewURL)
     643                 :            :         {
     644 [ #  # ][ #  # ]:          0 :             bActivate = bIsNotesViewActive && !bIsSlideSorterActive && !bIsHelpViewActive;
                 [ #  # ]
     645                 :            :         }
     646         [ #  # ]:          0 :         else if (sViewURL == PresenterViewFactory::msSlideSorterURL)
     647                 :            :         {
     648                 :          0 :             bActivate = bIsSlideSorterActive;
     649                 :            :         }
     650   [ #  #  #  # ]:          0 :         else if (sViewURL == PresenterViewFactory::msCurrentSlidePreviewViewURL
                 [ #  # ]
     651                 :          0 :             || sViewURL == PresenterViewFactory::msNextSlidePreviewViewURL)
     652                 :            :         {
     653 [ #  # ][ #  # ]:          0 :             bActivate = !bIsSlideSorterActive && ! bIsHelpViewActive;
     654                 :            :         }
     655         [ #  # ]:          0 :         else if (sViewURL == PresenterViewFactory::msToolBarViewURL)
     656                 :            :         {
     657                 :          0 :             bActivate = true;
     658                 :            :         }
     659         [ #  # ]:          0 :         else if (sViewURL == PresenterViewFactory::msHelpViewURL)
     660                 :            :         {
     661                 :          0 :             bActivate = bIsHelpViewActive;
     662                 :            :         }
     663                 :            : 
     664         [ #  # ]:          0 :         if (bActivate)
     665         [ #  # ]:          0 :             ShowView(sViewURL);
     666                 :            :         else
     667         [ #  # ]:          0 :             HideView(sViewURL);
     668                 :          0 :     }
     669                 :          0 : }
     670                 :            : 
     671                 :            : //----- XConfigurationChangeListener ------------------------------------------
     672                 :            : 
     673                 :          0 : void SAL_CALL PresenterController::notifyConfigurationChange (
     674                 :            :     const ConfigurationChangeEvent& rEvent)
     675                 :            :     throw (RuntimeException)
     676                 :            : {
     677         [ #  # ]:          0 :     ThrowIfDisposed();
     678                 :            : 
     679                 :          0 :     sal_Int32 nType (0);
     680         [ #  # ]:          0 :     if ( ! (rEvent.UserData >>= nType))
     681                 :          0 :         return;
     682                 :            : 
     683   [ #  #  #  # ]:          0 :     switch (nType)
     684                 :            :     {
     685                 :            :         case ResourceActivationEventType:
     686 [ #  # ][ #  # ]:          0 :             if (rEvent.ResourceId->compareTo(mxMainPaneId) == 0)
                 [ #  # ]
     687                 :            :             {
     688 [ #  # ][ #  # ]:          0 :                 InitializeMainPane(Reference<XPane>(rEvent.ResourceObject,UNO_QUERY));
     689                 :            :             }
     690 [ #  # ][ #  # ]:          0 :             else if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_DIRECT))
                 [ #  # ]
     691                 :            :             {
     692                 :            :                 // A pane bound to the main pane has been created and is
     693                 :            :                 // stored in the pane container.
     694         [ #  # ]:          0 :                 Reference<XPane> xPane (rEvent.ResourceObject,UNO_QUERY);
     695         [ #  # ]:          0 :                 if (xPane.is())
     696                 :            :                 {
     697                 :            :                     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     698 [ #  # ][ #  # ]:          0 :                         mpPaneContainer->FindPaneId(xPane->getResourceId()));
                 [ #  # ]
     699                 :            : 
     700                 :            :                     // When there is a call out anchor location set then tell the
     701                 :            :                     // window about it.
     702         [ #  # ]:          0 :                     if (pDescriptor->mbHasCalloutAnchor)
     703                 :          0 :                         pDescriptor->mxPane->SetCalloutAnchor(
     704 [ #  # ][ #  # ]:          0 :                             pDescriptor->maCalloutAnchorLocation);
     705                 :          0 :                 }
     706                 :            :             }
     707 [ #  # ][ #  # ]:          0 :             else if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_INDIRECT))
                 [ #  # ]
     708                 :            :             {
     709                 :            :                 // A view bound to one of the panes has been created and is
     710                 :            :                 // stored in the pane container along with its pane.
     711         [ #  # ]:          0 :                 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
     712         [ #  # ]:          0 :                 if (xView.is())
     713                 :            :                 {
     714                 :            :                     SharedBitmapDescriptor pViewBackground(
     715 [ #  # ][ #  # ]:          0 :                         GetViewBackground(xView->getResourceId()->getResourceURL()));
         [ #  # ][ #  # ]
                 [ #  # ]
     716 [ #  # ][ #  # ]:          0 :                     mpPaneContainer->StoreView(xView, pViewBackground);
     717         [ #  # ]:          0 :                     UpdateViews();
     718 [ #  # ][ #  # ]:          0 :                     mpWindowManager->NotifyViewCreation(xView);
     719                 :          0 :                 }
     720                 :            :             }
     721                 :          0 :             break;
     722                 :            : 
     723                 :            :         case ResourceDeactivationEventType:
     724 [ #  # ][ #  # ]:          0 :             if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_INDIRECT))
                 [ #  # ]
     725                 :            :             {
     726                 :            :                 // If this is a view then remove it from the pane container.
     727         [ #  # ]:          0 :                 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
     728         [ #  # ]:          0 :                 if (xView.is())
     729                 :            :                 {
     730                 :            :                     PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
     731         [ #  # ]:          0 :                         mpPaneContainer->RemoveView(xView));
     732                 :            : 
     733                 :            :                     // A possibly opaque view has been removed.  Update()
     734                 :            :                     // updates the clip polygon.
     735         [ #  # ]:          0 :                     mpWindowManager->Update();
     736                 :            :                     // Request the repainting of the area previously
     737                 :            :                     // occupied by the view.
     738         [ #  # ]:          0 :                     if (pDescriptor.get() != NULL)
     739 [ #  # ][ #  # ]:          0 :                         GetPaintManager()->Invalidate(pDescriptor->mxBorderWindow);
         [ #  # ][ #  # ]
     740                 :          0 :                 }
     741                 :            :             }
     742                 :          0 :             break;
     743                 :            : 
     744                 :            :         case ConfigurationUpdateEndEventType:
     745         [ #  # ]:          0 :             if (IsAccessibilityActive())
     746                 :            :             {
     747         [ #  # ]:          0 :                 mpAccessibleObject->UpdateAccessibilityHierarchy();
     748         [ #  # ]:          0 :                 UpdateCurrentSlide(0);
     749                 :            :             }
     750                 :          0 :             break;
     751                 :            :     }
     752                 :            : }
     753                 :            : 
     754                 :            : //----- XEventListener --------------------------------------------------------
     755                 :            : 
     756                 :          0 : void SAL_CALL PresenterController::disposing (
     757                 :            :     const lang::EventObject& rEvent)
     758                 :            :     throw (RuntimeException)
     759                 :            : {
     760         [ #  # ]:          0 :     if (rEvent.Source == mxController)
     761                 :          0 :         mxController = NULL;
     762         [ #  # ]:          0 :     else if (rEvent.Source == mxConfigurationController)
     763                 :          0 :         mxConfigurationController = NULL;
     764         [ #  # ]:          0 :     else if (rEvent.Source == mxSlideShowController)
     765                 :          0 :         mxSlideShowController = NULL;
     766         [ #  # ]:          0 :     else if (rEvent.Source == mxMainWindow)
     767                 :          0 :         mxMainWindow = NULL;
     768                 :          0 : }
     769                 :            : 
     770                 :            : //----- XFrameActionListener --------------------------------------------------
     771                 :            : 
     772                 :          0 : void SAL_CALL PresenterController::frameAction (
     773                 :            :     const frame::FrameActionEvent& rEvent)
     774                 :            :     throw (RuntimeException)
     775                 :            : {
     776         [ #  # ]:          0 :     if (rEvent.Action == frame::FrameAction_FRAME_ACTIVATED)
     777                 :            :     {
     778         [ #  # ]:          0 :         if (mxSlideShowController.is())
     779                 :          0 :             mxSlideShowController->activate();
     780                 :            :     }
     781                 :          0 : }
     782                 :            : 
     783                 :            : //----- XKeyListener ----------------------------------------------------------
     784                 :            : 
     785                 :          0 : void SAL_CALL PresenterController::keyPressed (const awt::KeyEvent& rEvent)
     786                 :            :     throw (RuntimeException)
     787                 :            : {
     788                 :            :     // Tell all views about the unhandled key event.
     789                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
     790 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
                 [ #  # ]
     791                 :            :     {
     792         [ #  # ]:          0 :         if ( ! (*iPane)->mbIsActive)
     793                 :          0 :             continue;
     794                 :            : 
     795         [ #  # ]:          0 :         Reference<awt::XKeyListener> xKeyListener ((*iPane)->mxView, UNO_QUERY);
     796         [ #  # ]:          0 :         if (xKeyListener.is())
     797 [ #  # ][ #  # ]:          0 :             xKeyListener->keyPressed(rEvent);
     798                 :          0 :     }
     799                 :          0 : }
     800                 :            : 
     801                 :          0 : void SAL_CALL PresenterController::keyReleased (const awt::KeyEvent& rEvent)
     802                 :            :     throw (RuntimeException)
     803                 :            : {
     804         [ #  # ]:          0 :     if (rEvent.Source != mxMainWindow)
     805                 :          0 :         return;
     806                 :            : 
     807   [ #  #  #  #  :          0 :     switch (rEvent.KeyCode)
          #  #  #  #  #  
             #  #  #  # ]
     808                 :            :     {
     809                 :            :         case awt::Key::ESCAPE:
     810                 :            :         case awt::Key::SUBTRACT:
     811                 :            :         {
     812         [ #  # ]:          0 :             if( mxController.is() )
     813                 :            :             {
     814 [ #  # ][ #  # ]:          0 :                 Reference< XPresentationSupplier > xPS( mxController->getModel(), UNO_QUERY );
                 [ #  # ]
     815         [ #  # ]:          0 :                 if( xPS.is() )
     816                 :            :                 {
     817 [ #  # ][ #  # ]:          0 :                     Reference< XPresentation > xP( xPS->getPresentation() );
     818         [ #  # ]:          0 :                     if( xP.is() )
     819 [ #  # ][ #  # ]:          0 :                         xP->end();
     820                 :          0 :                 }
     821                 :            :             }
     822                 :            :         }
     823                 :            :         break;
     824                 :            : 
     825                 :            :         case awt::Key::PAGEDOWN:
     826         [ #  # ]:          0 :             if (mxSlideShowController.is())
     827                 :            :             {
     828         [ #  # ]:          0 :                 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
     829 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->gotoNextSlide();
     830                 :            :                 else
     831 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->gotoNextEffect();
     832                 :            :             }
     833                 :            :             break;
     834                 :            : 
     835                 :            :         case awt::Key::RIGHT:
     836                 :            :         case awt::Key::SPACE:
     837                 :            :         case awt::Key::DOWN:
     838                 :            :         case awt::Key::N:
     839         [ #  # ]:          0 :             if (mxSlideShowController.is())
     840                 :            :             {
     841 [ #  # ][ #  # ]:          0 :                 mxSlideShowController->gotoNextEffect();
     842                 :            :             }
     843                 :            :             break;
     844                 :            : 
     845                 :            :         case awt::Key::PAGEUP:
     846         [ #  # ]:          0 :             if (mxSlideShowController.is())
     847                 :            :             {
     848         [ #  # ]:          0 :                 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
     849 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->gotoPreviousSlide();
     850                 :            :                 else
     851 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->gotoPreviousEffect();
     852                 :            :             }
     853                 :            :             break;
     854                 :            : 
     855                 :            :         case awt::Key::LEFT:
     856                 :            :         case awt::Key::UP:
     857                 :            :         case awt::Key::P:
     858                 :            :         case awt::Key::BACKSPACE:
     859         [ #  # ]:          0 :             if (mxSlideShowController.is())
     860                 :            :             {
     861 [ #  # ][ #  # ]:          0 :                 mxSlideShowController->gotoPreviousEffect();
     862                 :            :             }
     863                 :            :             break;
     864                 :            : 
     865                 :            :         case awt::Key::HOME:
     866         [ #  # ]:          0 :             if (mxSlideShowController.is())
     867                 :            :             {
     868 [ #  # ][ #  # ]:          0 :                 mxSlideShowController->gotoFirstSlide();
     869                 :            :             }
     870                 :            :             break;
     871                 :            : 
     872                 :            :         case awt::Key::END:
     873         [ #  # ]:          0 :             if (mxSlideShowController.is())
     874                 :            :             {
     875 [ #  # ][ #  # ]:          0 :                 mxSlideShowController->gotoLastSlide();
     876                 :            :             }
     877                 :            :             break;
     878                 :            : 
     879                 :            :         case awt::Key::W:
     880                 :            :         case awt::Key::COMMA:
     881         [ #  # ]:          0 :             if (mxSlideShowController.is())
     882                 :            :             {
     883 [ #  # ][ #  # ]:          0 :                 if (mxSlideShowController->isPaused())
                 [ #  # ]
     884 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->resume();
     885                 :            :                 else
     886 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->blankScreen(0x00ffffff);
     887                 :            :             }
     888                 :            :             break;
     889                 :            : 
     890                 :            :         case awt::Key::B:
     891                 :            :         case awt::Key::POINT:
     892         [ #  # ]:          0 :             if (mxSlideShowController.is())
     893                 :            :             {
     894 [ #  # ][ #  # ]:          0 :                 if (mxSlideShowController->isPaused())
                 [ #  # ]
     895 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->resume();
     896                 :            :                 else
     897 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->blankScreen(0x00000000);
     898                 :            :             }
     899                 :            :             break;
     900                 :            : 
     901                 :            :         case awt::Key::NUM0:
     902                 :            :         case awt::Key::NUM1:
     903                 :            :         case awt::Key::NUM2:
     904                 :            :         case awt::Key::NUM3:
     905                 :            :         case awt::Key::NUM4:
     906                 :            :         case awt::Key::NUM5:
     907                 :            :         case awt::Key::NUM6:
     908                 :            :         case awt::Key::NUM7:
     909                 :            :         case awt::Key::NUM8:
     910                 :            :         case awt::Key::NUM9:
     911         [ #  # ]:          0 :             HandleNumericKeyPress(rEvent.KeyCode-awt::Key::NUM0, rEvent.Modifiers);
     912                 :            :             break;
     913                 :            : 
     914                 :            :         case awt::Key::RETURN:
     915         [ #  # ]:          0 :             if (mnPendingSlideNumber > 0)
     916                 :            :             {
     917         [ #  # ]:          0 :                 if (mxSlideShowController.is())
     918 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->gotoSlideIndex(mnPendingSlideNumber - 1);
     919                 :          0 :                 mnPendingSlideNumber = -1;
     920                 :            :             }
     921                 :            :             else
     922                 :            :             {
     923         [ #  # ]:          0 :                 if (mxSlideShowController.is())
     924 [ #  # ][ #  # ]:          0 :                     mxSlideShowController->gotoNextEffect();
     925                 :            :             }
     926                 :            : 
     927                 :            :             break;
     928                 :            : 
     929                 :            :         case awt::Key::F1:
     930                 :            :             // Toggle the help view.
     931         [ #  # ]:          0 :             if (mpWindowManager.get() != NULL)
     932                 :            :             {
     933 [ #  # ][ #  # ]:          0 :                 if (mpWindowManager->GetViewMode() != PresenterWindowManager::VM_Help)
     934         [ #  # ]:          0 :                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_Help);
     935                 :            :                 else
     936         [ #  # ]:          0 :                     mpWindowManager->SetHelpViewState(false);
     937                 :            :             }
     938                 :            : 
     939                 :            :             break;
     940                 :            : 
     941                 :            :         default:
     942                 :            :             // Tell all views about the unhandled key event.
     943                 :          0 :             PresenterPaneContainer::PaneList::const_iterator iPane;
     944 [ #  # ][ #  # ]:          0 :             for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
                 [ #  # ]
     945                 :            :             {
     946         [ #  # ]:          0 :                 if ( ! (*iPane)->mbIsActive)
     947                 :          0 :                     continue;
     948                 :            : 
     949         [ #  # ]:          0 :                 Reference<awt::XKeyListener> xKeyListener ((*iPane)->mxView, UNO_QUERY);
     950         [ #  # ]:          0 :                 if (xKeyListener.is())
     951 [ #  # ][ #  # ]:          0 :                     xKeyListener->keyReleased(rEvent);
     952                 :          0 :             }
     953                 :            :             break;
     954                 :            :     }
     955                 :            : }
     956                 :            : 
     957                 :          0 : void PresenterController::HandleNumericKeyPress (
     958                 :            :     const sal_Int32 nKey,
     959                 :            :     const sal_Int32 nModifiers)
     960                 :            : {
     961      [ #  #  # ]:          0 :     switch (nModifiers)
     962                 :            :     {
     963                 :            :         case 0:
     964         [ #  # ]:          0 :             if (mnPendingSlideNumber == -1)
     965                 :          0 :                 mnPendingSlideNumber = 0;
     966                 :          0 :             UpdatePendingSlideNumber(mnPendingSlideNumber * 10 + nKey);
     967                 :          0 :             break;
     968                 :            : 
     969                 :            :         case awt::KeyModifier::MOD1:
     970                 :            :             // Ctrl-1, Ctrl-2, and Ctrl-3 are used to switch between views
     971                 :            :             // (slide view, notes view, normal)
     972                 :          0 :             mnPendingSlideNumber = -1;
     973         [ #  # ]:          0 :             if (mpWindowManager.get() == NULL)
     974                 :          0 :                 return;
     975   [ #  #  #  # ]:          0 :             switch(nKey)
     976                 :            :             {
     977                 :            :                 case 1:
     978                 :          0 :                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_Standard);
     979                 :          0 :                     break;
     980                 :            :                 case 2:
     981                 :          0 :                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_Notes);
     982                 :          0 :                     break;
     983                 :            :                 case 3:
     984                 :          0 :                     mpWindowManager->SetViewMode(PresenterWindowManager::VM_SlideOverview);
     985                 :          0 :                     break;
     986                 :            :                 default:
     987                 :            :                     // Ignore unsupported key.
     988                 :          0 :                     break;
     989                 :            :             }
     990                 :            : 
     991                 :            :         default:
     992                 :            :             // Ignore unsupported modifiers.
     993                 :          0 :             break;
     994                 :            :     }
     995                 :            : }
     996                 :            : 
     997                 :            : //----- XFocusListener --------------------------------------------------------
     998                 :            : 
     999                 :          0 : void SAL_CALL PresenterController::focusGained (const css::awt::FocusEvent& rEvent)
    1000                 :            :     throw (css::uno::RuntimeException)
    1001                 :            : {
    1002                 :            :     (void)rEvent;
    1003                 :          0 : }
    1004                 :            : 
    1005                 :          0 : void SAL_CALL PresenterController::focusLost (const css::awt::FocusEvent& rEvent)
    1006                 :            :     throw (css::uno::RuntimeException)
    1007                 :            : {
    1008                 :            :     (void)rEvent;
    1009                 :          0 : }
    1010                 :            : 
    1011                 :            : //----- XMouseListener --------------------------------------------------------
    1012                 :            : 
    1013                 :          0 : void SAL_CALL PresenterController::mousePressed (const css::awt::MouseEvent& rEvent)
    1014                 :            :     throw (css::uno::RuntimeException)
    1015                 :            : {
    1016                 :            :     (void)rEvent;
    1017         [ #  # ]:          0 :     if (mxMainWindow.is())
    1018                 :          0 :         mxMainWindow->setFocus();
    1019                 :          0 : }
    1020                 :            : 
    1021                 :          0 : void SAL_CALL PresenterController::mouseReleased (const css::awt::MouseEvent& rEvent)
    1022                 :            :     throw (css::uno::RuntimeException)
    1023                 :            : {
    1024                 :            :     (void)rEvent;
    1025                 :          0 : }
    1026                 :            : 
    1027                 :          0 : void SAL_CALL PresenterController::mouseEntered (const css::awt::MouseEvent& rEvent)
    1028                 :            :     throw (css::uno::RuntimeException)
    1029                 :            : {
    1030                 :            :     (void)rEvent;
    1031                 :          0 : }
    1032                 :            : 
    1033                 :          0 : void SAL_CALL PresenterController::mouseExited (const css::awt::MouseEvent& rEvent)
    1034                 :            :     throw (css::uno::RuntimeException)
    1035                 :            : {
    1036                 :            :     (void)rEvent;
    1037                 :          0 : }
    1038                 :            : 
    1039                 :            : //----- XMouseMotionListener --------------------------------------------------
    1040                 :            : 
    1041                 :          0 : void SAL_CALL PresenterController::mouseMoved (const css::awt::MouseEvent& rEvent)
    1042                 :            :     throw (css::uno::RuntimeException)
    1043                 :            : {
    1044                 :            :     (void)rEvent;
    1045                 :          0 : }
    1046                 :            : 
    1047                 :          0 : void SAL_CALL PresenterController::mouseDragged (const css::awt::MouseEvent& rEvent)
    1048                 :            :     throw (css::uno::RuntimeException)
    1049                 :            : {
    1050                 :            :     (void)rEvent;
    1051                 :          0 : }
    1052                 :            : 
    1053                 :            : //-----------------------------------------------------------------------------
    1054                 :            : 
    1055                 :          0 : void PresenterController::InitializeMainPane (const Reference<XPane>& rxPane)
    1056                 :            : {
    1057         [ #  # ]:          0 :     if ( ! rxPane.is())
    1058                 :          0 :         return;
    1059                 :            : 
    1060                 :            :     mpAccessibleObject = new PresenterAccessible(
    1061                 :            :         mxComponentContext,
    1062                 :            :         this,
    1063 [ #  # ][ #  # ]:          0 :         rxPane);
    1064                 :            : 
    1065         [ #  # ]:          0 :     LoadTheme(rxPane);
    1066                 :            : 
    1067                 :            :     // Main pane has been created and is now observed by the window
    1068                 :            :     // manager.
    1069         [ #  # ]:          0 :     mpWindowManager->SetParentPane(rxPane);
    1070         [ #  # ]:          0 :     mpWindowManager->SetTheme(mpTheme);
    1071                 :            : 
    1072         [ #  # ]:          0 :     if (mpPaneBorderPainter.get() != NULL)
    1073         [ #  # ]:          0 :         mpPaneBorderPainter->SetTheme(mpTheme);
    1074                 :            : 
    1075                 :            :     // Add key listener
    1076 [ #  # ][ #  # ]:          0 :     mxMainWindow = rxPane->getWindow();
                 [ #  # ]
    1077         [ #  # ]:          0 :     if (mxMainWindow.is())
    1078                 :            :     {
    1079 [ #  # ][ #  # ]:          0 :         mxMainWindow->addKeyListener(this);
                 [ #  # ]
    1080 [ #  # ][ #  # ]:          0 :         mxMainWindow->addFocusListener(this);
                 [ #  # ]
    1081 [ #  # ][ #  # ]:          0 :         mxMainWindow->addMouseListener(this);
                 [ #  # ]
    1082 [ #  # ][ #  # ]:          0 :         mxMainWindow->addMouseMotionListener(this);
                 [ #  # ]
    1083                 :            :     }
    1084         [ #  # ]:          0 :     Reference<XPane2> xPane2 (rxPane, UNO_QUERY);
    1085         [ #  # ]:          0 :     if (xPane2.is())
    1086 [ #  # ][ #  # ]:          0 :         xPane2->setVisible(sal_True);
    1087                 :            : 
    1088 [ #  # ][ #  # ]:          0 :     mpPaintManager.reset(new PresenterPaintManager(mxMainWindow, mxPresenterHelper, mpPaneContainer));
                 [ #  # ]
    1089                 :            : 
    1090 [ #  # ][ #  # ]:          0 :     mxCanvas = Reference<rendering::XSpriteCanvas>(rxPane->getCanvas(), UNO_QUERY);
         [ #  # ][ #  # ]
    1091                 :            : 
    1092         [ #  # ]:          0 :     if (mxSlideShowController.is())
    1093 [ #  # ][ #  # ]:          0 :         mxSlideShowController->activate();
    1094                 :            : 
    1095         [ #  # ]:          0 :     UpdateCurrentSlide(0);
    1096                 :            : }
    1097                 :            : 
    1098                 :          0 : void PresenterController::LoadTheme (const Reference<XPane>& rxPane)
    1099                 :            : {
    1100                 :            :     // Create (load) the current theme.
    1101         [ #  # ]:          0 :     if (rxPane.is())
    1102 [ #  # ][ #  # ]:          0 :         mpTheme.reset(new PresenterTheme(mxComponentContext, OUString(), rxPane->getCanvas()));
         [ #  # ][ #  # ]
                 [ #  # ]
    1103                 :          0 : }
    1104                 :            : 
    1105                 :          0 : double PresenterController::GetSlideAspectRatio (void) const
    1106                 :            : {
    1107                 :          0 :     double nSlideAspectRatio (28.0/21.0);
    1108                 :            : 
    1109                 :            :     try
    1110                 :            :     {
    1111         [ #  # ]:          0 :         if (mxController.is())
    1112                 :            :         {
    1113                 :            :             Reference<drawing::XDrawPagesSupplier> xSlideSupplier (
    1114 [ #  # ][ #  # ]:          0 :                 mxController->getModel(), UNO_QUERY_THROW);
                 [ #  # ]
    1115 [ #  # ][ #  # ]:          0 :             Reference<drawing::XDrawPages> xSlides (xSlideSupplier->getDrawPages());
    1116 [ #  # ][ #  # ]:          0 :             if (xSlides.is() && xSlides->getCount()>0)
         [ #  # ][ #  # ]
                 [ #  # ]
    1117                 :            :             {
    1118 [ #  # ][ #  # ]:          0 :                 Reference<beans::XPropertySet> xProperties(xSlides->getByIndex(0),UNO_QUERY_THROW);
                 [ #  # ]
    1119                 :          0 :                 sal_Int32 nWidth (28000);
    1120                 :          0 :                 sal_Int32 nHeight (21000);
    1121         [ #  # ]:          0 :                 if ((xProperties->getPropertyValue(OUString("Width")) >>= nWidth)
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
             #  #  #  # ]
                 [ #  # ]
    1122 [ #  # ][ #  # ]:          0 :                     && (xProperties->getPropertyValue(OUString("Height")) >>= nHeight)
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1123                 :            :                     && nHeight > 0)
    1124                 :            :                 {
    1125                 :          0 :                     nSlideAspectRatio = double(nWidth) / double(nHeight);
    1126                 :          0 :                 }
    1127         [ #  # ]:          0 :             }
    1128                 :            :         }
    1129                 :            :     }
    1130                 :          0 :     catch (RuntimeException&)
    1131                 :            :     {
    1132                 :            :         OSL_ASSERT(false);
    1133                 :            :     }
    1134                 :            : 
    1135                 :          0 :     return nSlideAspectRatio;
    1136                 :            : }
    1137                 :            : 
    1138                 :          0 : void PresenterController::UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber)
    1139                 :            : {
    1140                 :          0 :     mnPendingSlideNumber = nPendingSlideNumber;
    1141                 :            : 
    1142         [ #  # ]:          0 :     if (mpTheme.get() == NULL)
    1143                 :            :         return;
    1144                 :            : 
    1145         [ #  # ]:          0 :     if ( ! mxMainWindow.is())
    1146                 :            :         return;
    1147                 :            : 
    1148                 :            :     PresenterTheme::SharedFontDescriptor pFont (
    1149         [ #  # ]:          0 :         mpTheme->GetFont(A2S("PendingSlideNumberFont")));
    1150         [ #  # ]:          0 :     if (pFont.get() == NULL)
    1151                 :            :         return;
    1152                 :            : 
    1153 [ #  # ][ #  # ]:          0 :     pFont->PrepareFont(Reference<rendering::XCanvas>(mxCanvas, UNO_QUERY));
    1154         [ #  # ]:          0 :     if ( ! pFont->mxFont.is())
    1155                 :            :         return;
    1156                 :            : 
    1157                 :          0 :     const OUString sText (OUString::valueOf(mnPendingSlideNumber));
    1158                 :          0 :     rendering::StringContext aContext (sText, 0, sText.getLength());
    1159                 :            :     Reference<rendering::XTextLayout> xLayout (
    1160         [ #  # ]:          0 :         pFont->mxFont->createTextLayout(
    1161                 :            :             aContext,
    1162                 :            :             rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
    1163 [ #  # ][ #  # ]:          0 :             0));
                 [ #  # ]
    1164                 :            : }
    1165                 :            : 
    1166                 :          0 : void PresenterController::ThrowIfDisposed (void) const
    1167                 :            :     throw (::com::sun::star::lang::DisposedException)
    1168                 :            : {
    1169 [ #  # ][ #  # ]:          0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
    1170                 :            :     {
    1171                 :            :         throw lang::DisposedException (
    1172                 :            :             OUString( "PresenterController object has already been disposed"),
    1173 [ #  # ][ #  # ]:          0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
    1174                 :            :     }
    1175                 :          0 : }
    1176                 :            : 
    1177                 :          0 : void PresenterController::SwitchMonitors (void)
    1178                 :            : {
    1179         [ #  # ]:          0 :     Reference<lang::XEventListener> xScreen( mxScreen );
    1180         [ #  # ]:          0 :     if (!xScreen.is())
    1181                 :            :         return;
    1182                 :            : 
    1183 [ #  # ][ #  # ]:          0 :     PresenterScreen *pScreen = dynamic_cast<PresenterScreen *>(xScreen.get());
    1184         [ #  # ]:          0 :     if (!pScreen)
    1185                 :            :         return;
    1186                 :            : 
    1187 [ #  # ][ #  # ]:          0 :     pScreen->SwitchMonitors();
    1188                 :            : }
    1189                 :            : 
    1190 [ +  - ][ +  - ]:         24 : } } // end of namespace ::sdext::presenter
    1191                 :            : 
    1192                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10