LCOV - code coverage report
Current view: top level - libreoffice/sdext/source/presenter - PresenterWindowManager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 515 0.0 %
Date: 2012-12-27 Functions: 0 48 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10