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     /** Transorm 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         throw(css::uno::RuntimeException);
110 
111     virtual css::awt::Rectangle SAL_CALL removeBorder (
112         const rtl::OUString& rsPaneBorderStyleName,
113         const css::awt::Rectangle& rRectangle,
114         css::drawing::framework::BorderType eBorderType)
115         throw(css::uno::RuntimeException);
116 
117     virtual void SAL_CALL paintBorder (
118         const rtl::OUString& rsPaneBorderStyleName,
119         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
120         const css::awt::Rectangle& rOuterBorderRectangle,
121         const css::awt::Rectangle& rRepaintArea,
122         const rtl::OUString& rsTitle)
123         throw(css::uno::RuntimeException);
124 
125     virtual void SAL_CALL paintBorderWithCallout (
126         const rtl::OUString& rsPaneBorderStyleName,
127         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
128         const css::awt::Rectangle& rOuterBorderRectangle,
129         const css::awt::Rectangle& rRepaintArea,
130         const rtl::OUString& rsTitle,
131         const css::awt::Point& rCalloutAnchor)
132         throw(css::uno::RuntimeException);
133 
134     virtual css::awt::Point SAL_CALL getCalloutOffset (
135         const rtl::OUString& rsPaneBorderStyleName)
136         throw(css::uno::RuntimeException);
137 
138 private:
139     css::uno::Reference<css::uno::XComponentContext> mxContext;
140     ::boost::shared_ptr<PresenterTheme> mpTheme;
141     ::boost::scoped_ptr<Renderer> mpRenderer;
142 
143     /** When the theme for the border has not yet been loaded then try again
144         when this method is called.
145         @return
146             Returns <TRUE/> only one time when the theme is loaded and/or the
147             renderer is initialized.
148     */
149     bool ProvideTheme (
150         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
151     bool ProvideTheme (void);
152 
153     void ThrowIfDisposed (void) const
154         throw (::com::sun::star::lang::DisposedException);
155 };
156 
157 } } // end of namespace ::sd::presenter
158 
159 #endif
160