LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterTheme.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 438 0.2 %
Date: 2012-08-25 Functions: 2 61 3.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 844 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 "PresenterTheme.hxx"
      30                 :            : #include "PresenterBitmapContainer.hxx"
      31                 :            : #include "PresenterCanvasHelper.hxx"
      32                 :            : #include "PresenterComponent.hxx"
      33                 :            : #include "PresenterConfigurationAccess.hxx"
      34                 :            : #include "PresenterHelper.hxx"
      35                 :            : #include <com/sun/star/awt/Point.hpp>
      36                 :            : #include <com/sun/star/beans/UnknownPropertyException.hpp>
      37                 :            : #include <com/sun/star/deployment/XPackageInformationProvider.hpp>
      38                 :            : #include <com/sun/star/drawing/XPresenterHelper.hpp>
      39                 :            : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      40                 :            : #include <com/sun/star/rendering/PanoseWeight.hpp>
      41                 :            : #include <com/sun/star/rendering/XBitmap.hpp>
      42                 :            : #include <com/sun/star/util/Color.hpp>
      43                 :            : #include <boost/bind.hpp>
      44                 :            : #include <map>
      45                 :            : 
      46                 :            : using namespace ::com::sun::star;
      47                 :            : using namespace ::com::sun::star::uno;
      48                 :            : using namespace ::std;
      49                 :            : using ::rtl::OUString;
      50                 :            : 
      51                 :            : #define A2S(s) (::rtl::OUString(s))
      52                 :            : 
      53                 :            : namespace sdext { namespace presenter {
      54                 :            : 
      55                 :            : namespace {
      56                 :            : 
      57                 :            : class BorderSize
      58                 :            : {
      59                 :            : public:
      60                 :            :     const static sal_Int32 mnInvalidValue = -10000;
      61                 :            : 
      62                 :          0 :     BorderSize (void) : mnLeft(mnInvalidValue),
      63                 :            :                         mnTop(mnInvalidValue),
      64                 :            :                         mnRight(mnInvalidValue),
      65                 :          0 :                         mnBottom(mnInvalidValue) {}
      66                 :            : 
      67                 :            :     sal_Int32 mnLeft;
      68                 :            :     sal_Int32 mnTop;
      69                 :            :     sal_Int32 mnRight;
      70                 :            :     sal_Int32 mnBottom;
      71                 :            : 
      72                 :          0 :     vector<sal_Int32> ToVector (void)
      73                 :            :     {
      74                 :          0 :         vector<sal_Int32> aSequence (4);
      75 [ #  # ][ #  # ]:          0 :         aSequence[0] = mnLeft == mnInvalidValue ? 0 : mnLeft;
      76 [ #  # ][ #  # ]:          0 :         aSequence[1] = mnTop == mnInvalidValue ? 0 : mnTop;
      77 [ #  # ][ #  # ]:          0 :         aSequence[2] = mnRight == mnInvalidValue ? 0 : mnRight;
      78 [ #  # ][ #  # ]:          0 :         aSequence[3] = mnBottom == mnInvalidValue ? 0 : mnBottom;
      79                 :          0 :         return aSequence;
      80                 :            :     };
      81                 :            : 
      82                 :          0 :     void Merge (const BorderSize& rBorderSize)
      83                 :            :     {
      84         [ #  # ]:          0 :         if (mnLeft == mnInvalidValue)
      85                 :          0 :             mnLeft = rBorderSize.mnLeft;
      86         [ #  # ]:          0 :         if (mnTop == mnInvalidValue)
      87                 :          0 :             mnTop = rBorderSize.mnTop;
      88         [ #  # ]:          0 :         if (mnRight == mnInvalidValue)
      89                 :          0 :             mnRight = rBorderSize.mnRight;
      90         [ #  # ]:          0 :         if (mnBottom == mnInvalidValue)
      91                 :          0 :             mnBottom = rBorderSize.mnBottom;
      92                 :          0 :     }
      93                 :            : };
      94                 :            : 
      95                 :            : /** Reading a theme from the configurations is done in various classes.  The
      96                 :            :     ReadContext gives access to frequently used objects and functions to make
      97                 :            :     the configuration handling easier.
      98                 :            : */
      99                 :            : class ReadContext
     100                 :            : {
     101                 :            : public:
     102                 :            :     Reference<XComponentContext> mxComponentContext;
     103                 :            :     Reference<rendering::XCanvas> mxCanvas;
     104                 :            :     Reference<drawing::XPresenterHelper> mxPresenterHelper;
     105                 :            :     OUString msBasePath;
     106                 :            : 
     107                 :            :     ReadContext (
     108                 :            :         const Reference<XComponentContext>& rxContext,
     109                 :            :         const Reference<rendering::XCanvas>& rxCanvas);
     110                 :            :     ~ReadContext (void);
     111                 :            : 
     112                 :            :     /** Read data describing a font from the node that can be reached from
     113                 :            :         the given root via the given path.
     114                 :            :         @param rsFontPath
     115                 :            :             May be empty.
     116                 :            :     */
     117                 :            :     static PresenterTheme::SharedFontDescriptor ReadFont (
     118                 :            :         const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxTheme,
     119                 :            :         const ::rtl::OUString& rsFontPath,
     120                 :            :         const PresenterTheme::SharedFontDescriptor& rpDefault);
     121                 :            :     static PresenterTheme::SharedFontDescriptor ReadFont (
     122                 :            :         const Reference<beans::XPropertySet>& rxFontProperties,
     123                 :            :         const PresenterTheme::SharedFontDescriptor& rpDefault);
     124                 :            : 
     125                 :            :     ::boost::shared_ptr<PresenterTheme::Theme> ReadTheme (
     126                 :            :         PresenterConfigurationAccess& rConfiguration,
     127                 :            :         const OUString& rsThemeName);
     128                 :            : 
     129                 :            :     BorderSize ReadBorderSize (const Reference<container::XNameAccess>& rxNode);
     130                 :            : 
     131                 :            :     void SetBitmapSourceExtension (const OUString& rsExtensionName);
     132                 :            : 
     133                 :            : private:
     134                 :            :     Any GetByName (
     135                 :            :         const Reference<container::XNameAccess>& rxNode,
     136                 :            :         const OUString& rsName) const;
     137                 :            : };
     138                 :            : 
     139                 :            : /** A PaneStyle describes how a pane is rendered.
     140                 :            : */
     141                 :            : class PaneStyle
     142                 :            : {
     143                 :            : public:
     144                 :            :     PaneStyle (void);
     145                 :            :     ~PaneStyle (void);
     146                 :            : 
     147                 :            :     const SharedBitmapDescriptor GetBitmap (const OUString& sBitmapName) const;
     148                 :            : 
     149                 :            :     OUString msStyleName;
     150                 :            :     ::boost::shared_ptr<PaneStyle> mpParentStyle;
     151                 :            :     PresenterTheme::SharedFontDescriptor mpFont;
     152                 :            :     BorderSize maInnerBorderSize;
     153                 :            :     BorderSize maOuterBorderSize;
     154                 :            :     ::boost::shared_ptr<PresenterBitmapContainer> mpBitmaps;
     155                 :            : 
     156                 :            :     PresenterTheme::SharedFontDescriptor GetFont (void) const;
     157                 :            : 
     158                 :            : private:
     159                 :            : 
     160                 :            :     void UpdateBorderSize (BorderSize& rBorderSize, bool bInner);
     161                 :            : };
     162                 :            : 
     163                 :            : typedef ::boost::shared_ptr<PaneStyle> SharedPaneStyle;
     164                 :            : 
     165                 :          0 : class PaneStyleContainer : vector<SharedPaneStyle>
     166                 :            : {
     167                 :            : public:
     168                 :            :     void Read (
     169                 :            :         ReadContext& rReadContext,
     170                 :            :         const Reference<container::XHierarchicalNameAccess>& rThemeRoot);
     171                 :            : 
     172                 :            :     SharedPaneStyle GetPaneStyle (const OUString& rsStyleName) const;
     173                 :            : 
     174                 :            : private:
     175                 :            :     void ProcessPaneStyle (
     176                 :            :         ReadContext& rReadContext,
     177                 :            :         const ::rtl::OUString& rsKey,
     178                 :            :         const ::std::vector<css::uno::Any>& rValues);
     179                 :            : };
     180                 :            : 
     181                 :            : /** A ViewStyle describes how a view is displayed.
     182                 :            : */
     183                 :            : class ViewStyle
     184                 :            : {
     185                 :            : public:
     186                 :            :     ViewStyle (void);
     187                 :            :     ~ViewStyle (void);
     188                 :            : 
     189                 :            :     const SharedBitmapDescriptor GetBitmap (const OUString& sBitmapName) const;
     190                 :            : 
     191                 :            :     PresenterTheme::SharedFontDescriptor GetFont (void) const;
     192                 :            : 
     193                 :            :     OUString msStyleName;
     194                 :            :     ::boost::shared_ptr<ViewStyle> mpParentStyle;
     195                 :            :     PresenterTheme::SharedFontDescriptor mpFont;
     196                 :            :     ::boost::shared_ptr<PresenterBitmapContainer> mpBitmaps;
     197                 :            :     SharedBitmapDescriptor mpBackground;
     198                 :            : };
     199                 :            : 
     200                 :            : typedef ::boost::shared_ptr<ViewStyle> SharedViewStyle;
     201                 :            : 
     202                 :          0 : class ViewStyleContainer : vector<SharedViewStyle>
     203                 :            : {
     204                 :            : public:
     205                 :            :     void Read (
     206                 :            :         ReadContext& rReadContext,
     207                 :            :         const Reference<container::XHierarchicalNameAccess>& rThemeRoot);
     208                 :            : 
     209                 :            :     SharedViewStyle GetViewStyle (const OUString& rsStyleName) const;
     210                 :            : 
     211                 :            : private:
     212                 :            :     void ProcessViewStyle(
     213                 :            :         ReadContext& rReadContext,
     214                 :            :         const Reference<beans::XPropertySet>& rxProperties);
     215                 :            : };
     216                 :            : 
     217                 :            : class ViewDescriptor
     218                 :            : {
     219                 :            : };
     220                 :            : typedef ::boost::shared_ptr<ViewDescriptor> SharedViewDescriptor;
     221                 :            : typedef ::std::vector<SharedViewDescriptor> ViewDescriptorContainer;
     222                 :            : 
     223                 :          0 : class StyleAssociationContainer
     224                 :            : {
     225                 :            : public:
     226                 :            :     void Read (
     227                 :            :         ReadContext& rReadContext,
     228                 :            :         const Reference<container::XHierarchicalNameAccess>& rThemeRoot);
     229                 :            : 
     230                 :            :     OUString GetStyleName (const OUString& rsResourceName) const;
     231                 :            : 
     232                 :            : private:
     233                 :            :     typedef map<OUString, OUString> StyleAssociations;
     234                 :            :     StyleAssociations maStyleAssociations;
     235                 :            : 
     236                 :            :     void ProcessStyleAssociation(
     237                 :            :         ReadContext& rReadContext,
     238                 :            :         const ::rtl::OUString& rsKey,
     239                 :            :         const ::std::vector<css::uno::Any>& rValues);
     240                 :            : };
     241                 :            : 
     242                 :            : } // end of anonymous namespace
     243                 :            : 
     244                 :            : class PresenterTheme::Theme
     245                 :            : {
     246                 :            : public:
     247                 :            :     Theme (
     248                 :            :         const OUString& rsName,
     249                 :            :         const Reference<container::XHierarchicalNameAccess>& rThemeRoot,
     250                 :            :         const OUString& rsNodeName);
     251                 :            :     ~Theme (void);
     252                 :            : 
     253                 :            :     void Read (
     254                 :            :         PresenterConfigurationAccess& rConfiguration,
     255                 :            :         ReadContext& rReadContext);
     256                 :            : 
     257                 :            :     OUString msThemeName;
     258                 :            :     OUString msConfigurationNodeName;
     259                 :            :     ::boost::shared_ptr<Theme> mpParentTheme;
     260                 :            :     SharedBitmapDescriptor mpBackground;
     261                 :            :     PaneStyleContainer maPaneStyles;
     262                 :            :     ViewStyleContainer maViewStyles;
     263                 :            :     ViewDescriptorContainer maViewDescriptors;
     264                 :            :     StyleAssociationContainer maStyleAssociations;
     265                 :            :     Reference<container::XHierarchicalNameAccess> mxThemeRoot;
     266                 :            :     ::boost::shared_ptr<PresenterBitmapContainer> mpIconContainer;
     267                 :            :     typedef map<rtl::OUString,SharedFontDescriptor> FontContainer;
     268                 :            :     FontContainer maFontContainer;
     269                 :            : 
     270                 :            :     SharedPaneStyle GetPaneStyle (const OUString& rsStyleName) const;
     271                 :            :     SharedViewStyle GetViewStyle (const OUString& rsStyleName) const;
     272                 :            : 
     273                 :            : private:
     274                 :            :     void ProcessFont(
     275                 :            :         ReadContext& rReadContext,
     276                 :            :         const OUString& rsKey,
     277                 :            :         const Reference<beans::XPropertySet>& rxProperties);
     278                 :            : };
     279                 :            : 
     280                 :            : //===== PresenterTheme ========================================================
     281                 :            : 
     282                 :          0 : PresenterTheme::PresenterTheme (
     283                 :            :     const css::uno::Reference<css::uno::XComponentContext>& rxContext,
     284                 :            :     const rtl::OUString& rsThemeName,
     285                 :            :     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
     286                 :            :     : mxContext(rxContext),
     287                 :            :       msThemeName(rsThemeName),
     288                 :            :       mpTheme(),
     289                 :            :       mpBitmapContainer(),
     290 [ #  # ][ #  # ]:          0 :       mxCanvas(rxCanvas)
     291                 :            : {
     292 [ #  # ][ #  # ]:          0 :     mpTheme = ReadTheme();
                 [ #  # ]
     293                 :          0 : }
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 : PresenterTheme::~PresenterTheme (void)
     296                 :            : {
     297                 :          0 : }
     298                 :            : 
     299                 :          0 : ::boost::shared_ptr<PresenterTheme::Theme> PresenterTheme::ReadTheme (void)
     300                 :            : {
     301         [ #  # ]:          0 :     ReadContext aReadContext(mxContext, mxCanvas);
     302                 :            : 
     303                 :            :     PresenterConfigurationAccess aConfiguration (
     304                 :            :         mxContext,
     305                 :            :         OUString("/org.openoffice.Office.extension.PresenterScreen/"),
     306         [ #  # ]:          0 :         PresenterConfigurationAccess::READ_ONLY);
     307                 :            : 
     308 [ #  # ][ #  # ]:          0 :     return aReadContext.ReadTheme(aConfiguration, msThemeName);
                 [ #  # ]
     309                 :            : }
     310                 :            : 
     311                 :          0 : bool PresenterTheme::HasCanvas (void) const
     312                 :            : {
     313                 :          0 :     return mxCanvas.is();
     314                 :            : }
     315                 :            : 
     316                 :          0 : void PresenterTheme::ProvideCanvas (const Reference<rendering::XCanvas>& rxCanvas)
     317                 :            : {
     318 [ #  # ][ #  # ]:          0 :     if ( ! mxCanvas.is() && rxCanvas.is())
                 [ #  # ]
     319                 :            :     {
     320                 :          0 :         mxCanvas = rxCanvas;
     321                 :          0 :         ReadTheme();
     322                 :            :     }
     323                 :          0 : }
     324                 :            : 
     325                 :          0 : OUString PresenterTheme::GetStyleName (const ::rtl::OUString& rsResourceURL) const
     326                 :            : {
     327                 :          0 :     OUString sStyleName;
     328         [ #  # ]:          0 :     ::boost::shared_ptr<Theme> pTheme (mpTheme);
     329 [ #  # ][ #  # ]:          0 :     while (sStyleName.isEmpty() && pTheme.get()!=NULL)
                 [ #  # ]
     330                 :            :     {
     331         [ #  # ]:          0 :         sStyleName = pTheme->maStyleAssociations.GetStyleName(rsResourceURL);
     332         [ #  # ]:          0 :         pTheme = pTheme->mpParentTheme;
     333                 :            :     }
     334         [ #  # ]:          0 :     return sStyleName;
     335                 :            : }
     336                 :            : 
     337                 :          0 : ::std::vector<sal_Int32> PresenterTheme::GetBorderSize (
     338                 :            :     const ::rtl::OUString& rsStyleName,
     339                 :            :     const bool bOuter) const
     340                 :            : {
     341                 :            :     OSL_ASSERT(mpTheme.get() != NULL);
     342                 :            : 
     343         [ #  # ]:          0 :     SharedPaneStyle pPaneStyle (mpTheme->GetPaneStyle(rsStyleName));
     344         [ #  # ]:          0 :     if (pPaneStyle.get() != NULL)
     345         [ #  # ]:          0 :         if (bOuter)
     346         [ #  # ]:          0 :             return pPaneStyle->maOuterBorderSize.ToVector();
     347                 :            :         else
     348         [ #  # ]:          0 :             return pPaneStyle->maInnerBorderSize.ToVector();
     349                 :            :     else
     350                 :            :     {
     351         [ #  # ]:          0 :         return ::std::vector<sal_Int32>(4,0);
     352         [ #  # ]:          0 :     }
     353                 :            : }
     354                 :            : 
     355                 :          0 : PresenterTheme::SharedFontDescriptor PresenterTheme::ReadFont (
     356                 :            :     const Reference<container::XHierarchicalNameAccess>& rxNode,
     357                 :            :     const OUString& rsFontPath,
     358                 :            :     const PresenterTheme::SharedFontDescriptor& rpDefault)
     359                 :            : {
     360                 :          0 :     return ReadContext::ReadFont(rxNode, rsFontPath, rpDefault);
     361                 :            : }
     362                 :            : 
     363                 :          0 : bool PresenterTheme::ConvertToColor (
     364                 :            :     const Any& rColorSequence,
     365                 :            :     sal_uInt32& rColor)
     366                 :            : {
     367         [ #  # ]:          0 :     Sequence<sal_Int8> aByteSequence;
     368 [ #  # ][ #  # ]:          0 :     if (rColorSequence >>= aByteSequence)
     369                 :            :     {
     370                 :          0 :         const sal_Int32 nByteCount (aByteSequence.getLength());
     371                 :          0 :         const sal_uInt8* pArray = reinterpret_cast<const sal_uInt8*>(aByteSequence.getConstArray());
     372                 :          0 :         rColor = 0;
     373         [ #  # ]:          0 :         for (sal_Int32 nIndex=0; nIndex<nByteCount; ++nIndex)
     374                 :            :         {
     375                 :          0 :             rColor = (rColor << 8) | *pArray++;
     376                 :            :         }
     377                 :          0 :         return true;
     378                 :            :     }
     379                 :            :     else
     380         [ #  # ]:          0 :         return false;
     381                 :            : }
     382                 :            : 
     383                 :          0 : ::boost::shared_ptr<PresenterConfigurationAccess> PresenterTheme::GetNodeForViewStyle (
     384                 :            :     const ::rtl::OUString& rsStyleName) const
     385                 :            : {
     386         [ #  # ]:          0 :     if (mpTheme.get() == NULL)
     387         [ #  # ]:          0 :         return ::boost::shared_ptr<PresenterConfigurationAccess>();
     388                 :            : 
     389                 :            :     // Open configuration for writing.
     390                 :            :     ::boost::shared_ptr<PresenterConfigurationAccess> pConfiguration (
     391                 :            :         new PresenterConfigurationAccess(
     392                 :            :             mxContext,
     393                 :            :             OUString("/org.openoffice.Office.extension.PresenterScreen/"),
     394 [ #  # ][ #  # ]:          0 :             PresenterConfigurationAccess::READ_WRITE));
                 [ #  # ]
     395                 :            : 
     396                 :            :     // Get configuration node for the view style container of the current
     397                 :            :     // theme.
     398   [ #  #  #  # ]:          0 :     if (pConfiguration->GoToChild(
     399                 :          0 :         A2S("Presenter/Themes/") + mpTheme->msConfigurationNodeName + A2S("/ViewStyles")))
     400                 :            :     {
     401                 :            :         pConfiguration->GoToChild(
     402                 :            :             ::boost::bind(&PresenterConfigurationAccess::IsStringPropertyEqual,
     403                 :            :                 rsStyleName,
     404                 :            :                 A2S("StyleName"),
     405 [ #  # ][ #  # ]:          0 :                 _2));
         [ #  # ][ #  # ]
     406                 :            :     }
     407 [ #  # ][ #  # ]:          0 :     return pConfiguration;
     408                 :            : }
     409                 :            : 
     410                 :          0 : SharedBitmapDescriptor PresenterTheme::GetBitmap (
     411                 :            :     const OUString& rsStyleName,
     412                 :            :     const OUString& rsBitmapName) const
     413                 :            : {
     414         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     415                 :            :     {
     416         [ #  # ]:          0 :         if (rsStyleName.isEmpty())
     417                 :            :         {
     418         [ #  # ]:          0 :             if (rsBitmapName == A2S("Background"))
     419                 :            :             {
     420         [ #  # ]:          0 :                 ::boost::shared_ptr<Theme> pTheme (mpTheme);
     421 [ #  # ][ #  # ]:          0 :                 while (pTheme.get()!=NULL && pTheme->mpBackground.get()==NULL)
                 [ #  # ]
     422         [ #  # ]:          0 :                     pTheme = pTheme->mpParentTheme;
     423         [ #  # ]:          0 :                 if (pTheme.get() != NULL)
     424         [ #  # ]:          0 :                     return pTheme->mpBackground;
     425                 :            :                 else
     426 [ #  # ][ #  # ]:          0 :                     return SharedBitmapDescriptor();
     427                 :            :             }
     428                 :            :         }
     429                 :            :         else
     430                 :            :         {
     431         [ #  # ]:          0 :             SharedPaneStyle pPaneStyle (mpTheme->GetPaneStyle(rsStyleName));
     432         [ #  # ]:          0 :             if (pPaneStyle.get() != NULL)
     433                 :            :             {
     434         [ #  # ]:          0 :                 SharedBitmapDescriptor pBitmap (pPaneStyle->GetBitmap(rsBitmapName));
     435         [ #  # ]:          0 :                 if (pBitmap.get() != NULL)
     436 [ #  # ][ #  # ]:          0 :                     return pBitmap;
                 [ #  # ]
     437                 :            :             }
     438                 :            : 
     439         [ #  # ]:          0 :             SharedViewStyle pViewStyle (mpTheme->GetViewStyle(rsStyleName));
     440         [ #  # ]:          0 :             if (pViewStyle.get() != NULL)
     441                 :            :             {
     442         [ #  # ]:          0 :                 SharedBitmapDescriptor pBitmap (pViewStyle->GetBitmap(rsBitmapName));
     443         [ #  # ]:          0 :                 if (pBitmap.get() != NULL)
     444 [ #  # ][ #  # ]:          0 :                     return pBitmap;
                 [ #  # ]
     445 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     446                 :            :         }
     447                 :            :     }
     448                 :            : 
     449                 :          0 :     return SharedBitmapDescriptor();
     450                 :            : }
     451                 :            : 
     452                 :          0 : SharedBitmapDescriptor PresenterTheme::GetBitmap (
     453                 :            :     const OUString& rsBitmapName) const
     454                 :            : {
     455         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     456                 :            :     {
     457         [ #  # ]:          0 :         if (rsBitmapName == A2S("Background"))
     458                 :            :         {
     459         [ #  # ]:          0 :             ::boost::shared_ptr<Theme> pTheme (mpTheme);
     460 [ #  # ][ #  # ]:          0 :             while (pTheme.get()!=NULL && pTheme->mpBackground.get()==NULL)
                 [ #  # ]
     461         [ #  # ]:          0 :                 pTheme = pTheme->mpParentTheme;
     462         [ #  # ]:          0 :             if (pTheme.get() != NULL)
     463         [ #  # ]:          0 :                 return pTheme->mpBackground;
     464                 :            :             else
     465 [ #  # ][ #  # ]:          0 :                 return SharedBitmapDescriptor();
     466                 :            :         }
     467                 :            :         else
     468                 :            :         {
     469         [ #  # ]:          0 :             if (mpTheme->mpIconContainer.get() != NULL)
     470                 :          0 :                 return mpTheme->mpIconContainer->GetBitmap(rsBitmapName);
     471                 :            :         }
     472                 :            :     }
     473                 :            : 
     474                 :          0 :     return SharedBitmapDescriptor();
     475                 :            : }
     476                 :            : 
     477                 :          0 : ::boost::shared_ptr<PresenterBitmapContainer> PresenterTheme::GetBitmapContainer (void) const
     478                 :            : {
     479         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     480                 :          0 :         return mpTheme->mpIconContainer;
     481                 :            :     else
     482                 :          0 :         return ::boost::shared_ptr<PresenterBitmapContainer>();
     483                 :            : }
     484                 :            : 
     485                 :          0 : PresenterTheme::SharedFontDescriptor PresenterTheme::GetFont (
     486                 :            :     const OUString& rsStyleName) const
     487                 :            : {
     488         [ #  # ]:          0 :     if (mpTheme.get() != NULL)
     489                 :            :     {
     490         [ #  # ]:          0 :         SharedPaneStyle pPaneStyle (mpTheme->GetPaneStyle(rsStyleName));
     491         [ #  # ]:          0 :         if (pPaneStyle.get() != NULL)
     492         [ #  # ]:          0 :             return pPaneStyle->GetFont();
     493                 :            : 
     494         [ #  # ]:          0 :         SharedViewStyle pViewStyle (mpTheme->GetViewStyle(rsStyleName));
     495         [ #  # ]:          0 :         if (pViewStyle.get() != NULL)
     496         [ #  # ]:          0 :             return pViewStyle->GetFont();
     497                 :            : 
     498         [ #  # ]:          0 :         ::boost::shared_ptr<Theme> pTheme (mpTheme);
     499         [ #  # ]:          0 :         while (pTheme.get() != NULL)
     500                 :            :         {
     501         [ #  # ]:          0 :             Theme::FontContainer::const_iterator iFont (pTheme->maFontContainer.find(rsStyleName));
     502         [ #  # ]:          0 :             if (iFont != pTheme->maFontContainer.end())
     503         [ #  # ]:          0 :                 return iFont->second;
     504                 :            : 
     505         [ #  # ]:          0 :             pTheme = pTheme->mpParentTheme;
     506 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     507                 :            :     }
     508                 :            : 
     509                 :          0 :     return SharedFontDescriptor();
     510                 :            : }
     511                 :            : 
     512                 :            : //===== FontDescriptor ========================================================
     513                 :            : 
     514                 :          0 : PresenterTheme::FontDescriptor::FontDescriptor (
     515                 :            :     const ::boost::shared_ptr<FontDescriptor>& rpDescriptor)
     516                 :            :     : msFamilyName(),
     517                 :            :       msStyleName(),
     518                 :            :       mnSize(12),
     519                 :            :       mnColor(0x00000000),
     520                 :            :       msAnchor(OUString("Left")),
     521                 :            :       mnXOffset(0),
     522                 :          0 :       mnYOffset(0)
     523                 :            : {
     524         [ #  # ]:          0 :     if (rpDescriptor.get() != NULL)
     525                 :            :     {
     526                 :          0 :         msFamilyName = rpDescriptor->msFamilyName;
     527                 :          0 :         msStyleName = rpDescriptor->msStyleName;
     528                 :          0 :         mnSize = rpDescriptor->mnSize;
     529                 :          0 :         mnColor = rpDescriptor->mnColor;
     530                 :          0 :         msAnchor = rpDescriptor->msAnchor;
     531                 :          0 :         mnXOffset = rpDescriptor->mnXOffset;
     532                 :          0 :         mnYOffset = rpDescriptor->mnYOffset;
     533                 :            :     }
     534                 :          0 : }
     535                 :            : 
     536                 :          0 : bool PresenterTheme::FontDescriptor::PrepareFont (
     537                 :            :     const Reference<rendering::XCanvas>& rxCanvas)
     538                 :            : {
     539         [ #  # ]:          0 :     if (mxFont.is())
     540                 :          0 :         return true;
     541                 :            : 
     542         [ #  # ]:          0 :     if ( ! rxCanvas.is())
     543                 :          0 :         return false;
     544                 :            : 
     545                 :          0 :     const double nCellSize (GetCellSizeForDesignSize(rxCanvas, mnSize));
     546         [ #  # ]:          0 :     mxFont = CreateFont(rxCanvas, nCellSize);
     547                 :            : 
     548                 :          0 :     return mxFont.is();
     549                 :            : }
     550                 :            : 
     551                 :          0 : Reference<rendering::XCanvasFont> PresenterTheme::FontDescriptor::CreateFont (
     552                 :            :     const Reference<rendering::XCanvas>& rxCanvas,
     553                 :            :     const double nCellSize) const
     554                 :            : {
     555                 :          0 :     rendering::FontRequest aFontRequest;
     556                 :          0 :     aFontRequest.FontDescription.FamilyName = msFamilyName;
     557         [ #  # ]:          0 :     if (msFamilyName.isEmpty())
     558                 :          0 :         aFontRequest.FontDescription.FamilyName = A2S("Tahoma");
     559                 :          0 :     aFontRequest.FontDescription.StyleName = msStyleName;
     560                 :          0 :     aFontRequest.CellSize = nCellSize;
     561                 :            : 
     562                 :            :     // Make an attempt at translating the style name(s)into a corresponding
     563                 :            :     // font description.
     564         [ #  # ]:          0 :     if (msStyleName == A2S("Bold"))
     565                 :          0 :         aFontRequest.FontDescription.FontDescription.Weight = rendering::PanoseWeight::HEAVY;
     566                 :            : 
     567         [ #  # ]:          0 :     return rxCanvas->createFont(
     568                 :            :         aFontRequest,
     569                 :            :         Sequence<beans::PropertyValue>(),
     570 [ #  # ][ #  # ]:          0 :         geometry::Matrix2D(1,0,0,1));
                 [ #  # ]
     571                 :            : }
     572                 :            : 
     573                 :          0 : double PresenterTheme::FontDescriptor::GetCellSizeForDesignSize (
     574                 :            :     const Reference<rendering::XCanvas>& rxCanvas,
     575                 :            :     const double nDesignSize) const
     576                 :            : {
     577                 :            :     // Use the given design size as initial value in calculating the cell
     578                 :            :     // size.
     579                 :          0 :     double nCellSize (nDesignSize);
     580                 :            : 
     581         [ #  # ]:          0 :     if ( ! rxCanvas.is())
     582                 :            :     {
     583                 :            :         // We need the canvas to do the conversion.  Return the design size,
     584                 :            :         // it is the our best guess in this circumstance.
     585                 :          0 :         return nDesignSize;
     586                 :            :     }
     587                 :            : 
     588         [ #  # ]:          0 :     Reference<rendering::XCanvasFont> xFont (CreateFont(rxCanvas, nCellSize));
     589         [ #  # ]:          0 :     if ( ! xFont.is())
     590                 :          0 :         return nDesignSize;
     591                 :            : 
     592         [ #  # ]:          0 :     geometry::RealRectangle2D aBox (PresenterCanvasHelper::GetTextBoundingBox (xFont, A2S("X")));
     593                 :            : 
     594                 :          0 :     const double nAscent (-aBox.Y1);
     595                 :          0 :     const double nDescent (aBox.Y2);
     596                 :          0 :     const double nScale = (nAscent+nDescent) / nAscent;
     597                 :          0 :     return nDesignSize * nScale;
     598                 :            : }
     599                 :            : 
     600                 :            : //===== Theme =================================================================
     601                 :            : 
     602                 :          0 : PresenterTheme::Theme::Theme (
     603                 :            :     const OUString& rsName,
     604                 :            :     const Reference<container::XHierarchicalNameAccess>& rxThemeRoot,
     605                 :            :     const OUString& rsNodeName)
     606                 :            :     : msThemeName(rsName),
     607                 :            :       msConfigurationNodeName(rsNodeName),
     608                 :            :       mpParentTheme(),
     609                 :            :       maPaneStyles(),
     610                 :            :       maViewStyles(),
     611                 :            :       maStyleAssociations(),
     612                 :            :       mxThemeRoot(rxThemeRoot),
     613 [ #  # ][ #  # ]:          0 :       mpIconContainer()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     614                 :            : {
     615                 :          0 : }
     616                 :            : 
     617 [ #  # ][ #  # ]:          0 : PresenterTheme::Theme::~Theme (void)
                 [ #  # ]
     618                 :            : {
     619                 :          0 : }
     620                 :            : 
     621                 :          0 : void PresenterTheme::Theme::Read (
     622                 :            :     PresenterConfigurationAccess& rConfiguration,
     623                 :            :     ReadContext& rReadContext)
     624                 :            : {
     625                 :            :     PresenterConfigurationAccess::GetConfigurationNode(mxThemeRoot, A2S("ThemeName"))
     626         [ #  # ]:          0 :         >>= msThemeName;
     627                 :            : 
     628                 :            :     // Parent theme name.
     629                 :          0 :     OUString sParentThemeName;
     630         [ #  # ]:          0 :     if ((PresenterConfigurationAccess::GetConfigurationNode(mxThemeRoot, A2S("ParentTheme"))
           [ #  #  #  # ]
     631 [ #  # ][ #  # ]:          0 :             >>= sParentThemeName)
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
     632                 :          0 :         && !sParentThemeName.isEmpty())
     633                 :            :     {
     634 [ #  # ][ #  # ]:          0 :         mpParentTheme = rReadContext.ReadTheme(rConfiguration, sParentThemeName);
                 [ #  # ]
     635                 :            :     }
     636                 :            : 
     637                 :            :     // Read the extension that contains the bitmaps referenced in this
     638                 :            :     // theme.
     639                 :          0 :     OUString sBitmapSourceExtension;
     640         [ #  # ]:          0 :     if ((PresenterConfigurationAccess::GetConfigurationNode(
           [ #  #  #  # ]
     641 [ #  # ][ #  # ]:          0 :         mxThemeRoot, A2S("BitmapSourceExtension")) >>= sBitmapSourceExtension)
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
     642                 :          0 :         && !sBitmapSourceExtension.isEmpty())
     643                 :            :     {
     644         [ #  # ]:          0 :         rReadContext.SetBitmapSourceExtension(sBitmapSourceExtension);
     645                 :            :     }
     646                 :            :     else
     647                 :            :     {
     648         [ #  # ]:          0 :         rReadContext.SetBitmapSourceExtension(PresenterComponent::gsExtensionIdentifier);
     649                 :            :     }
     650                 :            : 
     651                 :            :     // Background.
     652                 :            :     mpBackground = PresenterBitmapContainer::LoadBitmap(
     653                 :            :         mxThemeRoot,
     654                 :            :         A2S("Background"),
     655                 :            :         rReadContext.mxPresenterHelper,
     656                 :            :         rReadContext.msBasePath,
     657                 :            :         rReadContext.mxCanvas,
     658 [ #  # ][ #  # ]:          0 :         SharedBitmapDescriptor());
         [ #  # ][ #  # ]
                 [ #  # ]
     659                 :            : 
     660                 :            :     // Style associations.
     661         [ #  # ]:          0 :     maStyleAssociations.Read(rReadContext, mxThemeRoot);
     662                 :            : 
     663                 :            :     // Pane styles.
     664         [ #  # ]:          0 :     maPaneStyles.Read(rReadContext, mxThemeRoot);
     665                 :            : 
     666                 :            :     // View styles.
     667         [ #  # ]:          0 :     maViewStyles.Read(rReadContext, mxThemeRoot);
     668                 :            : 
     669                 :            :     // Read bitmaps.
     670                 :            :     mpIconContainer.reset(
     671                 :            :         new PresenterBitmapContainer(
     672                 :            :             Reference<container::XNameAccess>(
     673                 :            :                 PresenterConfigurationAccess::GetConfigurationNode(mxThemeRoot, A2S("Bitmaps")),
     674                 :            :                 UNO_QUERY),
     675                 :          0 :             mpParentTheme.get()!=NULL
     676                 :          0 :                 ? mpParentTheme->mpIconContainer
     677                 :            :                 : ::boost::shared_ptr<PresenterBitmapContainer>(),
     678                 :            :             rReadContext.mxComponentContext,
     679                 :            :             rReadContext.mxCanvas,
     680 [ #  # ][ #  #  :          0 :             rReadContext.msBasePath));
             #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     681                 :            : 
     682                 :            :     // Read fonts.
     683                 :            :     Reference<container::XNameAccess> xFontNode(
     684                 :            :         PresenterConfigurationAccess::GetConfigurationNode(mxThemeRoot, A2S("Fonts")),
     685 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
     686                 :            :     PresenterConfigurationAccess::ForAll(
     687                 :            :         xFontNode,
     688                 :            :         ::boost::bind(&PresenterTheme::Theme::ProcessFont,
     689 [ #  # ][ #  # ]:          0 :             this, ::boost::ref(rReadContext), _1, _2));
         [ #  # ][ #  # ]
                 [ #  # ]
     690                 :          0 : }
     691                 :            : 
     692                 :          0 : SharedPaneStyle PresenterTheme::Theme::GetPaneStyle (const OUString& rsStyleName) const
     693                 :            : {
     694         [ #  # ]:          0 :     SharedPaneStyle pPaneStyle (maPaneStyles.GetPaneStyle(rsStyleName));
     695         [ #  # ]:          0 :     if (pPaneStyle.get() != NULL)
     696         [ #  # ]:          0 :         return pPaneStyle;
     697         [ #  # ]:          0 :     else if (mpParentTheme.get() != NULL)
     698         [ #  # ]:          0 :         return mpParentTheme->GetPaneStyle(rsStyleName);
     699                 :            :     else
     700 [ #  # ][ #  # ]:          0 :         return SharedPaneStyle();
     701                 :            : }
     702                 :            : 
     703                 :          0 : SharedViewStyle PresenterTheme::Theme::GetViewStyle (const OUString& rsStyleName) const
     704                 :            : {
     705         [ #  # ]:          0 :     SharedViewStyle pViewStyle (maViewStyles.GetViewStyle(rsStyleName));
     706         [ #  # ]:          0 :     if (pViewStyle.get() != NULL)
     707         [ #  # ]:          0 :         return pViewStyle;
     708         [ #  # ]:          0 :     else if (mpParentTheme.get() != NULL)
     709         [ #  # ]:          0 :         return mpParentTheme->GetViewStyle(rsStyleName);
     710                 :            :     else
     711 [ #  # ][ #  # ]:          0 :         return SharedViewStyle();
     712                 :            : }
     713                 :            : 
     714                 :          0 : void PresenterTheme::Theme::ProcessFont(
     715                 :            :     ReadContext& rReadContext,
     716                 :            :     const OUString& rsKey,
     717                 :            :     const Reference<beans::XPropertySet>& rxProperties)
     718                 :            : {
     719                 :            :     (void)rReadContext;
     720 [ #  # ][ #  # ]:          0 :     maFontContainer[rsKey] = ReadContext::ReadFont(rxProperties, SharedFontDescriptor());
         [ #  # ][ #  # ]
     721                 :          0 : }
     722                 :            : 
     723                 :            : namespace {
     724                 :            : 
     725                 :            : //===== ReadContext ===========================================================
     726                 :            : 
     727                 :          0 : ReadContext::ReadContext (
     728                 :            :     const css::uno::Reference<css::uno::XComponentContext>& rxContext,
     729                 :            :     const Reference<rendering::XCanvas>& rxCanvas)
     730                 :            :     : mxComponentContext(rxContext),
     731                 :            :       mxCanvas(rxCanvas),
     732                 :            :       mxPresenterHelper(),
     733                 :          0 :       msBasePath()
     734                 :            : {
     735 [ #  # ][ #  # ]:          0 :     Reference<lang::XMultiComponentFactory> xFactory (rxContext->getServiceManager());
     736         [ #  # ]:          0 :     if (xFactory.is())
     737                 :            :     {
     738                 :            :         mxPresenterHelper = Reference<drawing::XPresenterHelper>(
     739         [ #  # ]:          0 :             xFactory->createInstanceWithContext(
     740                 :            :                 OUString("com.sun.star.comp.Draw.PresenterHelper"),
     741                 :          0 :                 rxContext),
     742 [ #  # ][ #  # ]:          0 :             UNO_QUERY_THROW);
                 [ #  # ]
     743                 :            :     }
     744                 :            : 
     745                 :            :     // Get base path to bitmaps.
     746         [ #  # ]:          0 :     SetBitmapSourceExtension(PresenterComponent::gsExtensionIdentifier);
     747                 :          0 : }
     748                 :            : 
     749                 :          0 : ReadContext::~ReadContext (void)
     750                 :            : {
     751                 :          0 : }
     752                 :            : 
     753                 :          0 : PresenterTheme::SharedFontDescriptor ReadContext::ReadFont (
     754                 :            :     const Reference<container::XHierarchicalNameAccess>& rxNode,
     755                 :            :     const OUString& rsFontPath,
     756                 :            :     const PresenterTheme::SharedFontDescriptor& rpDefault)
     757                 :            : {
     758         [ #  # ]:          0 :     if ( ! rxNode.is())
     759                 :          0 :         return PresenterTheme::SharedFontDescriptor();
     760                 :            : 
     761                 :            :     try
     762                 :            :     {
     763                 :            :         Reference<container::XHierarchicalNameAccess> xFont (
     764                 :            :             PresenterConfigurationAccess::GetConfigurationNode(
     765                 :            :                 rxNode,
     766                 :            :                 rsFontPath),
     767 [ #  # ][ #  # ]:          0 :                 UNO_QUERY_THROW);
     768                 :            : 
     769         [ #  # ]:          0 :         Reference<beans::XPropertySet> xProperties (xFont, UNO_QUERY_THROW);
     770 [ #  # ][ #  # ]:          0 :         return ReadFont(xProperties, rpDefault);
     771                 :            :     }
     772                 :          0 :     catch (Exception&)
     773                 :            :     {
     774                 :            :         OSL_ASSERT(false);
     775                 :            :     }
     776                 :            : 
     777                 :          0 :     return PresenterTheme::SharedFontDescriptor();
     778                 :            : }
     779                 :            : 
     780                 :          0 : PresenterTheme::SharedFontDescriptor ReadContext::ReadFont (
     781                 :            :     const Reference<beans::XPropertySet>& rxProperties,
     782                 :            :     const PresenterTheme::SharedFontDescriptor& rpDefault)
     783                 :            : {
     784                 :            :     ::boost::shared_ptr<PresenterTheme::FontDescriptor> pDescriptor (
     785 [ #  # ][ #  # ]:          0 :         new PresenterTheme::FontDescriptor(rpDefault));
     786                 :            : 
     787         [ #  # ]:          0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("FamilyName")) >>= pDescriptor->msFamilyName;
     788         [ #  # ]:          0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Style")) >>= pDescriptor->msStyleName;
     789         [ #  # ]:          0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Size")) >>= pDescriptor->mnSize;
     790                 :            :     PresenterTheme::ConvertToColor(
     791                 :            :         PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Color")),
     792 [ #  # ][ #  # ]:          0 :         pDescriptor->mnColor);
     793         [ #  # ]:          0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Anchor")) >>= pDescriptor->msAnchor;
     794         [ #  # ]:          0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("XOffset")) >>= pDescriptor->mnXOffset;
     795         [ #  # ]:          0 :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("YOffset")) >>= pDescriptor->mnYOffset;
     796                 :            : 
     797                 :          0 :     return pDescriptor;
     798                 :            : }
     799                 :            : 
     800                 :          0 : Any ReadContext::GetByName (
     801                 :            :     const Reference<container::XNameAccess>& rxNode,
     802                 :            :     const OUString& rsName) const
     803                 :            : {
     804                 :            :     OSL_ASSERT(rxNode.is());
     805         [ #  # ]:          0 :     if (rxNode->hasByName(rsName))
     806                 :          0 :         return rxNode->getByName(rsName);
     807                 :            :     else
     808                 :          0 :         return Any();
     809                 :            : }
     810                 :            : 
     811                 :          0 : ::boost::shared_ptr<PresenterTheme::Theme> ReadContext::ReadTheme (
     812                 :            :     PresenterConfigurationAccess& rConfiguration,
     813                 :            :     const OUString& rsThemeName)
     814                 :            : {
     815         [ #  # ]:          0 :     ::boost::shared_ptr<PresenterTheme::Theme> pTheme;
     816                 :            : 
     817                 :          0 :     OUString sCurrentThemeName (rsThemeName);
     818         [ #  # ]:          0 :      if (sCurrentThemeName.isEmpty())
     819                 :            :      {
     820                 :            :          // No theme name given.  Look up the CurrentTheme property.
     821         [ #  # ]:          0 :          rConfiguration.GetConfigurationNode(A2S("Presenter/CurrentTheme")) >>= sCurrentThemeName;
     822         [ #  # ]:          0 :          if (sCurrentThemeName.isEmpty())
     823                 :            :          {
     824                 :            :              // Still no name.  Use "DefaultTheme".
     825                 :          0 :              sCurrentThemeName = A2S("DefaultTheme");
     826                 :            :          }
     827                 :            :      }
     828                 :            : 
     829                 :            :     Reference<container::XNameAccess> xThemes (
     830                 :            :         rConfiguration.GetConfigurationNode(A2S("Presenter/Themes")),
     831 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
     832         [ #  # ]:          0 :     if (xThemes.is())
     833                 :            :     {
     834                 :            :         // Iterate over all themes and search the one with the given name.
     835 [ #  # ][ #  # ]:          0 :         Sequence<OUString> aKeys (xThemes->getElementNames());
     836         [ #  # ]:          0 :         for (sal_Int32 nItemIndex=0; nItemIndex < aKeys.getLength(); ++nItemIndex)
     837                 :            :         {
     838         [ #  # ]:          0 :              const OUString& rsKey (aKeys[nItemIndex]);
     839                 :            :             Reference<container::XHierarchicalNameAccess> xTheme (
     840 [ #  # ][ #  # ]:          0 :                 xThemes->getByName(rsKey), UNO_QUERY);
                 [ #  # ]
     841         [ #  # ]:          0 :             if (xTheme.is())
     842                 :            :             {
     843                 :          0 :                 OUString sThemeName;
     844                 :            :                 PresenterConfigurationAccess::GetConfigurationNode(xTheme, A2S("ThemeName"))
     845         [ #  # ]:          0 :                     >>= sThemeName;
     846         [ #  # ]:          0 :                 if (sThemeName == sCurrentThemeName)
     847                 :            :                 {
     848 [ #  # ][ #  # ]:          0 :                     pTheme.reset(new PresenterTheme::Theme(sThemeName,xTheme,rsKey));
                 [ #  # ]
     849                 :            :                     break;
     850         [ #  # ]:          0 :                 }
     851                 :            :             }
     852 [ #  # ][ #  # ]:          0 :         }
     853                 :            :     }
     854                 :            : 
     855         [ #  # ]:          0 :     if (pTheme.get() != NULL)
     856                 :            :     {
     857         [ #  # ]:          0 :         pTheme->Read(rConfiguration, *this);
     858                 :            :     }
     859                 :            : 
     860                 :          0 :     return pTheme;
     861                 :            : }
     862                 :            : 
     863                 :          0 : BorderSize ReadContext::ReadBorderSize (const Reference<container::XNameAccess>& rxNode)
     864                 :            : {
     865                 :          0 :     BorderSize aBorderSize;
     866                 :            : 
     867         [ #  # ]:          0 :     if (rxNode.is())
     868                 :            :     {
     869         [ #  # ]:          0 :         GetByName(rxNode, A2S("Left")) >>= aBorderSize.mnLeft;
     870         [ #  # ]:          0 :         GetByName(rxNode, A2S("Top")) >>= aBorderSize.mnTop;
     871         [ #  # ]:          0 :         GetByName(rxNode, A2S("Right")) >>= aBorderSize.mnRight;
     872         [ #  # ]:          0 :         GetByName(rxNode, A2S("Bottom")) >>= aBorderSize.mnBottom;
     873                 :            :     }
     874                 :            : 
     875                 :          0 :     return aBorderSize;
     876                 :            : }
     877                 :            : 
     878                 :          0 : void ReadContext::SetBitmapSourceExtension (const OUString& rsExtensionIdentifier)
     879                 :            : {
     880                 :            :     // Get base path to bitmaps.
     881                 :          0 :     msBasePath = PresenterComponent::GetBasePath(mxComponentContext, rsExtensionIdentifier);
     882                 :          0 : }
     883                 :            : 
     884                 :            : //===== PaneStyleContainer ====================================================
     885                 :            : 
     886                 :          0 : void PaneStyleContainer::Read (
     887                 :            :     ReadContext& rReadContext,
     888                 :            :     const Reference<container::XHierarchicalNameAccess>& rxThemeRoot)
     889                 :            : {
     890                 :            :     Reference<container::XNameAccess> xPaneStyleList (
     891                 :            :         PresenterConfigurationAccess::GetConfigurationNode(
     892                 :            :             rxThemeRoot,
     893                 :            :             A2S("PaneStyles")),
     894 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
     895         [ #  # ]:          0 :     if (xPaneStyleList.is())
     896                 :            :     {
     897         [ #  # ]:          0 :         ::std::vector<rtl::OUString> aProperties;
     898         [ #  # ]:          0 :         aProperties.reserve(6);
     899         [ #  # ]:          0 :         aProperties.push_back(A2S("StyleName"));
     900         [ #  # ]:          0 :         aProperties.push_back(A2S("ParentStyle"));
     901         [ #  # ]:          0 :         aProperties.push_back(A2S("TitleFont"));
     902         [ #  # ]:          0 :         aProperties.push_back(A2S("InnerBorderSize"));
     903         [ #  # ]:          0 :         aProperties.push_back(A2S("OuterBorderSize"));
     904         [ #  # ]:          0 :         aProperties.push_back(A2S("BorderBitmapList"));
     905                 :            :         PresenterConfigurationAccess::ForAll(
     906                 :            :             xPaneStyleList,
     907                 :            :             aProperties,
     908                 :            :             ::boost::bind(&PaneStyleContainer::ProcessPaneStyle,
     909 [ #  # ][ #  # ]:          0 :                 this, ::boost::ref(rReadContext), _1, _2));
         [ #  # ][ #  # ]
                 [ #  # ]
     910                 :          0 :     }
     911                 :          0 : }
     912                 :            : 
     913                 :          0 : void PaneStyleContainer::ProcessPaneStyle(
     914                 :            :     ReadContext& rReadContext,
     915                 :            :     const OUString& rsKey,
     916                 :            :     const ::std::vector<Any>& rValues)
     917                 :            : {
     918                 :            :     (void)rsKey;
     919                 :            : 
     920         [ #  # ]:          0 :     if (rValues.size() != 6)
     921                 :          0 :         return;
     922                 :            : 
     923 [ #  # ][ #  # ]:          0 :     ::boost::shared_ptr<PaneStyle> pStyle (new PaneStyle());
                 [ #  # ]
     924                 :            : 
     925                 :          0 :     rValues[0] >>= pStyle->msStyleName;
     926                 :            : 
     927                 :          0 :     OUString sParentStyleName;
     928         [ #  # ]:          0 :     if (rValues[1] >>= sParentStyleName)
     929                 :            :     {
     930                 :            :         // Find parent style.
     931                 :          0 :         PaneStyleContainer::const_iterator iStyle;
     932 [ #  # ][ #  # ]:          0 :         for (iStyle=begin(); iStyle!=end(); ++iStyle)
                 [ #  # ]
     933         [ #  # ]:          0 :             if ((*iStyle)->msStyleName.equals(sParentStyleName))
     934                 :            :             {
     935         [ #  # ]:          0 :                 pStyle->mpParentStyle = *iStyle;
     936                 :          0 :                 break;
     937                 :            :             }
     938                 :            :     }
     939                 :            : 
     940         [ #  # ]:          0 :     Reference<container::XHierarchicalNameAccess> xFontNode (rValues[2], UNO_QUERY);
     941                 :          0 :     pStyle->mpFont = rReadContext.ReadFont(
     942         [ #  # ]:          0 :         xFontNode, A2S(""), PresenterTheme::SharedFontDescriptor());
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     943                 :            : 
     944         [ #  # ]:          0 :     Reference<container::XNameAccess> xInnerBorderSizeNode (rValues[3], UNO_QUERY);
     945         [ #  # ]:          0 :     pStyle->maInnerBorderSize = rReadContext.ReadBorderSize(xInnerBorderSizeNode);
     946         [ #  # ]:          0 :     Reference<container::XNameAccess> xOuterBorderSizeNode (rValues[4], UNO_QUERY);
     947         [ #  # ]:          0 :     pStyle->maOuterBorderSize = rReadContext.ReadBorderSize(xOuterBorderSizeNode);
     948                 :            : 
     949         [ #  # ]:          0 :     if (pStyle->mpParentStyle.get() != NULL)
     950                 :            :     {
     951                 :          0 :         pStyle->maInnerBorderSize.Merge(pStyle->mpParentStyle->maInnerBorderSize);
     952                 :          0 :         pStyle->maOuterBorderSize.Merge(pStyle->mpParentStyle->maOuterBorderSize);
     953                 :            :     }
     954                 :            : 
     955         [ #  # ]:          0 :     if (rReadContext.mxCanvas.is())
     956                 :            :     {
     957         [ #  # ]:          0 :         Reference<container::XNameAccess> xBitmapsNode (rValues[5], UNO_QUERY);
     958                 :          0 :         pStyle->mpBitmaps.reset(new PresenterBitmapContainer(
     959                 :            :             xBitmapsNode,
     960                 :          0 :             pStyle->mpParentStyle.get()!=NULL
     961                 :          0 :                 ? pStyle->mpParentStyle->mpBitmaps
     962                 :            :                 : ::boost::shared_ptr<PresenterBitmapContainer>(),
     963                 :            :             rReadContext.mxComponentContext,
     964                 :            :             rReadContext.mxCanvas,
     965                 :            :             rReadContext.msBasePath,
     966 [ #  # ][ #  # ]:          0 :             rReadContext.mxPresenterHelper));
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     967                 :            :     }
     968                 :            : 
     969 [ #  # ][ #  # ]:          0 :     push_back(pStyle);
     970                 :            : }
     971                 :            : 
     972                 :          0 : SharedPaneStyle PaneStyleContainer::GetPaneStyle (const OUString& rsStyleName) const
     973                 :            : {
     974                 :          0 :     const_iterator iEnd (end());
     975 [ #  # ][ #  # ]:          0 :     for (const_iterator iStyle=begin(); iStyle!=iEnd; ++iStyle)
     976         [ #  # ]:          0 :         if ((*iStyle)->msStyleName == rsStyleName)
     977         [ #  # ]:          0 :             return *iStyle;
     978         [ #  # ]:          0 :     return SharedPaneStyle();
     979                 :            : }
     980                 :            : 
     981                 :            : //===== PaneStyle =============================================================
     982                 :            : 
     983                 :          0 : PaneStyle::PaneStyle (void)
     984                 :            :     : msStyleName(),
     985                 :            :       mpParentStyle(),
     986                 :            :       mpFont(),
     987                 :            :       maInnerBorderSize(),
     988                 :            :       maOuterBorderSize(),
     989 [ #  # ][ #  # ]:          0 :       mpBitmaps()
                 [ #  # ]
     990                 :            : {
     991                 :          0 : }
     992                 :            : 
     993 [ #  # ][ #  # ]:          0 : PaneStyle::~PaneStyle (void)
                 [ #  # ]
     994                 :            : {
     995                 :          0 : }
     996                 :            : 
     997                 :          0 : void PaneStyle::UpdateBorderSize (BorderSize& rBorderSize, bool bInner)
     998                 :            : {
     999         [ #  # ]:          0 :     if (mpParentStyle.get() != NULL)
    1000                 :          0 :         mpParentStyle->UpdateBorderSize(rBorderSize, bInner);
    1001                 :            : 
    1002         [ #  # ]:          0 :     BorderSize& rThisBorderSize (bInner ? maInnerBorderSize : maOuterBorderSize);
    1003         [ #  # ]:          0 :     if (rThisBorderSize.mnLeft >= 0)
    1004                 :          0 :         rBorderSize.mnLeft = rThisBorderSize.mnLeft;
    1005         [ #  # ]:          0 :     if (rThisBorderSize.mnTop >= 0)
    1006                 :          0 :         rBorderSize.mnTop = rThisBorderSize.mnTop;
    1007         [ #  # ]:          0 :     if (rThisBorderSize.mnRight >= 0)
    1008                 :          0 :         rBorderSize.mnRight = rThisBorderSize.mnRight;
    1009         [ #  # ]:          0 :     if (rThisBorderSize.mnBottom >= 0)
    1010                 :          0 :         rBorderSize.mnBottom = rThisBorderSize.mnBottom;
    1011                 :          0 : }
    1012                 :            : 
    1013                 :          0 : const SharedBitmapDescriptor PaneStyle::GetBitmap (const OUString& rsBitmapName) const
    1014                 :            : {
    1015         [ #  # ]:          0 :     if (mpBitmaps.get() != NULL)
    1016                 :            :     {
    1017         [ #  # ]:          0 :         const SharedBitmapDescriptor pBitmap = mpBitmaps->GetBitmap(rsBitmapName);
    1018         [ #  # ]:          0 :         if (pBitmap.get() != NULL)
    1019 [ #  # ][ #  # ]:          0 :             return pBitmap;
                 [ #  # ]
    1020                 :            :     }
    1021                 :            : 
    1022         [ #  # ]:          0 :     if (mpParentStyle.get() != NULL)
    1023                 :          0 :         return mpParentStyle->GetBitmap(rsBitmapName);
    1024                 :            :     else
    1025                 :          0 :         return SharedBitmapDescriptor();
    1026                 :            : }
    1027                 :            : 
    1028                 :          0 : PresenterTheme::SharedFontDescriptor PaneStyle::GetFont (void) const
    1029                 :            : {
    1030         [ #  # ]:          0 :     if (mpFont.get() != NULL)
    1031                 :          0 :         return mpFont;
    1032         [ #  # ]:          0 :     else if (mpParentStyle.get() != NULL)
    1033                 :          0 :         return mpParentStyle->GetFont();
    1034                 :            :     else
    1035                 :          0 :         return PresenterTheme::SharedFontDescriptor();
    1036                 :            : }
    1037                 :            : 
    1038                 :            : //===== ViewStyleContainer ====================================================
    1039                 :            : 
    1040                 :          0 : void ViewStyleContainer::Read (
    1041                 :            :     ReadContext& rReadContext,
    1042                 :            :     const Reference<container::XHierarchicalNameAccess>& rxThemeRoot)
    1043                 :            : {
    1044                 :            :     (void)rReadContext;
    1045                 :            : 
    1046                 :            :     Reference<container::XNameAccess> xViewStyleList (
    1047                 :            :         PresenterConfigurationAccess::GetConfigurationNode(
    1048                 :            :             rxThemeRoot,
    1049                 :            :             A2S("ViewStyles")),
    1050 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
    1051         [ #  # ]:          0 :     if (xViewStyleList.is())
    1052                 :            :     {
    1053                 :            :         PresenterConfigurationAccess::ForAll(
    1054                 :            :             xViewStyleList,
    1055                 :            :             ::boost::bind(&ViewStyleContainer::ProcessViewStyle,
    1056 [ #  # ][ #  # ]:          0 :                 this, ::boost::ref(rReadContext), _2));
         [ #  # ][ #  # ]
                 [ #  # ]
    1057                 :          0 :     }
    1058                 :          0 : }
    1059                 :            : 
    1060                 :          0 : void ViewStyleContainer::ProcessViewStyle(
    1061                 :            :     ReadContext& rReadContext,
    1062                 :            :     const Reference<beans::XPropertySet>& rxProperties)
    1063                 :            : {
    1064 [ #  # ][ #  # ]:          0 :     ::boost::shared_ptr<ViewStyle> pStyle (new ViewStyle());
                 [ #  # ]
    1065                 :            : 
    1066                 :            :     PresenterConfigurationAccess::GetProperty(rxProperties, A2S("StyleName"))
    1067         [ #  # ]:          0 :         >>= pStyle->msStyleName;
    1068                 :            : 
    1069                 :          0 :     OUString sParentStyleName;
    1070         [ #  # ]:          0 :     if (PresenterConfigurationAccess::GetProperty(rxProperties, A2S("ParentStyle"))
    1071         [ #  # ]:          0 :         >>= sParentStyleName)
    1072                 :            :     {
    1073                 :            :         // Find parent style.
    1074                 :          0 :         ViewStyleContainer::const_iterator iStyle;
    1075 [ #  # ][ #  # ]:          0 :         for (iStyle=begin(); iStyle!=end(); ++iStyle)
                 [ #  # ]
    1076         [ #  # ]:          0 :             if ((*iStyle)->msStyleName.equals(sParentStyleName))
    1077                 :            :             {
    1078         [ #  # ]:          0 :                 pStyle->mpParentStyle = *iStyle;
    1079         [ #  # ]:          0 :                 pStyle->mpFont = (*iStyle)->mpFont;
    1080         [ #  # ]:          0 :                 pStyle->mpBackground = (*iStyle)->mpBackground;
    1081                 :          0 :                 break;
    1082                 :            :             }
    1083                 :            :     }
    1084                 :            : 
    1085                 :          0 :     const OUString sPathToFont; // empty string
    1086                 :            :     Reference<container::XHierarchicalNameAccess> xFontNode (
    1087 [ #  # ][ #  # ]:          0 :         PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Font")), UNO_QUERY);
    1088                 :            :     PresenterTheme::SharedFontDescriptor pFont (
    1089 [ #  # ][ #  # ]:          0 :         rReadContext.ReadFont(xFontNode, sPathToFont, PresenterTheme::SharedFontDescriptor()));
                 [ #  # ]
    1090         [ #  # ]:          0 :     if (pFont.get() != NULL)
    1091         [ #  # ]:          0 :         pStyle->mpFont = pFont;
    1092                 :            : 
    1093                 :            :     Reference<container::XHierarchicalNameAccess> xBackgroundNode (
    1094                 :            :         PresenterConfigurationAccess::GetProperty(rxProperties, A2S("Background")),
    1095 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
    1096                 :            :     SharedBitmapDescriptor pBackground (PresenterBitmapContainer::LoadBitmap(
    1097                 :            :         xBackgroundNode,
    1098                 :            :         OUString(),
    1099                 :            :         rReadContext.mxPresenterHelper,
    1100                 :            :         rReadContext.msBasePath,
    1101                 :            :         rReadContext.mxCanvas,
    1102 [ #  # ][ #  # ]:          0 :         SharedBitmapDescriptor()));
                 [ #  # ]
    1103 [ #  # ][ #  # ]:          0 :     if (pBackground.get() != NULL && pBackground->GetNormalBitmap().is())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1104         [ #  # ]:          0 :         pStyle->mpBackground = pBackground;
    1105                 :            : 
    1106 [ #  # ][ #  # ]:          0 :     push_back(pStyle);
         [ #  # ][ #  # ]
    1107                 :          0 : }
    1108                 :            : 
    1109                 :          0 : SharedViewStyle ViewStyleContainer::GetViewStyle (const OUString& rsStyleName) const
    1110                 :            : {
    1111                 :          0 :     const_iterator iEnd (end());
    1112 [ #  # ][ #  # ]:          0 :     for (const_iterator iStyle=begin(); iStyle!=iEnd; ++iStyle)
    1113         [ #  # ]:          0 :         if ((*iStyle)->msStyleName == rsStyleName)
    1114         [ #  # ]:          0 :             return *iStyle;
    1115         [ #  # ]:          0 :     return SharedViewStyle();
    1116                 :            : }
    1117                 :            : 
    1118                 :            : //===== ViewStyle =============================================================
    1119                 :            : 
    1120                 :          0 : ViewStyle::ViewStyle (void)
    1121                 :            :     : msStyleName(),
    1122                 :            :       mpParentStyle(),
    1123                 :            :       mpFont(),
    1124 [ #  # ][ #  # ]:          0 :       mpBackground()
         [ #  # ][ #  # ]
    1125                 :            : {
    1126                 :          0 : }
    1127                 :            : 
    1128 [ #  # ][ #  # ]:          0 : ViewStyle::~ViewStyle (void)
         [ #  # ][ #  # ]
    1129                 :            : {
    1130                 :          0 : }
    1131                 :            : 
    1132                 :          0 : const SharedBitmapDescriptor ViewStyle::GetBitmap (const OUString& rsBitmapName) const
    1133                 :            : {
    1134         [ #  # ]:          0 :     if (rsBitmapName == A2S("Background"))
    1135                 :          0 :         return mpBackground;
    1136                 :            :     else
    1137                 :          0 :         return SharedBitmapDescriptor();
    1138                 :            : }
    1139                 :            : 
    1140                 :          0 : PresenterTheme::SharedFontDescriptor ViewStyle::GetFont (void) const
    1141                 :            : {
    1142         [ #  # ]:          0 :     if (mpFont.get() != NULL)
    1143                 :          0 :         return mpFont;
    1144         [ #  # ]:          0 :     else if (mpParentStyle.get() != NULL)
    1145                 :          0 :         return mpParentStyle->GetFont();
    1146                 :            :     else
    1147                 :          0 :         return PresenterTheme::SharedFontDescriptor();
    1148                 :            : }
    1149                 :            : 
    1150                 :            : //===== StyleAssociationContainer =============================================
    1151                 :            : 
    1152                 :          0 : void StyleAssociationContainer::Read (
    1153                 :            :     ReadContext& rReadContext,
    1154                 :            :     const Reference<container::XHierarchicalNameAccess>& rxThemeRoot)
    1155                 :            : {
    1156                 :            :     Reference<container::XNameAccess> xStyleAssociationList (
    1157                 :            :         PresenterConfigurationAccess::GetConfigurationNode(
    1158                 :            :             rxThemeRoot,
    1159                 :            :             A2S("StyleAssociations")),
    1160 [ #  # ][ #  # ]:          0 :         UNO_QUERY);
    1161         [ #  # ]:          0 :     if (xStyleAssociationList.is())
    1162                 :            :     {
    1163         [ #  # ]:          0 :         ::std::vector<rtl::OUString> aProperties (2);
    1164                 :          0 :         aProperties[0] = A2S("ResourceURL");
    1165                 :          0 :         aProperties[1] = A2S("StyleName");
    1166                 :            :         PresenterConfigurationAccess::ForAll(
    1167                 :            :             xStyleAssociationList,
    1168                 :            :             aProperties,
    1169                 :            :             ::boost::bind(&StyleAssociationContainer::ProcessStyleAssociation,
    1170 [ #  # ][ #  # ]:          0 :                 this, ::boost::ref(rReadContext), _1, _2));
         [ #  # ][ #  # ]
                 [ #  # ]
    1171                 :          0 :     }
    1172                 :          0 : }
    1173                 :            : 
    1174                 :          0 : OUString StyleAssociationContainer::GetStyleName (const OUString& rsResourceName) const
    1175                 :            : {
    1176         [ #  # ]:          0 :     StyleAssociations::const_iterator iAssociation (maStyleAssociations.find(rsResourceName));
    1177         [ #  # ]:          0 :     if (iAssociation != maStyleAssociations.end())
    1178                 :          0 :         return iAssociation->second;
    1179                 :            :     else
    1180                 :          0 :         return OUString();
    1181                 :            : }
    1182                 :            : 
    1183                 :          0 : void StyleAssociationContainer::ProcessStyleAssociation(
    1184                 :            :     ReadContext& rReadContext,
    1185                 :            :     const OUString& rsKey,
    1186                 :            :     const ::std::vector<Any>& rValues)
    1187                 :            : {
    1188                 :            :     (void)rReadContext;
    1189                 :            :     (void)rsKey;
    1190                 :            : 
    1191         [ #  # ]:          0 :     if (rValues.size() != 2)
    1192                 :          0 :         return;
    1193                 :            : 
    1194                 :          0 :     OUString sResourceURL;
    1195                 :          0 :     OUString sStyleName;
    1196         [ #  # ]:          0 :     if ((rValues[0] >>= sResourceURL)
           [ #  #  #  # ]
    1197                 :          0 :         && (rValues[1] >>= sStyleName))
    1198                 :            :     {
    1199         [ #  # ]:          0 :         maStyleAssociations[sResourceURL] = sStyleName;
    1200                 :          0 :     }
    1201                 :            : }
    1202                 :            : 
    1203                 :            : } // end of anonymous namespace
    1204                 :            : 
    1205 [ +  - ][ +  - ]:         24 : } } // end of namespace ::sdext::presenter
    1206                 :            : 
    1207                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10