1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06bcd5d2SAndrew Rist  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06bcd5d2SAndrew Rist  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19*06bcd5d2SAndrew Rist  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PRESENTER_THEME_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_PRESENTER_THEME_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterBitmapContainer.hxx"
28cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
29cdf0e10cSrcweir #include "PresenterTheme.hxx"
30cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
31cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
32cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvasFont.hpp>
33cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
34cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
35cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace css = ::com::sun::star;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace sdext { namespace presenter {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /** A theme is a set of properties describing fonts, colors, and bitmaps to be used to draw
42cdf0e10cSrcweir     background, pane borders, and view content.
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     At the moment the properties can be accessed via the getPropertyValue() method.
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     For a resource URL of a pane or a view you get the name of the
47cdf0e10cSrcweir     associated PaneStyle or ViewStyle.
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     For the name of pane or view style suffixed with and underscore and the
50cdf0e10cSrcweir     name of configuration property, and maybe additionally suffixed by
51cdf0e10cSrcweir     another underscore and sub property name you get the associated
52cdf0e10cSrcweir     property.
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     Example: you want to access the top left bitmap of a pane border
55cdf0e10cSrcweir         (simplified code):
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     String sStyleName = getPropertyValue("private:resource/pane/Presenter/Pane1");
58cdf0e10cSrcweir     XBitmap xBitmap = getPropertyValue(sStyleName + "_TopLeftBitmap");
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     For the offset of the bitmap you can call
61cdf0e10cSrcweir     Point aOffset = getPropertyValue(sStyleName + "_TopLeftOffset");
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     This is work in progress.
64cdf0e10cSrcweir */
65cdf0e10cSrcweir class PresenterTheme
66cdf0e10cSrcweir {
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir     PresenterTheme (
69cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
70cdf0e10cSrcweir         const rtl::OUString& rsThemeName,
71cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
72cdf0e10cSrcweir     ~PresenterTheme (void);
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     void SAL_CALL disposing (void);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     bool HasCanvas (void) const;
77cdf0e10cSrcweir     void ProvideCanvas (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     ::rtl::OUString GetStyleName (const ::rtl::OUString& rsResourceURL) const;
80cdf0e10cSrcweir     ::std::vector<sal_Int32> GetBorderSize (
81cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName,
82cdf0e10cSrcweir         const bool bOuter) const;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     class FontDescriptor;
85cdf0e10cSrcweir     class Theme;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     class FontDescriptor
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir     public:
90cdf0e10cSrcweir         explicit FontDescriptor (void);
91cdf0e10cSrcweir         explicit FontDescriptor (const ::boost::shared_ptr<FontDescriptor>& rpDescriptor);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         ::rtl::OUString msFamilyName;
94cdf0e10cSrcweir         ::rtl::OUString msStyleName;
95cdf0e10cSrcweir         sal_Int32 mnSize;
96cdf0e10cSrcweir         sal_uInt32 mnColor;
97cdf0e10cSrcweir         ::rtl::OUString msAnchor;
98cdf0e10cSrcweir         sal_Int32 mnXOffset;
99cdf0e10cSrcweir         sal_Int32 mnYOffset;
100cdf0e10cSrcweir         css::uno::Reference<css::rendering::XCanvasFont> mxFont;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         bool PrepareFont (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     private:
105cdf0e10cSrcweir         css::uno::Reference<css::rendering::XCanvasFont> CreateFont (
106cdf0e10cSrcweir             const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
107cdf0e10cSrcweir             const double nCellSize) const;
108cdf0e10cSrcweir         double GetCellSizeForDesignSize (
109cdf0e10cSrcweir             const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
110cdf0e10cSrcweir             const double nDesignSize) const;
111cdf0e10cSrcweir     };
112cdf0e10cSrcweir     typedef ::boost::shared_ptr<FontDescriptor> SharedFontDescriptor;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     ::rtl::OUString GetThemeName (void) const;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     SharedBitmapDescriptor GetBitmap (
117cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName,
118cdf0e10cSrcweir         const ::rtl::OUString& rsBitmapName) const;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     SharedBitmapDescriptor GetBitmap (
121cdf0e10cSrcweir         const ::rtl::OUString& rsBitmapName) const;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     ::boost::shared_ptr<PresenterBitmapContainer> GetBitmapContainer (void) const;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     SharedFontDescriptor GetFont (
126cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName) const;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     static SharedFontDescriptor ReadFont (
129cdf0e10cSrcweir         const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
130cdf0e10cSrcweir         const ::rtl::OUString& rsFontPath,
131cdf0e10cSrcweir         const SharedFontDescriptor& rDefaultFount);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     static bool ConvertToColor (
134cdf0e10cSrcweir         const css::uno::Any& rColorSequence,
135cdf0e10cSrcweir         sal_uInt32& rColor);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     ::boost::shared_ptr<PresenterConfigurationAccess> GetNodeForViewStyle (
138cdf0e10cSrcweir         const ::rtl::OUString& rsStyleName,
139cdf0e10cSrcweir         const PresenterConfigurationAccess::WriteMode) const;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir private:
142cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxContext;
143cdf0e10cSrcweir     const ::rtl::OUString msThemeName;
144cdf0e10cSrcweir     ::boost::shared_ptr<Theme> mpTheme;
145cdf0e10cSrcweir     ::boost::shared_ptr<PresenterBitmapContainer> mpBitmapContainer;
146cdf0e10cSrcweir     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     ::boost::shared_ptr<Theme> ReadTheme (void);
149cdf0e10cSrcweir };
150cdf0e10cSrcweir 
151cdf0e10cSrcweir } } // end of namespace ::sd::presenter
152cdf0e10cSrcweir 
153cdf0e10cSrcweir #endif
154