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_BITMAP_CONTAINER_HXX 25 #define SDEXT_PRESENTER_BITMAP_CONTAINER_HXX 26 27 #include <com/sun/star/beans/XPropertySet.hpp> 28 #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 29 #include <com/sun/star/container/XNameAccess.hpp> 30 #include <com/sun/star/drawing/XPresenterHelper.hpp> 31 #include <com/sun/star/rendering/XBitmap.hpp> 32 #include <com/sun/star/rendering/XCanvas.hpp> 33 #include <com/sun/star/uno/XComponentContext.hpp> 34 #include <com/sun/star/util/Color.hpp> 35 #include <boost/noncopyable.hpp> 36 #include <boost/scoped_ptr.hpp> 37 #include <map> 38 #include <vector> 39 #include <boost/shared_ptr.hpp> 40 41 namespace css = ::com::sun::star; 42 43 44 namespace sdext { namespace presenter { 45 46 /** Manage a set of bitmap groups as they are used for buttons: three 47 bitmaps, one for the normal state, one for a mouse over effect and one 48 to show that the button has been pressed. 49 A bitmap group is defined by some entries in the configuration. 50 */ 51 class PresenterBitmapContainer 52 : private ::boost::noncopyable 53 { 54 public: 55 /** There is one bitmap for the normal state, one for a mouse over effect and one 56 to show that a button has been pressed. 57 */ 58 class BitmapDescriptor 59 { 60 public: 61 BitmapDescriptor (void); 62 BitmapDescriptor (const ::boost::shared_ptr<BitmapDescriptor>& rpDefault); 63 64 enum Mode {Normal, MouseOver, ButtonDown, Disabled, Mask}; 65 css::uno::Reference<css::rendering::XBitmap> GetNormalBitmap (void) const; 66 css::uno::Reference<css::rendering::XBitmap> GetBitmap ( 67 const Mode eMode, 68 const bool bMissingDefaultsToNormal = true) const; 69 void SetBitmap ( 70 const Mode eMode, 71 const css::uno::Reference<css::rendering::XBitmap>& rxBitmap); 72 73 sal_Int32 mnWidth; 74 sal_Int32 mnHeight; 75 sal_Int32 mnXOffset; 76 sal_Int32 mnYOffset; 77 sal_Int32 mnXHotSpot; 78 sal_Int32 mnYHotSpot; 79 css::util::Color maReplacementColor; 80 enum TexturingMode { Once, Repeat, Stretch }; 81 TexturingMode meHorizontalTexturingMode; 82 TexturingMode meVerticalTexturingMode; 83 84 private: 85 css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap; 86 css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap; 87 css::uno::Reference<css::rendering::XBitmap> mxButtonDownBitmap; 88 css::uno::Reference<css::rendering::XBitmap> mxDisabledBitmap; 89 css::uno::Reference<css::rendering::XBitmap> mxMaskBitmap; 90 }; 91 92 /** Create a new bitmap container from a section of the configuration. 93 @param rxComponentContext 94 The component context is used to create new API objects. 95 @param rxCanvas 96 Bitmaps are created specifically for this canvas. 97 @param rsConfigurationBase 98 The name of a configuration node whose sub-tree defines the 99 bitmap sets. 100 */ 101 PresenterBitmapContainer ( 102 const ::rtl::OUString& rsConfigurationBase, 103 const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer, 104 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext, 105 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 106 const ::rtl::OUString& rsBasePath, 107 const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL); 108 PresenterBitmapContainer ( 109 const css::uno::Reference<css::container::XNameAccess>& rsRootNode, 110 const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer, 111 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext, 112 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 113 const ::rtl::OUString& rsBasePath, 114 const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper = NULL); 115 ~PresenterBitmapContainer (void); 116 117 void Initialize ( 118 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext); 119 120 /** Return the bitmap set that is associated with the given name. 121 */ 122 ::boost::shared_ptr<BitmapDescriptor> GetBitmap (const ::rtl::OUString& rsName) const; 123 124 static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap ( 125 const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode, 126 const ::rtl::OUString& rsPathToBitmapNode, 127 const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper, 128 const ::rtl::OUString& rsBitmapBasePath, 129 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 130 const ::boost::shared_ptr<BitmapDescriptor>& rpDefaultBitmap); 131 132 private: 133 ::boost::shared_ptr<PresenterBitmapContainer> mpParentContainer; 134 typedef ::std::map<rtl::OUString, ::boost::shared_ptr<BitmapDescriptor> > BitmapContainer; 135 BitmapContainer maIconContainer; 136 ::rtl::OUString msBasePath; 137 css::uno::Reference<css::rendering::XCanvas> mxCanvas; 138 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 139 140 void LoadBitmaps ( 141 const css::uno::Reference<css::container::XNameAccess>& rsRootNode); 142 void ProcessBitmap ( 143 const ::rtl::OUString& rsKey, 144 const css::uno::Reference<css::beans::XPropertySet>& rProperties); 145 static ::boost::shared_ptr<BitmapDescriptor> LoadBitmap ( 146 const css::uno::Reference<css::beans::XPropertySet>& rxProperties, 147 const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper, 148 const ::rtl::OUString& rsBasePath, 149 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 150 const ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor>& rpDefault); 151 static BitmapDescriptor::TexturingMode 152 StringToTexturingMode (const ::rtl::OUString& rsTexturingMode); 153 }; 154 155 156 typedef PresenterBitmapContainer::BitmapDescriptor PresenterBitmapDescriptor; 157 typedef ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor> SharedBitmapDescriptor; 158 159 } } // end of namespace ::sdext::presenter 160 161 #endif 162