LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterTheme.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 419 0.2 %
Date: 2014-04-11 Functions: 2 59 3.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10