LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterToolBar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 755 0.1 %
Date: 2012-08-25 Functions: 2 135 1.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 1156 0.2 %

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

Generated by: LCOV version 1.10