LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterButton.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 196 0.5 %
Date: 2012-08-25 Functions: 2 29 6.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 424 0.5 %

           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 "PresenterButton.hxx"
      30                 :            : #include "PresenterCanvasHelper.hxx"
      31                 :            : #include "PresenterController.hxx"
      32                 :            : #include "PresenterGeometryHelper.hxx"
      33                 :            : #include "PresenterPaintManager.hxx"
      34                 :            : #include "PresenterUIPainter.hxx"
      35                 :            : #include <com/sun/star/awt/PosSize.hpp>
      36                 :            : #include <com/sun/star/awt/XWindowPeer.hpp>
      37                 :            : #include <com/sun/star/drawing/XPresenterHelper.hpp>
      38                 :            : #include <com/sun/star/rendering/CompositeOperation.hpp>
      39                 :            : #include <com/sun/star/rendering/TextDirection.hpp>
      40                 :            : #include <boost/bind.hpp>
      41                 :            : 
      42                 :            : using namespace ::com::sun::star;
      43                 :            : using namespace ::com::sun::star::uno;
      44                 :            : using ::rtl::OUString;
      45                 :            : 
      46                 :            : #define A2S(pString) (::rtl::OUString(pString))
      47                 :            : 
      48                 :            : namespace sdext { namespace presenter {
      49                 :            : 
      50                 :            : const static double gnHorizontalBorder (15);
      51                 :            : const static double gnVerticalBorder (5);
      52                 :            : 
      53                 :          0 : ::rtl::Reference<PresenterButton> PresenterButton::Create (
      54                 :            :     const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
      55                 :            :     const ::rtl::Reference<PresenterController>& rpPresenterController,
      56                 :            :     const ::boost::shared_ptr<PresenterTheme>& rpTheme,
      57                 :            :     const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
      58                 :            :     const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas,
      59                 :            :     const OUString& rsConfigurationName)
      60                 :            : {
      61                 :            :     Reference<beans::XPropertySet> xProperties (GetConfigurationProperties(
      62                 :            :         rxComponentContext,
      63         [ #  # ]:          0 :         rsConfigurationName));
      64         [ #  # ]:          0 :     if (xProperties.is())
      65                 :            :     {
      66                 :          0 :         OUString sText;
      67                 :          0 :         OUString sAction;
      68         [ #  # ]:          0 :         PresenterConfigurationAccess::GetProperty(xProperties, A2S("Text")) >>= sText;
      69         [ #  # ]:          0 :         PresenterConfigurationAccess::GetProperty(xProperties, A2S("Action")) >>= sAction;
      70                 :            : 
      71         [ #  # ]:          0 :         PresenterTheme::SharedFontDescriptor pFont;
      72         [ #  # ]:          0 :         if (rpTheme.get() != NULL)
      73 [ #  # ][ #  # ]:          0 :             pFont = rpTheme->GetFont(A2S("ButtonFont"));
                 [ #  # ]
      74                 :            : 
      75         [ #  # ]:          0 :         PresenterTheme::SharedFontDescriptor pMouseOverFont;
      76         [ #  # ]:          0 :         if (rpTheme.get() != NULL)
      77 [ #  # ][ #  # ]:          0 :             pMouseOverFont = rpTheme->GetFont(A2S("ButtonMouseOverFont"));
                 [ #  # ]
      78                 :            : 
      79                 :            :         rtl::Reference<PresenterButton> pButton (
      80                 :            :             new PresenterButton(
      81                 :            :                 rxComponentContext,
      82                 :            :                 rpPresenterController,
      83                 :            :                 rpTheme,
      84                 :            :                 rxParentWindow,
      85                 :            :                 pFont,
      86                 :            :                 pMouseOverFont,
      87                 :            :                 sText,
      88         [ #  # ]:          0 :                 sAction));
      89         [ #  # ]:          0 :         pButton->SetCanvas(rxParentCanvas, rxParentWindow);
      90 [ #  # ][ #  # ]:          0 :         return pButton;
      91                 :            :     }
      92                 :            :     else
      93                 :          0 :         return NULL;
      94                 :            : }
      95                 :            : 
      96                 :          0 : PresenterButton::PresenterButton (
      97                 :            :     const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
      98                 :            :     const ::rtl::Reference<PresenterController>& rpPresenterController,
      99                 :            :     const ::boost::shared_ptr<PresenterTheme>& rpTheme,
     100                 :            :     const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
     101                 :            :     const PresenterTheme::SharedFontDescriptor& rpFont,
     102                 :            :     const PresenterTheme::SharedFontDescriptor& rpMouseOverFont,
     103                 :            :     const OUString& rsText,
     104                 :            :     const OUString& rsAction)
     105                 :            :     : PresenterButtonInterfaceBase(m_aMutex),
     106                 :            :       mpPresenterController(rpPresenterController),
     107                 :            :       mpTheme(rpTheme),
     108                 :            :       mxWindow(),
     109                 :            :       mxCanvas(),
     110                 :            :       mxPresenterHelper(),
     111                 :            :       msText(rsText),
     112                 :            :       mpFont(rpFont),
     113                 :            :       mpMouseOverFont(rpMouseOverFont),
     114                 :            :       msAction(rsAction),
     115                 :            :       maCenter(),
     116                 :            :       maButtonSize(-1,-1),
     117                 :            :       meState(PresenterBitmapDescriptor::Normal),
     118                 :            :       mxNormalBitmap(),
     119 [ #  # ][ #  # ]:          0 :       mxMouseOverBitmap()
         [ #  # ][ #  # ]
     120                 :            : {
     121                 :            :     try
     122                 :            :     {
     123 [ #  # ][ #  # ]:          0 :         Reference<lang::XMultiComponentFactory> xFactory (rxComponentContext->getServiceManager());
     124         [ #  # ]:          0 :         if ( ! xFactory.is())
     125         [ #  # ]:          0 :             throw RuntimeException();
     126                 :            : 
     127                 :            :         mxPresenterHelper = Reference<drawing::XPresenterHelper>(
     128         [ #  # ]:          0 :             xFactory->createInstanceWithContext(
     129                 :            :                 OUString("com.sun.star.comp.Draw.PresenterHelper"),
     130                 :          0 :                 rxComponentContext),
     131 [ #  # ][ #  # ]:          0 :             UNO_QUERY_THROW);
                 [ #  # ]
     132                 :            : 
     133         [ #  # ]:          0 :         if (mxPresenterHelper.is())
     134         [ #  # ]:          0 :             mxWindow = mxPresenterHelper->createWindow(rxParentWindow,
     135                 :            :                 sal_False,
     136                 :            :                 sal_False,
     137                 :            :                 sal_False,
     138 [ #  # ][ #  # ]:          0 :                 sal_False);
     139                 :            : 
     140                 :            :         // Make the background transparent.
     141         [ #  # ]:          0 :         Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY_THROW);
     142         [ #  # ]:          0 :         if (xPeer.is())
     143                 :            :         {
     144 [ #  # ][ #  # ]:          0 :             xPeer->setBackground(0xff000000);
     145                 :            :         }
     146                 :            : 
     147 [ #  # ][ #  # ]:          0 :         mxWindow->setVisible(sal_True);
     148 [ #  # ][ #  # ]:          0 :         mxWindow->addWindowListener(this);
                 [ #  # ]
     149 [ #  # ][ #  # ]:          0 :         mxWindow->addPaintListener(this);
                 [ #  # ]
     150 [ #  # ][ #  # ]:          0 :         mxWindow->addMouseListener(this);
                 [ #  # ]
     151 [ #  # ][ #  # ]:          0 :         mxWindow->addMouseMotionListener(this);
         [ #  # ][ #  # ]
     152                 :            :     }
     153         [ #  # ]:          0 :     catch (RuntimeException&)
     154                 :            :     {
     155                 :            :     }
     156                 :          0 : }
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 : PresenterButton::~PresenterButton (void)
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            : {
     160         [ #  # ]:          0 : }
     161                 :            : 
     162                 :          0 : void SAL_CALL PresenterButton::disposing (void)
     163                 :            : {
     164         [ #  # ]:          0 :     if (mxCanvas.is())
     165                 :            :     {
     166         [ #  # ]:          0 :         Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
     167         [ #  # ]:          0 :         mxCanvas = NULL;
     168         [ #  # ]:          0 :         if (xComponent.is())
     169 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
     170                 :            :     }
     171                 :            : 
     172         [ #  # ]:          0 :     if (mxWindow.is())
     173                 :            :     {
     174 [ #  # ][ #  # ]:          0 :         mxWindow->removeWindowListener(this);
                 [ #  # ]
     175 [ #  # ][ #  # ]:          0 :         mxWindow->removePaintListener(this);
                 [ #  # ]
     176 [ #  # ][ #  # ]:          0 :         mxWindow->removeMouseListener(this);
                 [ #  # ]
     177 [ #  # ][ #  # ]:          0 :         mxWindow->removeMouseMotionListener(this);
                 [ #  # ]
     178         [ #  # ]:          0 :         Reference<lang::XComponent> xComponent (mxWindow, UNO_QUERY);
     179         [ #  # ]:          0 :         mxWindow = NULL;
     180         [ #  # ]:          0 :         if (xComponent.is())
     181 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
     182                 :            :     }
     183                 :          0 : }
     184                 :            : 
     185                 :          0 : void PresenterButton::SetCenter (const css::geometry::RealPoint2D& rLocation)
     186                 :            : {
     187         [ #  # ]:          0 :     if (mxCanvas.is())
     188                 :            :     {
     189                 :          0 :         Invalidate();
     190                 :            : 
     191                 :          0 :         maCenter = rLocation;
     192                 :          0 :         mxWindow->setPosSize(
     193                 :            :             sal_Int32(0.5 + maCenter.X - maButtonSize.Width/2),
     194                 :            :             sal_Int32(0.5 + maCenter.Y - maButtonSize.Height/2),
     195                 :            :             maButtonSize.Width,
     196                 :            :             maButtonSize.Height,
     197                 :          0 :             awt::PosSize::POSSIZE);
     198                 :            : 
     199                 :          0 :         Invalidate();
     200                 :            :     }
     201                 :            :     else
     202                 :            :     {
     203                 :            :         // The button can not be painted but we can at least store the new center.
     204                 :          0 :         maCenter = rLocation;
     205                 :            :     }
     206                 :          0 : }
     207                 :            : 
     208                 :          0 : void PresenterButton::SetCanvas (
     209                 :            :     const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas,
     210                 :            :     const css::uno::Reference<css::awt::XWindow>& rxParentWindow)
     211                 :            : {
     212         [ #  # ]:          0 :     if (mxCanvas.is())
     213                 :            :     {
     214         [ #  # ]:          0 :         Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
     215         [ #  # ]:          0 :         mxCanvas = NULL;
     216         [ #  # ]:          0 :         if (xComponent.is())
     217 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
     218                 :            :     }
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :     if (mxPresenterHelper.is() && rxParentCanvas.is() && rxParentWindow.is())
         [ #  # ][ #  # ]
     221                 :            :     {
     222                 :          0 :         mxCanvas = mxPresenterHelper->createSharedCanvas (
     223                 :            :             Reference<rendering::XSpriteCanvas>(rxParentCanvas, UNO_QUERY),
     224                 :            :             rxParentWindow,
     225                 :            :             rxParentCanvas,
     226                 :            :             rxParentWindow,
     227 [ #  # ][ #  # ]:          0 :             mxWindow);
     228         [ #  # ]:          0 :         if (mxCanvas.is())
     229                 :            :         {
     230                 :          0 :             SetupButtonBitmaps();
     231                 :          0 :             SetCenter(maCenter);
     232                 :            :         }
     233                 :            :     }
     234                 :          0 : }
     235                 :            : 
     236                 :          0 : css::geometry::IntegerSize2D PresenterButton::GetSize (void)
     237                 :            : {
     238         [ #  # ]:          0 :     if (maButtonSize.Width < 0)
     239                 :          0 :         CalculateButtonSize();
     240                 :          0 :     return maButtonSize;
     241                 :            : }
     242                 :            : 
     243                 :            : //----- XWindowListener -------------------------------------------------------
     244                 :            : 
     245                 :          0 : void SAL_CALL PresenterButton::windowResized (const css::awt::WindowEvent& rEvent)
     246                 :            :     throw (css::uno::RuntimeException)
     247                 :            : {
     248                 :            :     (void)rEvent;
     249                 :          0 :     ThrowIfDisposed();
     250                 :          0 : }
     251                 :            : 
     252                 :          0 : void SAL_CALL PresenterButton::windowMoved (const css::awt::WindowEvent& rEvent)
     253                 :            :     throw (css::uno::RuntimeException)
     254                 :            : {
     255                 :            :     (void)rEvent;
     256                 :          0 :     ThrowIfDisposed();
     257                 :          0 : }
     258                 :            : 
     259                 :          0 : void SAL_CALL PresenterButton::windowShown (const css::lang::EventObject& rEvent)
     260                 :            :     throw (css::uno::RuntimeException)
     261                 :            : {
     262                 :            :     (void)rEvent;
     263                 :          0 :     ThrowIfDisposed();
     264                 :          0 : }
     265                 :            : 
     266                 :          0 : void SAL_CALL PresenterButton::windowHidden (const css::lang::EventObject& rEvent)
     267                 :            :     throw (css::uno::RuntimeException)
     268                 :            : {
     269                 :            :     (void)rEvent;
     270                 :          0 :     ThrowIfDisposed();
     271                 :          0 : }
     272                 :            : 
     273                 :            : //----- XPaintListener --------------------------------------------------------
     274                 :            : 
     275                 :          0 : void SAL_CALL PresenterButton::windowPaint (const css::awt::PaintEvent& rEvent)
     276                 :            :     throw (css::uno::RuntimeException)
     277                 :            : {
     278                 :          0 :     ThrowIfDisposed();
     279 [ #  # ][ #  # ]:          0 :     if (mxWindow.is() && mxCanvas.is())
                 [ #  # ]
     280                 :            :     {
     281                 :          0 :         Reference<rendering::XBitmap> xBitmap;
     282         [ #  # ]:          0 :         if (meState == PresenterBitmapDescriptor::MouseOver)
     283         [ #  # ]:          0 :             xBitmap = mxMouseOverBitmap;
     284                 :            :         else
     285         [ #  # ]:          0 :             xBitmap = mxNormalBitmap;
     286         [ #  # ]:          0 :         if ( ! xBitmap.is())
     287                 :          0 :             return;
     288                 :            : 
     289                 :            :         rendering::ViewState aViewState(
     290                 :            :             geometry::AffineMatrix2D(1,0,0, 0,1,0),
     291 [ #  # ][ #  # ]:          0 :             NULL);
     292                 :            :         rendering::RenderState aRenderState(
     293                 :            :             geometry::AffineMatrix2D(1,0,0, 0,1,0),
     294         [ #  # ]:          0 :             PresenterGeometryHelper::CreatePolygon(rEvent.UpdateRect, mxCanvas->getDevice()),
     295                 :            :             Sequence<double>(4),
     296 [ #  # ][ #  # ]:          0 :             rendering::CompositeOperation::SOURCE);
         [ #  # ][ #  # ]
                 [ #  # ]
     297                 :            : 
     298 [ #  # ][ #  # ]:          0 :         mxCanvas->drawBitmap(xBitmap, aViewState, aRenderState);
     299                 :            : 
     300         [ #  # ]:          0 :         Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
     301         [ #  # ]:          0 :         if (xSpriteCanvas.is())
     302 [ #  # ][ #  # ]:          0 :             xSpriteCanvas->updateScreen(sal_False);
         [ #  # ][ #  # ]
                 [ #  # ]
     303                 :            :     }
     304                 :            : }
     305                 :            : 
     306                 :            : //----- XMouseListener --------------------------------------------------------
     307                 :            : 
     308                 :          0 : void SAL_CALL PresenterButton::mousePressed (const css::awt::MouseEvent& rEvent)
     309                 :            :     throw(css::uno::RuntimeException)
     310                 :            : {
     311                 :            :     (void)rEvent;
     312                 :          0 :     ThrowIfDisposed();
     313                 :            : 
     314                 :          0 :     meState = PresenterBitmapDescriptor::ButtonDown;
     315                 :          0 : }
     316                 :            : 
     317                 :          0 : void SAL_CALL PresenterButton::mouseReleased (const css::awt::MouseEvent& rEvent)
     318                 :            :     throw(css::uno::RuntimeException)
     319                 :            : {
     320                 :            :     (void)rEvent;
     321                 :          0 :     ThrowIfDisposed();
     322                 :            : 
     323         [ #  # ]:          0 :     if (meState == PresenterBitmapDescriptor::ButtonDown)
     324                 :            :     {
     325                 :            :         OSL_ASSERT(mpPresenterController.get()!=NULL);
     326                 :          0 :         mpPresenterController->DispatchUnoCommand(msAction);
     327                 :            : 
     328                 :          0 :         meState = PresenterBitmapDescriptor::Normal;
     329                 :          0 :         Invalidate();
     330                 :            :     }
     331                 :          0 : }
     332                 :            : 
     333                 :          0 : void SAL_CALL PresenterButton::mouseEntered (const css::awt::MouseEvent& rEvent)
     334                 :            :     throw(css::uno::RuntimeException)
     335                 :            : {
     336                 :            :     (void)rEvent;
     337                 :          0 :     ThrowIfDisposed();
     338                 :          0 :     meState = PresenterBitmapDescriptor::MouseOver;
     339                 :          0 :     Invalidate();
     340                 :          0 : }
     341                 :            : 
     342                 :          0 : void SAL_CALL PresenterButton::mouseExited (const css::awt::MouseEvent& rEvent)
     343                 :            :     throw(css::uno::RuntimeException)
     344                 :            : {
     345                 :            :     (void)rEvent;
     346                 :          0 :     ThrowIfDisposed();
     347                 :          0 :     meState = PresenterBitmapDescriptor::Normal;
     348                 :          0 :     Invalidate();
     349                 :          0 : }
     350                 :            : 
     351                 :            : //----- XMouseMotionListener --------------------------------------------------
     352                 :            : 
     353                 :          0 : void SAL_CALL PresenterButton::mouseMoved (const css::awt::MouseEvent& rEvent)
     354                 :            :     throw (css::uno::RuntimeException)
     355                 :            : {
     356                 :            :     (void)rEvent;
     357                 :          0 :     ThrowIfDisposed();
     358                 :          0 : }
     359                 :            : 
     360                 :          0 : void SAL_CALL PresenterButton::mouseDragged (const css::awt::MouseEvent& rEvent)
     361                 :            :     throw (css::uno::RuntimeException)
     362                 :            : {
     363                 :            :     (void)rEvent;
     364                 :          0 :     ThrowIfDisposed();
     365                 :          0 : }
     366                 :            : 
     367                 :            : //----- lang::XEventListener --------------------------------------------------
     368                 :            : 
     369                 :          0 : void SAL_CALL PresenterButton::disposing (const css::lang::EventObject& rEvent)
     370                 :            :     throw (css::uno::RuntimeException)
     371                 :            : {
     372         [ #  # ]:          0 :     if (rEvent.Source == mxWindow)
     373                 :          0 :         mxWindow = NULL;
     374                 :          0 : }
     375                 :            : 
     376                 :            : //-----------------------------------------------------------------------------
     377                 :            : 
     378                 :          0 : css::geometry::IntegerSize2D PresenterButton::CalculateButtonSize (void)
     379                 :            : {
     380 [ #  # ][ #  # ]:          0 :     if (mpFont.get()!=NULL && !mpFont->mxFont.is() && mxCanvas.is())
         [ #  # ][ #  # ]
     381         [ #  # ]:          0 :         mpFont->PrepareFont(mxCanvas);
     382 [ #  # ][ #  # ]:          0 :     if (mpFont.get()==NULL || !mpFont->mxFont.is())
                 [ #  # ]
     383                 :          0 :         return geometry::IntegerSize2D(-1,-1);
     384                 :            : 
     385         [ #  # ]:          0 :     geometry::RealSize2D aTextSize (PresenterCanvasHelper::GetTextSize(mpFont->mxFont,msText));
     386                 :            : 
     387                 :            :     return geometry::IntegerSize2D (
     388                 :            :         sal_Int32(0.5 + aTextSize.Width + 2*gnHorizontalBorder),
     389                 :          0 :         sal_Int32(0.5 + aTextSize.Height + 2*gnVerticalBorder));
     390                 :            : }
     391                 :            : 
     392                 :          0 : void PresenterButton::RenderButton (
     393                 :            :     const Reference<rendering::XCanvas>& rxCanvas,
     394                 :            :     const geometry::IntegerSize2D& rSize,
     395                 :            :     const PresenterTheme::SharedFontDescriptor& rpFont,
     396                 :            :     const PresenterBitmapDescriptor::Mode eMode,
     397                 :            :     const SharedBitmapDescriptor& rpLeft,
     398                 :            :     const SharedBitmapDescriptor& rpCenter,
     399                 :            :     const SharedBitmapDescriptor& rpRight)
     400                 :            : {
     401         [ #  # ]:          0 :     if ( ! rxCanvas.is())
     402                 :            :         return;
     403                 :            : 
     404                 :          0 :     const awt::Rectangle aBox(0,0, rSize.Width, rSize.Height);
     405                 :            : 
     406                 :            :     PresenterUIPainter::PaintHorizontalBitmapComposite (
     407                 :            :         rxCanvas,
     408                 :            :         aBox,
     409                 :            :         aBox,
     410                 :            :         GetBitmap(rpLeft, eMode),
     411                 :            :         GetBitmap(rpCenter, eMode),
     412 [ #  # ][ #  # ]:          0 :         GetBitmap(rpRight, eMode));
         [ #  # ][ #  # ]
     413                 :            : 
     414 [ #  # ][ #  # ]:          0 :     if (rpFont.get()==NULL || ! rpFont->mxFont.is())
                 [ #  # ]
     415                 :            :         return;
     416                 :            : 
     417                 :          0 :     const rendering::StringContext aContext (msText, 0, msText.getLength());
     418                 :            :     const Reference<rendering::XTextLayout> xLayout (
     419 [ #  # ][ #  # ]:          0 :         rpFont->mxFont->createTextLayout(aContext,rendering::TextDirection::WEAK_LEFT_TO_RIGHT,0));
     420 [ #  # ][ #  # ]:          0 :     const geometry::RealRectangle2D aTextBBox (xLayout->queryTextBounds());
     421                 :            : 
     422                 :            :     rendering::RenderState aRenderState (geometry::AffineMatrix2D(1,0,0, 0,1,0), NULL,
     423 [ #  # ][ #  # ]:          0 :         Sequence<double>(4), rendering::CompositeOperation::SOURCE);
         [ #  # ][ #  # ]
     424         [ #  # ]:          0 :     PresenterCanvasHelper::SetDeviceColor(aRenderState, rpFont->mnColor);
     425                 :          0 :     aRenderState.AffineTransform.m02 = (rSize.Width - aTextBBox.X2 + aTextBBox.X1)/2;
     426                 :          0 :     aRenderState.AffineTransform.m12 = (rSize.Height - aTextBBox.Y2 + aTextBBox.Y1)/2 - aTextBBox.Y1;
     427                 :            : 
     428         [ #  # ]:          0 :     rxCanvas->drawText(
     429                 :            :         aContext,
     430                 :          0 :         rpFont->mxFont,
     431                 :            :         rendering::ViewState(geometry::AffineMatrix2D(1,0,0, 0,1,0), NULL),
     432                 :            :         aRenderState,
     433         [ #  # ]:          0 :         rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     434                 :            : }
     435                 :            : 
     436                 :          0 : void PresenterButton::Invalidate (void)
     437                 :            : {
     438         [ #  # ]:          0 :     mpPresenterController->GetPaintManager()->Invalidate(mxWindow);
     439                 :          0 : }
     440                 :            : 
     441                 :          0 : Reference<rendering::XBitmap> PresenterButton::GetBitmap (
     442                 :            :     const SharedBitmapDescriptor& mpIcon,
     443                 :            :     const PresenterBitmapDescriptor::Mode eMode)
     444                 :            : {
     445         [ #  # ]:          0 :     if (mpIcon.get() != NULL)
     446                 :          0 :         return mpIcon->GetBitmap(eMode);
     447                 :            :     else
     448                 :            :     {
     449                 :            :         OSL_ASSERT(mpIcon.get()!=NULL);
     450                 :          0 :         return NULL;
     451                 :            :     }
     452                 :            : }
     453                 :            : 
     454                 :          0 : void PresenterButton::SetupButtonBitmaps (void)
     455                 :            : {
     456         [ #  # ]:          0 :     if ( ! mxCanvas.is())
     457                 :            :         return;
     458 [ #  # ][ #  # ]:          0 :     if ( ! mxCanvas->getDevice().is())
                 [ #  # ]
     459                 :            :         return;
     460                 :            : 
     461                 :            :     // Get the bitmaps for the button border.
     462         [ #  # ]:          0 :     SharedBitmapDescriptor pLeftBitmap (mpTheme->GetBitmap(A2S("ButtonFrameLeft")));
     463         [ #  # ]:          0 :     SharedBitmapDescriptor pCenterBitmap(mpTheme->GetBitmap(A2S("ButtonFrameCenter")));
     464         [ #  # ]:          0 :     SharedBitmapDescriptor pRightBitmap(mpTheme->GetBitmap(A2S("ButtonFrameRight")));
     465                 :            : 
     466         [ #  # ]:          0 :     maButtonSize = CalculateButtonSize();
     467                 :            : 
     468 [ #  # ][ #  # ]:          0 :     if (maButtonSize.Height<=0 && maButtonSize.Width<= 0)
     469                 :            :         return;
     470                 :            : 
     471 [ #  # ][ #  # ]:          0 :     mxNormalBitmap = mxCanvas->getDevice()->createCompatibleAlphaBitmap(maButtonSize);
         [ #  # ][ #  # ]
                 [ #  # ]
     472         [ #  # ]:          0 :     Reference<rendering::XCanvas> xCanvas (mxNormalBitmap, UNO_QUERY);
     473         [ #  # ]:          0 :     if (xCanvas.is())
     474                 :            :         RenderButton(
     475                 :            :             xCanvas,
     476                 :            :             maButtonSize,
     477                 :            :             mpFont,
     478                 :            :             PresenterBitmapDescriptor::Normal,
     479                 :            :             pLeftBitmap,
     480                 :            :             pCenterBitmap,
     481         [ #  # ]:          0 :             pRightBitmap);
     482                 :            : 
     483 [ #  # ][ #  # ]:          0 :     mxMouseOverBitmap = mxCanvas->getDevice()->createCompatibleAlphaBitmap(maButtonSize);
         [ #  # ][ #  # ]
                 [ #  # ]
     484 [ #  # ][ #  # ]:          0 :     xCanvas = Reference<rendering::XCanvas>(mxMouseOverBitmap, UNO_QUERY);
     485 [ #  # ][ #  # ]:          0 :     if (mpMouseOverFont.get()!=NULL && !mpMouseOverFont->mxFont.is() && mxCanvas.is())
         [ #  # ][ #  # ]
     486         [ #  # ]:          0 :         mpMouseOverFont->PrepareFont(mxCanvas);
     487         [ #  # ]:          0 :     if (xCanvas.is())
     488                 :            :         RenderButton(
     489                 :            :             xCanvas,
     490                 :            :             maButtonSize,
     491                 :            :             mpMouseOverFont,
     492                 :            :             PresenterBitmapDescriptor::MouseOver,
     493                 :            :             pLeftBitmap,
     494                 :            :             pCenterBitmap,
     495 [ #  # ][ #  # ]:          0 :             pRightBitmap);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     496                 :            : }
     497                 :            : 
     498                 :          0 : Reference<beans::XPropertySet> PresenterButton::GetConfigurationProperties (
     499                 :            :     const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
     500                 :            :     const OUString& rsConfgurationName)
     501                 :            : {
     502                 :            :     PresenterConfigurationAccess aConfiguration (
     503                 :            :         rxComponentContext,
     504                 :            :         PresenterConfigurationAccess::msPresenterScreenRootName,
     505         [ #  # ]:          0 :         PresenterConfigurationAccess::READ_ONLY);
     506                 :            :     return Reference<beans::XPropertySet>(
     507                 :            :         PresenterConfigurationAccess::Find (
     508                 :            :             Reference<container::XNameAccess>(
     509                 :            :                 aConfiguration.GetConfigurationNode(A2S("PresenterScreenSettings/Buttons")),
     510                 :            :                 UNO_QUERY),
     511                 :            :             ::boost::bind(&PresenterConfigurationAccess::IsStringPropertyEqual,
     512                 :            :                 rsConfgurationName,
     513                 :            :                 A2S("Name"),
     514                 :            :                 _2)),
     515 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     516                 :            : }
     517                 :            : 
     518                 :          0 : void PresenterButton::ThrowIfDisposed (void) const
     519                 :            :     throw (::com::sun::star::lang::DisposedException)
     520                 :            : {
     521 [ #  # ][ #  # ]:          0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     522                 :            :     {
     523                 :            :         throw lang::DisposedException (
     524                 :            :             OUString( "PresenterButton object has already been disposed"),
     525 [ #  # ][ #  # ]:          0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     526                 :            :     }
     527                 :          0 : }
     528                 :            : 
     529 [ +  - ][ +  - ]:         24 : } } // end of namespace sdext::presenter
     530                 :            : 
     531                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10