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_PANE_BORDER_PAINTER_HXX 25 #define SDEXT_PRESENTER_PRESENTER_PANE_BORDER_PAINTER_HXX 26 27 #include <com/sun/star/uno/XComponentContext.hpp> 28 #include <com/sun/star/awt/Rectangle.hpp> 29 #include <com/sun/star/drawing/framework/XPaneBorderPainter.hpp> 30 #include <com/sun/star/graphic/XGraphicProvider.hpp> 31 #include <com/sun/star/rendering/XCanvas.hpp> 32 #include <com/sun/star/util/XMacroExpander.hpp> 33 #include <com/sun/star/awt/XGraphics.hpp> 34 #include <cppuhelper/basemutex.hxx> 35 #include <cppuhelper/compbase1.hxx> 36 #include <boost/noncopyable.hpp> 37 #include <boost/scoped_ptr.hpp> 38 #include <boost/shared_ptr.hpp> 39 40 namespace css = ::com::sun::star; 41 42 namespace sdext { namespace tools { 43 class ConfigurationAccess; 44 } } 45 46 namespace sdext { namespace presenter { 47 48 class PresenterPane; 49 class PresenterTheme; 50 51 namespace { 52 typedef ::cppu::WeakComponentImplHelper1< 53 css::drawing::framework::XPaneBorderPainter 54 > PresenterPaneBorderPainterInterfaceBase; 55 } 56 57 /** This class is responsible for painting window borders of PresenterPane 58 objects. 59 */ 60 class PresenterPaneBorderPainter 61 : private ::boost::noncopyable, 62 protected ::cppu::BaseMutex, 63 public PresenterPaneBorderPainterInterfaceBase 64 { 65 public: 66 PresenterPaneBorderPainter ( 67 const css::uno::Reference<css::uno::XComponentContext>& rxContext); 68 virtual ~PresenterPaneBorderPainter (void); 69 70 /** Transform the bounding box of the window content to the outer 71 bounding box of the border that is painted around it. 72 @param rsPaneURL 73 Specifies the pane style that is used to determine the border sizes. 74 @param rInnerBox 75 The rectangle of the inner window content. 76 */ 77 css::awt::Rectangle AddBorder ( 78 const ::rtl::OUString& rsPaneURL, 79 const css::awt::Rectangle& rInnerBox, 80 const css::drawing::framework::BorderType eBorderType) const; 81 82 /** Transform the outer bounding box of a window to the bounding box of 83 the inner content area. 84 @param rsPaneURL 85 Specifies the pane style that is used to determine the border sizes. 86 @param rOuterBox 87 The bounding box of the rectangle around the window. 88 @param bIsTitleVisible 89 This flag controls whether the upper part of the frame is 90 supposed to contain the window title. 91 */ 92 css::awt::Rectangle RemoveBorder ( 93 const ::rtl::OUString& rsPaneURL, 94 const css::awt::Rectangle& rOuterBox, 95 const css::drawing::framework::BorderType eBorderType) const; 96 97 bool HasTheme (void) const; 98 99 void SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme); 100 101 class Renderer; 102 103 // XPaneBorderPainter 104 105 virtual css::awt::Rectangle SAL_CALL addBorder ( 106 const rtl::OUString& rsPaneBorderStyleName, 107 const css::awt::Rectangle& rRectangle, 108 css::drawing::framework::BorderType eBorderType); 109 110 virtual css::awt::Rectangle SAL_CALL removeBorder ( 111 const rtl::OUString& rsPaneBorderStyleName, 112 const css::awt::Rectangle& rRectangle, 113 css::drawing::framework::BorderType eBorderType); 114 115 virtual void SAL_CALL paintBorder ( 116 const rtl::OUString& rsPaneBorderStyleName, 117 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 118 const css::awt::Rectangle& rOuterBorderRectangle, 119 const css::awt::Rectangle& rRepaintArea, 120 const rtl::OUString& rsTitle); 121 122 virtual void SAL_CALL paintBorderWithCallout ( 123 const rtl::OUString& rsPaneBorderStyleName, 124 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 125 const css::awt::Rectangle& rOuterBorderRectangle, 126 const css::awt::Rectangle& rRepaintArea, 127 const rtl::OUString& rsTitle, 128 const css::awt::Point& rCalloutAnchor); 129 130 virtual css::awt::Point SAL_CALL getCalloutOffset ( 131 const rtl::OUString& rsPaneBorderStyleName); 132 133 private: 134 css::uno::Reference<css::uno::XComponentContext> mxContext; 135 ::boost::shared_ptr<PresenterTheme> mpTheme; 136 ::boost::scoped_ptr<Renderer> mpRenderer; 137 138 /** When the theme for the border has not yet been loaded then try again 139 when this method is called. 140 @return 141 Returns <TRUE/> only one time when the theme is loaded and/or the 142 renderer is initialized. 143 */ 144 bool ProvideTheme ( 145 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas); 146 bool ProvideTheme (void); 147 148 void ThrowIfDisposed (void) const; 149 }; 150 151 } } // end of namespace ::sd::presenter 152 153 #endif 154