LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterWindowManager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 487 0.0 %
Date: 2012-08-25 Functions: 0 48 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 761 0.0 %

           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                 :            : #undef ENABLE_PANE_RESIZING
      30                 :            : //#define ENABLE_PANE_RESIZING
      31                 :            : 
      32                 :            : #include "PresenterWindowManager.hxx"
      33                 :            : #include "PresenterController.hxx"
      34                 :            : #include "PresenterGeometryHelper.hxx"
      35                 :            : #include "PresenterHelper.hxx"
      36                 :            : #include "PresenterPaintManager.hxx"
      37                 :            : #include "PresenterPaneBase.hxx"
      38                 :            : #include "PresenterPaneBorderManager.hxx"
      39                 :            : #include "PresenterPaneBorderPainter.hxx"
      40                 :            : #include "PresenterPaneContainer.hxx"
      41                 :            : #include "PresenterPaneFactory.hxx"
      42                 :            : #include "PresenterSprite.hxx"
      43                 :            : #include "PresenterToolBar.hxx"
      44                 :            : #include "PresenterViewFactory.hxx"
      45                 :            : #include "PresenterTheme.hxx"
      46                 :            : #include <com/sun/star/awt/InvalidateStyle.hpp>
      47                 :            : #include <com/sun/star/awt/PosSize.hpp>
      48                 :            : #include <com/sun/star/awt/SystemPointer.hpp>
      49                 :            : #include <com/sun/star/awt/XDevice.hpp>
      50                 :            : #include <com/sun/star/awt/XWindow2.hpp>
      51                 :            : #include <com/sun/star/awt/XWindowPeer.hpp>
      52                 :            : #include <com/sun/star/awt/WindowAttribute.hpp>
      53                 :            : #include <com/sun/star/container/XChild.hpp>
      54                 :            : #include <com/sun/star/drawing/framework/ResourceId.hpp>
      55                 :            : #include <com/sun/star/rendering/CompositeOperation.hpp>
      56                 :            : #include <com/sun/star/rendering/FillRule.hpp>
      57                 :            : #include <com/sun/star/rendering/PathCapType.hpp>
      58                 :            : #include <com/sun/star/rendering/PathJoinType.hpp>
      59                 :            : #include <com/sun/star/rendering/Texture.hpp>
      60                 :            : #include <com/sun/star/rendering/TexturingMode.hpp>
      61                 :            : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
      62                 :            : #include <math.h>
      63                 :            : 
      64                 :            : using namespace ::com::sun::star;
      65                 :            : using namespace ::com::sun::star::uno;
      66                 :            : using namespace ::com::sun::star::drawing::framework;
      67                 :            : using ::rtl::OUString;
      68                 :            : 
      69                 :            : #define A2S(pString) (::rtl::OUString(pString))
      70                 :            : 
      71                 :            : namespace sdext { namespace presenter {
      72                 :            : 
      73                 :            : //===== PresenterWindowManager ================================================
      74                 :            : 
      75                 :          0 : PresenterWindowManager::PresenterWindowManager (
      76                 :            :     const Reference<XComponentContext>& rxContext,
      77                 :            :     const ::rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
      78                 :            :     const ::rtl::Reference<PresenterController>& rpPresenterController)
      79                 :            :     : PresenterWindowManagerInterfaceBase(m_aMutex),
      80                 :            :       mxComponentContext(rxContext),
      81                 :            :       mpPresenterController(rpPresenterController),
      82                 :            :       mxParentWindow(),
      83                 :            :       mxParentCanvas(),
      84                 :            :       mxPaneBorderManager(),
      85                 :            :       mpPaneBorderPainter(),
      86                 :            :       mpPaneContainer(rpPaneContainer),
      87                 :            :       mbIsLayoutPending(true),
      88                 :            :       mbIsLayouting(false),
      89                 :            :       mpTheme(),
      90                 :            :       mpBackgroundBitmap(),
      91                 :            :       mxScaledBackgroundBitmap(),
      92                 :            :       maPaneBackgroundColor(),
      93                 :            :       mxClipPolygon(),
      94                 :            :       meLayoutMode(LM_Generic),
      95                 :            :       mbIsSlideSorterActive(false),
      96                 :            :       mbIsHelpViewActive(false),
      97                 :            :       maLayoutListeners(),
      98 [ #  # ][ #  # ]:          0 :       mbIsMouseClickPending(false)
         [ #  # ][ #  # ]
      99                 :            : {
     100                 :          0 :     UpdateWindowList();
     101                 :          0 : }
     102                 :            : 
     103 [ #  # ][ #  # ]:          0 : PresenterWindowManager::~PresenterWindowManager (void)
         [ #  # ][ #  # ]
     104                 :            : {
     105         [ #  # ]:          0 : }
     106                 :            : 
     107                 :          0 : void SAL_CALL PresenterWindowManager::disposing (void)
     108                 :            : {
     109         [ #  # ]:          0 :     NotifyDisposing();
     110                 :            : 
     111 [ #  # ][ #  # ]:          0 :     SetParentPane(NULL);
     112                 :            : 
     113         [ #  # ]:          0 :     Reference<lang::XComponent> xComponent (mxPaneBorderManager, UNO_QUERY);
     114         [ #  # ]:          0 :     if (xComponent.is())
     115 [ #  # ][ #  # ]:          0 :         xComponent->dispose();
     116         [ #  # ]:          0 :     mxPaneBorderManager = NULL;
     117                 :            : 
     118                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
     119         [ #  # ]:          0 :     PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
     120 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
                 [ #  # ]
     121                 :            :     {
     122         [ #  # ]:          0 :         if ((*iPane)->mxBorderWindow.is())
     123                 :            :         {
     124 [ #  # ][ #  # ]:          0 :             (*iPane)->mxBorderWindow->removeWindowListener(this);
                 [ #  # ]
     125 [ #  # ][ #  # ]:          0 :             (*iPane)->mxBorderWindow->removeFocusListener(this);
                 [ #  # ]
     126                 :            : #ifndef ENABLE_PANE_RESIZING
     127 [ #  # ][ #  # ]:          0 :             (*iPane)->mxBorderWindow->removeMouseListener(this);
                 [ #  # ]
     128                 :            : #endif
     129                 :            :         }
     130                 :          0 :     }
     131                 :          0 : }
     132                 :            : 
     133                 :          0 : void PresenterWindowManager::SetParentPane (
     134                 :            :     const Reference<drawing::framework::XPane>& rxPane)
     135                 :            : {
     136         [ #  # ]:          0 :     if (mxParentWindow.is())
     137                 :            :     {
     138         [ #  # ]:          0 :         mxParentWindow->removeWindowListener(this);
     139         [ #  # ]:          0 :         mxParentWindow->removePaintListener(this);
     140         [ #  # ]:          0 :         mxParentWindow->removeMouseListener(this);
     141         [ #  # ]:          0 :         mxParentWindow->removeFocusListener(this);
     142                 :            :     }
     143                 :          0 :     mxParentWindow = NULL;
     144                 :          0 :     mxParentCanvas = NULL;
     145                 :            : 
     146         [ #  # ]:          0 :     if (rxPane.is())
     147                 :            :     {
     148         [ #  # ]:          0 :         mxParentWindow = rxPane->getWindow();
     149         [ #  # ]:          0 :         mxParentCanvas = rxPane->getCanvas();
     150                 :            :     }
     151                 :            :     else
     152                 :            :     {
     153                 :          0 :         mxParentWindow = NULL;
     154                 :            :     }
     155                 :            : 
     156         [ #  # ]:          0 :     if (mxParentWindow.is())
     157                 :            :     {
     158 [ #  # ][ #  # ]:          0 :         mxParentWindow->addWindowListener(this);
                 [ #  # ]
     159 [ #  # ][ #  # ]:          0 :         mxParentWindow->addPaintListener(this);
                 [ #  # ]
     160 [ #  # ][ #  # ]:          0 :         mxParentWindow->addMouseListener(this);
                 [ #  # ]
     161 [ #  # ][ #  # ]:          0 :         mxParentWindow->addFocusListener(this);
                 [ #  # ]
     162                 :            : 
     163                 :            :         // We paint our own background, make that of the parent window transparent.
     164         [ #  # ]:          0 :         Reference<awt::XWindowPeer> xPeer (mxParentWindow, UNO_QUERY);
     165         [ #  # ]:          0 :         if (xPeer.is())
     166 [ #  # ][ #  # ]:          0 :             xPeer->setBackground(util::Color(0xff000000));
     167                 :            :     }
     168                 :          0 : }
     169                 :            : 
     170                 :          0 : void PresenterWindowManager::SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme)
     171                 :            : {
     172                 :          0 :     mpTheme = rpTheme;
     173                 :            : 
     174                 :            :     // Get background bitmap or background color from the theme.
     175                 :            : 
     176         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     177                 :            :     {
     178 [ #  # ][ #  # ]:          0 :         mpBackgroundBitmap = mpTheme->GetBitmap(OUString(), A2S("Background"));
                 [ #  # ]
     179                 :            :     }
     180                 :          0 : }
     181                 :            : 
     182                 :          0 : void PresenterWindowManager::NotifyViewCreation (const Reference<XView>& rxView)
     183                 :            : {
     184                 :            :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     185 [ #  # ][ #  # ]:          0 :         mpPaneContainer->FindPaneId(rxView->getResourceId()->getAnchor()));
         [ #  # ][ #  # ]
                 [ #  # ]
     186                 :            :     OSL_ASSERT(pDescriptor.get() != NULL);
     187         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     188                 :            :     {
     189         [ #  # ]:          0 :         Layout();
     190                 :            : 
     191                 :            :         mpPresenterController->GetPaintManager()->Invalidate(
     192                 :          0 :             pDescriptor->mxContentWindow,
     193                 :            :             (sal_Int16)(awt::InvalidateStyle::TRANSPARENT
     194 [ #  # ][ #  # ]:          0 :             | awt::InvalidateStyle::CHILDREN));
                 [ #  # ]
     195         [ #  # ]:          0 :     }
     196                 :          0 : }
     197                 :            : 
     198                 :          0 : void PresenterWindowManager::SetPanePosSizeAbsolute (
     199                 :            :     const OUString& rsPaneURL,
     200                 :            :     const double nX,
     201                 :            :     const double nY,
     202                 :            :     const double nWidth,
     203                 :            :     const double nHeight)
     204                 :            : {
     205                 :            :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     206         [ #  # ]:          0 :         mpPaneContainer->FindPaneURL(rsPaneURL));
     207         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     208                 :            :     {
     209 [ #  # ][ #  # ]:          0 :         awt::Rectangle aParentBox = mxParentWindow->getPosSize();
     210 [ #  # ][ #  # ]:          0 :         if (aParentBox.Width > 0 && aParentBox.Height > 0)
     211                 :            :         {
     212                 :          0 :             pDescriptor->mnLeft = nX / aParentBox.Width;
     213                 :          0 :             pDescriptor->mnTop = nY / aParentBox.Height;
     214                 :          0 :             pDescriptor->mnRight = (nX + nWidth) / aParentBox.Width;
     215                 :          0 :             pDescriptor->mnBottom = (nY + nHeight) / aParentBox.Height;
     216                 :            :         }
     217         [ #  # ]:          0 :         if (pDescriptor->mxBorderWindow.is())
     218         [ #  # ]:          0 :             pDescriptor->mxBorderWindow->setPosSize(
     219                 :            :                 ::sal::static_int_cast<sal_Int32>(nX),
     220                 :            :                 ::sal::static_int_cast<sal_Int32>(nY),
     221                 :            :                 ::sal::static_int_cast<sal_Int32>(nWidth),
     222                 :            :                 ::sal::static_int_cast<sal_Int32>(nHeight),
     223         [ #  # ]:          0 :                 awt::PosSize::POSSIZE);
     224         [ #  # ]:          0 :     }
     225                 :          0 : }
     226                 :            : 
     227                 :          0 : void PresenterWindowManager::SetPaneBorderPainter (
     228                 :            :     const ::rtl::Reference<PresenterPaneBorderPainter>& rPainter)
     229                 :            : {
     230                 :          0 :     mpPaneBorderPainter = rPainter;
     231                 :          0 : }
     232                 :            : 
     233                 :            : //----- XWindowListener -------------------------------------------------------
     234                 :            : 
     235                 :          0 : void SAL_CALL PresenterWindowManager::windowResized (const awt::WindowEvent& rEvent)
     236                 :            :     throw (RuntimeException)
     237                 :            : {
     238                 :          0 :     ThrowIfDisposed();
     239         [ #  # ]:          0 :     if (rEvent.Source == mxParentWindow)
     240                 :            :     {
     241                 :          0 :         Layout();
     242                 :            :     }
     243                 :            :     else
     244                 :            :     {
     245         [ #  # ]:          0 :         Reference<awt::XWindow> xWindow (rEvent.Source,UNO_QUERY);
     246         [ #  # ]:          0 :         if (xWindow.is())
     247                 :            :         {
     248         [ #  # ]:          0 :             UpdateWindowSize(xWindow);
     249                 :            : 
     250                 :            :             // Make sure the background of a transparent window is painted.
     251 [ #  # ][ #  # ]:          0 :             mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow);
                 [ #  # ]
     252                 :          0 :         }
     253                 :            :     }
     254                 :          0 : }
     255                 :            : 
     256                 :          0 : void SAL_CALL PresenterWindowManager::windowMoved (const awt::WindowEvent& rEvent)
     257                 :            :     throw (RuntimeException)
     258                 :            : {
     259                 :          0 :     ThrowIfDisposed();
     260         [ #  # ]:          0 :     if (rEvent.Source != mxParentWindow)
     261                 :            :     {
     262         [ #  # ]:          0 :         Reference<awt::XWindow> xWindow (rEvent.Source,UNO_QUERY);
     263         [ #  # ]:          0 :         UpdateWindowSize(xWindow);
     264                 :            : 
     265                 :            :         // Make sure the background of a transparent window is painted.
     266 [ #  # ][ #  # ]:          0 :         mpPresenterController->GetPaintManager()->Invalidate(xWindow);
                 [ #  # ]
     267                 :            :     }
     268                 :          0 : }
     269                 :            : 
     270                 :          0 : void SAL_CALL PresenterWindowManager::windowShown (const lang::EventObject& rEvent)
     271                 :            :     throw (RuntimeException)
     272                 :            : {
     273                 :            :     (void)rEvent;
     274                 :          0 : }
     275                 :            : 
     276                 :          0 : void SAL_CALL PresenterWindowManager::windowHidden (const lang::EventObject& rEvent)
     277                 :            :     throw (RuntimeException)
     278                 :            : {
     279                 :            :     (void)rEvent;
     280                 :          0 : }
     281                 :            : 
     282                 :            : //----- XPaintListener --------------------------------------------------------
     283                 :            : 
     284                 :          0 : void SAL_CALL PresenterWindowManager::windowPaint (const awt::PaintEvent& rEvent)
     285                 :            :     throw (RuntimeException)
     286                 :            : {
     287                 :          0 :     ThrowIfDisposed();
     288                 :            : 
     289         [ #  # ]:          0 :     if ( ! mxParentWindow.is())
     290                 :          0 :         return;
     291         [ #  # ]:          0 :     if ( ! mxParentCanvas.is())
     292                 :          0 :         return;
     293                 :            : 
     294         [ #  # ]:          0 :     if (mpTheme.get()!=NULL)
     295                 :            :     {
     296                 :            :         try
     297                 :            :         {
     298         [ #  # ]:          0 :             if (mbIsLayoutPending)
     299         [ #  # ]:          0 :                 Layout();
     300         [ #  # ]:          0 :             PaintBackground(rEvent.UpdateRect);
     301 [ #  # ][ #  # ]:          0 :             if ( ! PaintChildren(rEvent))
     302                 :            :             {
     303 [ #  # ][ #  # ]:          0 :                 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxParentCanvas, UNO_QUERY);
     304                 :            :                 //                if (xSpriteCanvas.is())
     305                 :            :                 //                    xSpriteCanvas->updateScreen(sal_False);
     306                 :            :             }
     307                 :            :         }
     308                 :          0 :         catch (RuntimeException&)
     309                 :            :         {
     310                 :            :             OSL_FAIL("paint failed!");
     311                 :            :         }
     312                 :            :     }
     313                 :            : }
     314                 :            : 
     315                 :            : //----- XMouseListener --------------------------------------------------------
     316                 :            : 
     317                 :          0 : void SAL_CALL PresenterWindowManager::mousePressed (const css::awt::MouseEvent& rEvent)
     318                 :            :     throw(css::uno::RuntimeException)
     319                 :            : {
     320                 :            :     (void)rEvent;
     321                 :          0 :     mbIsMouseClickPending = true;
     322                 :          0 : }
     323                 :            : 
     324                 :          0 : void SAL_CALL PresenterWindowManager::mouseReleased (const css::awt::MouseEvent& rEvent)
     325                 :            :     throw(css::uno::RuntimeException)
     326                 :            : {
     327                 :            : #ifndef ENABLE_PANE_RESIZING
     328         [ #  # ]:          0 :     if (mbIsMouseClickPending)
     329                 :            :     {
     330                 :          0 :         mbIsMouseClickPending = false;
     331                 :          0 :         mpPresenterController->HandleMouseClick(rEvent);
     332                 :            :     }
     333                 :            : #else
     334                 :            :     (void)rEvent;
     335                 :            : #endif
     336                 :          0 : }
     337                 :            : 
     338                 :          0 : void SAL_CALL PresenterWindowManager::mouseEntered (const css::awt::MouseEvent& rEvent)
     339                 :            :     throw(css::uno::RuntimeException)
     340                 :            : {
     341                 :            :     (void)rEvent;
     342                 :          0 :     mbIsMouseClickPending = false;
     343                 :          0 : }
     344                 :            : 
     345                 :          0 : void SAL_CALL PresenterWindowManager::mouseExited (const css::awt::MouseEvent& rEvent)
     346                 :            :     throw(css::uno::RuntimeException)
     347                 :            : {
     348                 :            :     (void)rEvent;
     349                 :          0 :     mbIsMouseClickPending = false;
     350                 :          0 : }
     351                 :            : 
     352                 :            : //----- XFocusListener --------------------------------------------------------
     353                 :            : 
     354                 :          0 : void SAL_CALL PresenterWindowManager::focusGained (const css::awt::FocusEvent& rEvent)
     355                 :            :     throw (css::uno::RuntimeException)
     356                 :            : {
     357                 :          0 :     ThrowIfDisposed();
     358                 :            :     (void)rEvent;
     359                 :            :     OSL_TRACE("PresenterWindowManager::focusGained window %x\n",
     360                 :            :         rEvent.Source.get());
     361                 :          0 : }
     362                 :            : 
     363                 :          0 : void SAL_CALL PresenterWindowManager::focusLost (const css::awt::FocusEvent& rEvent)
     364                 :            :     throw (css::uno::RuntimeException)
     365                 :            : {
     366                 :          0 :     ThrowIfDisposed();
     367                 :            :     (void)rEvent;
     368                 :          0 : }
     369                 :            : 
     370                 :            : //----- XEventListener --------------------------------------------------------
     371                 :            : 
     372                 :          0 : void SAL_CALL PresenterWindowManager::disposing (const lang::EventObject& rEvent)
     373                 :            :     throw (RuntimeException)
     374                 :            : {
     375         [ #  # ]:          0 :     if (rEvent.Source == mxParentWindow)
     376                 :          0 :         mxParentWindow = NULL;
     377                 :            :     else
     378                 :            :     {
     379         [ #  # ]:          0 :         Reference<awt::XWindow> xWindow (rEvent.Source, UNO_QUERY);
     380                 :            :     }
     381                 :          0 : }
     382                 :            : 
     383                 :            : //-----------------------------------------------------------------------------
     384                 :            : 
     385                 :          0 : bool PresenterWindowManager::PaintChildren (const awt::PaintEvent& rEvent) const
     386                 :            : {
     387                 :          0 :     bool bChildInvalidated (false);
     388                 :            : 
     389                 :            :     // Call windowPaint on all children that lie in or touch the
     390                 :            :     // update rectangle.
     391                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
     392         [ #  # ]:          0 :     PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
     393 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
                 [ #  # ]
     394                 :            :     {
     395                 :            :         try
     396                 :            :         {
     397                 :            :             // Make sure that the pane shall and can be painted.
     398         [ #  # ]:          0 :             if ( ! (*iPane)->mbIsActive)
     399                 :          0 :                 continue;
     400         [ #  # ]:          0 :             if ((*iPane)->mbIsSprite)
     401                 :          0 :                 continue;
     402         [ #  # ]:          0 :             if ( ! (*iPane)->mxPane.is())
     403                 :          0 :                 continue;
     404         [ #  # ]:          0 :             if ( ! (*iPane)->mxBorderWindow.is())
     405                 :          0 :                 continue;
     406                 :          0 :             Reference<awt::XWindow> xBorderWindow ((*iPane)->mxBorderWindow);
     407         [ #  # ]:          0 :             if ( ! xBorderWindow.is())
     408                 :          0 :                 continue;
     409                 :            : 
     410                 :            :             // Get the area in which the border of the pane has to be painted.
     411 [ #  # ][ #  # ]:          0 :             const awt::Rectangle aBorderBox (xBorderWindow->getPosSize());
     412                 :            :             const awt::Rectangle aBorderUpdateBox(
     413                 :            :                 PresenterGeometryHelper::Intersection(
     414                 :            :                     rEvent.UpdateRect,
     415         [ #  # ]:          0 :                     aBorderBox));
     416 [ #  # ][ #  # ]:          0 :             if (aBorderUpdateBox.Width<=0 || aBorderUpdateBox.Height<=0)
     417                 :          0 :                 continue;
     418                 :            : 
     419                 :            :             const awt::Rectangle aLocalBorderUpdateBox(
     420                 :            :                 PresenterGeometryHelper::TranslateRectangle(
     421                 :            :                     aBorderUpdateBox,
     422                 :            :                     -aBorderBox.X,
     423         [ #  # ]:          0 :                     -aBorderBox.Y));
     424                 :            : 
     425                 :            :             // Invalidate the area of the content window.
     426                 :            :             mpPresenterController->GetPaintManager()->Invalidate(
     427                 :            :                 xBorderWindow,
     428                 :            :                 aLocalBorderUpdateBox,
     429                 :            :                 sal_Int16(awt::InvalidateStyle::CHILDREN
     430 [ #  # ][ #  # ]:          0 :                     | awt::InvalidateStyle::NOTRANSPARENT));
         [ #  # ][ #  # ]
                 [ #  # ]
     431                 :            :         }
     432         [ #  # ]:          0 :         catch (RuntimeException&)
     433                 :            :         {
     434                 :            :             OSL_FAIL("paint children failed!");
     435                 :            :         }
     436                 :            :     }
     437                 :            : 
     438                 :          0 :     return bChildInvalidated;
     439                 :            : }
     440                 :            : 
     441                 :          0 : void PresenterWindowManager::SetLayoutMode (const LayoutMode eMode)
     442                 :            : {
     443                 :            :     OSL_ASSERT(mpPresenterController.get() != NULL);
     444                 :            : 
     445 [ #  # ][ #  # ]:          0 :     if (meLayoutMode != eMode
                 [ #  # ]
     446                 :            :         || mbIsSlideSorterActive
     447                 :            :         || mbIsHelpViewActive)
     448                 :            :     {
     449                 :          0 :         meLayoutMode = eMode;
     450                 :          0 :         mbIsSlideSorterActive = false;
     451                 :          0 :         mbIsHelpViewActive = false;
     452                 :            : 
     453                 :            :         mpPresenterController->RequestViews(
     454                 :            :             mbIsSlideSorterActive,
     455                 :            :             meLayoutMode==LM_Notes,
     456                 :          0 :             mbIsHelpViewActive);
     457                 :          0 :         Layout();
     458                 :          0 :         NotifyLayoutModeChange();
     459                 :            :     }
     460                 :          0 : }
     461                 :            : 
     462                 :          0 : void PresenterWindowManager::SetSlideSorterState (bool bIsActive)
     463                 :            : {
     464         [ #  # ]:          0 :     if (mbIsSlideSorterActive != bIsActive)
     465                 :            :     {
     466                 :          0 :         mbIsSlideSorterActive = bIsActive;
     467         [ #  # ]:          0 :         if (mbIsSlideSorterActive)
     468                 :          0 :             mbIsHelpViewActive = false;
     469                 :          0 :         StoreViewMode(GetViewMode());
     470                 :            : 
     471                 :            :         mpPresenterController->RequestViews(
     472                 :            :             mbIsSlideSorterActive,
     473                 :            :             meLayoutMode==LM_Notes,
     474                 :          0 :             mbIsHelpViewActive);
     475                 :          0 :         Layout();
     476                 :          0 :         NotifyLayoutModeChange();
     477                 :            :     }
     478                 :          0 : }
     479                 :            : 
     480                 :          0 : void PresenterWindowManager::SetHelpViewState (bool bIsActive)
     481                 :            : {
     482         [ #  # ]:          0 :     if (mbIsHelpViewActive != bIsActive)
     483                 :            :     {
     484                 :          0 :         mbIsHelpViewActive = bIsActive;
     485         [ #  # ]:          0 :         if (mbIsHelpViewActive)
     486                 :          0 :             mbIsSlideSorterActive = false;
     487                 :          0 :         StoreViewMode(GetViewMode());
     488                 :            : 
     489                 :            :         mpPresenterController->RequestViews(
     490                 :            :             mbIsSlideSorterActive,
     491                 :            :             meLayoutMode==LM_Notes,
     492                 :          0 :             mbIsHelpViewActive);
     493                 :          0 :         Layout();
     494                 :          0 :         NotifyLayoutModeChange();
     495                 :            :     }
     496                 :          0 : }
     497                 :            : 
     498                 :          0 : void PresenterWindowManager::SetViewMode (const ViewMode eMode)
     499                 :            : {
     500   [ #  #  #  #  :          0 :     switch (eMode)
                      # ]
     501                 :            :     {
     502                 :            :         case VM_Standard:
     503                 :          0 :             SetSlideSorterState(false);
     504                 :          0 :             SetHelpViewState(false);
     505                 :          0 :             SetLayoutMode(LM_Standard);
     506                 :          0 :             break;
     507                 :            : 
     508                 :            :         case VM_Notes:
     509                 :          0 :             SetSlideSorterState(false);
     510                 :          0 :             SetHelpViewState(false);
     511                 :          0 :             SetLayoutMode(LM_Notes);
     512                 :          0 :             break;
     513                 :            : 
     514                 :            :         case VM_SlideOverview:
     515                 :          0 :             SetHelpViewState(false);
     516                 :          0 :             SetSlideSorterState(true);
     517                 :          0 :             break;
     518                 :            : 
     519                 :            :         case VM_Help:
     520                 :          0 :             SetHelpViewState(true);
     521                 :          0 :             SetSlideSorterState(false);
     522                 :          0 :             break;
     523                 :            :     }
     524                 :            : 
     525                 :          0 :     StoreViewMode(eMode);
     526                 :          0 : }
     527                 :            : 
     528                 :          0 : PresenterWindowManager::ViewMode PresenterWindowManager::GetViewMode (void) const
     529                 :            : {
     530         [ #  # ]:          0 :     if (mbIsHelpViewActive)
     531                 :          0 :         return VM_Help;
     532         [ #  # ]:          0 :     else if (mbIsSlideSorterActive)
     533                 :          0 :         return VM_SlideOverview;
     534         [ #  # ]:          0 :     else if (meLayoutMode == LM_Notes)
     535                 :          0 :         return VM_Notes;
     536                 :            :     else
     537                 :          0 :         return VM_Standard;
     538                 :            : }
     539                 :            : 
     540                 :          0 : void PresenterWindowManager::RestoreViewMode (void)
     541                 :            : {
     542                 :          0 :     sal_Int32 nMode (0);
     543                 :            :     PresenterConfigurationAccess aConfiguration (
     544                 :            :         mxComponentContext,
     545                 :            :         OUString("/org.openoffice.Office.extension.PresenterScreen/"),
     546         [ #  # ]:          0 :         PresenterConfigurationAccess::READ_ONLY);
     547         [ #  # ]:          0 :     aConfiguration.GetConfigurationNode(A2S("Presenter/InitialViewMode")) >>= nMode;
     548      [ #  #  # ]:          0 :     switch (nMode)
     549                 :            :     {
     550                 :            :         default:
     551                 :            :         case 0:
     552         [ #  # ]:          0 :             SetViewMode(VM_Standard);
     553                 :          0 :             break;
     554                 :            : 
     555                 :            :         case 1:
     556         [ #  # ]:          0 :             SetViewMode(VM_Notes);
     557                 :          0 :             break;
     558                 :            : 
     559                 :            :         case 2:
     560         [ #  # ]:          0 :             SetViewMode(VM_SlideOverview);
     561                 :          0 :             break;
     562         [ #  # ]:          0 :     }
     563                 :          0 : }
     564                 :            : 
     565                 :          0 : void PresenterWindowManager::StoreViewMode (const ViewMode eViewMode)
     566                 :            : {
     567                 :            :     try
     568                 :            :     {
     569                 :            :         PresenterConfigurationAccess aConfiguration (
     570                 :            :             mxComponentContext,
     571                 :            :             OUString("/org.openoffice.Office.extension.PresenterScreen/"),
     572         [ #  # ]:          0 :             PresenterConfigurationAccess::READ_WRITE);
     573         [ #  # ]:          0 :         aConfiguration.GoToChild(A2S("Presenter"));
     574                 :          0 :         Any aValue;
     575      [ #  #  # ]:          0 :         switch (eViewMode)
     576                 :            :         {
     577                 :            :             default:
     578                 :            :             case VM_Standard:
     579         [ #  # ]:          0 :                 aValue = Any(sal_Int32(0));
     580                 :          0 :                 break;
     581                 :            : 
     582                 :            :             case VM_Notes:
     583         [ #  # ]:          0 :                 aValue = Any(sal_Int32(1));
     584                 :          0 :                 break;
     585                 :            : 
     586                 :            :             case VM_SlideOverview:
     587         [ #  # ]:          0 :                 aValue = Any(sal_Int32(2));
     588                 :          0 :                 break;
     589                 :            :         }
     590                 :            : 
     591         [ #  # ]:          0 :         aConfiguration.SetProperty (A2S("InitialViewMode"), aValue);
     592 [ #  # ][ #  # ]:          0 :         aConfiguration.CommitChanges();
                 [ #  # ]
     593                 :            :     }
     594                 :          0 :     catch (Exception&)
     595                 :            :     {
     596                 :            :     }
     597                 :          0 : }
     598                 :            : 
     599                 :          0 : void PresenterWindowManager::AddLayoutListener (
     600                 :            :     const Reference<document::XEventListener>& rxListener)
     601                 :            : {
     602                 :          0 :     maLayoutListeners.push_back(rxListener);
     603                 :          0 : }
     604                 :            : 
     605                 :          0 : void PresenterWindowManager::RemoveLayoutListener (
     606                 :            :     const Reference<document::XEventListener>& rxListener)
     607                 :            : {
     608                 :          0 :     LayoutListenerContainer::iterator iListener (maLayoutListeners.begin());
     609                 :          0 :     LayoutListenerContainer::iterator iEnd (maLayoutListeners.end());
     610 [ #  # ][ #  # ]:          0 :     for ( ; iListener!=iEnd; ++iListener)
     611                 :            :     {
     612 [ #  # ][ #  # ]:          0 :         if (*iListener == rxListener)
     613                 :            :         {
     614         [ #  # ]:          0 :             maLayoutListeners.erase(iListener);
     615                 :            :             // Assume that there are no multiple entries.
     616                 :          0 :             break;
     617                 :            :         }
     618                 :            :     }
     619                 :          0 : }
     620                 :            : 
     621                 :          0 : void PresenterWindowManager::Layout (void)
     622                 :            : {
     623 [ #  # ][ #  # ]:          0 :     if (mxParentWindow.is() && ! mbIsLayouting)
                 [ #  # ]
     624                 :            :     {
     625                 :          0 :         mbIsLayoutPending = false;
     626                 :          0 :         mbIsLayouting = true;
     627                 :          0 :         mxScaledBackgroundBitmap = NULL;
     628                 :          0 :         mxClipPolygon = NULL;
     629                 :            : 
     630                 :            :         try
     631                 :            :         {
     632         [ #  # ]:          0 :             if (mbIsSlideSorterActive)
     633         [ #  # ]:          0 :                 LayoutSlideSorterMode();
     634         [ #  # ]:          0 :             else if (mbIsHelpViewActive)
     635         [ #  # ]:          0 :                 LayoutHelpMode();
     636                 :            :             else
     637         [ #  # ]:          0 :                 switch (meLayoutMode)
     638                 :            :                 {
     639                 :            :                     case LM_Standard:
     640                 :            :                     default:
     641         [ #  # ]:          0 :                         LayoutStandardMode();
     642                 :          0 :                         break;
     643                 :            : 
     644                 :            :                     case LM_Notes:
     645         [ #  # ]:          0 :                         LayoutNotesMode();
     646                 :          0 :                         break;
     647                 :            :                 }
     648                 :            :         }
     649         [ #  # ]:          0 :         catch (Exception&)
     650                 :            :         {
     651                 :            :             OSL_ASSERT(false);
     652                 :          0 :             throw;
     653                 :            :         }
     654                 :            : 
     655                 :          0 :         mbIsLayouting = false;
     656                 :            :     }
     657                 :          0 : }
     658                 :            : 
     659                 :          0 : void PresenterWindowManager::LayoutStandardMode (void)
     660                 :            : {
     661 [ #  # ][ #  # ]:          0 :     awt::Rectangle aBox = mxParentWindow->getPosSize();
     662                 :            : 
     663                 :          0 :     const double nGoldenRatio ((1 + sqrt(5.0)) / 2);
     664                 :          0 :     const double nGap (20);
     665                 :          0 :     const double nHorizontalSlideDivide (aBox.Width / nGoldenRatio);
     666                 :          0 :     double nSlidePreviewTop (0);
     667                 :            : 
     668                 :            :     // For the current slide view calculate the outer height from the outer
     669                 :            :     // width.  This takes into acount the slide aspect ratio and thus has to
     670                 :            :     // go over the inner pane size.
     671                 :            :     PresenterPaneContainer::SharedPaneDescriptor pPane (
     672         [ #  # ]:          0 :         mpPaneContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
     673         [ #  # ]:          0 :     if (pPane.get() != NULL)
     674                 :            :     {
     675                 :            :         const awt::Size aCurrentSlideOuterBox(CalculatePaneSize(
     676                 :            :             nHorizontalSlideDivide - 1.5*nGap,
     677         [ #  # ]:          0 :             PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
     678                 :          0 :         nSlidePreviewTop = (aBox.Height - aCurrentSlideOuterBox.Height) / 2;
     679                 :            :         SetPanePosSizeAbsolute (
     680                 :            :             PresenterPaneFactory::msCurrentSlidePreviewPaneURL,
     681                 :            :             nGap,
     682                 :            :             nSlidePreviewTop,
     683                 :            :             aCurrentSlideOuterBox.Width,
     684         [ #  # ]:          0 :             aCurrentSlideOuterBox.Height);
     685                 :            :     }
     686                 :            : 
     687                 :            :     // For the next slide view calculate the outer height from the outer
     688                 :            :     // width.  This takes into acount the slide aspect ratio and thus has to
     689                 :            :     // go over the inner pane size.
     690 [ #  # ][ #  # ]:          0 :     pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNextSlidePreviewPaneURL);
                 [ #  # ]
     691         [ #  # ]:          0 :     if (pPane.get() != NULL)
     692                 :            :     {
     693                 :            :         const awt::Size aNextSlideOuterBox (CalculatePaneSize(
     694                 :            :             aBox.Width - nHorizontalSlideDivide - 1.5*nGap,
     695         [ #  # ]:          0 :             PresenterPaneFactory::msNextSlidePreviewPaneURL));
     696                 :            :         SetPanePosSizeAbsolute (
     697                 :            :             PresenterPaneFactory::msNextSlidePreviewPaneURL,
     698                 :            :             aBox.Width - aNextSlideOuterBox.Width - nGap,
     699                 :            :             nSlidePreviewTop,
     700                 :            :             aNextSlideOuterBox.Width,
     701         [ #  # ]:          0 :             aNextSlideOuterBox.Height);
     702                 :            :     }
     703                 :            : 
     704 [ #  # ][ #  # ]:          0 :     LayoutToolBar();
     705                 :          0 : }
     706                 :            : 
     707                 :          0 : void PresenterWindowManager::LayoutNotesMode (void)
     708                 :            : {
     709 [ #  # ][ #  # ]:          0 :     awt::Rectangle aBox = mxParentWindow->getPosSize();
     710                 :            : 
     711         [ #  # ]:          0 :     const geometry::RealRectangle2D aToolBarBox (LayoutToolBar());
     712                 :            : 
     713                 :          0 :     const double nGoldenRatio ((1 + sqrt(5.0)) / 2);
     714                 :          0 :     const double nGap (20);
     715                 :          0 :     const double nPrimaryWidth (aBox.Width / nGoldenRatio);
     716                 :          0 :     const double nSecondaryWidth (aBox.Width - nPrimaryWidth);
     717                 :          0 :     const double nTertiaryWidth (nSecondaryWidth / nGoldenRatio);
     718                 :          0 :     double nSlidePreviewTop (0);
     719                 :          0 :     double nNotesViewBottom (aToolBarBox.Y1 - nGap);
     720                 :            : 
     721                 :            :     // The notes view has no fixed aspect ratio.
     722                 :            :     PresenterPaneContainer::SharedPaneDescriptor pPane (
     723         [ #  # ]:          0 :         mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL));
     724         [ #  # ]:          0 :     if (pPane.get() != NULL)
     725                 :            :     {
     726                 :            :         const geometry::RealSize2D aNotesViewOuterSize(
     727                 :            :             nPrimaryWidth - 1.5*nGap + 0.5,
     728                 :          0 :             nNotesViewBottom);
     729                 :            :         nSlidePreviewTop = (aBox.Height
     730                 :          0 :             - aToolBarBox.Y2 + aToolBarBox.Y1 - aNotesViewOuterSize.Height) / 2;
     731                 :            :         SetPanePosSizeAbsolute (
     732                 :            :             PresenterPaneFactory::msNotesPaneURL,
     733                 :            :             aBox.Width - aNotesViewOuterSize.Width - nGap,
     734                 :            :             nSlidePreviewTop,
     735                 :            :             aNotesViewOuterSize.Width,
     736         [ #  # ]:          0 :             aNotesViewOuterSize.Height);
     737                 :          0 :         nNotesViewBottom = nSlidePreviewTop + aNotesViewOuterSize.Height;
     738                 :            :     }
     739                 :            : 
     740                 :            :     // For the current slide view calculate the outer height from the outer
     741                 :            :     // width.  This takes into acount the slide aspect ratio and thus has to
     742                 :            :     // go over the inner pane size.
     743 [ #  # ][ #  # ]:          0 :     pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL);
                 [ #  # ]
     744         [ #  # ]:          0 :     if (pPane.get() != NULL)
     745                 :            :     {
     746                 :            :         const awt::Size aCurrentSlideOuterBox(CalculatePaneSize(
     747                 :            :             nSecondaryWidth - 1.5*nGap,
     748         [ #  # ]:          0 :             PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
     749                 :            :         SetPanePosSizeAbsolute (
     750                 :            :             PresenterPaneFactory::msCurrentSlidePreviewPaneURL,
     751                 :            :             nGap,
     752                 :            :             nSlidePreviewTop,
     753                 :            :             aCurrentSlideOuterBox.Width,
     754         [ #  # ]:          0 :             aCurrentSlideOuterBox.Height);
     755                 :            :     }
     756                 :            : 
     757                 :            :     // For the next slide view calculate the outer height from the outer
     758                 :            :     // width.  This takes into acount the slide aspect ratio and thus has to
     759                 :            :     // go over the inner pane size.
     760 [ #  # ][ #  # ]:          0 :     pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNextSlidePreviewPaneURL);
                 [ #  # ]
     761         [ #  # ]:          0 :     if (pPane.get() != NULL)
     762                 :            :     {
     763                 :            :         const awt::Size aNextSlideOuterBox (CalculatePaneSize(
     764                 :            :             nTertiaryWidth,
     765         [ #  # ]:          0 :             PresenterPaneFactory::msNextSlidePreviewPaneURL));
     766                 :            :         SetPanePosSizeAbsolute (
     767                 :            :             PresenterPaneFactory::msNextSlidePreviewPaneURL,
     768                 :            :             nGap,
     769                 :            :             nNotesViewBottom - aNextSlideOuterBox.Height,
     770                 :            :             aNextSlideOuterBox.Width,
     771         [ #  # ]:          0 :             aNextSlideOuterBox.Height);
     772         [ #  # ]:          0 :     }
     773                 :          0 : }
     774                 :            : 
     775                 :          0 : void PresenterWindowManager::LayoutSlideSorterMode (void)
     776                 :            : {
     777         [ #  # ]:          0 :     const geometry::RealRectangle2D aToolBarBox (LayoutToolBar());
     778                 :            : 
     779 [ #  # ][ #  # ]:          0 :     awt::Rectangle aWindowBox = mxParentWindow->getPosSize();
     780                 :          0 :     const double nGap (20);
     781                 :            :     SetPanePosSizeAbsolute(
     782                 :            :         mpPaneContainer->GetPaneURLForViewURL(PresenterViewFactory::msSlideSorterURL),
     783                 :            :         nGap,
     784                 :            :         nGap,
     785                 :            :         aWindowBox.Width - 2*nGap,
     786 [ #  # ][ #  # ]:          0 :         aToolBarBox.Y1 - 2*nGap);
     787                 :          0 : }
     788                 :            : 
     789                 :          0 : void PresenterWindowManager::LayoutHelpMode (void)
     790                 :            : {
     791         [ #  # ]:          0 :     const geometry::RealRectangle2D aToolBarBox (LayoutToolBar());
     792                 :            : 
     793 [ #  # ][ #  # ]:          0 :     awt::Rectangle aWindowBox = mxParentWindow->getPosSize();
     794                 :          0 :     const double nGap (20);
     795                 :          0 :     const double nGoldenRatio ((1 + sqrt(5.0)) / 2);
     796         [ #  # ]:          0 :     const double nWidth = ::std::min(aWindowBox.Width - 2*nGap, aWindowBox.Width/nGoldenRatio);
     797                 :            :     SetPanePosSizeAbsolute(
     798                 :            :         mpPaneContainer->GetPaneURLForViewURL(PresenterViewFactory::msHelpViewURL),
     799                 :            :         (aWindowBox.Width - nWidth)/2,
     800                 :            :         nGap,
     801                 :            :         nWidth,
     802 [ #  # ][ #  # ]:          0 :         aToolBarBox.Y1 - 2*nGap);
     803                 :          0 : }
     804                 :            : 
     805                 :          0 : geometry::RealRectangle2D PresenterWindowManager::LayoutToolBar (void)
     806                 :            : {
     807                 :          0 :     double nToolBarWidth (400);
     808                 :          0 :     double nToolBarHeight (80);
     809                 :            : 
     810                 :            :     // Get access to the tool bar.
     811                 :            :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
     812         [ #  # ]:          0 :         mpPaneContainer->FindPaneURL(PresenterPaneFactory::msToolBarPaneURL));
     813         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     814                 :            :     {
     815                 :            :         PresenterToolBarView* pToolBarView
     816 [ #  # ][ #  # ]:          0 :             = dynamic_cast<PresenterToolBarView*>(pDescriptor->mxView.get());
     817 [ #  # ][ #  # ]:          0 :         if (pToolBarView != NULL && pToolBarView->GetPresenterToolBar().is())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     818                 :            :         {
     819 [ #  # ][ #  # ]:          0 :             geometry::RealSize2D aSize (pToolBarView->GetPresenterToolBar()->GetMinimalSize());
     820                 :            : 
     821         [ #  # ]:          0 :             if (mpPaneBorderPainter.is())
     822                 :            :             {
     823                 :          0 :                 const awt::Rectangle aBox (mpPaneBorderPainter->addBorder (
     824                 :            :                     PresenterPaneFactory::msToolBarPaneURL,
     825                 :            :                     awt::Rectangle(
     826                 :            :                         0,
     827                 :            :                         0,
     828         [ #  # ]:          0 :                         PresenterGeometryHelper::Round(aSize.Width),
     829         [ #  # ]:          0 :                         PresenterGeometryHelper::Round(aSize.Height)),
     830         [ #  # ]:          0 :                     css::drawing::framework::BorderType_TOTAL_BORDER));
     831                 :            : 
     832                 :          0 :                 nToolBarWidth = aBox.Width;
     833                 :          0 :                 nToolBarHeight = aBox.Height;
     834                 :            :             }
     835                 :            :             else
     836                 :            :             {
     837                 :          0 :                 nToolBarWidth = aSize.Width + 20;
     838                 :          0 :                 nToolBarHeight = aSize.Height + 10;
     839                 :            :             }
     840                 :            :         }
     841                 :            :     }
     842                 :            : 
     843 [ #  # ][ #  # ]:          0 :     const awt::Rectangle aBox = mxParentWindow->getPosSize();
     844                 :          0 :     const double nToolBarX ((aBox.Width - nToolBarWidth) / 2);
     845                 :          0 :     const double nToolBarY (aBox.Height - nToolBarHeight);
     846                 :            :     SetPanePosSizeAbsolute(
     847                 :            :         PresenterPaneFactory::msToolBarPaneURL,
     848                 :            :         nToolBarX,
     849                 :            :         nToolBarY,
     850                 :            :         nToolBarWidth,
     851         [ #  # ]:          0 :         nToolBarHeight);
     852                 :            : 
     853                 :            :     return geometry::RealRectangle2D(
     854                 :            :         nToolBarX,
     855                 :            :         nToolBarY,
     856                 :            :         nToolBarX + nToolBarWidth - 1,
     857         [ #  # ]:          0 :         nToolBarY + nToolBarHeight - 1);
     858                 :            : }
     859                 :            : 
     860                 :          0 : awt::Size PresenterWindowManager::CalculatePaneSize (
     861                 :            :     const double nOuterWidth,
     862                 :            :     const OUString& rsPaneURL)
     863                 :            : {
     864                 :            :     // Calculate the inner width by removing the pane border.
     865                 :            :     awt::Rectangle aInnerBox (mpPaneBorderPainter->RemoveBorder (
     866                 :            :         rsPaneURL,
     867                 :            :         awt::Rectangle(0,0,
     868                 :            :             sal_Int32(nOuterWidth+0.5),sal_Int32(nOuterWidth)),
     869         [ #  # ]:          0 :         drawing::framework::BorderType_TOTAL_BORDER));
     870                 :            : 
     871                 :            :     // Calculate the inner height with the help of the slide aspect ratio.
     872                 :            :     const double nCurrentSlideInnerHeight (
     873         [ #  # ]:          0 :         aInnerBox.Width / mpPresenterController->GetSlideAspectRatio());
     874                 :            : 
     875                 :            :     // Add the pane border to get the outer box.
     876                 :            :     awt::Rectangle aOuterBox (mpPaneBorderPainter->AddBorder (
     877                 :            :         rsPaneURL,
     878                 :            :         awt::Rectangle(0,0,
     879                 :            :             aInnerBox.Width,sal_Int32(nCurrentSlideInnerHeight+0.5)),
     880         [ #  # ]:          0 :         drawing::framework::BorderType_TOTAL_BORDER));
     881                 :            : 
     882                 :          0 :     return awt::Size(aOuterBox.Width, aOuterBox.Height);
     883                 :            : }
     884                 :            : 
     885                 :          0 : void PresenterWindowManager::NotifyLayoutModeChange (void)
     886                 :            : {
     887         [ #  # ]:          0 :     document::EventObject aEvent;
     888 [ #  # ][ #  # ]:          0 :     aEvent.Source = Reference<XInterface>(static_cast<XWeak*>(this));
     889                 :            : 
     890         [ #  # ]:          0 :     LayoutListenerContainer aContainerCopy (maLayoutListeners);
     891                 :          0 :     LayoutListenerContainer::iterator iListener (aContainerCopy.begin());
     892                 :          0 :     LayoutListenerContainer::iterator iEnd (aContainerCopy.end());
     893 [ #  # ][ #  # ]:          0 :     for ( ; iListener!=iEnd; ++iListener)
     894                 :            :     {
     895         [ #  # ]:          0 :         if (iListener->is())
     896                 :            :         {
     897                 :            :             try
     898                 :            :             {
     899 [ #  # ][ #  # ]:          0 :                 (*iListener)->notifyEvent(aEvent);
     900                 :            :             }
     901   [ #  #  #  #  :          0 :             catch (lang::DisposedException&)
                      # ]
     902                 :            :             {
     903         [ #  # ]:          0 :                 RemoveLayoutListener(*iListener);
     904                 :            :             }
     905         [ #  # ]:          0 :             catch (RuntimeException&)
     906                 :            :             {
     907                 :            :             }
     908                 :            :         }
     909         [ #  # ]:          0 :     }
     910                 :          0 : }
     911                 :            : 
     912                 :          0 : void PresenterWindowManager::NotifyDisposing (void)
     913                 :            : {
     914         [ #  # ]:          0 :     lang::EventObject aEvent;
     915         [ #  # ]:          0 :     aEvent.Source = static_cast<XWeak*>(this);
     916                 :            : 
     917         [ #  # ]:          0 :     LayoutListenerContainer aContainer;
     918                 :          0 :     aContainer.swap(maLayoutListeners);
     919                 :          0 :     LayoutListenerContainer::iterator iListener (aContainer.begin());
     920                 :          0 :     LayoutListenerContainer::iterator iEnd (aContainer.end());
     921 [ #  # ][ #  # ]:          0 :     for ( ; iListener!=iEnd; ++iListener)
     922                 :            :     {
     923         [ #  # ]:          0 :         if (iListener->is())
     924                 :            :         {
     925                 :            :             try
     926                 :            :             {
     927 [ #  # ][ #  # ]:          0 :                 (*iListener)->disposing(aEvent);
     928                 :            :             }
     929         [ #  # ]:          0 :             catch (lang::DisposedException&)
     930                 :            :             {
     931                 :            :             }
     932         [ #  # ]:          0 :             catch (RuntimeException&)
     933                 :            :             {
     934                 :            :             }
     935                 :            :         }
     936         [ #  # ]:          0 :     }
     937      [ #  #  # ]:          0 : }
     938                 :            : 
     939                 :          0 : void PresenterWindowManager::UpdateWindowSize (const Reference<awt::XWindow>& rxBorderWindow)
     940                 :            : {
     941                 :            :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     942         [ #  # ]:          0 :         mpPaneContainer->FindBorderWindow(rxBorderWindow));
     943         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     944                 :            :     {
     945         [ #  # ]:          0 :         mxClipPolygon = NULL;
     946                 :            : 
     947 [ #  # ][ #  # ]:          0 :         awt::Rectangle aParentBox = mxParentWindow->getPosSize();
     948 [ #  # ][ #  # ]:          0 :         awt::Rectangle aBorderBox (pDescriptor->mxBorderWindow->getPosSize());
     949                 :            : 
     950         [ #  # ]:          0 :         if ( ! mbIsLayouting)
     951                 :            :         {
     952                 :          0 :             const double nWidth (aParentBox.Width);
     953                 :          0 :             const double nHeight (aParentBox.Height);
     954                 :          0 :             pDescriptor->mnLeft = double(aBorderBox.X) / nWidth;
     955                 :          0 :             pDescriptor->mnTop = double(aBorderBox.Y) / nHeight;
     956                 :          0 :             pDescriptor->mnRight = double(aBorderBox.X + aBorderBox.Width) / nWidth;
     957                 :          0 :             pDescriptor->mnBottom = double(aBorderBox.Y + aBorderBox.Height) / nHeight;
     958                 :            :         }
     959                 :            :         else
     960                 :            :         {
     961                 :            :             // This update of the window size was initiated by
     962                 :            :             // Layout(). Therefore the window size does not have to be
     963                 :            :             // updated.
     964                 :            :         }
     965                 :            : 
     966                 :            :         // ToTop is called last because it may invalidate the iterator.
     967         [ #  # ]:          0 :         if ( ! mbIsLayouting)
     968         [ #  # ]:          0 :             mpPaneContainer->ToTop(pDescriptor);
     969         [ #  # ]:          0 :     }
     970                 :          0 : }
     971                 :            : 
     972                 :          0 : void PresenterWindowManager::PaintBackground (const awt::Rectangle& rUpdateBox)
     973                 :            : {
     974                 :            :     (void)rUpdateBox;
     975         [ #  # ]:          0 :     if ( ! mxParentWindow.is())
     976                 :            :         return;
     977                 :            : 
     978 [ #  # ][ #  # ]:          0 :     Reference<rendering::XGraphicDevice> xDevice (mxParentCanvas->getDevice());
     979         [ #  # ]:          0 :     if ( ! xDevice.is())
     980                 :            :         return;
     981                 :            : 
     982                 :            :     // Create a polygon for the background and for clipping.
     983                 :            :     Reference<rendering::XPolyPolygon2D> xBackgroundPolygon (
     984 [ #  # ][ #  # ]:          0 :         PresenterGeometryHelper::CreatePolygon(mxParentWindow->getPosSize(), xDevice));
                 [ #  # ]
     985         [ #  # ]:          0 :     if ( ! mxClipPolygon.is())
     986 [ #  # ][ #  # ]:          0 :         mxClipPolygon = CreateClipPolyPolygon();
     987                 :            : 
     988                 :            :     // Create View- and RenderState structs.
     989                 :            :     const rendering::ViewState aViewState(
     990                 :            :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     991 [ #  # ][ #  # ]:          0 :         PresenterGeometryHelper::CreatePolygon(rUpdateBox, xDevice));
     992                 :            :     rendering::RenderState aRenderState (
     993                 :            :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     994                 :            :         mxClipPolygon,
     995                 :            :         Sequence<double>(4),
     996 [ #  # ][ #  # ]:          0 :         rendering::CompositeOperation::SOURCE);
                 [ #  # ]
     997                 :            : 
     998                 :            :     // Paint the background.
     999         [ #  # ]:          0 :     if (mpBackgroundBitmap.get() != NULL)
    1000                 :            :     {
    1001         [ #  # ]:          0 :         ProvideBackgroundBitmap();
    1002                 :            : 
    1003         [ #  # ]:          0 :         if (mxScaledBackgroundBitmap.is())
    1004                 :            :         {
    1005         [ #  # ]:          0 :             Sequence<rendering::Texture> aTextures (1);
    1006 [ #  # ][ #  # ]:          0 :             const geometry::IntegerSize2D aBitmapSize(mxScaledBackgroundBitmap->getSize());
    1007         [ #  # ]:          0 :             aTextures[0] = rendering::Texture (
    1008                 :            :                 geometry::AffineMatrix2D(
    1009                 :            :                     aBitmapSize.Width,0,0,
    1010                 :            :                     0,aBitmapSize.Height,0),
    1011                 :            :                 1,
    1012                 :            :                 0,
    1013                 :            :                 mxScaledBackgroundBitmap,
    1014                 :            :                 NULL,
    1015                 :            :                 NULL,
    1016                 :            :                 rendering::StrokeAttributes(),
    1017                 :            :                 rendering::TexturingMode::REPEAT,
    1018 [ #  # ][ #  # ]:          0 :                 rendering::TexturingMode::REPEAT);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1019                 :            : 
    1020         [ #  # ]:          0 :             mxParentCanvas->fillTexturedPolyPolygon(
    1021                 :            :                 xBackgroundPolygon,
    1022                 :            :                 aViewState,
    1023                 :            :                 aRenderState,
    1024 [ #  # ][ #  # ]:          0 :                 aTextures);
    1025                 :            :         }
    1026                 :            :         else
    1027                 :            :         {
    1028                 :          0 :             const util::Color aBackgroundColor (mpBackgroundBitmap->maReplacementColor);
    1029         [ #  # ]:          0 :             aRenderState.DeviceColor[0] = ((aBackgroundColor >> 16) & 0x0ff) / 255.0;
    1030         [ #  # ]:          0 :             aRenderState.DeviceColor[1] = ((aBackgroundColor >> 8) & 0x0ff) / 255.0;
    1031         [ #  # ]:          0 :             aRenderState.DeviceColor[2] = ((aBackgroundColor >> 0) & 0x0ff) / 255.0;
    1032         [ #  # ]:          0 :             aRenderState.DeviceColor[3] = ((aBackgroundColor >> 24) & 0x0ff) / 255.0;
    1033         [ #  # ]:          0 :             mxParentCanvas->fillPolyPolygon(
    1034                 :            :                 xBackgroundPolygon,
    1035                 :            :                 aViewState,
    1036         [ #  # ]:          0 :                 aRenderState);
    1037                 :            :         }
    1038 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
    1039                 :            : }
    1040                 :            : 
    1041                 :          0 : void PresenterWindowManager::ProvideBackgroundBitmap (void)
    1042                 :            : {
    1043         [ #  # ]:          0 :     if ( ! mxScaledBackgroundBitmap.is())
    1044                 :            :     {
    1045         [ #  # ]:          0 :         Reference<rendering::XBitmap> xBitmap (mpBackgroundBitmap->GetNormalBitmap());
    1046         [ #  # ]:          0 :         if (xBitmap.is())
    1047                 :            :         {
    1048                 :          0 :             const bool bStretchVertical (mpBackgroundBitmap->meVerticalTexturingMode
    1049                 :          0 :                 == PresenterBitmapDescriptor::Stretch);
    1050                 :          0 :             const bool bStretchHorizontal (mpBackgroundBitmap->meHorizontalTexturingMode
    1051                 :          0 :                 == PresenterBitmapDescriptor::Stretch);
    1052 [ #  # ][ #  # ]:          0 :             if (bStretchHorizontal || bStretchVertical)
    1053                 :            :             {
    1054                 :          0 :                 geometry::RealSize2D aSize;
    1055         [ #  # ]:          0 :                 if (bStretchVertical)
    1056 [ #  # ][ #  # ]:          0 :                     aSize.Height = mxParentWindow->getPosSize().Height;
    1057                 :            :                 else
    1058 [ #  # ][ #  # ]:          0 :                     aSize.Height = xBitmap->getSize().Height;
    1059         [ #  # ]:          0 :                 if (bStretchHorizontal)
    1060 [ #  # ][ #  # ]:          0 :                     aSize.Width = mxParentWindow->getPosSize().Width;
    1061                 :            :                 else
    1062 [ #  # ][ #  # ]:          0 :                     aSize.Width = xBitmap->getSize().Width;
    1063 [ #  # ][ #  # ]:          0 :                 mxScaledBackgroundBitmap = xBitmap->getScaledBitmap(aSize, sal_False);
                 [ #  # ]
    1064                 :            :             }
    1065                 :            :             else
    1066                 :            :             {
    1067                 :            :                 mxScaledBackgroundBitmap
    1068 [ #  # ][ #  # ]:          0 :                     = Reference<rendering::XBitmap>(xBitmap, UNO_QUERY);
    1069                 :            :             }
    1070                 :          0 :         }
    1071                 :            :     }
    1072                 :          0 : }
    1073                 :            : 
    1074                 :          0 : Reference<rendering::XPolyPolygon2D> PresenterWindowManager::CreateClipPolyPolygon (void) const
    1075                 :            : {
    1076                 :            :     // Create a clip polygon that includes the whole update area but has the
    1077                 :            :     // content windows as holes.
    1078                 :          0 :     const sal_Int32 nPaneCount (mpPaneContainer->maPanes.size());
    1079         [ #  # ]:          0 :     ::std::vector<awt::Rectangle> aRectangles;
    1080         [ #  # ]:          0 :     aRectangles.reserve(1+nPaneCount);
    1081 [ #  # ][ #  # ]:          0 :     aRectangles.push_back(mxParentWindow->getPosSize());
                 [ #  # ]
    1082                 :          0 :     PresenterPaneContainer::PaneList::const_iterator iPane;
    1083         [ #  # ]:          0 :     PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
    1084 [ #  # ][ #  # ]:          0 :     for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
                 [ #  # ]
    1085                 :            :     {
    1086         [ #  # ]:          0 :         PresenterPaneContainer::SharedPaneDescriptor pDescriptor (*iPane);
    1087         [ #  # ]:          0 :         if ( ! pDescriptor->mbIsActive)
    1088                 :          0 :             continue;
    1089         [ #  # ]:          0 :         if ( ! pDescriptor->mbIsOpaque)
    1090                 :          0 :             continue;
    1091 [ #  # ][ #  # ]:          0 :         if ( ! pDescriptor->mxBorderWindow.is() || ! pDescriptor->mxContentWindow.is())
                 [ #  # ]
    1092                 :          0 :             continue;
    1093         [ #  # ]:          0 :         Reference<awt::XWindow2> xWindow (pDescriptor->mxBorderWindow, UNO_QUERY);
    1094 [ #  # ][ #  # ]:          0 :         if (xWindow.is() && ! xWindow->isVisible())
         [ #  # ][ #  # ]
                 [ #  # ]
    1095                 :          0 :             continue;
    1096                 :            : 
    1097 [ #  # ][ #  # ]:          0 :         const awt::Rectangle aOuterBorderBox (pDescriptor->mxBorderWindow->getPosSize());
    1098 [ #  # ][ #  # ]:          0 :         awt::Rectangle aInnerBorderBox (pDescriptor->mxContentWindow->getPosSize());
    1099                 :          0 :         aInnerBorderBox.X += aOuterBorderBox.X;
    1100                 :          0 :         aInnerBorderBox.Y += aOuterBorderBox.Y;
    1101 [ #  # ][ #  # ]:          0 :         aRectangles.push_back(aInnerBorderBox);
    1102 [ #  # ][ #  # ]:          0 :     }
    1103                 :            :     Reference<rendering::XPolyPolygon2D> xPolyPolygon (
    1104                 :            :         PresenterGeometryHelper::CreatePolygon(
    1105                 :            :             aRectangles,
    1106 [ #  # ][ #  # ]:          0 :             mxParentCanvas->getDevice()));
                 [ #  # ]
    1107         [ #  # ]:          0 :     if (xPolyPolygon.is())
    1108 [ #  # ][ #  # ]:          0 :         xPolyPolygon->setFillRule(rendering::FillRule_EVEN_ODD);
    1109                 :          0 :     return xPolyPolygon;
    1110                 :            : }
    1111                 :            : 
    1112                 :          0 : void PresenterWindowManager::UpdateWindowList (void)
    1113                 :            : {
    1114                 :            : #ifdef ENABLE_PANE_RESIZING
    1115                 :            :     try
    1116                 :            :     {
    1117                 :            :         OSL_ASSERT(mxComponentContext.is());
    1118                 :            : 
    1119                 :            :         Reference<lang::XComponent> xComponent (mxPaneBorderManager, UNO_QUERY);
    1120                 :            :         if (xComponent.is())
    1121                 :            :             xComponent->dispose();
    1122                 :            : 
    1123                 :            :         Reference<lang::XMultiComponentFactory> xFactory (mxComponentContext->getServiceManager());
    1124                 :            :         if (xFactory.is())
    1125                 :            :         {
    1126                 :            :             Sequence<Any> aArguments (1 + mpPaneContainer->maPanes.size()*2);
    1127                 :            :             sal_Int32 nIndex (0);
    1128                 :            :             aArguments[nIndex++] = Any(mxParentWindow);
    1129                 :            :             for (sal_uInt32 nPaneIndex=0; nPaneIndex<mpPaneContainer->maPanes.size(); ++nPaneIndex)
    1130                 :            :             {
    1131                 :            :                 if ( ! mpPaneContainer->maPanes[nPaneIndex]->mbIsActive)
    1132                 :            :                     continue;
    1133                 :            : 
    1134                 :            :                 const Reference<awt::XWindow> xBorderWindow (
    1135                 :            :                     mpPaneContainer->maPanes[nPaneIndex]->mxBorderWindow);
    1136                 :            :                 const Reference<awt::XWindow> xContentWindow (
    1137                 :            :                     mpPaneContainer->maPanes[nPaneIndex]->mxContentWindow);
    1138                 :            :                 const Reference<awt::XWindow2> xBorderWindow2(xBorderWindow, UNO_QUERY);
    1139                 :            :                 if (xBorderWindow.is()
    1140                 :            :                     && xContentWindow.is()
    1141                 :            :                     && ( ! xBorderWindow2.is() || xBorderWindow2->isVisible()))
    1142                 :            :                 {
    1143                 :            :                     aArguments[nIndex++] = Any(xBorderWindow);
    1144                 :            :                     aArguments[nIndex++] = Any(xContentWindow);
    1145                 :            :                 }
    1146                 :            :             }
    1147                 :            : 
    1148                 :            :             aArguments.realloc(nIndex);
    1149                 :            :             rtl::Reference<PresenterPaneBorderManager> pManager (
    1150                 :            :                 new PresenterPaneBorderManager (
    1151                 :            :                     mxComponentContext,
    1152                 :            :                     mpPresenterController));
    1153                 :            :             pManager->initialize(aArguments);
    1154                 :            :             mxPaneBorderManager = Reference<XInterface>(static_cast<XWeak*>(pManager.get()));
    1155                 :            :         }
    1156                 :            :     }
    1157                 :            :     catch (RuntimeException&)
    1158                 :            :     {
    1159                 :            :     }
    1160                 :            : #endif
    1161                 :          0 : }
    1162                 :            : 
    1163                 :          0 : void PresenterWindowManager::Invalidate (void)
    1164                 :            : {
    1165         [ #  # ]:          0 :     mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow);
    1166                 :          0 : }
    1167                 :          0 : void PresenterWindowManager::Update (void)
    1168                 :            : {
    1169                 :          0 :     mxClipPolygon = NULL;
    1170                 :          0 :     mbIsLayoutPending = true;
    1171                 :            : 
    1172                 :          0 :     UpdateWindowList();
    1173                 :          0 :     Invalidate();
    1174                 :          0 : }
    1175                 :            : 
    1176                 :          0 : void PresenterWindowManager::ThrowIfDisposed (void) const
    1177                 :            :     throw (::com::sun::star::lang::DisposedException)
    1178                 :            : {
    1179 [ #  # ][ #  # ]:          0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
    1180                 :            :     {
    1181                 :            :         throw lang::DisposedException (
    1182                 :            :             OUString( "PresenterWindowManager has already been disposed"),
    1183 [ #  # ][ #  # ]:          0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
    1184                 :            :     }
    1185                 :          0 : }
    1186                 :            : 
    1187                 :            : } } // end of namespace ::sdext::presenter
    1188                 :            : 
    1189                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10