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 : : #ifndef SDEXT_PRESENTER_PRESENTER_THEME_HXX
30 : : #define SDEXT_PRESENTER_PRESENTER_THEME_HXX
31 : :
32 : : #include "PresenterBitmapContainer.hxx"
33 : : #include "PresenterConfigurationAccess.hxx"
34 : : #include <com/sun/star/uno/XComponentContext.hpp>
35 : : #include <com/sun/star/rendering/XCanvas.hpp>
36 : : #include <com/sun/star/rendering/XCanvasFont.hpp>
37 : : #include <com/sun/star/rendering/XIntegerBitmap.hpp>
38 : : #include <com/sun/star/util/Color.hpp>
39 : : #include <boost/shared_ptr.hpp>
40 : :
41 : : namespace css = ::com::sun::star;
42 : :
43 : : namespace sdext { namespace presenter {
44 : :
45 : : /** A theme is a set of properties describing fonts, colors, and bitmaps to be used to draw
46 : : background, pane borders, and view content.
47 : :
48 : : At the moment the properties can be accessed via the getPropertyValue() method.
49 : :
50 : : For a resource URL of a pane or a view you get the name of the
51 : : associated PaneStyle or ViewStyle.
52 : :
53 : : For the name of pane or view style suffixed with and underscore and the
54 : : name of configuration property, and maybe additionally suffixed by
55 : : another underscore and sub property name you get the associated
56 : : property.
57 : :
58 : : Example: you want to access the top left bitmap of a pane border
59 : : (simplified code):
60 : :
61 : : String sStyleName = getPropertyValue("private:resource/pane/Presenter/Pane1");
62 : : XBitmap xBitmap = getPropertyValue(sStyleName + "_TopLeftBitmap");
63 : :
64 : : For the offset of the bitmap you can call
65 : : Point aOffset = getPropertyValue(sStyleName + "_TopLeftOffset");
66 : :
67 : : This is work in progress.
68 : : */
69 : : class PresenterTheme
70 : : {
71 : : public:
72 : : PresenterTheme (
73 : : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
74 : : const rtl::OUString& rsThemeName,
75 : : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
76 : : ~PresenterTheme (void);
77 : :
78 : : bool HasCanvas (void) const;
79 : : void ProvideCanvas (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
80 : :
81 : : ::rtl::OUString GetStyleName (const ::rtl::OUString& rsResourceURL) const;
82 : : ::std::vector<sal_Int32> GetBorderSize (
83 : : const ::rtl::OUString& rsStyleName,
84 : : const bool bOuter) const;
85 : :
86 : : class Theme;
87 : 0 : class FontDescriptor
88 : : {
89 : : public:
90 : : explicit FontDescriptor (const ::boost::shared_ptr<FontDescriptor>& rpDescriptor);
91 : :
92 : : ::rtl::OUString msFamilyName;
93 : : ::rtl::OUString msStyleName;
94 : : sal_Int32 mnSize;
95 : : sal_uInt32 mnColor;
96 : : ::rtl::OUString msAnchor;
97 : : sal_Int32 mnXOffset;
98 : : sal_Int32 mnYOffset;
99 : : css::uno::Reference<css::rendering::XCanvasFont> mxFont;
100 : :
101 : : bool PrepareFont (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
102 : :
103 : : private:
104 : : css::uno::Reference<css::rendering::XCanvasFont> CreateFont (
105 : : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
106 : : const double nCellSize) const;
107 : : double GetCellSizeForDesignSize (
108 : : const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
109 : : const double nDesignSize) const;
110 : : };
111 : : typedef ::boost::shared_ptr<FontDescriptor> SharedFontDescriptor;
112 : :
113 : : SharedBitmapDescriptor GetBitmap (
114 : : const ::rtl::OUString& rsStyleName,
115 : : const ::rtl::OUString& rsBitmapName) const;
116 : :
117 : : SharedBitmapDescriptor GetBitmap (
118 : : const ::rtl::OUString& rsBitmapName) const;
119 : :
120 : : ::boost::shared_ptr<PresenterBitmapContainer> GetBitmapContainer (void) const;
121 : :
122 : : SharedFontDescriptor GetFont (
123 : : const ::rtl::OUString& rsStyleName) const;
124 : :
125 : : static SharedFontDescriptor ReadFont (
126 : : const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
127 : : const ::rtl::OUString& rsFontPath,
128 : : const SharedFontDescriptor& rDefaultFount);
129 : :
130 : : static bool ConvertToColor (
131 : : const css::uno::Any& rColorSequence,
132 : : sal_uInt32& rColor);
133 : :
134 : : ::boost::shared_ptr<PresenterConfigurationAccess> GetNodeForViewStyle (
135 : : const ::rtl::OUString& rsStyleName) const;
136 : :
137 : : private:
138 : : css::uno::Reference<css::uno::XComponentContext> mxContext;
139 : : const ::rtl::OUString msThemeName;
140 : : ::boost::shared_ptr<Theme> mpTheme;
141 : : ::boost::shared_ptr<PresenterBitmapContainer> mpBitmapContainer;
142 : : css::uno::Reference<css::rendering::XCanvas> mxCanvas;
143 : :
144 : : ::boost::shared_ptr<Theme> ReadTheme (void);
145 : : };
146 : :
147 : : } } // end of namespace ::sd::presenter
148 : :
149 : : #endif
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|