xref: /AOO41X/main/sdext/source/presenter/PresenterTheme.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PRESENTER_THEME_HXX
29*cdf0e10cSrcweir #define SDEXT_PRESENTER_PRESENTER_THEME_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterBitmapContainer.hxx"
32*cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
33*cdf0e10cSrcweir #include "PresenterTheme.hxx"
34*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvasFont.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
39*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace css = ::com::sun::star;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir namespace sdext { namespace presenter {
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir /** A theme is a set of properties describing fonts, colors, and bitmaps to be used to draw
46*cdf0e10cSrcweir     background, pane borders, and view content.
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     At the moment the properties can be accessed via the getPropertyValue() method.
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir     For a resource URL of a pane or a view you get the name of the
51*cdf0e10cSrcweir     associated PaneStyle or ViewStyle.
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     For the name of pane or view style suffixed with and underscore and the
54*cdf0e10cSrcweir     name of configuration property, and maybe additionally suffixed by
55*cdf0e10cSrcweir     another underscore and sub property name you get the associated
56*cdf0e10cSrcweir     property.
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir     Example: you want to access the top left bitmap of a pane border
59*cdf0e10cSrcweir         (simplified code):
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     String sStyleName = getPropertyValue("private:resource/pane/Presenter/Pane1");
62*cdf0e10cSrcweir     XBitmap xBitmap = getPropertyValue(sStyleName + "_TopLeftBitmap");
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     For the offset of the bitmap you can call
65*cdf0e10cSrcweir     Point aOffset = getPropertyValue(sStyleName + "_TopLeftOffset");
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir     This is work in progress.
68*cdf0e10cSrcweir */
69*cdf0e10cSrcweir class PresenterTheme
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir public:
72*cdf0e10cSrcweir     PresenterTheme (
73*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
74*cdf0e10cSrcweir         const rtl::OUString& rsThemeName,
75*cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
76*cdf0e10cSrcweir     ~PresenterTheme (void);
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     void SAL_CALL disposing (void);
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     bool HasCanvas (void) const;
81*cdf0e10cSrcweir     void ProvideCanvas (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     ::rtl::OUString GetStyleName (const ::rtl::OUString& rsResourceURL) const;
84*cdf0e10cSrcweir     ::std::vector<sal_Int32> GetBorderSize (
85*cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName,
86*cdf0e10cSrcweir         const bool bOuter) const;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     class FontDescriptor;
89*cdf0e10cSrcweir     class Theme;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     class FontDescriptor
92*cdf0e10cSrcweir     {
93*cdf0e10cSrcweir     public:
94*cdf0e10cSrcweir         explicit FontDescriptor (void);
95*cdf0e10cSrcweir         explicit FontDescriptor (const ::boost::shared_ptr<FontDescriptor>& rpDescriptor);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir         ::rtl::OUString msFamilyName;
98*cdf0e10cSrcweir         ::rtl::OUString msStyleName;
99*cdf0e10cSrcweir         sal_Int32 mnSize;
100*cdf0e10cSrcweir         sal_uInt32 mnColor;
101*cdf0e10cSrcweir         ::rtl::OUString msAnchor;
102*cdf0e10cSrcweir         sal_Int32 mnXOffset;
103*cdf0e10cSrcweir         sal_Int32 mnYOffset;
104*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XCanvasFont> mxFont;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir         bool PrepareFont (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     private:
109*cdf0e10cSrcweir         css::uno::Reference<css::rendering::XCanvasFont> CreateFont (
110*cdf0e10cSrcweir             const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
111*cdf0e10cSrcweir             const double nCellSize) const;
112*cdf0e10cSrcweir         double GetCellSizeForDesignSize (
113*cdf0e10cSrcweir             const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
114*cdf0e10cSrcweir             const double nDesignSize) const;
115*cdf0e10cSrcweir     };
116*cdf0e10cSrcweir     typedef ::boost::shared_ptr<FontDescriptor> SharedFontDescriptor;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     ::rtl::OUString GetThemeName (void) const;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     SharedBitmapDescriptor GetBitmap (
121*cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName,
122*cdf0e10cSrcweir         const ::rtl::OUString& rsBitmapName) const;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     SharedBitmapDescriptor GetBitmap (
125*cdf0e10cSrcweir         const ::rtl::OUString& rsBitmapName) const;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     ::boost::shared_ptr<PresenterBitmapContainer> GetBitmapContainer (void) const;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     SharedFontDescriptor GetFont (
130*cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName) const;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     static SharedFontDescriptor ReadFont (
133*cdf0e10cSrcweir         const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
134*cdf0e10cSrcweir         const ::rtl::OUString& rsFontPath,
135*cdf0e10cSrcweir         const SharedFontDescriptor& rDefaultFount);
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     static bool ConvertToColor (
138*cdf0e10cSrcweir         const css::uno::Any& rColorSequence,
139*cdf0e10cSrcweir         sal_uInt32& rColor);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     ::boost::shared_ptr<PresenterConfigurationAccess> GetNodeForViewStyle (
142*cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName,
143*cdf0e10cSrcweir         const PresenterConfigurationAccess::WriteMode) const;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir private:
146*cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxContext;
147*cdf0e10cSrcweir     const ::rtl::OUString msThemeName;
148*cdf0e10cSrcweir     ::boost::shared_ptr<Theme> mpTheme;
149*cdf0e10cSrcweir     ::boost::shared_ptr<PresenterBitmapContainer> mpBitmapContainer;
150*cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     ::boost::shared_ptr<Theme> ReadTheme (void);
153*cdf0e10cSrcweir };
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir } } // end of namespace ::sd::presenter
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir #endif
158