LCOV - code coverage report
Current view: top level - libreoffice/sdext/source/presenter - PresenterToolBar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 845 0.0 %
Date: 2012-12-27 Functions: 0 135 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             : #include "vcl/svapp.hxx"
      21             : #include "PresenterToolBar.hxx"
      22             : 
      23             : #include "PresenterBitmapContainer.hxx"
      24             : #include "PresenterCanvasHelper.hxx"
      25             : #include "PresenterGeometryHelper.hxx"
      26             : #include "PresenterPaintManager.hxx"
      27             : #include "PresenterPaneBase.hxx"
      28             : #include "PresenterPaneFactory.hxx"
      29             : #include "PresenterTimer.hxx"
      30             : #include "PresenterWindowManager.hxx"
      31             : 
      32             : #include <cppuhelper/compbase2.hxx>
      33             : #include <com/sun/star/awt/FontDescriptor.hpp>
      34             : #include <com/sun/star/awt/PosSize.hpp>
      35             : #include <com/sun/star/awt/XWindowPeer.hpp>
      36             : #include <com/sun/star/deployment/XPackageInformationProvider.hpp>
      37             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      38             : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
      39             : #include <com/sun/star/drawing/framework/XPane.hpp>
      40             : #include <com/sun/star/geometry/AffineMatrix2D.hpp>
      41             : #include <com/sun/star/lang/XServiceName.hpp>
      42             : #include <com/sun/star/rendering/CompositeOperation.hpp>
      43             : #include <com/sun/star/rendering/RenderState.hpp>
      44             : #include <com/sun/star/rendering/TextDirection.hpp>
      45             : #include <com/sun/star/rendering/ViewState.hpp>
      46             : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
      47             : #include <com/sun/star/text/XTextRange.hpp>
      48             : #include <com/sun/star/util/Color.hpp>
      49             : #include <com/sun/star/util/XURLTransformer.hpp>
      50             : #include <rtl/ustrbuf.hxx>
      51             : #include <boost/bind.hpp>
      52             : #include <boost/function.hpp>
      53             : #include <boost/enable_shared_from_this.hpp>
      54             : #include <map>
      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             : static const sal_Int32 gnGapSize (20);
      66             : static const sal_Int32 gnMinimalSeparatorSize (20);
      67             : static const sal_Int32 gnSeparatorInset (0);
      68             : 
      69             : namespace {
      70             : 
      71           0 :     class Text
      72             :     {
      73             :     public:
      74             :         Text (void);
      75             :         Text (const Text& rText);
      76             :         Text (
      77             :             const OUString& rsText,
      78             :             const PresenterTheme::SharedFontDescriptor& rpFont);
      79             : 
      80             :         void SetText (const OUString& rsText);
      81             :         OUString GetText (void) const;
      82             :         PresenterTheme::SharedFontDescriptor GetFont (void) const;
      83             : 
      84             :         void Paint (
      85             :             const Reference<rendering::XCanvas>& rxCanvas,
      86             :             const rendering::ViewState& rViewState,
      87             :             const awt::Rectangle& rBoundingBox,
      88             :             const awt::Point& rOffset);
      89             : 
      90             :         geometry::RealRectangle2D GetBoundingBox (
      91             :             const Reference<rendering::XCanvas>& rxCanvas);
      92             : 
      93             :     private:
      94             :         OUString msText;
      95             :         PresenterTheme::SharedFontDescriptor mpFont;
      96             :     };
      97             : 
      98           0 :     class ElementMode
      99             :         : private ::boost::noncopyable
     100             :     {
     101             :     public:
     102             :         ElementMode (void);
     103             : 
     104             :         SharedBitmapDescriptor mpIcon;
     105             :         OUString msAction;
     106             :         Text maText;
     107             : 
     108             :         void ReadElementMode (
     109             :             const Reference<beans::XPropertySet>& rxProperties,
     110             :             const ::rtl::OUString& rsModeName,
     111             :             ::boost::shared_ptr<ElementMode>& rpDefaultMode,
     112             :             ::sdext::presenter::PresenterToolBar::Context& rContext);
     113             :     };
     114             :     typedef ::boost::shared_ptr<ElementMode> SharedElementMode;
     115             : 
     116             : }  // end of anonymous namespace
     117             : 
     118           0 : class PresenterToolBar::Context
     119             :     : private ::boost::noncopyable
     120             : {
     121             : public:
     122             :     Reference<drawing::XPresenterHelper> mxPresenterHelper;
     123             :     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
     124             : };
     125             : 
     126             : //===== PresenterToolBar::Element =============================================
     127             : 
     128             : namespace {
     129             :     typedef cppu::WeakComponentImplHelper2<
     130             :         css::document::XEventListener,
     131             :         css::frame::XStatusListener
     132             :         > ElementInterfaceBase;
     133             : 
     134             :     class Element
     135             :         : private ::cppu::BaseMutex,
     136             :           private ::boost::noncopyable,
     137             :           public ElementInterfaceBase
     138             :     {
     139             :     public:
     140             :         Element (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     141             :         virtual ~Element (void);
     142             : 
     143             :         virtual void SAL_CALL disposing (void);
     144             : 
     145             :         virtual void SetModes (
     146             :             const SharedElementMode& rpNormalMode,
     147             :             const SharedElementMode& rpMouseOverMode,
     148             :             const SharedElementMode& rpSelectedMode,
     149             :             const SharedElementMode& rpDisabledMode);
     150             :         virtual void CurrentSlideHasChanged (void);
     151             :         virtual void SetLocation (const awt::Point& rLocation);
     152             :         virtual void SetSize (const geometry::RealSize2D& rSize);
     153             :         virtual void Paint (
     154             :             const Reference<rendering::XCanvas>& rxCanvas,
     155             :             const rendering::ViewState& rViewState) = 0;
     156             :         awt::Size GetBoundingSize (
     157             :             const Reference<rendering::XCanvas>& rxCanvas);
     158             :         awt::Rectangle GetBoundingBox (void) const;
     159             :         virtual bool SetState (const bool bIsOver, const bool bIsPressed);
     160             :         virtual void Invalidate (const bool bSynchronous = true);
     161             :         virtual bool IsOutside (const awt::Rectangle& rBox);
     162             :         virtual bool IsFilling (void) const;
     163             :         void UpdateState (void);
     164             : 
     165             :         OUString GetAction (void) const;
     166             : 
     167             :         // lang::XEventListener
     168             : 
     169             :         virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
     170             :             throw(css::uno::RuntimeException);
     171             : 
     172             :         // document::XEventListener
     173             : 
     174             :         virtual void SAL_CALL notifyEvent (const css::document::EventObject& rEvent)
     175             :             throw(css::uno::RuntimeException);
     176             : 
     177             :         // frame::XStatusListener
     178             : 
     179             :         virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent)
     180             :             throw(css::uno::RuntimeException);
     181             : 
     182             :     protected:
     183             :         ::rtl::Reference<PresenterToolBar> mpToolBar;
     184             :         awt::Point maLocation;
     185             :         awt::Size maSize;
     186             :         SharedElementMode mpNormal;
     187             :         SharedElementMode mpMouseOver;
     188             :         SharedElementMode mpSelected;
     189             :         SharedElementMode mpDisabled;
     190             :         SharedElementMode mpMode;
     191             :         bool mbIsOver;
     192             :         bool mbIsPressed;
     193             :         bool mbIsSelected;
     194             : 
     195             :         virtual awt::Size CreateBoundingSize (
     196             :             const Reference<rendering::XCanvas>& rxCanvas) = 0;
     197             : 
     198             :         bool IsEnabled (void) const;
     199             :     private:
     200             :         bool mbIsEnabled;
     201             :     };
     202             : 
     203             : } // end of anonymous namespace
     204             : 
     205           0 : class PresenterToolBar::ElementContainerPart
     206             :     : public ::std::vector<rtl::Reference<Element> >
     207             : {
     208             : };
     209             : 
     210             : //===== Button ================================================================
     211             : 
     212             : namespace {
     213             : 
     214             :     class Button : public Element
     215             :     {
     216             :     public:
     217             :         static ::rtl::Reference<Element> Create (
     218             :             const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     219             : 
     220             :         virtual ~Button (void);
     221             :         virtual void SAL_CALL disposing (void);
     222             : 
     223             :         virtual void Paint (
     224             :             const Reference<rendering::XCanvas>& rxCanvas,
     225             :             const rendering::ViewState& rViewState);
     226             : 
     227             :         // lang::XEventListener
     228             : 
     229             :         virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
     230             :             throw(css::uno::RuntimeException);
     231             : 
     232             :     protected:
     233             :         virtual awt::Size CreateBoundingSize (
     234             :             const Reference<rendering::XCanvas>& rxCanvas);
     235             : 
     236             :     private:
     237             :         bool mbIsListenerRegistered;
     238             : 
     239             :         Button (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     240             :         void Initialize (void);
     241             :         void PaintIcon (
     242             :             const Reference<rendering::XCanvas>& rxCanvas,
     243             :             const sal_Int32 nTextHeight,
     244             :             const rendering::ViewState& rViewState);
     245             :         PresenterBitmapDescriptor::Mode GetMode (void) const;
     246             :     };
     247             : 
     248             : //===== Label =================================================================
     249             : 
     250           0 :     class Label : public Element
     251             :     {
     252             :     public:
     253             :         Label (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     254             : 
     255             :         void SetText (const OUString& rsText);
     256             :         virtual void Paint (
     257             :             const Reference<rendering::XCanvas>& rxCanvas,
     258             :             const rendering::ViewState& rViewState);
     259             :         virtual bool SetState (const bool bIsOver, const bool bIsPressed);
     260             : 
     261             :     protected:
     262             :         virtual awt::Size CreateBoundingSize (
     263             :             const Reference<rendering::XCanvas>& rxCanvas);
     264             :     };
     265             : 
     266             : // Some specialized controls.
     267             : 
     268             :     class TimeFormatter
     269             :     {
     270             :     public:
     271             :         TimeFormatter (void);
     272             :         OUString FormatTime (const oslDateTime& rTime);
     273             :     private:
     274             :         bool mbIs24HourFormat;
     275             :         bool mbIsAmPmFormat;
     276             :         bool mbIsShowSeconds;
     277             :     };
     278             : 
     279           0 :     class TimeLabel : public Label
     280             :     {
     281             :     public:
     282             :         void ConnectToTimer (void);
     283             :         virtual void TimeHasChanged (const oslDateTime& rCurrentTime) = 0;
     284             :     protected:
     285             :         TimeLabel(const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     286             :         using Element::disposing;
     287             :         virtual void SAL_CALL disposing (void);
     288             :     private:
     289             :         class Listener : public PresenterClockTimer::Listener
     290             :         {
     291             :         public:
     292           0 :             Listener (const ::rtl::Reference<TimeLabel>& rxLabel)
     293           0 :                 : mxLabel(rxLabel) {}
     294           0 :             virtual ~Listener (void) {}
     295           0 :             virtual void TimeHasChanged (const oslDateTime& rCurrentTime)
     296           0 :             { if (mxLabel.is()) mxLabel->TimeHasChanged(rCurrentTime); }
     297             :         private:
     298             :             ::rtl::Reference<TimeLabel> mxLabel;
     299             :         };
     300             :         ::boost::shared_ptr<PresenterClockTimer::Listener> mpListener;
     301             :     };
     302             : 
     303             :     class CurrentTimeLabel : public TimeLabel
     304             :     {
     305             :     public:
     306             :         static ::rtl::Reference<Element> Create (
     307             :             const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     308             :         virtual void SetModes (
     309             :             const SharedElementMode& rpNormalMode,
     310             :             const SharedElementMode& rpMouseOverMode,
     311             :             const SharedElementMode& rpSelectedMode,
     312             :             const SharedElementMode& rpDisabledMode);
     313             :     private:
     314             :         TimeFormatter maTimeFormatter;
     315             :         CurrentTimeLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     316             :         virtual ~CurrentTimeLabel (void);
     317             :         virtual void TimeHasChanged (const oslDateTime& rCurrentTime);
     318             :     };
     319             : 
     320             :     class PresentationTimeLabel : public TimeLabel
     321             :     {
     322             :     public:
     323             :         static ::rtl::Reference<Element> Create (
     324             :             const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     325             :         virtual void SetModes (
     326             :             const SharedElementMode& rpNormalMode,
     327             :             const SharedElementMode& rpMouseOverMode,
     328             :             const SharedElementMode& rpSelectedMode,
     329             :             const SharedElementMode& rpDisabledMode);
     330             :     private:
     331             :         TimeFormatter maTimeFormatter;
     332             :         TimeValue maStartTimeValue;
     333             :         PresentationTimeLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     334             :         virtual ~PresentationTimeLabel (void);
     335             :         virtual void TimeHasChanged (const oslDateTime& rCurrentTime);
     336             :     };
     337             : 
     338           0 :     class VerticalSeparator : public Element
     339             :     {
     340             :     public:
     341             :         explicit VerticalSeparator (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     342             :         virtual void Paint (
     343             :             const Reference<rendering::XCanvas>& rxCanvas,
     344             :             const rendering::ViewState& rViewState);
     345             :         virtual bool IsFilling (void) const;
     346             : 
     347             :     protected:
     348             :         virtual awt::Size CreateBoundingSize (
     349             :             const Reference<rendering::XCanvas>& rxCanvas);
     350             :     };
     351             : 
     352           0 :     class HorizontalSeparator : public Element
     353             :     {
     354             :     public:
     355             :         explicit HorizontalSeparator (const ::rtl::Reference<PresenterToolBar>& rpToolBar);
     356             :         virtual void Paint (
     357             :             const Reference<rendering::XCanvas>& rxCanvas,
     358             :             const rendering::ViewState& rViewState);
     359             :         virtual bool IsFilling (void) const;
     360             : 
     361             :     protected:
     362             :         virtual awt::Size CreateBoundingSize (
     363             :             const Reference<rendering::XCanvas>& rxCanvas);
     364             :     };
     365             : } // end of anonymous namespace
     366             : 
     367             : //===== PresenterToolBar ======================================================
     368             : 
     369           0 : PresenterToolBar::PresenterToolBar (
     370             :     const Reference<XComponentContext>& rxContext,
     371             :     const css::uno::Reference<css::awt::XWindow>& rxWindow,
     372             :     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
     373             :     const ::rtl::Reference<PresenterController>& rpPresenterController,
     374             :     const Anchor eAnchor)
     375             :     : PresenterToolBarInterfaceBase(m_aMutex),
     376             :       mxComponentContext(rxContext),
     377             :       maElementContainer(),
     378             :       mpCurrentContainerPart(),
     379             :       mxWindow(rxWindow),
     380             :       mxCanvas(rxCanvas),
     381             :       mxSlideShowController(),
     382             :       mxCurrentSlide(),
     383             :       mpPresenterController(rpPresenterController),
     384             :       mbIsLayoutPending(false),
     385             :       meAnchor(eAnchor),
     386             :       maBoundingBox(),
     387           0 :       maMinimalSize()
     388             : {
     389           0 : }
     390             : 
     391           0 : void PresenterToolBar::Initialize (
     392             :     const ::rtl::OUString& rsConfigurationPath)
     393             : {
     394             :     try
     395             :     {
     396           0 :         CreateControls(rsConfigurationPath);
     397             : 
     398           0 :         if (mxWindow.is())
     399             :         {
     400           0 :             mxWindow->addWindowListener(this);
     401           0 :             mxWindow->addPaintListener(this);
     402           0 :             mxWindow->addMouseListener(this);
     403           0 :             mxWindow->addMouseMotionListener(this);
     404             : 
     405           0 :             Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
     406           0 :             if (xPeer.is())
     407           0 :                 xPeer->setBackground(util::Color(0xff000000));
     408             : 
     409           0 :             mxWindow->setVisible(sal_True);
     410             :         }
     411             : 
     412           0 :         mxSlideShowController = mpPresenterController->GetSlideShowController();
     413           0 :         UpdateSlideNumber();
     414           0 :         mbIsLayoutPending = true;
     415             :     }
     416           0 :     catch (RuntimeException&)
     417             :     {
     418           0 :         mpCurrentContainerPart.reset();
     419           0 :         maElementContainer.clear();
     420           0 :         throw;
     421             :     }
     422           0 : }
     423             : 
     424           0 : PresenterToolBar::~PresenterToolBar (void)
     425             : {
     426           0 : }
     427             : 
     428           0 : void SAL_CALL PresenterToolBar::disposing (void)
     429             : {
     430           0 :     if (mxWindow.is())
     431             :     {
     432           0 :         mxWindow->removeWindowListener(this);
     433           0 :         mxWindow->removePaintListener(this);
     434           0 :         mxWindow->removeMouseListener(this);
     435           0 :         mxWindow->removeMouseMotionListener(this);
     436           0 :         mxWindow = NULL;
     437             :     }
     438             : 
     439             :     // Dispose tool bar elements.
     440           0 :     ElementContainer::iterator iPart (maElementContainer.begin());
     441           0 :     ElementContainer::const_iterator iEnd (maElementContainer.end());
     442           0 :     for ( ; iPart!=iEnd; ++iPart)
     443             :     {
     444             :         OSL_ASSERT(iPart->get()!=NULL);
     445           0 :         ElementContainerPart::iterator iElement ((*iPart)->begin());
     446           0 :         ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
     447           0 :         for ( ; iElement!=iPartEnd; ++iElement)
     448             :         {
     449           0 :             if (iElement->get() != NULL)
     450             :             {
     451           0 :                 ::rtl::Reference<Element> pElement (*iElement);
     452             :                 Reference<lang::XComponent> xComponent (
     453           0 :                     static_cast<XWeak*>(pElement.get()), UNO_QUERY);
     454           0 :                 if (xComponent.is())
     455           0 :                     xComponent->dispose();
     456             :             }
     457             :         }
     458             :     }
     459             : 
     460           0 :     mpCurrentContainerPart.reset();
     461           0 :     maElementContainer.clear();
     462           0 : }
     463             : 
     464           0 : void PresenterToolBar::InvalidateArea (
     465             :     const awt::Rectangle& rRepaintBox,
     466             :     const bool bSynchronous)
     467             : {
     468             :     mpPresenterController->GetPaintManager()->Invalidate(
     469             :         mxWindow,
     470             :         rRepaintBox,
     471           0 :         bSynchronous);
     472           0 : }
     473             : 
     474           0 : void PresenterToolBar::RequestLayout (void)
     475             : {
     476           0 :     mbIsLayoutPending = true;
     477             : 
     478           0 :     mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
     479           0 : }
     480             : 
     481           0 : geometry::RealSize2D PresenterToolBar::GetMinimalSize (void)
     482             : {
     483           0 :     if (mbIsLayoutPending)
     484           0 :         Layout(mxCanvas);
     485           0 :     return maMinimalSize;
     486             : }
     487             : 
     488           0 : ::rtl::Reference<PresenterController> PresenterToolBar::GetPresenterController (void) const
     489             : {
     490           0 :     return mpPresenterController;
     491             : }
     492             : 
     493           0 : Reference<XComponentContext> PresenterToolBar::GetComponentContext (void) const
     494             : {
     495           0 :     return mxComponentContext;
     496             : }
     497             : 
     498             : //-----  lang::XEventListener -------------------------------------------------
     499             : 
     500           0 : void SAL_CALL PresenterToolBar::disposing (const lang::EventObject& rEventObject)
     501             :     throw (RuntimeException)
     502             : {
     503           0 :     if (rEventObject.Source == mxWindow)
     504           0 :         mxWindow = NULL;
     505           0 : }
     506             : 
     507             : //----- XWindowListener -------------------------------------------------------
     508             : 
     509           0 : void SAL_CALL PresenterToolBar::windowResized (const awt::WindowEvent& rEvent)
     510             :     throw (RuntimeException)
     511             : {
     512             :     (void)rEvent;
     513           0 :     mbIsLayoutPending = true;
     514           0 : }
     515             : 
     516           0 : void SAL_CALL PresenterToolBar::windowMoved (const awt::WindowEvent& rEvent)
     517             :     throw (RuntimeException)
     518             : {
     519             :     (void)rEvent;
     520           0 : }
     521             : 
     522           0 : void SAL_CALL PresenterToolBar::windowShown (const lang::EventObject& rEvent)
     523             :     throw (RuntimeException)
     524             : {
     525             :     (void)rEvent;
     526           0 :     mbIsLayoutPending = true;
     527           0 : }
     528             : 
     529           0 : void SAL_CALL PresenterToolBar::windowHidden (const lang::EventObject& rEvent)
     530             :     throw (RuntimeException)
     531             : {
     532             :     (void)rEvent;
     533           0 : }
     534             : 
     535             : //----- XPaintListener --------------------------------------------------------
     536           0 : void SAL_CALL PresenterToolBar::windowPaint (const css::awt::PaintEvent& rEvent)
     537             :     throw (RuntimeException)
     538             : {
     539           0 :     if ( ! mxCanvas.is())
     540             :         return;
     541             : 
     542           0 :     if ( ! mbIsPresenterViewActive)
     543             :         return;
     544             : 
     545             :     const rendering::ViewState aViewState (
     546             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     547           0 :         PresenterGeometryHelper::CreatePolygon(rEvent.UpdateRect, mxCanvas->getDevice()));
     548             : 
     549           0 :     if (mbIsLayoutPending)
     550           0 :         Layout(mxCanvas);
     551             : 
     552           0 :     Paint(rEvent.UpdateRect, aViewState);
     553             : 
     554             :     // Make the back buffer visible.
     555           0 :     Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
     556           0 :     if (xSpriteCanvas.is())
     557           0 :         xSpriteCanvas->updateScreen(sal_False);
     558             : }
     559             : 
     560             : //----- XMouseListener --------------------------------------------------------
     561           0 : void SAL_CALL PresenterToolBar::mousePressed (const css::awt::MouseEvent& rEvent)
     562             :     throw(css::uno::RuntimeException)
     563             : {
     564           0 :         ThrowIfDisposed();
     565           0 :         CheckMouseOver(rEvent, true, true);
     566           0 : }
     567             : 
     568           0 : void SAL_CALL PresenterToolBar::mouseReleased (const css::awt::MouseEvent& rEvent)
     569             :     throw(css::uno::RuntimeException)
     570             : {
     571           0 :         ThrowIfDisposed();
     572           0 :         CheckMouseOver(rEvent, true);
     573           0 : }
     574             : 
     575           0 : void SAL_CALL PresenterToolBar::mouseEntered (const css::awt::MouseEvent& rEvent)
     576             :     throw(css::uno::RuntimeException)
     577             : {
     578           0 :         ThrowIfDisposed();
     579           0 :         CheckMouseOver(rEvent, true);
     580           0 : }
     581             : 
     582           0 : void SAL_CALL PresenterToolBar::mouseExited (const css::awt::MouseEvent& rEvent)
     583             :     throw(css::uno::RuntimeException)
     584             : {
     585           0 :         ThrowIfDisposed();
     586           0 :         CheckMouseOver(rEvent, false);
     587           0 :  }
     588             : 
     589             : //----- XMouseMotionListener --------------------------------------------------
     590             : 
     591           0 : void SAL_CALL PresenterToolBar::mouseMoved (const css::awt::MouseEvent& rEvent)
     592             :     throw (css::uno::RuntimeException)
     593             : {
     594           0 :         ThrowIfDisposed();
     595           0 :         CheckMouseOver(rEvent, true);
     596           0 :  }
     597             : 
     598           0 : void SAL_CALL PresenterToolBar::mouseDragged (const css::awt::MouseEvent& rEvent)
     599             :     throw (css::uno::RuntimeException)
     600             : {
     601           0 :     ThrowIfDisposed();
     602             :     (void)rEvent;
     603           0 : }
     604             : 
     605             : //----- XDrawView -------------------------------------------------------------
     606             : 
     607           0 : void SAL_CALL PresenterToolBar::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
     608             :     throw (RuntimeException)
     609             : {
     610           0 :     if (rxSlide != mxCurrentSlide)
     611             :     {
     612           0 :         mxCurrentSlide = rxSlide;
     613           0 :         UpdateSlideNumber();
     614             :     }
     615           0 : }
     616             : 
     617           0 : Reference<drawing::XDrawPage> SAL_CALL PresenterToolBar::getCurrentPage (void)
     618             :     throw (RuntimeException)
     619             : {
     620           0 :     return mxCurrentSlide;
     621             : }
     622             : 
     623             : //-----------------------------------------------------------------------------
     624             : 
     625           0 : void PresenterToolBar::CreateControls (
     626             :     const ::rtl::OUString& rsConfigurationPath)
     627             : {
     628           0 :     if ( ! mxWindow.is())
     629           0 :         return;
     630             : 
     631             :     // Expand the macro in the bitmap file names.
     632             :     PresenterConfigurationAccess aConfiguration (
     633             :         mxComponentContext,
     634             :         OUString("/org.openoffice.Office.PresenterScreen/"),
     635           0 :         PresenterConfigurationAccess::READ_ONLY);
     636             : 
     637           0 :     mpCurrentContainerPart.reset(new ElementContainerPart());
     638           0 :     maElementContainer.clear();
     639           0 :     maElementContainer.push_back(mpCurrentContainerPart);
     640             : 
     641             :     Reference<container::XHierarchicalNameAccess> xToolBarNode (
     642             :         aConfiguration.GetConfigurationNode(rsConfigurationPath),
     643           0 :         UNO_QUERY);
     644           0 :     if (xToolBarNode.is())
     645             :     {
     646             :         Reference<container::XNameAccess> xEntries (
     647             :             PresenterConfigurationAccess::GetConfigurationNode(xToolBarNode, A2S("Entries")),
     648           0 :             UNO_QUERY);
     649           0 :         Context aContext;
     650           0 :         aContext.mxPresenterHelper = mpPresenterController->GetPresenterHelper();
     651           0 :         aContext.mxCanvas = mxCanvas;
     652           0 :         if (xEntries.is()
     653           0 :             && aContext.mxPresenterHelper.is()
     654           0 :             && aContext.mxCanvas.is())
     655             :         {
     656             :             PresenterConfigurationAccess::ForAll(
     657             :                 xEntries,
     658           0 :                 ::boost::bind(&PresenterToolBar::ProcessEntry, this, _2, ::boost::ref(aContext)));
     659           0 :         }
     660           0 :     }
     661             : }
     662             : 
     663           0 : void PresenterToolBar::ProcessEntry (
     664             :     const Reference<beans::XPropertySet>& rxProperties,
     665             :     Context& rContext)
     666             : {
     667           0 :     if ( ! rxProperties.is())
     668             :         return;
     669             : 
     670             :     // Type has to be present.
     671           0 :     OUString sType;
     672           0 :     if ( ! (PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Type")) >>= sType))
     673             :         return;
     674             : 
     675           0 :     OUString sName;
     676           0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Name")) >>= sName;
     677             : 
     678             :     // Read mode specific values.
     679           0 :     SharedElementMode pNormalMode (new ElementMode());
     680           0 :     SharedElementMode pMouseOverMode (new ElementMode());
     681           0 :     SharedElementMode pSelectedMode (new ElementMode());
     682           0 :     SharedElementMode pDisabledMode (new ElementMode());
     683           0 :     pNormalMode->ReadElementMode(rxProperties, A2S("Normal"), pNormalMode, rContext);
     684           0 :     pMouseOverMode->ReadElementMode(rxProperties, A2S("MouseOver"), pNormalMode, rContext);
     685           0 :     pSelectedMode->ReadElementMode(rxProperties, A2S("Selected"), pNormalMode, rContext);
     686           0 :     pDisabledMode->ReadElementMode(rxProperties, A2S("Disabled"), pNormalMode, rContext);
     687             : 
     688             :     // Create new element.
     689           0 :     ::rtl::Reference<Element> pElement;
     690           0 :     if ( sType == "Button" )
     691           0 :         pElement = Button::Create(this);
     692           0 :     else if ( sType == "CurrentTimeLabel" )
     693           0 :         pElement = CurrentTimeLabel::Create(this);
     694           0 :     else if ( sType == "PresentationTimeLabel" )
     695           0 :         pElement = PresentationTimeLabel::Create(this);
     696           0 :     else if ( sType == "VerticalSeparator" )
     697           0 :         pElement = ::rtl::Reference<Element>(new VerticalSeparator(this));
     698           0 :     else if ( sType == "HorizontalSeparator" )
     699           0 :         pElement = ::rtl::Reference<Element>(new HorizontalSeparator(this));
     700           0 :     else if ( sType == "Label" )
     701           0 :         pElement = ::rtl::Reference<Element>(new Label(this));
     702           0 :     else if ( sType == "ChangeOrientation" )
     703             :     {
     704           0 :         mpCurrentContainerPart.reset(new ElementContainerPart());
     705           0 :         maElementContainer.push_back(mpCurrentContainerPart);
     706             :         return;
     707             :     }
     708           0 :     if (pElement.is())
     709             :     {
     710           0 :         pElement->SetModes( pNormalMode, pMouseOverMode, pSelectedMode, pDisabledMode);
     711           0 :         pElement->UpdateState();
     712           0 :         if (mpCurrentContainerPart.get() != NULL)
     713           0 :             mpCurrentContainerPart->push_back(pElement);
     714           0 :     }
     715             : }
     716             : 
     717           0 : void PresenterToolBar::Layout (
     718             :     const Reference<rendering::XCanvas>& rxCanvas)
     719             : {
     720           0 :     if (maElementContainer.empty())
     721           0 :         return;
     722             : 
     723           0 :     mbIsLayoutPending = false;
     724             : 
     725           0 :     const awt::Rectangle aWindowBox (mxWindow->getPosSize());
     726           0 :     ElementContainer::iterator iPart;
     727           0 :     ElementContainer::iterator iEnd (maElementContainer.end());
     728           0 :     ElementContainer::iterator iBegin (maElementContainer.begin());
     729           0 :     ::std::vector<geometry::RealSize2D> aPartSizes (maElementContainer.size());
     730           0 :     geometry::RealSize2D aTotalSize (0,0);
     731           0 :     bool bIsHorizontal (true);
     732             :     sal_Int32 nIndex;
     733           0 :     double nTotalHorizontalGap (0);
     734           0 :     sal_Int32 nGapCount (0);
     735           0 :     for (iPart=maElementContainer.begin(),nIndex=0; iPart!=iEnd; ++iPart,++nIndex)
     736             :     {
     737           0 :         geometry::RealSize2D aSize (CalculatePartSize(rxCanvas, *iPart, bIsHorizontal));
     738             : 
     739             :         // Remember the size of each part for later.
     740           0 :         aPartSizes[nIndex] = aSize;
     741             : 
     742             :         // Add gaps between elements.
     743           0 :         if ((*iPart)->size()>1 && bIsHorizontal)
     744             :         {
     745           0 :             nTotalHorizontalGap += ((*iPart)->size() - 1) * gnGapSize;
     746           0 :             nGapCount += (*iPart)->size()-1;
     747             :         }
     748             : 
     749             :         // Orientation changes for each part.
     750           0 :         bIsHorizontal = !bIsHorizontal;
     751             :         // Width is accumulated.
     752           0 :         aTotalSize.Width += aSize.Width;
     753             :         // Height is the maximum height of all parts.
     754           0 :         aTotalSize.Height = ::std::max(aTotalSize.Height, aSize.Height);
     755             :     }
     756             :     // Add gaps between parts.
     757           0 :     if (maElementContainer.size() > 1)
     758             :     {
     759           0 :         nTotalHorizontalGap += (maElementContainer.size() - 1) * gnGapSize;
     760           0 :         nGapCount += maElementContainer.size()-1;
     761             :     }
     762             : 
     763             :     // Calculate the minimal size so that the window size of the tool bar
     764             :     // can be adapted accordingly.
     765           0 :     maMinimalSize = aTotalSize;
     766           0 :     maMinimalSize.Width += nTotalHorizontalGap;
     767             : 
     768             :     // Calculate the gaps between elements.
     769           0 :     double nGapWidth (0);
     770           0 :     if (nGapCount > 0)
     771             :     {
     772           0 :         if (aTotalSize.Width + nTotalHorizontalGap > aWindowBox.Width)
     773           0 :             nTotalHorizontalGap = aWindowBox.Width - aTotalSize.Width;
     774           0 :         nGapWidth = nTotalHorizontalGap / nGapCount;
     775             :     }
     776             : 
     777             :     // Determine the location of the left edge.
     778           0 :     double nX (0);
     779           0 :     switch (meAnchor)
     780             :     {
     781           0 :         case Left : nX = 0; break;
     782           0 :         case Center: nX = (aWindowBox.Width - aTotalSize.Width - nTotalHorizontalGap) / 2; break;
     783           0 :         case Right: nX = aWindowBox.Width - aTotalSize.Width - nTotalHorizontalGap; break;
     784             :     }
     785             : 
     786             :     // Place the parts.
     787           0 :     double nY ((aWindowBox.Height - aTotalSize.Height) / 2);
     788           0 :     bIsHorizontal = true;
     789             : 
     790           0 :     maBoundingBox.X1 = nX;
     791           0 :     maBoundingBox.Y1 = nY;
     792           0 :     maBoundingBox.X2 = nX + aTotalSize.Width + nTotalHorizontalGap;
     793           0 :     maBoundingBox.Y2 = nY + aTotalSize.Height;
     794             : 
     795             :     /* push front or back ? ... */
     796             :     /// check whether RTL interface or not
     797           0 :     if(!Application::GetSettings().GetLayoutRTL()){
     798           0 :         for (iPart=maElementContainer.begin(), nIndex=0; iPart!=iEnd; ++iPart,++nIndex)
     799             :         {
     800             :             geometry::RealRectangle2D aBoundingBox(
     801             :                 nX, nY,
     802           0 :                 nX+aPartSizes[nIndex].Width, nY+aTotalSize.Height);
     803             : 
     804             :             // Add space for gaps between elements.
     805           0 :             if ((*iPart)->size() > 1)
     806           0 :                 if (bIsHorizontal)
     807           0 :                     aBoundingBox.X2 += ((*iPart)->size()-1) * nGapWidth;
     808             : 
     809           0 :             LayoutPart(rxCanvas, *iPart, aBoundingBox, aPartSizes[nIndex], bIsHorizontal);
     810           0 :             bIsHorizontal = !bIsHorizontal;
     811           0 :             nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
     812             :         }
     813             :     }
     814             :     else {
     815           0 :         for (iPart=maElementContainer.end()-1, nIndex=2; iPart!=iBegin-1; --iPart, --nIndex)
     816             :         {
     817             :             geometry::RealRectangle2D aBoundingBox(
     818             :                 nX, nY,
     819           0 :                 nX+aPartSizes[nIndex].Width, nY+aTotalSize.Height);
     820             : 
     821             :             // Add space for gaps between elements.
     822           0 :             if ((*iPart)->size() > 1)
     823           0 :                 if (bIsHorizontal)
     824           0 :                     aBoundingBox.X2 += ((*iPart)->size()-1) * nGapWidth;
     825             : 
     826           0 :             LayoutPart(rxCanvas, *iPart, aBoundingBox, aPartSizes[nIndex], bIsHorizontal);
     827           0 :             bIsHorizontal = !bIsHorizontal;
     828           0 :             nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
     829             :         }
     830             :     }
     831             : 
     832             :     // The whole window has to be repainted.
     833           0 :     mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
     834             : }
     835             : 
     836           0 : geometry::RealSize2D PresenterToolBar::CalculatePartSize (
     837             :     const Reference<rendering::XCanvas>& rxCanvas,
     838             :     const SharedElementContainerPart& rpPart,
     839             :     const bool bIsHorizontal)
     840             : {
     841           0 :     geometry::RealSize2D aTotalSize (0,0);
     842             : 
     843           0 :     if (mxWindow.is())
     844             :     {
     845             :         // Calculate the summed width of all elements.
     846           0 :         ElementContainerPart::const_iterator iElement;
     847           0 :         for (iElement=rpPart->begin(); iElement!=rpPart->end(); ++iElement)
     848             :         {
     849           0 :             if (iElement->get() == NULL)
     850           0 :                 continue;
     851             : 
     852           0 :             const awt::Size aBSize ((*iElement)->GetBoundingSize(rxCanvas));
     853           0 :             if (bIsHorizontal)
     854             :             {
     855           0 :                 aTotalSize.Width += aBSize.Width;
     856           0 :                 if (aBSize.Height > aTotalSize.Height)
     857           0 :                     aTotalSize.Height = aBSize.Height;
     858             :             }
     859             :             else
     860             :             {
     861           0 :                 aTotalSize.Height += aBSize.Height;
     862           0 :                 if (aBSize.Width > aTotalSize.Width)
     863           0 :                     aTotalSize.Width = aBSize.Width;
     864             :             }
     865             :         }
     866             :     }
     867           0 :     return aTotalSize;
     868             : }
     869             : 
     870           0 : void PresenterToolBar::LayoutPart (
     871             :     const Reference<rendering::XCanvas>& rxCanvas,
     872             :     const SharedElementContainerPart& rpPart,
     873             :     const geometry::RealRectangle2D& rBoundingBox,
     874             :     const geometry::RealSize2D& rPartSize,
     875             :     const bool bIsHorizontal)
     876             : {
     877           0 :     double nGap (0);
     878           0 :     if (rpPart->size() > 1)
     879             :     {
     880           0 :         if (bIsHorizontal)
     881           0 :             nGap = (rBoundingBox.X2 - rBoundingBox.X1 - rPartSize.Width) / (rpPart->size()-1);
     882             :         else
     883           0 :             nGap = (rBoundingBox.Y2 - rBoundingBox.Y1 - rPartSize.Height) / (rpPart->size()-1);
     884             :     }
     885             : 
     886             :     // Place the elements.
     887           0 :     double nX (rBoundingBox.X1);
     888           0 :     double nY (rBoundingBox.Y1);
     889             : 
     890           0 :     ElementContainerPart::const_iterator iElement;
     891           0 :     ElementContainerPart::const_iterator iEnd (rpPart->end());
     892           0 :     ElementContainerPart::const_iterator iBegin (rpPart->begin());
     893             : 
     894             :     /// check whether RTL interface or not
     895           0 :     if(!Application::GetSettings().GetLayoutRTL()){
     896           0 :         for (iElement=rpPart->begin(); iElement!=iEnd; ++iElement)
     897             :         {
     898           0 :             if (iElement->get() == NULL)
     899           0 :                 continue;
     900             : 
     901           0 :             const awt::Size aElementSize ((*iElement)->GetBoundingSize(rxCanvas));
     902           0 :             if (bIsHorizontal)
     903             :             {
     904           0 :                 if ((*iElement)->IsFilling())
     905             :                 {
     906           0 :                     nY = rBoundingBox.Y1;
     907           0 :                     (*iElement)->SetSize(geometry::RealSize2D(aElementSize.Width, rBoundingBox.Y2 - rBoundingBox.Y1));
     908             :                 }
     909             :                 else
     910           0 :                     nY = rBoundingBox.Y1 + (rBoundingBox.Y2-rBoundingBox.Y1 - aElementSize.Height) / 2;
     911           0 :                 (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
     912           0 :                 nX += aElementSize.Width + nGap;
     913             :             }
     914             :             else
     915             :             {
     916           0 :                 if ((*iElement)->IsFilling())
     917             :                 {
     918           0 :                     nX = rBoundingBox.X1;
     919           0 :                     (*iElement)->SetSize(geometry::RealSize2D(rBoundingBox.X2 - rBoundingBox.X1, aElementSize.Height));
     920             :                 }
     921             :                 else
     922           0 :                     nX = rBoundingBox.X1 + (rBoundingBox.X2-rBoundingBox.X1 - aElementSize.Width) / 2;
     923           0 :                 (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
     924           0 :                 nY += aElementSize.Height + nGap;
     925             :             }
     926             :         }
     927             :     }
     928             :     else {
     929           0 :         for (iElement=rpPart->end()-1; iElement!=iBegin-1; --iElement)
     930             :         {
     931           0 :             if (iElement->get() == NULL)
     932           0 :                 continue;
     933             : 
     934           0 :             const awt::Size aElementSize ((*iElement)->GetBoundingSize(rxCanvas));
     935           0 :             if (bIsHorizontal)
     936             :             {
     937           0 :                 if ((*iElement)->IsFilling())
     938             :                 {
     939           0 :                     nY = rBoundingBox.Y1;
     940           0 :                     (*iElement)->SetSize(geometry::RealSize2D(aElementSize.Width, rBoundingBox.Y2 - rBoundingBox.Y1));
     941             :                 }
     942             :                 else
     943           0 :                     nY = rBoundingBox.Y1 + (rBoundingBox.Y2-rBoundingBox.Y1 - aElementSize.Height) / 2;
     944           0 :                 (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
     945           0 :                 nX += aElementSize.Width + nGap;
     946             :             }
     947             :             else
     948             :             {
     949             :                 // reverse presentation time with current time
     950           0 :                 if (iElement==iBegin){
     951           0 :                     iElement=iBegin+2;
     952             :                 }
     953           0 :                 else if (iElement==iBegin+2){
     954           0 :                     iElement=iBegin;
     955             :                 }
     956           0 :                 const awt::Size aNewElementSize ((*iElement)->GetBoundingSize(rxCanvas));
     957           0 :                 if ((*iElement)->IsFilling())
     958             :                 {
     959           0 :                     nX = rBoundingBox.X1;
     960           0 :                     (*iElement)->SetSize(geometry::RealSize2D(rBoundingBox.X2 - rBoundingBox.X1, aNewElementSize.Height));
     961             :                 }
     962             :                 else
     963           0 :                     nX = rBoundingBox.X1 + (rBoundingBox.X2-rBoundingBox.X1 - aNewElementSize.Width) / 2;
     964           0 :                 (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
     965           0 :                 nY += aNewElementSize.Height + nGap;
     966             : 
     967             :                 // return the index as it was before the reversing
     968           0 :                 if (iElement==iBegin)
     969           0 :                     iElement=iBegin+2;
     970           0 :                 else if (iElement==iBegin+2)
     971           0 :                     iElement=iBegin;
     972             :             }
     973             :         }
     974             :     }
     975             : 
     976           0 : }
     977             : 
     978           0 : void PresenterToolBar::Paint (
     979             :     const awt::Rectangle& rUpdateBox,
     980             :     const rendering::ViewState& rViewState)
     981             : {
     982             :     OSL_ASSERT(mxCanvas.is());
     983             : 
     984           0 :     ElementContainer::iterator iPart;
     985           0 :     ElementContainer::const_iterator iEnd (maElementContainer.end());
     986           0 :     for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
     987             :     {
     988           0 :         ElementContainerPart::iterator iElement;
     989           0 :         ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
     990           0 :         for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
     991             :         {
     992           0 :             if (iElement->get() != NULL)
     993             :             {
     994           0 :                 if ( ! (*iElement)->IsOutside(rUpdateBox))
     995           0 :                     (*iElement)->Paint(mxCanvas, rViewState);
     996             :             }
     997             :         }
     998             :     }
     999           0 : }
    1000             : 
    1001           0 : void PresenterToolBar::UpdateSlideNumber (void)
    1002             : {
    1003           0 :     if( mxSlideShowController.is() )
    1004             :     {
    1005           0 :         ElementContainer::iterator iPart;
    1006           0 :         ElementContainer::const_iterator iEnd (maElementContainer.end());
    1007           0 :         for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
    1008             :         {
    1009           0 :             ElementContainerPart::iterator iElement;
    1010           0 :             ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
    1011           0 :             for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
    1012             :             {
    1013           0 :                 if (iElement->get() != NULL)
    1014           0 :                     (*iElement)->CurrentSlideHasChanged();
    1015             :             }
    1016             :         }
    1017             :     }
    1018           0 : }
    1019             : 
    1020           0 : void PresenterToolBar::CheckMouseOver (
    1021             :     const css::awt::MouseEvent& rEvent,
    1022             :     const bool bOverWindow,
    1023             :     const bool bMouseDown)
    1024             : {
    1025           0 :     css::awt::MouseEvent rTemp =rEvent;
    1026           0 :     if(Application::GetSettings().GetLayoutRTL()){
    1027           0 :         awt::Rectangle aWindowBox = mxWindow->getPosSize();
    1028           0 :         rTemp.X=aWindowBox.Width-rTemp.X;
    1029             :     }
    1030           0 :     ElementContainer::iterator iPart;
    1031           0 :     ElementContainer::const_iterator iEnd (maElementContainer.end());
    1032           0 :     for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
    1033             :     {
    1034           0 :         ElementContainerPart::iterator iElement;
    1035           0 :         ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
    1036           0 :         for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
    1037             :         {
    1038           0 :             if (iElement->get() == NULL)
    1039           0 :                 continue;
    1040             : 
    1041           0 :             awt::Rectangle aBox ((*iElement)->GetBoundingBox());
    1042             :             const bool bIsOver = bOverWindow
    1043             :                 && aBox.X <= rTemp.X
    1044             :                 && aBox.Width+aBox.X-1 >= rTemp.X
    1045             :                 && aBox.Y <= rTemp.Y
    1046           0 :                 && aBox.Height+aBox.Y-1 >= rTemp.Y;
    1047           0 :             (*iElement)->SetState(
    1048             :                 bIsOver,
    1049           0 :                 bIsOver && rTemp.Buttons!=0 && bMouseDown && rTemp.ClickCount>0);
    1050             :         }
    1051           0 :     }
    1052           0 : }
    1053             : 
    1054           0 : void PresenterToolBar::ThrowIfDisposed (void) const
    1055             :     throw (::com::sun::star::lang::DisposedException)
    1056             : {
    1057           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
    1058             :     {
    1059             :         throw lang::DisposedException (
    1060             :             OUString( "PresenterToolBar has already been disposed"),
    1061           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
    1062             :     }
    1063           0 : }
    1064             : 
    1065             : //===== PresenterToolBarView ==================================================
    1066             : 
    1067           0 : PresenterToolBarView::PresenterToolBarView (
    1068             :     const Reference<XComponentContext>& rxContext,
    1069             :     const Reference<XResourceId>& rxViewId,
    1070             :     const Reference<frame::XController>& rxController,
    1071             :     const ::rtl::Reference<PresenterController>& rpPresenterController)
    1072             :     : PresenterToolBarViewInterfaceBase(m_aMutex),
    1073             :       mxPane(),
    1074             :       mxViewId(rxViewId),
    1075             :       mxWindow(),
    1076             :       mxCanvas(),
    1077             :       mpPresenterController(rpPresenterController),
    1078             :       mxSlideShowController(rpPresenterController->GetSlideShowController()),
    1079           0 :       mpToolBar()
    1080             : {
    1081             :     try
    1082             :     {
    1083           0 :         Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
    1084           0 :         Reference<XConfigurationController> xCC(xCM->getConfigurationController(),UNO_QUERY_THROW);
    1085           0 :         mxPane = Reference<XPane>(xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
    1086             : 
    1087           0 :         mxWindow = mxPane->getWindow();
    1088           0 :         mxCanvas = mxPane->getCanvas();
    1089             : 
    1090             :         mpToolBar = new PresenterToolBar(
    1091             :             rxContext,
    1092             :             mxWindow,
    1093             :             mxCanvas,
    1094             :             rpPresenterController,
    1095           0 :             PresenterToolBar::Center);
    1096           0 :         mpToolBar->Initialize(A2S("PresenterScreenSettings/ToolBars/ToolBar"));
    1097             : 
    1098           0 :         if (mxWindow.is())
    1099             :         {
    1100           0 :             mxWindow->addPaintListener(this);
    1101             : 
    1102           0 :             Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
    1103           0 :             if (xPeer.is())
    1104           0 :                 xPeer->setBackground(util::Color(0xff000000));
    1105             : 
    1106           0 :             mxWindow->setVisible(sal_True);
    1107           0 :         }
    1108             :     }
    1109           0 :     catch (RuntimeException&)
    1110             :     {
    1111           0 :         mxViewId = NULL;
    1112           0 :         throw;
    1113             :     }
    1114           0 : }
    1115             : 
    1116           0 : PresenterToolBarView::~PresenterToolBarView (void)
    1117             : {
    1118           0 : }
    1119             : 
    1120           0 : void SAL_CALL PresenterToolBarView::disposing (void)
    1121             : {
    1122           0 :     Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
    1123           0 :     mpToolBar = NULL;
    1124           0 :     if (xComponent.is())
    1125           0 :         xComponent->dispose();
    1126             : 
    1127           0 :     if (mxWindow.is())
    1128             :     {
    1129           0 :         mxWindow->removePaintListener(this);
    1130           0 :         mxWindow = NULL;
    1131             :     }
    1132           0 :     mxCanvas = NULL;
    1133           0 :     mxViewId = NULL;
    1134           0 :     mxPane = NULL;
    1135           0 :     mpPresenterController = NULL;
    1136           0 :     mxSlideShowController = NULL;
    1137             : 
    1138           0 : }
    1139             : 
    1140           0 : ::rtl::Reference<PresenterToolBar> PresenterToolBarView::GetPresenterToolBar (void) const
    1141             : {
    1142           0 :     return mpToolBar;
    1143             : }
    1144             : 
    1145             : //----- XPaintListener --------------------------------------------------------
    1146             : 
    1147           0 : void SAL_CALL PresenterToolBarView::windowPaint (const css::awt::PaintEvent& rEvent)
    1148             :     throw (RuntimeException)
    1149             : {
    1150           0 :     awt::Rectangle aWindowBox (mxWindow->getPosSize());
    1151             :     mpPresenterController->GetCanvasHelper()->Paint(
    1152           0 :         mpPresenterController->GetViewBackground(mxViewId->getResourceURL()),
    1153             :         mxCanvas,
    1154             :         rEvent.UpdateRect,
    1155             :         awt::Rectangle(0,0,aWindowBox.Width, aWindowBox.Height),
    1156           0 :         awt::Rectangle());
    1157           0 : }
    1158             : 
    1159             : //-----  lang::XEventListener -------------------------------------------------
    1160             : 
    1161           0 : void SAL_CALL PresenterToolBarView::disposing (const lang::EventObject& rEventObject)
    1162             :     throw (RuntimeException)
    1163             : {
    1164           0 :     if (rEventObject.Source == mxWindow)
    1165           0 :         mxWindow = NULL;
    1166           0 : }
    1167             : 
    1168             : //----- XResourceId -----------------------------------------------------------
    1169             : 
    1170           0 : Reference<XResourceId> SAL_CALL PresenterToolBarView::getResourceId (void)
    1171             :     throw (RuntimeException)
    1172             : {
    1173           0 :     return mxViewId;
    1174             : }
    1175             : 
    1176           0 : sal_Bool SAL_CALL PresenterToolBarView::isAnchorOnly (void)
    1177             :     throw (RuntimeException)
    1178             : {
    1179           0 :     return false;
    1180             : }
    1181             : 
    1182             : //----- XDrawView -------------------------------------------------------------
    1183             : 
    1184           0 : void SAL_CALL PresenterToolBarView::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
    1185             :     throw (RuntimeException)
    1186             : {
    1187           0 :     Reference<drawing::XDrawView> xToolBar (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
    1188           0 :     if (xToolBar.is())
    1189           0 :         xToolBar->setCurrentPage(rxSlide);
    1190           0 : }
    1191             : 
    1192           0 : Reference<drawing::XDrawPage> SAL_CALL PresenterToolBarView::getCurrentPage (void)
    1193             :     throw (RuntimeException)
    1194             : {
    1195           0 :     return NULL;
    1196             : }
    1197             : 
    1198             : //===== PresenterToolBar::Element =============================================
    1199             : 
    1200             : namespace {
    1201             : 
    1202           0 : Element::Element (
    1203             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1204             :     : ElementInterfaceBase(m_aMutex),
    1205             :       mpToolBar(rpToolBar),
    1206             :       maLocation(),
    1207             :       maSize(),
    1208             :       mpNormal(),
    1209             :       mpMouseOver(),
    1210             :       mpSelected(),
    1211             :       mpDisabled(),
    1212             :       mpMode(),
    1213             :       mbIsOver(false),
    1214             :       mbIsPressed(false),
    1215             :       mbIsSelected(false),
    1216           0 :       mbIsEnabled(true)
    1217             : {
    1218           0 :     if (mpToolBar.get() != NULL)
    1219             :     {
    1220             :         OSL_ASSERT(mpToolBar->GetPresenterController().is());
    1221             :         OSL_ASSERT(mpToolBar->GetPresenterController()->GetWindowManager().is());
    1222             :     }
    1223           0 : }
    1224             : 
    1225           0 : Element::~Element (void)
    1226             : {
    1227           0 : }
    1228             : 
    1229           0 : void Element::SetModes (
    1230             :     const SharedElementMode& rpNormalMode,
    1231             :     const SharedElementMode& rpMouseOverMode,
    1232             :     const SharedElementMode& rpSelectedMode,
    1233             :     const SharedElementMode& rpDisabledMode)
    1234             : {
    1235           0 :     mpNormal = rpNormalMode;
    1236           0 :     mpMouseOver = rpMouseOverMode;
    1237           0 :     mpSelected = rpSelectedMode;
    1238           0 :     mpDisabled = rpDisabledMode;
    1239           0 :     mpMode = rpNormalMode;
    1240           0 : }
    1241             : 
    1242           0 : void Element::disposing (void)
    1243             : {
    1244           0 : }
    1245             : 
    1246           0 : awt::Size Element::GetBoundingSize (
    1247             :     const Reference<rendering::XCanvas>& rxCanvas)
    1248             : {
    1249           0 :     maSize = CreateBoundingSize(rxCanvas);
    1250           0 :     return maSize;
    1251             : }
    1252             : 
    1253           0 : awt::Rectangle Element::GetBoundingBox (void) const
    1254             : {
    1255           0 :     return awt::Rectangle(maLocation.X,maLocation.Y, maSize.Width, maSize.Height);
    1256             : }
    1257             : 
    1258           0 : void Element::CurrentSlideHasChanged (void)
    1259             : {
    1260           0 :     UpdateState();
    1261           0 : }
    1262             : 
    1263           0 : void Element::SetLocation (const awt::Point& rLocation)
    1264             : {
    1265           0 :     maLocation = rLocation;
    1266           0 : }
    1267             : 
    1268           0 : void Element::SetSize (const geometry::RealSize2D& rSize)
    1269             : {
    1270           0 :     maSize = awt::Size(sal_Int32(0.5+rSize.Width), sal_Int32(0.5+rSize.Height));
    1271           0 : }
    1272             : 
    1273           0 : bool Element::SetState (
    1274             :     const bool bIsOver,
    1275             :     const bool bIsPressed)
    1276             : {
    1277           0 :     bool bModified (mbIsOver != bIsOver || mbIsPressed != bIsPressed);
    1278           0 :     bool bClicked (mbIsPressed && bIsOver && ! bIsPressed);
    1279             : 
    1280           0 :     mbIsOver = bIsOver;
    1281           0 :     mbIsPressed = bIsPressed;
    1282             : 
    1283             :     // When the element is disabled then ignore mouse over or selection.
    1284             :     // When the element is selected then ignore mouse over.
    1285           0 :     if ( ! mbIsEnabled)
    1286           0 :         mpMode = mpDisabled;
    1287           0 :     else if (mbIsSelected)
    1288           0 :         mpMode = mpSelected;
    1289           0 :     else if (mbIsOver)
    1290           0 :         mpMode = mpMouseOver;
    1291             :     else
    1292           0 :         mpMode = mpNormal;
    1293             : 
    1294           0 :     if (bClicked && mbIsEnabled)
    1295             :     {
    1296           0 :         if (mpMode.get() != NULL)
    1297             :         {
    1298             :             do
    1299             :             {
    1300           0 :                 if (mpMode->msAction.isEmpty())
    1301           0 :                     break;
    1302             : 
    1303           0 :                 if (mpToolBar.get() == NULL)
    1304           0 :                     break;
    1305             : 
    1306           0 :                 if (mpToolBar->GetPresenterController().get() == NULL)
    1307           0 :                     break;
    1308             : 
    1309           0 :                 mpToolBar->GetPresenterController()->DispatchUnoCommand(mpMode->msAction);
    1310           0 :                 mpToolBar->RequestLayout();
    1311             :             }
    1312             :             while (false);
    1313             :         }
    1314             : 
    1315             :     }
    1316           0 :     else if (bModified)
    1317             :     {
    1318           0 :         Invalidate();
    1319             :     }
    1320             : 
    1321           0 :     return bModified;
    1322             : }
    1323             : 
    1324           0 : void Element::Invalidate (const bool bSynchronous)
    1325             : {
    1326             :     OSL_ASSERT(mpToolBar.is());
    1327           0 :     mpToolBar->InvalidateArea(GetBoundingBox(), bSynchronous);
    1328           0 : }
    1329             : 
    1330           0 : bool Element::IsOutside (const awt::Rectangle& rBox)
    1331             : {
    1332           0 :     if (rBox.X >= maLocation.X+maSize.Width)
    1333           0 :         return true;
    1334           0 :     else if (rBox.Y >= maLocation.Y+maSize.Height)
    1335           0 :         return true;
    1336           0 :     else if (maLocation.X >= rBox.X+rBox.Width)
    1337           0 :         return true;
    1338           0 :     else if (maLocation.Y >= rBox.Y+rBox.Height)
    1339           0 :         return true;
    1340             :     else
    1341           0 :         return false;
    1342             : }
    1343             : 
    1344           0 : bool Element::IsEnabled (void) const
    1345             : {
    1346           0 :     return mbIsEnabled;
    1347             : }
    1348             : 
    1349           0 : bool Element::IsFilling (void) const
    1350             : {
    1351           0 :     return false;
    1352             : }
    1353             : 
    1354           0 : void Element::UpdateState (void)
    1355             : {
    1356             :     OSL_ASSERT(mpToolBar.get() != NULL);
    1357             :     OSL_ASSERT(mpToolBar->GetPresenterController().get() != NULL);
    1358             : 
    1359           0 :     if (mpMode.get() == NULL)
    1360           0 :         return;
    1361             : 
    1362           0 :     util::URL aURL (mpToolBar->GetPresenterController()->CreateURLFromString(mpMode->msAction));
    1363           0 :     Reference<frame::XDispatch> xDispatch (mpToolBar->GetPresenterController()->GetDispatch(aURL));
    1364           0 :     if (xDispatch.is())
    1365             :     {
    1366           0 :         xDispatch->addStatusListener(this, aURL);
    1367           0 :         xDispatch->removeStatusListener(this, aURL);
    1368           0 :     }
    1369             : }
    1370             : 
    1371             : //----- lang::XEventListener --------------------------------------------------
    1372             : 
    1373           0 : void SAL_CALL Element::disposing (const css::lang::EventObject& rEvent)
    1374             :     throw(css::uno::RuntimeException)
    1375             : {
    1376             :     (void)rEvent;
    1377           0 : }
    1378             : 
    1379             : //----- document::XEventListener ----------------------------------------------
    1380             : 
    1381           0 : void SAL_CALL Element::notifyEvent (const css::document::EventObject& rEvent)
    1382             :     throw(css::uno::RuntimeException)
    1383             : {
    1384             :     (void)rEvent;
    1385           0 :     UpdateState();
    1386           0 : }
    1387             : 
    1388             : //----- frame::XStatusListener ------------------------------------------------
    1389             : 
    1390           0 : void SAL_CALL Element::statusChanged (const css::frame::FeatureStateEvent& rEvent)
    1391             :     throw(css::uno::RuntimeException)
    1392             : {
    1393           0 :     bool bIsSelected (mbIsSelected);
    1394           0 :     bool bIsEnabled (rEvent.IsEnabled);
    1395           0 :     rEvent.State >>= bIsSelected;
    1396             : 
    1397           0 :     if (bIsSelected != mbIsSelected || bIsEnabled != mbIsEnabled)
    1398             :     {
    1399           0 :         mbIsEnabled = bIsEnabled;
    1400           0 :         mbIsSelected = bIsSelected;
    1401           0 :         SetState(mbIsOver, mbIsPressed);
    1402           0 :         mpToolBar->RequestLayout();
    1403             :     }
    1404           0 : }
    1405             : 
    1406             : } // end of anonymous namespace
    1407             : 
    1408             : //===== ElementMode ===========================================================
    1409             : 
    1410             : namespace {
    1411             : 
    1412           0 : ElementMode::ElementMode (void)
    1413             :     : mpIcon(),
    1414             :       msAction(),
    1415           0 :       maText()
    1416             : {
    1417           0 : }
    1418             : 
    1419           0 : void ElementMode::ReadElementMode (
    1420             :     const Reference<beans::XPropertySet>& rxElementProperties,
    1421             :     const OUString& rsModeName,
    1422             :     ::boost::shared_ptr<ElementMode>& rpDefaultMode,
    1423             :     ::sdext::presenter::PresenterToolBar::Context& rContext)
    1424             : {
    1425             :     try
    1426             :     {
    1427             :     Reference<container::XHierarchicalNameAccess> xNode (
    1428             :         PresenterConfigurationAccess::GetProperty(rxElementProperties, rsModeName),
    1429           0 :         UNO_QUERY);
    1430             :     Reference<beans::XPropertySet> xProperties (
    1431           0 :         PresenterConfigurationAccess::GetNodeProperties(xNode, OUString()));
    1432           0 :     if ( ! xProperties.is() && rpDefaultMode.get()!=NULL)
    1433             :     {
    1434             :         // The mode is not specified.  Use the given, possibly empty,
    1435             :         // default mode instead.
    1436           0 :         mpIcon = rpDefaultMode->mpIcon;
    1437           0 :         msAction = rpDefaultMode->msAction;
    1438           0 :         maText = rpDefaultMode->maText;
    1439             :     }
    1440             : 
    1441             :     // Read action.
    1442           0 :     if ( ! (PresenterConfigurationAccess::GetProperty(xProperties, A2S("Action")) >>= msAction))
    1443           0 :         if (rpDefaultMode.get()!=NULL)
    1444           0 :             msAction = rpDefaultMode->msAction;
    1445             : 
    1446             :     // Read text and font
    1447           0 :     OUString sText (rpDefaultMode.get()!=NULL ? rpDefaultMode->maText.GetText() : OUString());
    1448           0 :     PresenterConfigurationAccess::GetProperty(xProperties, A2S("Text")) >>= sText;
    1449             :     Reference<container::XHierarchicalNameAccess> xFontNode (
    1450           0 :         PresenterConfigurationAccess::GetProperty(xProperties, A2S("Font")), UNO_QUERY);
    1451             :     PresenterTheme::SharedFontDescriptor pFont (PresenterTheme::ReadFont(
    1452             :         xFontNode,
    1453             :         A2S(""),
    1454           0 :         rpDefaultMode.get()!=NULL
    1455           0 :             ? rpDefaultMode->maText.GetFont()
    1456           0 :             : PresenterTheme::SharedFontDescriptor()));
    1457           0 :     maText = Text(sText,pFont);
    1458             : 
    1459             :     // Read bitmaps to display as icons.
    1460             :     Reference<container::XHierarchicalNameAccess> xIconNode (
    1461           0 :         PresenterConfigurationAccess::GetProperty(xProperties, A2S("Icon")), UNO_QUERY);
    1462             :     mpIcon = PresenterBitmapContainer::LoadBitmap(
    1463             :         xIconNode,
    1464             :         A2S(""),
    1465             :         rContext.mxPresenterHelper,
    1466             :         rContext.mxCanvas,
    1467           0 :         rpDefaultMode.get()!=NULL ? rpDefaultMode->mpIcon : SharedBitmapDescriptor());
    1468             :     }
    1469           0 :     catch(Exception&)
    1470             :     {
    1471             :         OSL_ASSERT(false);
    1472             :     }
    1473           0 : }
    1474             : 
    1475             : } // end of anonymous namespace
    1476             : 
    1477             : //===== Button ================================================================
    1478             : 
    1479             : namespace {
    1480             : 
    1481           0 : ::rtl::Reference<Element> Button::Create (
    1482             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1483             : {
    1484           0 :     ::rtl::Reference<Button> pElement (new Button(rpToolBar));
    1485           0 :     pElement->Initialize();
    1486           0 :     return ::rtl::Reference<Element>(pElement.get());
    1487             : }
    1488             : 
    1489           0 : Button::Button (
    1490             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1491             :     : Element(rpToolBar),
    1492           0 :       mbIsListenerRegistered(false)
    1493             : {
    1494             :     OSL_ASSERT(mpToolBar.get() != NULL);
    1495             :     OSL_ASSERT(mpToolBar->GetPresenterController().is());
    1496             :     OSL_ASSERT(mpToolBar->GetPresenterController()->GetWindowManager().is());
    1497           0 : }
    1498             : 
    1499           0 : Button::~Button (void)
    1500             : {
    1501           0 : }
    1502             : 
    1503           0 : void Button::Initialize (void)
    1504             : {
    1505           0 :     mpToolBar->GetPresenterController()->GetWindowManager()->AddLayoutListener(this);
    1506           0 :     mbIsListenerRegistered = true;
    1507           0 : }
    1508             : 
    1509           0 : void Button::disposing (void)
    1510             : {
    1511             :     OSL_ASSERT(mpToolBar.get() != NULL);
    1512           0 :     if (mpToolBar.get() != NULL
    1513             :         && mbIsListenerRegistered)
    1514             :     {
    1515             :         OSL_ASSERT(mpToolBar->GetPresenterController().is());
    1516             :         OSL_ASSERT(mpToolBar->GetPresenterController()->GetWindowManager().is());
    1517             : 
    1518           0 :         mbIsListenerRegistered = false;
    1519           0 :         mpToolBar->GetPresenterController()->GetWindowManager()->RemoveLayoutListener(this);
    1520             :     }
    1521           0 :     Element::disposing();
    1522           0 : }
    1523             : 
    1524           0 : void Button::Paint (
    1525             :     const Reference<rendering::XCanvas>& rxCanvas,
    1526             :     const rendering::ViewState& rViewState)
    1527             : {
    1528             :     OSL_ASSERT(rxCanvas.is());
    1529             : 
    1530           0 :     if (mpMode.get() == NULL)
    1531             :         return;
    1532             : 
    1533           0 :     if (mpMode->mpIcon.get() == NULL)
    1534             :         return;
    1535             : 
    1536           0 :     geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas));
    1537           0 :     sal_Int32 nTextHeight (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1));
    1538             : 
    1539           0 :     PaintIcon(rxCanvas, nTextHeight, rViewState);
    1540           0 :     awt::Point aOffset(0,0);
    1541           0 :     if ( ! IsEnabled())
    1542           0 :         if (mpMode->mpIcon.get() != NULL)
    1543             :         {
    1544           0 :             Reference<rendering::XBitmap> xBitmap (mpMode->mpIcon->GetNormalBitmap());
    1545           0 :             if (xBitmap.is())
    1546           0 :                 aOffset.Y = xBitmap->getSize().Height;
    1547             :         }
    1548           0 :     mpMode->maText.Paint(rxCanvas, rViewState, GetBoundingBox(), aOffset);
    1549             : }
    1550             : 
    1551           0 : awt::Size Button::CreateBoundingSize (
    1552             :     const Reference<rendering::XCanvas>& rxCanvas)
    1553             : {
    1554           0 :     if (mpMode.get() == NULL)
    1555           0 :         return awt::Size();
    1556             : 
    1557           0 :     geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas));
    1558           0 :     const sal_Int32 nGap (5);
    1559           0 :     sal_Int32 nTextHeight (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1));
    1560           0 :     sal_Int32 nTextWidth (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.X2 - aTextBBox.X1));
    1561           0 :     Reference<rendering::XBitmap> xBitmap;
    1562           0 :     if (mpMode->mpIcon.get() != NULL)
    1563           0 :         xBitmap = mpMode->mpIcon->GetNormalBitmap();
    1564           0 :     if (xBitmap.is())
    1565             :     {
    1566           0 :         geometry::IntegerSize2D aSize (xBitmap->getSize());
    1567             :         return awt::Size(
    1568           0 :             ::std::max(aSize.Width, sal_Int32(0.5 + aTextBBox.X2 - aTextBBox.X1)),
    1569           0 :             aSize.Height+ nGap + nTextHeight);
    1570             :     }
    1571             :     else
    1572           0 :         return awt::Size(nTextWidth,nTextHeight);
    1573             : }
    1574             : 
    1575           0 : void Button::PaintIcon (
    1576             :     const Reference<rendering::XCanvas>& rxCanvas,
    1577             :     const sal_Int32 nTextHeight,
    1578             :     const rendering::ViewState& rViewState)
    1579             : {
    1580           0 :     if (mpMode.get() == NULL)
    1581           0 :         return;
    1582             : 
    1583           0 :     Reference<rendering::XBitmap> xBitmap (mpMode->mpIcon->GetBitmap(GetMode()));
    1584           0 :     if (xBitmap.is())
    1585             :     {
    1586             :         /// check whether RTL interface or not
    1587           0 :         if(!Application::GetSettings().GetLayoutRTL()){
    1588             :             const sal_Int32 nX (maLocation.X
    1589           0 :                 + (maSize.Width-xBitmap->getSize().Width) / 2);
    1590             :             const sal_Int32 nY (maLocation.Y
    1591           0 :                 + (maSize.Height - nTextHeight - xBitmap->getSize().Height) / 2);
    1592             :             const rendering::RenderState aRenderState(
    1593             :                 geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
    1594             :                 NULL,
    1595             :                 Sequence<double>(4),
    1596           0 :                 rendering::CompositeOperation::OVER);
    1597           0 :             rxCanvas->drawBitmap(xBitmap, rViewState, aRenderState);
    1598             :         }
    1599             :         else {
    1600             :             const sal_Int32 nX (maLocation.X
    1601           0 :                 + (maSize.Width+xBitmap->getSize().Width) / 2);
    1602             :             const sal_Int32 nY (maLocation.Y
    1603           0 :                 + (maSize.Height - nTextHeight - xBitmap->getSize().Height) / 2);
    1604             :             const rendering::RenderState aRenderState(
    1605             :                 geometry::AffineMatrix2D(-1,0,nX, 0,1,nY),
    1606             :                 NULL,
    1607             :                 Sequence<double>(4),
    1608           0 :                 rendering::CompositeOperation::OVER);
    1609           0 :             rxCanvas->drawBitmap(xBitmap, rViewState, aRenderState);
    1610             :         }
    1611           0 :     }
    1612             : }
    1613             : 
    1614           0 : PresenterBitmapDescriptor::Mode Button::GetMode (void) const
    1615             : {
    1616           0 :     if ( ! IsEnabled())
    1617           0 :         return PresenterBitmapDescriptor::Disabled;
    1618           0 :     else if (mbIsPressed)
    1619           0 :         return PresenterBitmapDescriptor::ButtonDown;
    1620           0 :     else if (mbIsOver)
    1621           0 :         return PresenterBitmapDescriptor::MouseOver;
    1622             :     else
    1623           0 :         return PresenterBitmapDescriptor::Normal;
    1624             : }
    1625             : 
    1626             : //----- lang::XEventListener --------------------------------------------------
    1627             : 
    1628           0 : void SAL_CALL Button::disposing (const css::lang::EventObject& rEvent)
    1629             :     throw(css::uno::RuntimeException)
    1630             : {
    1631             :     (void)rEvent;
    1632           0 :     mbIsListenerRegistered = false;
    1633           0 :     Element::disposing(rEvent);
    1634           0 : }
    1635             : 
    1636             : } // end of anonymous namespace
    1637             : 
    1638             : //===== PresenterToolBar::Label ===============================================
    1639             : 
    1640             : namespace {
    1641             : 
    1642           0 : Label::Label (const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1643           0 :     : Element(rpToolBar)
    1644             : {
    1645           0 : }
    1646             : 
    1647           0 : awt::Size Label::CreateBoundingSize (
    1648             :     const Reference<rendering::XCanvas>& rxCanvas)
    1649             : {
    1650           0 :     if (mpMode.get() == NULL)
    1651           0 :         return awt::Size(0,0);
    1652             : 
    1653           0 :     geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas));
    1654             :     return awt::Size(
    1655           0 :         sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.X2 - aTextBBox.X1),
    1656           0 :         sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1));
    1657             : }
    1658             : 
    1659           0 : void Label::SetText (const OUString& rsText)
    1660             : {
    1661             :     OSL_ASSERT(mpToolBar.get() != NULL);
    1662           0 :     if (mpMode.get() == NULL)
    1663           0 :         return;
    1664             : 
    1665           0 :     const bool bRequestLayout (mpMode->maText.GetText().getLength() != rsText.getLength());
    1666             : 
    1667           0 :     mpMode->maText.SetText(rsText);
    1668             :     // Just use the character count for determing whether a layout is
    1669             :     // necessary.  This is an optimization to avoid layouts every time a new
    1670             :     // time value is set on some labels.
    1671           0 :     if (bRequestLayout)
    1672           0 :         mpToolBar->RequestLayout();
    1673             :     else
    1674           0 :         Invalidate(false);
    1675             : }
    1676             : 
    1677           0 : void Label::Paint (
    1678             :     const Reference<rendering::XCanvas>& rxCanvas,
    1679             :     const rendering::ViewState& rViewState)
    1680             : {
    1681             :     OSL_ASSERT(rxCanvas.is());
    1682           0 :     if (mpMode.get() == NULL)
    1683           0 :         return;
    1684             : 
    1685           0 :     mpMode->maText.Paint(rxCanvas, rViewState, GetBoundingBox(), awt::Point(0,0));
    1686             : }
    1687             : 
    1688           0 : bool Label::SetState (const bool bIsOver, const bool bIsPressed)
    1689             : {
    1690             :     // For labels there is no mouse over effect.
    1691             :     (void)bIsOver;
    1692             :     (void)bIsPressed;
    1693           0 :     return Element::SetState(false, false);
    1694             : }
    1695             : 
    1696             : } // end of anonymous namespace
    1697             : 
    1698             : //===== Text ==================================================================
    1699             : 
    1700             : namespace {
    1701             : 
    1702           0 : Text::Text (void)
    1703             :     : msText(),
    1704           0 :       mpFont()
    1705             : {
    1706           0 : }
    1707             : 
    1708           0 : Text::Text (const Text& rText)
    1709             :     : msText(rText.msText),
    1710           0 :       mpFont(rText.mpFont)
    1711             : {
    1712           0 : }
    1713             : 
    1714           0 : Text::Text (
    1715             :     const OUString& rsText,
    1716             :     const PresenterTheme::SharedFontDescriptor& rpFont)
    1717             :     : msText(rsText),
    1718           0 :       mpFont(rpFont)
    1719             : {
    1720           0 : }
    1721             : 
    1722           0 : void Text::SetText (const OUString& rsText)
    1723             : {
    1724           0 :     msText = rsText;
    1725           0 : }
    1726             : 
    1727           0 : OUString Text::GetText (void) const
    1728             : {
    1729           0 :     return msText;
    1730             : }
    1731             : 
    1732           0 : PresenterTheme::SharedFontDescriptor Text::GetFont (void) const
    1733             : {
    1734           0 :     return mpFont;
    1735             : }
    1736             : 
    1737           0 : void Text::Paint (
    1738             :     const Reference<rendering::XCanvas>& rxCanvas,
    1739             :     const rendering::ViewState& rViewState,
    1740             :     const awt::Rectangle& rBoundingBox,
    1741             :     const awt::Point& rOffset)
    1742             : {
    1743             :     (void)rOffset;
    1744             :     OSL_ASSERT(rxCanvas.is());
    1745             : 
    1746           0 :     if (msText.isEmpty())
    1747             :         return;
    1748           0 :     if (mpFont.get() == NULL)
    1749             :         return;
    1750             : 
    1751           0 :     if ( ! mpFont->mxFont.is())
    1752           0 :         mpFont->PrepareFont(rxCanvas);
    1753           0 :     if ( ! mpFont->mxFont.is())
    1754             :         return;
    1755             : 
    1756           0 :     rendering::StringContext aContext (msText, 0, msText.getLength());
    1757             : 
    1758             :     Reference<rendering::XTextLayout> xLayout (
    1759           0 :         mpFont->mxFont->createTextLayout(
    1760             :             aContext,
    1761             :             rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
    1762           0 :             0));
    1763             :     /** this responsible of the toolbar and the zoom
    1764             :         that in the note mode.
    1765             :         check whether RTL interface or not. */
    1766           0 :     if(!Application::GetSettings().GetLayoutRTL()){
    1767           0 :         geometry::RealRectangle2D aBox (xLayout->queryTextBounds());
    1768           0 :         const double nTextWidth = aBox.X2 - aBox.X1;
    1769           0 :         const double nY = rBoundingBox.Y + rBoundingBox.Height - aBox.Y2;
    1770           0 :         const double nX = rBoundingBox.X + (rBoundingBox.Width - nTextWidth)/2;
    1771             : 
    1772             :         rendering::RenderState aRenderState(
    1773             :             geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
    1774             :             NULL,
    1775             :             Sequence<double>(4),
    1776           0 :             rendering::CompositeOperation::SOURCE);
    1777           0 :         PresenterCanvasHelper::SetDeviceColor(aRenderState, mpFont->mnColor);
    1778           0 :         rxCanvas->drawText(
    1779             :             aContext,
    1780           0 :             mpFont->mxFont,
    1781             :             rViewState,
    1782             :             aRenderState,
    1783           0 :             rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
    1784             :     }
    1785             :     else {
    1786           0 :         geometry::RealRectangle2D aBox (xLayout->queryTextBounds());
    1787           0 :         const double nTextWidth = aBox.X2 - aBox.X1;
    1788           0 :         const double nY = rBoundingBox.Y + rBoundingBox.Height - aBox.Y2;
    1789           0 :         const double nX = rBoundingBox.X + (rBoundingBox.Width + nTextWidth)/2;
    1790             : 
    1791             :         rendering::RenderState aRenderState(
    1792             :             geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
    1793             :             NULL,
    1794             :             Sequence<double>(4),
    1795           0 :             rendering::CompositeOperation::SOURCE);
    1796           0 :         PresenterCanvasHelper::SetDeviceColor(aRenderState, mpFont->mnColor);
    1797           0 :         rxCanvas->drawText(
    1798             :             aContext,
    1799           0 :             mpFont->mxFont,
    1800             :             rViewState,
    1801             :             aRenderState,
    1802           0 :             rendering::TextDirection::WEAK_RIGHT_TO_LEFT);
    1803           0 :     }
    1804             : }
    1805             : 
    1806           0 : geometry::RealRectangle2D Text::GetBoundingBox (const Reference<rendering::XCanvas>& rxCanvas)
    1807             : {
    1808           0 :     if (mpFont.get() != NULL && !msText.isEmpty())
    1809             :     {
    1810           0 :         if ( ! mpFont->mxFont.is())
    1811           0 :             mpFont->PrepareFont(rxCanvas);
    1812           0 :         if (mpFont->mxFont.is())
    1813             :         {
    1814             :             /// check whether RTL interface or not
    1815           0 :             if(!Application::GetSettings().GetLayoutRTL()){
    1816           0 :                 rendering::StringContext aContext (msText, 0, msText.getLength());
    1817             :                     Reference<rendering::XTextLayout> xLayout (
    1818           0 :                     mpFont->mxFont->createTextLayout(
    1819             :                         aContext,
    1820             :                         rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
    1821           0 :                         0));
    1822           0 :                 return xLayout->queryTextBounds();
    1823             :             }
    1824             :             else {
    1825           0 :                 rendering::StringContext aContext (msText, 0, msText.getLength());
    1826             :                     Reference<rendering::XTextLayout> xLayout (
    1827           0 :                     mpFont->mxFont->createTextLayout(
    1828             :                         aContext,
    1829             :                         rendering::TextDirection::WEAK_RIGHT_TO_LEFT,
    1830           0 :                         0));
    1831           0 :                 return xLayout->queryTextBounds();
    1832             :             }
    1833             :         }
    1834             :     }
    1835           0 :     return geometry::RealRectangle2D(0,0,0,0);
    1836             : }
    1837             : 
    1838             : //===== TimeFormatter =========================================================
    1839             : 
    1840           0 : TimeFormatter::TimeFormatter (void)
    1841             :     : mbIs24HourFormat(true),
    1842             :       mbIsAmPmFormat(false),
    1843           0 :       mbIsShowSeconds(true)
    1844             : {
    1845           0 : }
    1846             : 
    1847           0 : OUString TimeFormatter::FormatTime (const oslDateTime& rTime)
    1848             : {
    1849           0 :     ::rtl::OUStringBuffer sText;
    1850             : 
    1851           0 :     const sal_Int32 nHours (sal::static_int_cast<sal_Int32>(rTime.Hours));
    1852           0 :     const sal_Int32 nMinutes (sal::static_int_cast<sal_Int32>(rTime.Minutes));
    1853           0 :     const sal_Int32 nSeconds(sal::static_int_cast<sal_Int32>(rTime.Seconds));
    1854             : 
    1855             :     /// check whether RTL interface or not
    1856           0 :     if(!Application::GetSettings().GetLayoutRTL()){
    1857             :         // Hours
    1858           0 :         if (mbIs24HourFormat)
    1859           0 :             sText.append(OUString::valueOf(nHours));
    1860             :         else
    1861             :             sText.append(OUString::valueOf(
    1862           0 :                 sal::static_int_cast<sal_Int32>(nHours>12 ? nHours-12 : nHours)));
    1863             : 
    1864           0 :         sText.append(A2S(":"));
    1865             : 
    1866             :         // Minutes
    1867           0 :         const OUString sMinutes (OUString::valueOf(nMinutes));
    1868           0 :         if (sMinutes.getLength() == 1)
    1869           0 :             sText.append(A2S("0"));
    1870           0 :         sText.append(sMinutes);
    1871             : 
    1872             :         // Seconds
    1873           0 :         if (mbIsShowSeconds)
    1874             :         {
    1875           0 :             sText.append(A2S(":"));
    1876           0 :             const OUString sSeconds (OUString::valueOf(nSeconds));
    1877           0 :             if (sSeconds.getLength() == 1)
    1878           0 :                 sText.append(A2S("0"));
    1879           0 :             sText.append(sSeconds);
    1880           0 :         }
    1881             :     }
    1882             :     else {
    1883             :         // Seconds
    1884           0 :         if (mbIsShowSeconds)
    1885             :         {
    1886           0 :             const OUString sSeconds (OUString::valueOf(nSeconds));
    1887           0 :             if (sSeconds.getLength() == 1){
    1888           0 :                 sText.append(sSeconds[0]);
    1889           0 :                 sText.append(A2S("0"));
    1890             :             }
    1891             :             else {
    1892           0 :                 sText.append(sSeconds[1]);
    1893           0 :                 sText.append(sSeconds[0]);
    1894             :             }
    1895           0 :             sText.append(A2S(":"));
    1896             :         }
    1897             : 
    1898             :         // Minutes
    1899           0 :         const OUString sMinutes (OUString::valueOf(nMinutes));
    1900           0 :         if (sMinutes.getLength() == 1){
    1901           0 :             sText.append(sMinutes[0]);
    1902           0 :             sText.append(A2S("0"));
    1903             :         }
    1904             :         else {
    1905           0 :             sText.append(sMinutes[1]);
    1906           0 :             sText.append(sMinutes[0]);
    1907             :         }
    1908             :         // Hours
    1909           0 :         OUString tempHours;
    1910           0 :             sText.append(A2S(":"));
    1911           0 :         if (mbIs24HourFormat)
    1912           0 :             tempHours = OUString::valueOf(nHours);
    1913             :         else
    1914             :             tempHours = OUString::valueOf(
    1915           0 :                 sal::static_int_cast<sal_Int32>(nHours>12 ? nHours-12 : nHours));
    1916           0 :         if (tempHours.getLength() > 1)
    1917           0 :             sText.append(tempHours[1]);
    1918           0 :         sText.append(tempHours[0]);
    1919             :     }
    1920           0 :     if (mbIsAmPmFormat)
    1921             :     {
    1922           0 :         if (rTime.Hours < 12)
    1923           0 :             sText.append(A2S("am"));
    1924             :         else
    1925           0 :             sText.append(A2S("pm"));
    1926             :     }
    1927           0 :     return sText.makeStringAndClear();
    1928             : }
    1929             : 
    1930             : //===== TimeLabel =============================================================
    1931             : 
    1932           0 : TimeLabel::TimeLabel (const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1933             :     : Label(rpToolBar),
    1934           0 :       mpListener()
    1935             : {
    1936           0 : }
    1937             : 
    1938           0 : void SAL_CALL TimeLabel::disposing (void)
    1939             : {
    1940           0 :     PresenterClockTimer::Instance(mpToolBar->GetComponentContext())->RemoveListener(mpListener);
    1941           0 :     mpListener.reset();
    1942           0 : }
    1943             : 
    1944           0 : void TimeLabel::ConnectToTimer (void)
    1945             : {
    1946           0 :     mpListener.reset(new Listener(this));
    1947           0 :     PresenterClockTimer::Instance(mpToolBar->GetComponentContext())->AddListener(mpListener);
    1948           0 : }
    1949             : 
    1950             : //===== CurrentTimeLabel ======================================================
    1951             : 
    1952           0 : ::rtl::Reference<Element> CurrentTimeLabel::Create (
    1953             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1954             : {
    1955           0 :     ::rtl::Reference<TimeLabel> pElement(new CurrentTimeLabel(rpToolBar));
    1956           0 :     pElement->ConnectToTimer();
    1957           0 :     return ::rtl::Reference<Element>(pElement.get());
    1958             : }
    1959             : 
    1960           0 : CurrentTimeLabel::~CurrentTimeLabel (void)
    1961             : {
    1962           0 : }
    1963             : 
    1964           0 : CurrentTimeLabel::CurrentTimeLabel (
    1965             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1966             :     : TimeLabel(rpToolBar),
    1967           0 :       maTimeFormatter()
    1968             : {
    1969           0 : }
    1970             : 
    1971           0 : void CurrentTimeLabel::TimeHasChanged (const oslDateTime& rCurrentTime)
    1972             : {
    1973           0 :     SetText(maTimeFormatter.FormatTime(rCurrentTime));
    1974           0 :     Invalidate(false);
    1975           0 : }
    1976             : 
    1977           0 : void CurrentTimeLabel::SetModes (
    1978             :     const SharedElementMode& rpNormalMode,
    1979             :     const SharedElementMode& rpMouseOverMode,
    1980             :     const SharedElementMode& rpSelectedMode,
    1981             :     const SharedElementMode& rpDisabledMode)
    1982             : {
    1983           0 :     TimeLabel::SetModes(rpNormalMode, rpMouseOverMode, rpSelectedMode, rpDisabledMode);
    1984           0 :     SetText(maTimeFormatter.FormatTime(PresenterClockTimer::GetCurrentTime()));
    1985           0 : }
    1986             : 
    1987             : //===== PresentationTimeLabel =================================================
    1988             : 
    1989           0 : ::rtl::Reference<Element> PresentationTimeLabel::Create (
    1990             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    1991             : {
    1992           0 :     ::rtl::Reference<TimeLabel> pElement(new PresentationTimeLabel(rpToolBar));
    1993           0 :     pElement->ConnectToTimer();
    1994           0 :     return ::rtl::Reference<Element>(pElement.get());
    1995             : }
    1996             : 
    1997           0 : PresentationTimeLabel::~PresentationTimeLabel (void)
    1998             : {
    1999           0 : }
    2000             : 
    2001           0 : PresentationTimeLabel::PresentationTimeLabel (
    2002             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    2003             :     : TimeLabel(rpToolBar),
    2004             :       maTimeFormatter(),
    2005           0 :       maStartTimeValue()
    2006             : {
    2007           0 :     maStartTimeValue.Seconds = 0;
    2008           0 :     maStartTimeValue.Nanosec = 0;
    2009           0 : }
    2010             : 
    2011           0 : void PresentationTimeLabel::TimeHasChanged (const oslDateTime& rCurrentTime)
    2012             : {
    2013             :     TimeValue aCurrentTimeValue;
    2014           0 :     if (osl_getTimeValueFromDateTime(const_cast<oslDateTime*>(&rCurrentTime), &aCurrentTimeValue))
    2015             :     {
    2016           0 :         if (maStartTimeValue.Seconds==0 && maStartTimeValue.Nanosec==0)
    2017             :         {
    2018             :             // This method is called for the first time.  Initialize the
    2019             :             // start time.  The start time is rounded to nearest second to
    2020             :             // keep the time updates synchronized with the current time label.
    2021           0 :             maStartTimeValue = aCurrentTimeValue;
    2022           0 :             if (maStartTimeValue.Nanosec >= 500000000)
    2023           0 :                 maStartTimeValue.Seconds += 1;
    2024           0 :             maStartTimeValue.Nanosec = 0;
    2025             :         }
    2026             : 
    2027             :         TimeValue aElapsedTimeValue;
    2028           0 :         aElapsedTimeValue.Seconds = aCurrentTimeValue.Seconds - maStartTimeValue.Seconds;
    2029           0 :         aElapsedTimeValue.Nanosec = aCurrentTimeValue.Nanosec - maStartTimeValue.Nanosec;
    2030             : 
    2031             :         oslDateTime aElapsedDateTime;
    2032           0 :         if (osl_getDateTimeFromTimeValue(&aElapsedTimeValue, &aElapsedDateTime))
    2033             :         {
    2034           0 :             SetText(maTimeFormatter.FormatTime(aElapsedDateTime));
    2035           0 :             Invalidate(false);
    2036             :         }
    2037             :     }
    2038           0 : }
    2039             : 
    2040           0 : void PresentationTimeLabel::SetModes (
    2041             :     const SharedElementMode& rpNormalMode,
    2042             :     const SharedElementMode& rpMouseOverMode,
    2043             :     const SharedElementMode& rpSelectedMode,
    2044             :     const SharedElementMode& rpDisabledMode)
    2045             : {
    2046           0 :     TimeLabel::SetModes(rpNormalMode, rpMouseOverMode, rpSelectedMode, rpDisabledMode);
    2047             : 
    2048             :     oslDateTime aStartDateTime;
    2049           0 :     if (osl_getDateTimeFromTimeValue(&maStartTimeValue, &aStartDateTime))
    2050             :     {
    2051           0 :         SetText(maTimeFormatter.FormatTime(aStartDateTime));
    2052             :     }
    2053           0 : }
    2054             : 
    2055             : //===== VerticalSeparator =====================================================
    2056             : 
    2057           0 : VerticalSeparator::VerticalSeparator (
    2058             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    2059           0 :     : Element(rpToolBar)
    2060             : {
    2061           0 : }
    2062             : 
    2063           0 : void VerticalSeparator::Paint (
    2064             :     const Reference<rendering::XCanvas>& rxCanvas,
    2065             :     const rendering::ViewState& rViewState)
    2066             : {
    2067             :     OSL_ASSERT(rxCanvas.is());
    2068             : 
    2069           0 :     awt::Rectangle aBBox (GetBoundingBox());
    2070             : 
    2071             :     rendering::RenderState aRenderState(
    2072             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
    2073             :         NULL,
    2074             :         Sequence<double>(4),
    2075           0 :         rendering::CompositeOperation::OVER);
    2076           0 :     if (mpMode.get() != NULL)
    2077             :     {
    2078           0 :         PresenterTheme::SharedFontDescriptor pFont (mpMode->maText.GetFont());
    2079           0 :         if (pFont.get() != NULL)
    2080           0 :             PresenterCanvasHelper::SetDeviceColor(aRenderState, pFont->mnColor);
    2081             :     }
    2082             : 
    2083           0 :     if (aBBox.Height >= gnMinimalSeparatorSize + 2*gnSeparatorInset)
    2084             :     {
    2085           0 :         aBBox.Height -= 2*gnSeparatorInset;
    2086           0 :         aBBox.Y += gnSeparatorInset;
    2087             :     }
    2088           0 :     rxCanvas->fillPolyPolygon(
    2089           0 :         PresenterGeometryHelper::CreatePolygon(aBBox, rxCanvas->getDevice()),
    2090             :         rViewState,
    2091           0 :         aRenderState);
    2092           0 : }
    2093             : 
    2094           0 : awt::Size VerticalSeparator::CreateBoundingSize (
    2095             :     const Reference<rendering::XCanvas>& rxCanvas)
    2096             : {
    2097             :     (void)rxCanvas;
    2098           0 :     return awt::Size(1,20);
    2099             : }
    2100             : 
    2101           0 : bool VerticalSeparator::IsFilling (void) const
    2102             : {
    2103           0 :     return true;
    2104             : }
    2105             : 
    2106             : //===== HorizontalSeparator ===================================================
    2107             : 
    2108           0 : HorizontalSeparator::HorizontalSeparator (
    2109             :     const ::rtl::Reference<PresenterToolBar>& rpToolBar)
    2110           0 :     : Element(rpToolBar)
    2111             : {
    2112           0 : }
    2113             : 
    2114           0 : void HorizontalSeparator::Paint (
    2115             :     const Reference<rendering::XCanvas>& rxCanvas,
    2116             :     const rendering::ViewState& rViewState)
    2117             : {
    2118             :     OSL_ASSERT(rxCanvas.is());
    2119             : 
    2120           0 :     awt::Rectangle aBBox (GetBoundingBox());
    2121             : 
    2122             :     rendering::RenderState aRenderState(
    2123             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
    2124             :         NULL,
    2125             :         Sequence<double>(4),
    2126           0 :         rendering::CompositeOperation::OVER);
    2127           0 :     if (mpMode.get() != NULL)
    2128             :     {
    2129           0 :         PresenterTheme::SharedFontDescriptor pFont (mpMode->maText.GetFont());
    2130           0 :         if (pFont.get() != NULL)
    2131           0 :             PresenterCanvasHelper::SetDeviceColor(aRenderState, pFont->mnColor);
    2132             :     }
    2133             : 
    2134           0 :     if (aBBox.Width >= gnMinimalSeparatorSize+2*gnSeparatorInset)
    2135             :     {
    2136           0 :         aBBox.Width -= 2*gnSeparatorInset;
    2137           0 :         aBBox.X += gnSeparatorInset;
    2138             :     }
    2139           0 :     rxCanvas->fillPolyPolygon(
    2140           0 :         PresenterGeometryHelper::CreatePolygon(aBBox, rxCanvas->getDevice()),
    2141             :         rViewState,
    2142           0 :         aRenderState);
    2143           0 : }
    2144             : 
    2145           0 : awt::Size HorizontalSeparator::CreateBoundingSize (
    2146             :     const Reference<rendering::XCanvas>& rxCanvas)
    2147             : {
    2148             :     (void)rxCanvas;
    2149           0 :     return awt::Size(20,1);
    2150             : }
    2151             : 
    2152           0 : bool HorizontalSeparator::IsFilling (void) const
    2153             : {
    2154           0 :     return true;
    2155             : }
    2156             : 
    2157             : } // end of anonymous namespace
    2158             : 
    2159           0 : } } // end of namespace ::sdext::presenter
    2160             : 
    2161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10