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