1*c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c142477cSAndrew Rist  * distributed with this work for additional information
6*c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9*c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c142477cSAndrew Rist  *
11*c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c142477cSAndrew Rist  *
13*c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c142477cSAndrew Rist  * software distributed under the License is distributed on an
15*c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c142477cSAndrew Rist  * specific language governing permissions and limitations
18*c142477cSAndrew Rist  * under the License.
19*c142477cSAndrew Rist  *
20*c142477cSAndrew Rist  *************************************************************/
21*c142477cSAndrew Rist 
22*c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterPaneBorderPainter.hxx"
28cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
29cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
30cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx"
31cdf0e10cSrcweir #include "PresenterTheme.hxx"
32cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/SimpleFontMetric.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/XFont.hpp>
37cdf0e10cSrcweir #include <com/sun/star/drawing/XPresenterHelper.hpp>
38cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
39cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicRenderer.hpp>
40cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
41cdf0e10cSrcweir #include <com/sun/star/rendering/FillRule.hpp>
42cdf0e10cSrcweir #include <com/sun/star/rendering/TextDirection.hpp>
43cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
44cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
45cdf0e10cSrcweir #include <map>
46cdf0e10cSrcweir #include <vector>
47cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir using namespace ::com::sun::star;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51cdf0e10cSrcweir using ::rtl::OUString;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #define A2S(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)))
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace sdext { namespace presenter {
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace {
58cdf0e10cSrcweir     class BorderSize
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir     public:
61cdf0e10cSrcweir         BorderSize (void);
62cdf0e10cSrcweir         BorderSize (const BorderSize& rBorderSize);
63cdf0e10cSrcweir         BorderSize& operator= (const BorderSize& rBoderSize);
64cdf0e10cSrcweir         sal_Int32 mnLeft;
65cdf0e10cSrcweir         sal_Int32 mnTop;
66cdf0e10cSrcweir         sal_Int32 mnRight;
67cdf0e10cSrcweir         sal_Int32 mnBottom;
68cdf0e10cSrcweir     };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     class RendererPaneStyle
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir     public:
73cdf0e10cSrcweir         RendererPaneStyle (
74cdf0e10cSrcweir             const ::boost::shared_ptr<PresenterTheme>& rpTheme,
75cdf0e10cSrcweir             const OUString& rsStyleName);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         awt::Rectangle AddBorder (
78cdf0e10cSrcweir             const awt::Rectangle& rBox,
79cdf0e10cSrcweir             drawing::framework::BorderType eBorderType) const;
80cdf0e10cSrcweir         awt::Rectangle RemoveBorder (
81cdf0e10cSrcweir             const awt::Rectangle& rBox,
82cdf0e10cSrcweir             drawing::framework::BorderType eBorderType) const;
83cdf0e10cSrcweir         const Reference<rendering::XCanvasFont> GetFont (
84cdf0e10cSrcweir             const Reference<rendering::XCanvas>& rxCanvas) const;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         SharedBitmapDescriptor mpTopLeft;
87cdf0e10cSrcweir         SharedBitmapDescriptor mpTop;
88cdf0e10cSrcweir         SharedBitmapDescriptor mpTopRight;
89cdf0e10cSrcweir         SharedBitmapDescriptor mpLeft;
90cdf0e10cSrcweir         SharedBitmapDescriptor mpRight;
91cdf0e10cSrcweir         SharedBitmapDescriptor mpBottomLeft;
92cdf0e10cSrcweir         SharedBitmapDescriptor mpBottom;
93cdf0e10cSrcweir         SharedBitmapDescriptor mpBottomRight;
94cdf0e10cSrcweir         SharedBitmapDescriptor mpBottomCallout;
95cdf0e10cSrcweir         SharedBitmapDescriptor mpBackground;
96cdf0e10cSrcweir         SharedBitmapDescriptor mpEmpty;
97cdf0e10cSrcweir         PresenterTheme::SharedFontDescriptor mpFont;
98cdf0e10cSrcweir         sal_Int32 mnFontXOffset;
99cdf0e10cSrcweir         sal_Int32 mnFontYOffset;
100cdf0e10cSrcweir         enum Anchor { AnchorLeft, AnchorRight, AnchorCenter } meFontAnchor;
101cdf0e10cSrcweir         BorderSize maInnerBorderSize;
102cdf0e10cSrcweir         BorderSize maOuterBorderSize;
103cdf0e10cSrcweir         BorderSize maTotalBorderSize;
104cdf0e10cSrcweir         enum Side { Left, Top, Right, Bottom };
105cdf0e10cSrcweir     private:
106cdf0e10cSrcweir         void UpdateBorderSizes (void);
107cdf0e10cSrcweir         SharedBitmapDescriptor GetBitmap(
108cdf0e10cSrcweir             const ::boost::shared_ptr<PresenterTheme>& rpTheme,
109cdf0e10cSrcweir             const OUString& rsStyleName,
110cdf0e10cSrcweir             const OUString& rsBitmapName);
111cdf0e10cSrcweir     };
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 
116cdf0e10cSrcweir class  PresenterPaneBorderPainter::Renderer
117cdf0e10cSrcweir {
118cdf0e10cSrcweir public:
119cdf0e10cSrcweir     Renderer (
120cdf0e10cSrcweir         const Reference<XComponentContext>& rxContext,
121cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterTheme>& rpTheme);
122cdf0e10cSrcweir     ~Renderer (void);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     void SetCanvas (const Reference<rendering::XCanvas>& rxCanvas);
125cdf0e10cSrcweir     void PaintBorder (
126cdf0e10cSrcweir         const OUString& rsTitle,
127cdf0e10cSrcweir         const awt::Rectangle& rBBox,
128cdf0e10cSrcweir         const awt::Rectangle& rUpdateBox,
129cdf0e10cSrcweir         const OUString& rsPaneURL);
130cdf0e10cSrcweir     void PaintTitle (
131cdf0e10cSrcweir         const OUString& rsTitle,
132cdf0e10cSrcweir         const ::boost::shared_ptr<RendererPaneStyle>& rpStyle,
133cdf0e10cSrcweir         const awt::Rectangle& rUpdateBox,
134cdf0e10cSrcweir         const awt::Rectangle& rOuterBox,
135cdf0e10cSrcweir         const awt::Rectangle& rInnerBox,
136cdf0e10cSrcweir         const bool bPaintBackground);
137cdf0e10cSrcweir     void SetupClipping (
138cdf0e10cSrcweir         const awt::Rectangle& rUpdateBox,
139cdf0e10cSrcweir         const awt::Rectangle& rOuterBox,
140cdf0e10cSrcweir         const OUString& rsPaneStyleName);
141cdf0e10cSrcweir     ::boost::shared_ptr<RendererPaneStyle> GetRendererPaneStyle (const OUString& rsResourceURL);
142cdf0e10cSrcweir     void SetCalloutAnchor (
143cdf0e10cSrcweir         const awt::Point& rCalloutAnchor);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir private:
146cdf0e10cSrcweir     ::boost::shared_ptr<PresenterTheme> mpTheme;
147cdf0e10cSrcweir     typedef ::std::map<OUString, ::boost::shared_ptr<RendererPaneStyle> > RendererPaneStyleContainer;
148cdf0e10cSrcweir     RendererPaneStyleContainer maRendererPaneStyles;
149cdf0e10cSrcweir     Reference<rendering::XCanvas> mxCanvas;
150cdf0e10cSrcweir     Reference<drawing::XPresenterHelper> mxPresenterHelper;
151cdf0e10cSrcweir     css::rendering::ViewState maViewState;
152cdf0e10cSrcweir     Reference<rendering::XPolyPolygon2D> mxViewStateClip;
153cdf0e10cSrcweir     bool mbHasCallout;
154cdf0e10cSrcweir     awt::Point maCalloutAnchor;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     void PaintBitmap(
157cdf0e10cSrcweir         const awt::Rectangle& rBox,
158cdf0e10cSrcweir         const awt::Rectangle& rUpdateBox,
159cdf0e10cSrcweir         const sal_Int32 nXPosition,
160cdf0e10cSrcweir         const sal_Int32 nYPosition,
161cdf0e10cSrcweir         const sal_Int32 nStartOffset,
162cdf0e10cSrcweir         const sal_Int32 nEndOffset,
163cdf0e10cSrcweir         const bool bExpand,
164cdf0e10cSrcweir         const SharedBitmapDescriptor& rpBitmap,
165cdf0e10cSrcweir         const SharedBitmapDescriptor& rpBackgroundBitmap);
166cdf0e10cSrcweir };
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 
171cdf0e10cSrcweir // ===== PresenterPaneBorderPainter ===========================================
172cdf0e10cSrcweir 
PresenterPaneBorderPainter(const Reference<XComponentContext> & rxContext)173cdf0e10cSrcweir PresenterPaneBorderPainter::PresenterPaneBorderPainter (
174cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext)
175cdf0e10cSrcweir     : PresenterPaneBorderPainterInterfaceBase(m_aMutex),
176cdf0e10cSrcweir       mxContext(rxContext),
177cdf0e10cSrcweir       mpTheme(),
178cdf0e10cSrcweir       mpRenderer()
179cdf0e10cSrcweir {
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
~PresenterPaneBorderPainter(void)185cdf0e10cSrcweir PresenterPaneBorderPainter::~PresenterPaneBorderPainter (void)
186cdf0e10cSrcweir {
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //----- XPaneBorderPainter ----------------------------------------------------
193cdf0e10cSrcweir 
addBorder(const rtl::OUString & rsPaneBorderStyleName,const css::awt::Rectangle & rRectangle,drawing::framework::BorderType eBorderType)194cdf0e10cSrcweir awt::Rectangle SAL_CALL PresenterPaneBorderPainter::addBorder (
195cdf0e10cSrcweir     const rtl::OUString& rsPaneBorderStyleName,
196cdf0e10cSrcweir     const css::awt::Rectangle& rRectangle,
197cdf0e10cSrcweir     drawing::framework::BorderType eBorderType)
198cdf0e10cSrcweir     throw(css::uno::RuntimeException)
199cdf0e10cSrcweir {
200cdf0e10cSrcweir     ThrowIfDisposed();
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     ProvideTheme();
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     return AddBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
removeBorder(const rtl::OUString & rsPaneBorderStyleName,const css::awt::Rectangle & rRectangle,drawing::framework::BorderType eBorderType)210cdf0e10cSrcweir awt::Rectangle SAL_CALL PresenterPaneBorderPainter::removeBorder (
211cdf0e10cSrcweir     const rtl::OUString& rsPaneBorderStyleName,
212cdf0e10cSrcweir     const css::awt::Rectangle& rRectangle,
213cdf0e10cSrcweir     drawing::framework::BorderType eBorderType)
214cdf0e10cSrcweir     throw(css::uno::RuntimeException)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     ThrowIfDisposed();
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     ProvideTheme();
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     return RemoveBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 
paintBorder(const rtl::OUString & rsPaneBorderStyleName,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const css::awt::Rectangle & rOuterBorderRectangle,const css::awt::Rectangle & rRepaintArea,const rtl::OUString & rsTitle)226cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderPainter::paintBorder (
227cdf0e10cSrcweir     const rtl::OUString& rsPaneBorderStyleName,
228cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
229cdf0e10cSrcweir     const css::awt::Rectangle& rOuterBorderRectangle,
230cdf0e10cSrcweir     const css::awt::Rectangle& rRepaintArea,
231cdf0e10cSrcweir     const rtl::OUString& rsTitle)
232cdf0e10cSrcweir     throw(css::uno::RuntimeException)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir     ThrowIfDisposed();
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     // Early reject paints completely outside the repaint area.
237cdf0e10cSrcweir     if (rRepaintArea.X >= rOuterBorderRectangle.X+rOuterBorderRectangle.Width
238cdf0e10cSrcweir         || rRepaintArea.Y >= rOuterBorderRectangle.Y+rOuterBorderRectangle.Height
239cdf0e10cSrcweir         || rRepaintArea.X+rRepaintArea.Width <= rOuterBorderRectangle.X
240cdf0e10cSrcweir         || rRepaintArea.Y+rRepaintArea.Height <= rOuterBorderRectangle.Y)
241cdf0e10cSrcweir     {
242cdf0e10cSrcweir         return;
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir     ProvideTheme(rxCanvas);
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     if (mpRenderer.get() != NULL)
247cdf0e10cSrcweir     {
248cdf0e10cSrcweir         mpRenderer->SetCanvas(rxCanvas);
249cdf0e10cSrcweir         mpRenderer->SetupClipping(
250cdf0e10cSrcweir             rRepaintArea,
251cdf0e10cSrcweir             rOuterBorderRectangle,
252cdf0e10cSrcweir             rsPaneBorderStyleName);
253cdf0e10cSrcweir         mpRenderer->PaintBorder(
254cdf0e10cSrcweir             rsTitle,
255cdf0e10cSrcweir             rOuterBorderRectangle,
256cdf0e10cSrcweir             rRepaintArea,
257cdf0e10cSrcweir             rsPaneBorderStyleName);
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 
paintBorderWithCallout(const rtl::OUString & rsPaneBorderStyleName,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const css::awt::Rectangle & rOuterBorderRectangle,const css::awt::Rectangle & rRepaintArea,const rtl::OUString & rsTitle,const css::awt::Point & rCalloutAnchor)264cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderPainter::paintBorderWithCallout (
265cdf0e10cSrcweir     const rtl::OUString& rsPaneBorderStyleName,
266cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
267cdf0e10cSrcweir     const css::awt::Rectangle& rOuterBorderRectangle,
268cdf0e10cSrcweir     const css::awt::Rectangle& rRepaintArea,
269cdf0e10cSrcweir     const rtl::OUString& rsTitle,
270cdf0e10cSrcweir     const css::awt::Point& rCalloutAnchor)
271cdf0e10cSrcweir     throw(css::uno::RuntimeException)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir     ThrowIfDisposed();
274cdf0e10cSrcweir 
275cdf0e10cSrcweir     // Early reject paints completely outside the repaint area.
276cdf0e10cSrcweir     if (rRepaintArea.X >= rOuterBorderRectangle.X+rOuterBorderRectangle.Width
277cdf0e10cSrcweir         || rRepaintArea.Y >= rOuterBorderRectangle.Y+rOuterBorderRectangle.Height
278cdf0e10cSrcweir         || rRepaintArea.X+rRepaintArea.Width <= rOuterBorderRectangle.X
279cdf0e10cSrcweir         || rRepaintArea.Y+rRepaintArea.Height <= rOuterBorderRectangle.Y)
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         return;
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir     ProvideTheme(rxCanvas);
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     if (mpRenderer.get() != NULL)
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir         mpRenderer->SetCanvas(rxCanvas);
288cdf0e10cSrcweir         mpRenderer->SetupClipping(
289cdf0e10cSrcweir             rRepaintArea,
290cdf0e10cSrcweir             rOuterBorderRectangle,
291cdf0e10cSrcweir             rsPaneBorderStyleName);
292cdf0e10cSrcweir         mpRenderer->SetCalloutAnchor(rCalloutAnchor);
293cdf0e10cSrcweir         mpRenderer->PaintBorder(
294cdf0e10cSrcweir             rsTitle,
295cdf0e10cSrcweir             rOuterBorderRectangle,
296cdf0e10cSrcweir             rRepaintArea,
297cdf0e10cSrcweir             rsPaneBorderStyleName);
298cdf0e10cSrcweir     }
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 
getCalloutOffset(const rtl::OUString & rsPaneBorderStyleName)304cdf0e10cSrcweir awt::Point SAL_CALL PresenterPaneBorderPainter::getCalloutOffset (
305cdf0e10cSrcweir     const rtl::OUString& rsPaneBorderStyleName)
306cdf0e10cSrcweir     throw(css::uno::RuntimeException)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     ThrowIfDisposed();
309cdf0e10cSrcweir     ProvideTheme();
310cdf0e10cSrcweir     if (mpRenderer.get() != NULL)
311cdf0e10cSrcweir     {
312cdf0e10cSrcweir         const ::boost::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
313cdf0e10cSrcweir             mpRenderer->GetRendererPaneStyle(rsPaneBorderStyleName));
314cdf0e10cSrcweir         if (pRendererPaneStyle.get() != NULL
315cdf0e10cSrcweir             && pRendererPaneStyle->mpBottomCallout.get() != NULL)
316cdf0e10cSrcweir         {
317cdf0e10cSrcweir             return awt::Point (
318cdf0e10cSrcweir                 0,
319cdf0e10cSrcweir                 pRendererPaneStyle->mpBottomCallout->mnHeight
320cdf0e10cSrcweir                     - pRendererPaneStyle->mpBottomCallout->mnYHotSpot);
321cdf0e10cSrcweir         }
322cdf0e10cSrcweir     }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir     return awt::Point(0,0);
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 
330cdf0e10cSrcweir //-----------------------------------------------------------------------------
331cdf0e10cSrcweir 
ProvideTheme(const Reference<rendering::XCanvas> & rxCanvas)332cdf0e10cSrcweir bool PresenterPaneBorderPainter::ProvideTheme (const Reference<rendering::XCanvas>& rxCanvas)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir     bool bModified (false);
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     if ( ! mxContext.is())
337cdf0e10cSrcweir         return false;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     if (mpTheme.get() != NULL)
340cdf0e10cSrcweir     {
341cdf0e10cSrcweir         // Check if the theme already has a canvas.
342cdf0e10cSrcweir         if ( ! mpTheme->HasCanvas())
343cdf0e10cSrcweir         {
344cdf0e10cSrcweir             mpTheme->ProvideCanvas(rxCanvas);
345cdf0e10cSrcweir             bModified = true;
346cdf0e10cSrcweir         }
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir     else
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         mpTheme.reset(new PresenterTheme(mxContext, OUString(), rxCanvas));
351cdf0e10cSrcweir         bModified = true;
352cdf0e10cSrcweir     }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     if (mpTheme.get() != NULL && bModified)
355cdf0e10cSrcweir     {
356cdf0e10cSrcweir         if (mpRenderer.get() == NULL)
357cdf0e10cSrcweir             mpRenderer.reset(new Renderer(mxContext, mpTheme));
358cdf0e10cSrcweir         else
359cdf0e10cSrcweir             mpRenderer->SetCanvas(rxCanvas);
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir     return bModified;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 
ProvideTheme(void)368cdf0e10cSrcweir bool PresenterPaneBorderPainter::ProvideTheme (void)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir     if (mpTheme.get() == NULL)
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         // Create a theme without bitmaps (no canvas => no bitmaps).
373cdf0e10cSrcweir         return ProvideTheme(NULL);
374cdf0e10cSrcweir     }
375cdf0e10cSrcweir     else
376cdf0e10cSrcweir     {
377cdf0e10cSrcweir         // When there already is a theme then without a canvas we can not
378cdf0e10cSrcweir         // add anything new.
379cdf0e10cSrcweir         return false;
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 
HasTheme(void) const386cdf0e10cSrcweir bool PresenterPaneBorderPainter::HasTheme (void) const
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     return mpTheme.get()!=NULL && mpRenderer.get()!=NULL;
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
SetTheme(const::boost::shared_ptr<PresenterTheme> & rpTheme)394cdf0e10cSrcweir void PresenterPaneBorderPainter::SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir     mpTheme = rpTheme;
397cdf0e10cSrcweir     if (mpRenderer.get() == NULL)
398cdf0e10cSrcweir         mpRenderer.reset(new Renderer(mxContext, mpTheme));
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 
AddBorder(const::rtl::OUString & rsPaneURL,const awt::Rectangle & rInnerBox,const css::drawing::framework::BorderType eBorderType) const404cdf0e10cSrcweir awt::Rectangle PresenterPaneBorderPainter::AddBorder (
405cdf0e10cSrcweir     const ::rtl::OUString& rsPaneURL,
406cdf0e10cSrcweir     const awt::Rectangle& rInnerBox,
407cdf0e10cSrcweir     const css::drawing::framework::BorderType eBorderType) const
408cdf0e10cSrcweir {
409cdf0e10cSrcweir     if (mpRenderer.get() != NULL)
410cdf0e10cSrcweir     {
411cdf0e10cSrcweir         const ::boost::shared_ptr<RendererPaneStyle> pRendererPaneStyle(mpRenderer->GetRendererPaneStyle(rsPaneURL));
412cdf0e10cSrcweir         if (pRendererPaneStyle.get() != NULL)
413cdf0e10cSrcweir             return pRendererPaneStyle->AddBorder(rInnerBox, eBorderType);
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir     return rInnerBox;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 
RemoveBorder(const::rtl::OUString & rsPaneURL,const css::awt::Rectangle & rOuterBox,const css::drawing::framework::BorderType eBorderType) const421cdf0e10cSrcweir awt::Rectangle PresenterPaneBorderPainter::RemoveBorder (
422cdf0e10cSrcweir     const ::rtl::OUString& rsPaneURL,
423cdf0e10cSrcweir     const css::awt::Rectangle& rOuterBox,
424cdf0e10cSrcweir     const css::drawing::framework::BorderType eBorderType) const
425cdf0e10cSrcweir {
426cdf0e10cSrcweir     if (mpRenderer.get() != NULL)
427cdf0e10cSrcweir     {
428cdf0e10cSrcweir         const ::boost::shared_ptr<RendererPaneStyle> pRendererPaneStyle(mpRenderer->GetRendererPaneStyle(rsPaneURL));
429cdf0e10cSrcweir         if (pRendererPaneStyle.get() != NULL)
430cdf0e10cSrcweir             return pRendererPaneStyle->RemoveBorder(rOuterBox, eBorderType);
431cdf0e10cSrcweir     }
432cdf0e10cSrcweir     return rOuterBox;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 
ThrowIfDisposed(void) const438cdf0e10cSrcweir void PresenterPaneBorderPainter::ThrowIfDisposed (void) const
439cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
440cdf0e10cSrcweir {
441cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
442cdf0e10cSrcweir 	{
443cdf0e10cSrcweir         throw lang::DisposedException (
444cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
445cdf0e10cSrcweir                 "PresenterPaneBorderPainter object has already been disposed")),
446cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
447cdf0e10cSrcweir     }
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 
453cdf0e10cSrcweir //===== PresenterPaneBorderPainter::Renderer =====================================
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 
Renderer(const Reference<XComponentContext> & rxContext,const::boost::shared_ptr<PresenterTheme> & rpTheme)456cdf0e10cSrcweir PresenterPaneBorderPainter::Renderer::Renderer (
457cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
458cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterTheme>& rpTheme)
459cdf0e10cSrcweir     : mpTheme(rpTheme),
460cdf0e10cSrcweir       maRendererPaneStyles(),
461cdf0e10cSrcweir       mxCanvas(),
462cdf0e10cSrcweir       mxPresenterHelper(),
463cdf0e10cSrcweir       maViewState(geometry::AffineMatrix2D(1,0,0, 0,1,0), NULL),
464cdf0e10cSrcweir       mxViewStateClip(),
465cdf0e10cSrcweir       mbHasCallout(false),
466cdf0e10cSrcweir       maCalloutAnchor()
467cdf0e10cSrcweir {
468cdf0e10cSrcweir     (void)rxContext;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir     Reference<lang::XMultiComponentFactory> xFactory (rxContext->getServiceManager());
471cdf0e10cSrcweir     if (xFactory.is())
472cdf0e10cSrcweir     {
473cdf0e10cSrcweir         mxPresenterHelper = Reference<drawing::XPresenterHelper>(
474cdf0e10cSrcweir             xFactory->createInstanceWithContext(
475cdf0e10cSrcweir                 OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
476cdf0e10cSrcweir                 rxContext),
477cdf0e10cSrcweir             UNO_QUERY_THROW);
478cdf0e10cSrcweir     }
479cdf0e10cSrcweir }
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 
~Renderer(void)484cdf0e10cSrcweir PresenterPaneBorderPainter::Renderer::~Renderer (void)
485cdf0e10cSrcweir {
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 
SetCanvas(const Reference<rendering::XCanvas> & rxCanvas)491cdf0e10cSrcweir void PresenterPaneBorderPainter::Renderer::SetCanvas (const Reference<rendering::XCanvas>& rxCanvas)
492cdf0e10cSrcweir {
493cdf0e10cSrcweir     if (mxCanvas != rxCanvas)
494cdf0e10cSrcweir     {
495cdf0e10cSrcweir         mxCanvas = rxCanvas;
496cdf0e10cSrcweir     }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 
PaintBorder(const OUString & rsTitle,const awt::Rectangle & rBBox,const awt::Rectangle & rUpdateBox,const OUString & rsPaneURL)502cdf0e10cSrcweir void PresenterPaneBorderPainter::Renderer::PaintBorder (
503cdf0e10cSrcweir     const OUString& rsTitle,
504cdf0e10cSrcweir     const awt::Rectangle& rBBox,
505cdf0e10cSrcweir     const awt::Rectangle& rUpdateBox,
506cdf0e10cSrcweir     const OUString& rsPaneURL)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir     if ( ! mxCanvas.is())
509cdf0e10cSrcweir         return;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     // Create the outer and inner border of the, ahm, border.
512cdf0e10cSrcweir     ::boost::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneURL));
513cdf0e10cSrcweir     if (pStyle.get() == NULL)
514cdf0e10cSrcweir         return;
515cdf0e10cSrcweir 
516cdf0e10cSrcweir     awt::Rectangle aOuterBox (rBBox);
517cdf0e10cSrcweir     awt::Rectangle aCenterBox (
518cdf0e10cSrcweir         pStyle->RemoveBorder(aOuterBox, drawing::framework::BorderType_OUTER_BORDER));
519cdf0e10cSrcweir     awt::Rectangle aInnerBox (
520cdf0e10cSrcweir         pStyle->RemoveBorder(aOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     // Prepare references for all used bitmaps.
523cdf0e10cSrcweir     SharedBitmapDescriptor pTop (pStyle->mpTop);
524cdf0e10cSrcweir     SharedBitmapDescriptor pTopLeft (pStyle->mpTopLeft);
525cdf0e10cSrcweir     SharedBitmapDescriptor pTopRight (pStyle->mpTopRight);
526cdf0e10cSrcweir     SharedBitmapDescriptor pLeft (pStyle->mpLeft);
527cdf0e10cSrcweir     SharedBitmapDescriptor pRight (pStyle->mpRight);
528cdf0e10cSrcweir     SharedBitmapDescriptor pBottomLeft (pStyle->mpBottomLeft);
529cdf0e10cSrcweir     SharedBitmapDescriptor pBottomRight (pStyle->mpBottomRight);
530cdf0e10cSrcweir     SharedBitmapDescriptor pBottom (pStyle->mpBottom);
531cdf0e10cSrcweir     SharedBitmapDescriptor pBackground (pStyle->mpBackground);
532cdf0e10cSrcweir 
533cdf0e10cSrcweir     // Paint the sides.
534cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, 0,-1,
535cdf0e10cSrcweir         pTopLeft->mnXOffset, pTopRight->mnXOffset, true, pTop, pBackground);
536cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, -1,0,
537cdf0e10cSrcweir         pTopLeft->mnYOffset, pBottomLeft->mnYOffset, true, pLeft, pBackground);
538cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, +1,0,
539cdf0e10cSrcweir         pTopRight->mnYOffset, pBottomRight->mnYOffset, true, pRight, pBackground);
540cdf0e10cSrcweir     if (mbHasCallout && pStyle->mpBottomCallout->GetNormalBitmap().is())
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         const sal_Int32 nCalloutWidth (pStyle->mpBottomCallout->mnWidth);
543cdf0e10cSrcweir         sal_Int32 nCalloutX (maCalloutAnchor.X - pStyle->mpBottomCallout->mnXHotSpot
544cdf0e10cSrcweir             - (aCenterBox.X - aOuterBox.X));
545cdf0e10cSrcweir         if (nCalloutX < pBottomLeft->mnXOffset + aCenterBox.X)
546cdf0e10cSrcweir             nCalloutX = pBottomLeft->mnXOffset + aCenterBox.X;
547cdf0e10cSrcweir         if (nCalloutX > pBottomRight->mnXOffset + aCenterBox.X + aCenterBox.Width)
548cdf0e10cSrcweir             nCalloutX = pBottomRight->mnXOffset + aCenterBox.X + aCenterBox.Width;
549cdf0e10cSrcweir         // Paint bottom callout.
550cdf0e10cSrcweir         PaintBitmap(aCenterBox, rUpdateBox, 0,+1, nCalloutX,0, false, pStyle->mpBottomCallout, pBackground);
551cdf0e10cSrcweir         // Paint regular bottom bitmap left and right.
552cdf0e10cSrcweir         PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
553cdf0e10cSrcweir             pBottomLeft->mnXOffset, nCalloutX-aCenterBox.Width, true, pBottom, pBackground);
554cdf0e10cSrcweir         PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
555cdf0e10cSrcweir             nCalloutX+nCalloutWidth, pBottomRight->mnXOffset, true, pBottom, pBackground);
556cdf0e10cSrcweir     }
557cdf0e10cSrcweir     else
558cdf0e10cSrcweir     {
559cdf0e10cSrcweir         // Stretch the bottom bitmap over the full width.
560cdf0e10cSrcweir         PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
561cdf0e10cSrcweir             pBottomLeft->mnXOffset, pBottomRight->mnXOffset, true, pBottom, pBackground);
562cdf0e10cSrcweir     }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir     // Paint the corners.
565cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, -1,-1, 0,0, false, pTopLeft, pBackground);
566cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, +1,-1, 0,0, false, pTopRight, pBackground);
567cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, -1,+1, 0,0, false, pBottomLeft, pBackground);
568cdf0e10cSrcweir     PaintBitmap(aCenterBox, rUpdateBox, +1,+1, 0,0, false, pBottomRight, pBackground);
569cdf0e10cSrcweir 
570cdf0e10cSrcweir     // Paint the title.
571cdf0e10cSrcweir     PaintTitle(rsTitle, pStyle, rUpdateBox, aOuterBox, aInnerBox, false);
572cdf0e10cSrcweir 
573cdf0e10cSrcweir     // In a double buffering environment request to make the changes visible.
574cdf0e10cSrcweir     Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
575cdf0e10cSrcweir     if (xSpriteCanvas.is())
576cdf0e10cSrcweir         xSpriteCanvas->updateScreen(sal_False);
577cdf0e10cSrcweir }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 
PaintTitle(const OUString & rsTitle,const::boost::shared_ptr<RendererPaneStyle> & rpStyle,const awt::Rectangle & rUpdateBox,const awt::Rectangle & rOuterBox,const awt::Rectangle & rInnerBox,bool bPaintBackground)582cdf0e10cSrcweir void PresenterPaneBorderPainter::Renderer::PaintTitle (
583cdf0e10cSrcweir     const OUString& rsTitle,
584cdf0e10cSrcweir     const ::boost::shared_ptr<RendererPaneStyle>& rpStyle,
585cdf0e10cSrcweir     const awt::Rectangle& rUpdateBox,
586cdf0e10cSrcweir     const awt::Rectangle& rOuterBox,
587cdf0e10cSrcweir     const awt::Rectangle& rInnerBox,
588cdf0e10cSrcweir     bool bPaintBackground)
589cdf0e10cSrcweir {
590cdf0e10cSrcweir     if ( ! mxCanvas.is())
591cdf0e10cSrcweir         return;
592cdf0e10cSrcweir 
593cdf0e10cSrcweir     if (rsTitle.getLength() == 0)
594cdf0e10cSrcweir         return;
595cdf0e10cSrcweir 
596cdf0e10cSrcweir     Reference<rendering::XCanvasFont> xFont (rpStyle->GetFont(mxCanvas));
597cdf0e10cSrcweir     if ( ! xFont.is())
598cdf0e10cSrcweir         return;
599cdf0e10cSrcweir 
600cdf0e10cSrcweir     rendering::StringContext aContext (
601cdf0e10cSrcweir         rsTitle,
602cdf0e10cSrcweir         0,
603cdf0e10cSrcweir         rsTitle.getLength());
604cdf0e10cSrcweir     Reference<rendering::XTextLayout> xLayout (xFont->createTextLayout(
605cdf0e10cSrcweir         aContext,
606cdf0e10cSrcweir         rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
607cdf0e10cSrcweir         0));
608cdf0e10cSrcweir     if ( ! xLayout.is())
609cdf0e10cSrcweir         return;
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     geometry::RealRectangle2D aBox (xLayout->queryTextBounds());
612cdf0e10cSrcweir     const double nTextHeight = aBox.Y2 - aBox.Y1;
613cdf0e10cSrcweir     const double nTextWidth = aBox.X2 - aBox.X1;
614cdf0e10cSrcweir     double nX = rInnerBox.X + (rInnerBox.Width - nTextWidth)/2;
615cdf0e10cSrcweir     const sal_Int32 nTitleBarHeight = rInnerBox.Y - rOuterBox.Y - 1;
616cdf0e10cSrcweir     double nY = rOuterBox.Y + (nTitleBarHeight - nTextHeight) / 2 - aBox.Y1;
617cdf0e10cSrcweir     if (nY >= rInnerBox.Y)
618cdf0e10cSrcweir         nY = rInnerBox.Y - 1;
619cdf0e10cSrcweir     switch (rpStyle->meFontAnchor)
620cdf0e10cSrcweir     {
621cdf0e10cSrcweir         default:
622cdf0e10cSrcweir         case RendererPaneStyle::AnchorLeft:
623cdf0e10cSrcweir             nX = rInnerBox.X;
624cdf0e10cSrcweir             break;
625cdf0e10cSrcweir         case RendererPaneStyle::AnchorRight:
626cdf0e10cSrcweir             nX = rInnerBox.X + rInnerBox.Width - nTextWidth;
627cdf0e10cSrcweir             break;
628cdf0e10cSrcweir         case RendererPaneStyle::AnchorCenter:
629cdf0e10cSrcweir             nX = rInnerBox.X + (rInnerBox.Width - nTextWidth)/2;
630cdf0e10cSrcweir             break;
631cdf0e10cSrcweir     }
632cdf0e10cSrcweir     nX += rpStyle->mnFontXOffset;
633cdf0e10cSrcweir     nY += rpStyle->mnFontYOffset;
634cdf0e10cSrcweir 
635cdf0e10cSrcweir     if (rUpdateBox.X >= nX+nTextWidth
636cdf0e10cSrcweir         || rUpdateBox.Y >= nY+nTextHeight
637cdf0e10cSrcweir         || rUpdateBox.X+rUpdateBox.Width <= nX
638cdf0e10cSrcweir         || rUpdateBox.Y+rUpdateBox.Height <= nY)
639cdf0e10cSrcweir     {
640cdf0e10cSrcweir         return;
641cdf0e10cSrcweir     }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir     rendering::RenderState aRenderState(
644cdf0e10cSrcweir         geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
645cdf0e10cSrcweir         NULL,
646cdf0e10cSrcweir         Sequence<double>(4),
647cdf0e10cSrcweir         rendering::CompositeOperation::SOURCE);
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     if (bPaintBackground)
650cdf0e10cSrcweir     {
651cdf0e10cSrcweir         PresenterCanvasHelper::SetDeviceColor(aRenderState, util::Color(0x00ffffff));
652cdf0e10cSrcweir         Sequence<Sequence<geometry::RealPoint2D> > aPolygons(1);
653cdf0e10cSrcweir         aPolygons[0] = Sequence<geometry::RealPoint2D>(4);
654cdf0e10cSrcweir         aPolygons[0][0] = geometry::RealPoint2D(0, -nTextHeight);
655cdf0e10cSrcweir         aPolygons[0][1] = geometry::RealPoint2D(0, 0);
656cdf0e10cSrcweir         aPolygons[0][2] = geometry::RealPoint2D(nTextWidth, 0);
657cdf0e10cSrcweir         aPolygons[0][3] = geometry::RealPoint2D(nTextWidth, -nTextHeight);
658cdf0e10cSrcweir         Reference<rendering::XPolyPolygon2D> xPolygon (
659cdf0e10cSrcweir             mxCanvas->getDevice()->createCompatibleLinePolyPolygon(aPolygons), UNO_QUERY);
660cdf0e10cSrcweir         if (xPolygon.is())
661cdf0e10cSrcweir             xPolygon->setClosed(0, sal_True);
662cdf0e10cSrcweir         mxCanvas->fillPolyPolygon(
663cdf0e10cSrcweir             xPolygon,
664cdf0e10cSrcweir             maViewState,
665cdf0e10cSrcweir             aRenderState);
666cdf0e10cSrcweir     }
667cdf0e10cSrcweir     else
668cdf0e10cSrcweir     {
669cdf0e10cSrcweir         PresenterCanvasHelper::SetDeviceColor(
670cdf0e10cSrcweir             aRenderState,
671cdf0e10cSrcweir             rpStyle->mpFont->mnColor);
672cdf0e10cSrcweir 
673cdf0e10cSrcweir         mxCanvas->drawText(
674cdf0e10cSrcweir             aContext,
675cdf0e10cSrcweir             xFont,
676cdf0e10cSrcweir             maViewState,
677cdf0e10cSrcweir             aRenderState,
678cdf0e10cSrcweir             rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
679cdf0e10cSrcweir     }
680cdf0e10cSrcweir }
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 
684cdf0e10cSrcweir ::boost::shared_ptr<RendererPaneStyle>
GetRendererPaneStyle(const OUString & rsResourceURL)685cdf0e10cSrcweir     PresenterPaneBorderPainter::Renderer::GetRendererPaneStyle (const OUString& rsResourceURL)
686cdf0e10cSrcweir {
687cdf0e10cSrcweir     OSL_ASSERT(mpTheme.get()!=NULL);
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     RendererPaneStyleContainer::const_iterator iStyle (maRendererPaneStyles.find(rsResourceURL));
690cdf0e10cSrcweir     if (iStyle == maRendererPaneStyles.end())
691cdf0e10cSrcweir     {
692cdf0e10cSrcweir         OUString sPaneStyleName (OUString::createFromAscii("DefaultRendererPaneStyle"));
693cdf0e10cSrcweir 
694cdf0e10cSrcweir         // Get pane layout name for resource URL.
695cdf0e10cSrcweir         const OUString sStyleName (mpTheme->GetStyleName(rsResourceURL));
696cdf0e10cSrcweir         if (sStyleName.getLength() > 0)
697cdf0e10cSrcweir             sPaneStyleName = sStyleName;
698cdf0e10cSrcweir 
699cdf0e10cSrcweir         // Create a new pane style object and initialize it with bitmaps.
700cdf0e10cSrcweir         ::boost::shared_ptr<RendererPaneStyle> pStyle (
701cdf0e10cSrcweir             new RendererPaneStyle(mpTheme,sPaneStyleName));
702cdf0e10cSrcweir         iStyle = maRendererPaneStyles.insert(
703cdf0e10cSrcweir             RendererPaneStyleContainer::value_type(rsResourceURL, pStyle)).first;
704cdf0e10cSrcweir     }
705cdf0e10cSrcweir     if (iStyle != maRendererPaneStyles.end())
706cdf0e10cSrcweir         return iStyle->second;
707cdf0e10cSrcweir     else
708cdf0e10cSrcweir         return ::boost::shared_ptr<RendererPaneStyle>();
709cdf0e10cSrcweir }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 
SetCalloutAnchor(const awt::Point & rCalloutAnchor)714cdf0e10cSrcweir void PresenterPaneBorderPainter::Renderer::SetCalloutAnchor (
715cdf0e10cSrcweir     const awt::Point& rCalloutAnchor)
716cdf0e10cSrcweir {
717cdf0e10cSrcweir     mbHasCallout = true;
718cdf0e10cSrcweir     maCalloutAnchor = rCalloutAnchor;
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 
PaintBitmap(const awt::Rectangle & rBox,const awt::Rectangle & rUpdateBox,const sal_Int32 nXPosition,const sal_Int32 nYPosition,const sal_Int32 nStartOffset,const sal_Int32 nEndOffset,const bool bExpand,const SharedBitmapDescriptor & rpBitmap,const SharedBitmapDescriptor & rpBackgroundBitmap)724cdf0e10cSrcweir void PresenterPaneBorderPainter::Renderer::PaintBitmap(
725cdf0e10cSrcweir     const awt::Rectangle& rBox,
726cdf0e10cSrcweir     const awt::Rectangle& rUpdateBox,
727cdf0e10cSrcweir     const sal_Int32 nXPosition,
728cdf0e10cSrcweir     const sal_Int32 nYPosition,
729cdf0e10cSrcweir     const sal_Int32 nStartOffset,
730cdf0e10cSrcweir     const sal_Int32 nEndOffset,
731cdf0e10cSrcweir     const bool bExpand,
732cdf0e10cSrcweir     const SharedBitmapDescriptor& rpBitmap,
733cdf0e10cSrcweir     const SharedBitmapDescriptor& rpBackgroundBitmap)
734cdf0e10cSrcweir {
735cdf0e10cSrcweir     (void)rpBackgroundBitmap;
736cdf0e10cSrcweir 
737cdf0e10cSrcweir     bool bUseCanvas (mxCanvas.is());
738cdf0e10cSrcweir     if ( ! bUseCanvas)
739cdf0e10cSrcweir         return;
740cdf0e10cSrcweir 
741cdf0e10cSrcweir     if (rpBitmap->mnWidth<=0 || rpBitmap->mnHeight<=0)
742cdf0e10cSrcweir         return;
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     Reference<rendering::XBitmap> xBitmap (rpBitmap->GetNormalBitmap(), UNO_QUERY);
745cdf0e10cSrcweir     if ( ! xBitmap.is())
746cdf0e10cSrcweir         return;
747cdf0e10cSrcweir 
748cdf0e10cSrcweir     // Calculate position, and for side bitmaps, the size.
749cdf0e10cSrcweir     sal_Int32 nX = 0;
750cdf0e10cSrcweir     sal_Int32 nY = 0;
751cdf0e10cSrcweir     sal_Int32 nW = rpBitmap->mnWidth;
752cdf0e10cSrcweir     sal_Int32 nH = rpBitmap->mnHeight;
753cdf0e10cSrcweir     if (nXPosition < 0)
754cdf0e10cSrcweir     {
755cdf0e10cSrcweir         nX = rBox.X - rpBitmap->mnWidth + rpBitmap->mnXOffset;
756cdf0e10cSrcweir     }
757cdf0e10cSrcweir     else if (nXPosition > 0)
758cdf0e10cSrcweir     {
759cdf0e10cSrcweir         nX = rBox.X + rBox.Width + rpBitmap->mnXOffset;
760cdf0e10cSrcweir     }
761cdf0e10cSrcweir     else
762cdf0e10cSrcweir     {
763cdf0e10cSrcweir         nX = rBox.X + nStartOffset;
764cdf0e10cSrcweir         if (bExpand)
765cdf0e10cSrcweir             nW = rBox.Width - nStartOffset + nEndOffset;
766cdf0e10cSrcweir     }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir     if (nYPosition < 0)
769cdf0e10cSrcweir     {
770cdf0e10cSrcweir         nY = rBox.Y - rpBitmap->mnHeight + rpBitmap->mnYOffset;
771cdf0e10cSrcweir     }
772cdf0e10cSrcweir     else if (nYPosition > 0)
773cdf0e10cSrcweir     {
774cdf0e10cSrcweir         nY = rBox.Y + rBox.Height + rpBitmap->mnYOffset;
775cdf0e10cSrcweir     }
776cdf0e10cSrcweir     else
777cdf0e10cSrcweir     {
778cdf0e10cSrcweir         nY = rBox.Y + nStartOffset;
779cdf0e10cSrcweir         if (bExpand)
780cdf0e10cSrcweir             nH = rBox.Height - nStartOffset + nEndOffset;
781cdf0e10cSrcweir     }
782cdf0e10cSrcweir 
783cdf0e10cSrcweir     // Do not paint when bitmap area does not intersect with update box.
784cdf0e10cSrcweir     if (nX >= rUpdateBox.X + rUpdateBox.Width
785cdf0e10cSrcweir         || nX+nW <= rUpdateBox.X
786cdf0e10cSrcweir         || nY >= rUpdateBox.Y + rUpdateBox.Height
787cdf0e10cSrcweir         || nY+nH <= rUpdateBox.Y)
788cdf0e10cSrcweir     {
789cdf0e10cSrcweir         return;
790cdf0e10cSrcweir     }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir     /*
793cdf0e10cSrcweir     Reference<rendering::XBitmap> xMaskedBitmap (
794cdf0e10cSrcweir         PresenterBitmapHelper::FillMaskedWithColor (
795cdf0e10cSrcweir             mxCanvas,
796cdf0e10cSrcweir             Reference<rendering::XIntegerBitmap>(xBitmap, UNO_QUERY),
797cdf0e10cSrcweir             rBitmap.mxMaskBitmap,
798cdf0e10cSrcweir             0x00ff0000,
799cdf0e10cSrcweir             rBackgroundBitmap.maReplacementColor));
800cdf0e10cSrcweir     if (xMaskedBitmap.is())
801cdf0e10cSrcweir         xBitmap = xMaskedBitmap;
802cdf0e10cSrcweir     else if (rBitmap.mxMaskBitmap.is() && mxPresenterHelper.is())
803cdf0e10cSrcweir     {
804cdf0e10cSrcweir         const static sal_Int32 nOutsideMaskColor (0x00ff0000);
805cdf0e10cSrcweir         Reference<rendering::XIntegerBitmap> xMask (
806cdf0e10cSrcweir             mxPresenterHelper->createMask(
807cdf0e10cSrcweir                 mxCanvas,
808cdf0e10cSrcweir                 rBitmap.mxMaskBitmap,
809cdf0e10cSrcweir                 nOutsideMaskColor,
810cdf0e10cSrcweir                 false));
811cdf0e10cSrcweir         xBitmap = mxPresenterHelper->applyBitmapMaskWithColor(
812cdf0e10cSrcweir             mxCanvas,
813cdf0e10cSrcweir             Reference<rendering::XIntegerBitmap>(xBitmap, UNO_QUERY),
814cdf0e10cSrcweir             xMask,
815cdf0e10cSrcweir             rBackgroundBitmap.maReplacementColor);
816cdf0e10cSrcweir     }
817cdf0e10cSrcweir     */
818cdf0e10cSrcweir     rendering::RenderState aRenderState (
819cdf0e10cSrcweir         geometry::AffineMatrix2D(
820cdf0e10cSrcweir             double(nW)/rpBitmap->mnWidth, 0, nX,
821cdf0e10cSrcweir             0, double(nH)/rpBitmap->mnHeight, nY),
822cdf0e10cSrcweir         NULL,
823cdf0e10cSrcweir         Sequence<double>(4),
824cdf0e10cSrcweir         rendering::CompositeOperation::OVER);
825cdf0e10cSrcweir 
826cdf0e10cSrcweir     if (xBitmap.is())
827cdf0e10cSrcweir         mxCanvas->drawBitmap(
828cdf0e10cSrcweir             xBitmap,
829cdf0e10cSrcweir             maViewState,
830cdf0e10cSrcweir             aRenderState);
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 
SetupClipping(const awt::Rectangle & rUpdateBox,const awt::Rectangle & rOuterBox,const OUString & rsPaneStyleName)836cdf0e10cSrcweir void PresenterPaneBorderPainter::Renderer::SetupClipping (
837cdf0e10cSrcweir     const awt::Rectangle& rUpdateBox,
838cdf0e10cSrcweir     const awt::Rectangle& rOuterBox,
839cdf0e10cSrcweir     const OUString& rsPaneStyleName)
840cdf0e10cSrcweir {
841cdf0e10cSrcweir     mxViewStateClip = NULL;
842cdf0e10cSrcweir     maViewState.Clip = NULL;
843cdf0e10cSrcweir 
844cdf0e10cSrcweir     if ( ! mxCanvas.is())
845cdf0e10cSrcweir         return;
846cdf0e10cSrcweir 
847cdf0e10cSrcweir     ::boost::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneStyleName));
848cdf0e10cSrcweir     if (pStyle.get() == NULL)
849cdf0e10cSrcweir     {
850cdf0e10cSrcweir         mxViewStateClip = PresenterGeometryHelper::CreatePolygon(
851cdf0e10cSrcweir             rUpdateBox,
852cdf0e10cSrcweir             mxCanvas->getDevice());
853cdf0e10cSrcweir     }
854cdf0e10cSrcweir     else
855cdf0e10cSrcweir     {
856cdf0e10cSrcweir         awt::Rectangle aInnerBox (
857cdf0e10cSrcweir             pStyle->RemoveBorder(rOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
858cdf0e10cSrcweir         ::std::vector<awt::Rectangle> aRectangles;
859cdf0e10cSrcweir         aRectangles.push_back(PresenterGeometryHelper::Intersection(rUpdateBox, rOuterBox));
860cdf0e10cSrcweir         aRectangles.push_back(PresenterGeometryHelper::Intersection(rUpdateBox, aInnerBox));
861cdf0e10cSrcweir         mxViewStateClip = PresenterGeometryHelper::CreatePolygon(
862cdf0e10cSrcweir             aRectangles,
863cdf0e10cSrcweir             mxCanvas->getDevice());
864cdf0e10cSrcweir         if (mxViewStateClip.is())
865cdf0e10cSrcweir             mxViewStateClip->setFillRule(rendering::FillRule_EVEN_ODD);
866cdf0e10cSrcweir     }
867cdf0e10cSrcweir     maViewState.Clip = mxViewStateClip;
868cdf0e10cSrcweir }
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 
871cdf0e10cSrcweir 
872cdf0e10cSrcweir namespace {
873cdf0e10cSrcweir 
874cdf0e10cSrcweir //===== BorderSize ============================================================
875cdf0e10cSrcweir 
BorderSize(void)876cdf0e10cSrcweir BorderSize::BorderSize (void)
877cdf0e10cSrcweir     : mnLeft(0),
878cdf0e10cSrcweir       mnTop(0),
879cdf0e10cSrcweir       mnRight(0),
880cdf0e10cSrcweir       mnBottom(0)
881cdf0e10cSrcweir {
882cdf0e10cSrcweir }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 
BorderSize(const BorderSize & rBorderSize)887cdf0e10cSrcweir BorderSize::BorderSize (const BorderSize& rBorderSize)
888cdf0e10cSrcweir     : mnLeft(rBorderSize.mnLeft),
889cdf0e10cSrcweir       mnTop(rBorderSize.mnTop),
890cdf0e10cSrcweir       mnRight(rBorderSize.mnRight),
891cdf0e10cSrcweir       mnBottom(rBorderSize.mnBottom)
892cdf0e10cSrcweir {
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 
operator =(const BorderSize & rBorderSize)898cdf0e10cSrcweir BorderSize& BorderSize::operator= (const BorderSize& rBorderSize)
899cdf0e10cSrcweir {
900cdf0e10cSrcweir     if (&rBorderSize != this)
901cdf0e10cSrcweir     {
902cdf0e10cSrcweir         mnLeft = rBorderSize.mnLeft;
903cdf0e10cSrcweir         mnTop = rBorderSize.mnTop;
904cdf0e10cSrcweir         mnRight = rBorderSize.mnRight;
905cdf0e10cSrcweir         mnBottom = rBorderSize.mnBottom;
906cdf0e10cSrcweir     }
907cdf0e10cSrcweir     return *this;
908cdf0e10cSrcweir }
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 
913cdf0e10cSrcweir //===== RendererPaneStyle  ============================================================
914cdf0e10cSrcweir 
RendererPaneStyle(const::boost::shared_ptr<PresenterTheme> & rpTheme,const OUString & rsStyleName)915cdf0e10cSrcweir RendererPaneStyle::RendererPaneStyle (
916cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterTheme>& rpTheme,
917cdf0e10cSrcweir     const OUString& rsStyleName)
918cdf0e10cSrcweir     : mpTopLeft(),
919cdf0e10cSrcweir       mpTop(),
920cdf0e10cSrcweir       mpTopRight(),
921cdf0e10cSrcweir       mpLeft(),
922cdf0e10cSrcweir       mpRight(),
923cdf0e10cSrcweir       mpBottomLeft(),
924cdf0e10cSrcweir       mpBottom(),
925cdf0e10cSrcweir       mpBottomRight(),
926cdf0e10cSrcweir       mpBottomCallout(),
927cdf0e10cSrcweir       mpBackground(),
928cdf0e10cSrcweir       mpEmpty(new PresenterBitmapDescriptor()),
929cdf0e10cSrcweir       mpFont(),
930cdf0e10cSrcweir       mnFontXOffset(0),
931cdf0e10cSrcweir       mnFontYOffset(0),
932cdf0e10cSrcweir       meFontAnchor(AnchorCenter),
933cdf0e10cSrcweir       maInnerBorderSize(),
934cdf0e10cSrcweir       maOuterBorderSize(),
935cdf0e10cSrcweir       maTotalBorderSize()
936cdf0e10cSrcweir {
937cdf0e10cSrcweir     if (rpTheme.get() != NULL)
938cdf0e10cSrcweir     {
939cdf0e10cSrcweir         mpTopLeft = GetBitmap(rpTheme, rsStyleName, A2S("TopLeft"));
940cdf0e10cSrcweir         mpTop = GetBitmap(rpTheme, rsStyleName,  A2S("Top"));
941cdf0e10cSrcweir         mpTopRight = GetBitmap(rpTheme, rsStyleName,  A2S("TopRight"));
942cdf0e10cSrcweir         mpLeft = GetBitmap(rpTheme, rsStyleName, A2S("Left"));
943cdf0e10cSrcweir         mpRight = GetBitmap(rpTheme, rsStyleName,  A2S("Right"));
944cdf0e10cSrcweir         mpBottomLeft = GetBitmap(rpTheme, rsStyleName, A2S("BottomLeft"));
945cdf0e10cSrcweir         mpBottom = GetBitmap(rpTheme, rsStyleName,  A2S("Bottom"));
946cdf0e10cSrcweir         mpBottomRight = GetBitmap(rpTheme, rsStyleName,  A2S("BottomRight"));
947cdf0e10cSrcweir         mpBottomCallout = GetBitmap(rpTheme, rsStyleName,  A2S("BottomCallout"));
948cdf0e10cSrcweir         mpBackground = GetBitmap(rpTheme, OUString(), A2S("Background"));
949cdf0e10cSrcweir 
950cdf0e10cSrcweir         // Get font description.
951cdf0e10cSrcweir         mpFont = rpTheme->GetFont(rsStyleName);
952cdf0e10cSrcweir 
953cdf0e10cSrcweir         OUString sAnchor (OUString::createFromAscii("Left"));
954cdf0e10cSrcweir         if (mpFont.get() != NULL)
955cdf0e10cSrcweir         {
956cdf0e10cSrcweir             sAnchor = mpFont->msAnchor;
957cdf0e10cSrcweir             mnFontXOffset = mpFont->mnXOffset;
958cdf0e10cSrcweir             mnFontYOffset = mpFont->mnYOffset;
959cdf0e10cSrcweir         }
960cdf0e10cSrcweir 
961cdf0e10cSrcweir         if (sAnchor == OUString::createFromAscii("Left"))
962cdf0e10cSrcweir             meFontAnchor = AnchorLeft;
963cdf0e10cSrcweir         else if (sAnchor == OUString::createFromAscii("Right"))
964cdf0e10cSrcweir             meFontAnchor = AnchorRight;
965cdf0e10cSrcweir         else if (sAnchor == OUString::createFromAscii("Center"))
966cdf0e10cSrcweir             meFontAnchor = AnchorCenter;
967cdf0e10cSrcweir         else
968cdf0e10cSrcweir             meFontAnchor = AnchorCenter;
969cdf0e10cSrcweir 
970cdf0e10cSrcweir         // Get border sizes.
971cdf0e10cSrcweir         try
972cdf0e10cSrcweir         {
973cdf0e10cSrcweir             ::std::vector<sal_Int32> aInnerBorder (rpTheme->GetBorderSize(rsStyleName, false));
974cdf0e10cSrcweir             OSL_ASSERT(aInnerBorder.size()==4);
975cdf0e10cSrcweir             maInnerBorderSize.mnLeft = aInnerBorder[0];
976cdf0e10cSrcweir             maInnerBorderSize.mnTop = aInnerBorder[1];
977cdf0e10cSrcweir             maInnerBorderSize.mnRight = aInnerBorder[2];
978cdf0e10cSrcweir             maInnerBorderSize.mnBottom = aInnerBorder[3];
979cdf0e10cSrcweir 
980cdf0e10cSrcweir             ::std::vector<sal_Int32> aOuterBorder (rpTheme->GetBorderSize(rsStyleName, true));
981cdf0e10cSrcweir             OSL_ASSERT(aOuterBorder.size()==4);
982cdf0e10cSrcweir             maOuterBorderSize.mnLeft = aOuterBorder[0];
983cdf0e10cSrcweir             maOuterBorderSize.mnTop = aOuterBorder[1];
984cdf0e10cSrcweir             maOuterBorderSize.mnRight = aOuterBorder[2];
985cdf0e10cSrcweir             maOuterBorderSize.mnBottom = aOuterBorder[3];
986cdf0e10cSrcweir         }
987cdf0e10cSrcweir         catch(beans::UnknownPropertyException&)
988cdf0e10cSrcweir         {
989cdf0e10cSrcweir             OSL_ASSERT(false);
990cdf0e10cSrcweir         }
991cdf0e10cSrcweir 
992cdf0e10cSrcweir         UpdateBorderSizes();
993cdf0e10cSrcweir     }
994cdf0e10cSrcweir }
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 
998cdf0e10cSrcweir 
999cdf0e10cSrcweir 
AddBorder(const awt::Rectangle & rBox,const drawing::framework::BorderType eBorderType) const1000cdf0e10cSrcweir awt::Rectangle RendererPaneStyle::AddBorder (
1001cdf0e10cSrcweir     const awt::Rectangle& rBox,
1002cdf0e10cSrcweir     const drawing::framework::BorderType eBorderType) const
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir     const BorderSize* pBorderSize = NULL;
1005cdf0e10cSrcweir     switch (eBorderType)
1006cdf0e10cSrcweir     {
1007cdf0e10cSrcweir         case drawing::framework::BorderType_INNER_BORDER:
1008cdf0e10cSrcweir             pBorderSize = &maInnerBorderSize;
1009cdf0e10cSrcweir             break;
1010cdf0e10cSrcweir         case drawing::framework::BorderType_OUTER_BORDER:
1011cdf0e10cSrcweir             pBorderSize = &maOuterBorderSize;
1012cdf0e10cSrcweir             break;
1013cdf0e10cSrcweir         case drawing::framework::BorderType_TOTAL_BORDER:
1014cdf0e10cSrcweir             pBorderSize = &maTotalBorderSize;
1015cdf0e10cSrcweir             break;
1016cdf0e10cSrcweir         default:
1017cdf0e10cSrcweir             return rBox;
1018cdf0e10cSrcweir     }
1019cdf0e10cSrcweir     return awt::Rectangle (
1020cdf0e10cSrcweir         rBox.X - pBorderSize->mnLeft,
1021cdf0e10cSrcweir         rBox.Y - pBorderSize->mnTop,
1022cdf0e10cSrcweir         rBox.Width + pBorderSize->mnLeft + pBorderSize->mnRight,
1023cdf0e10cSrcweir         rBox.Height + pBorderSize->mnTop + pBorderSize->mnBottom);
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 
RemoveBorder(const awt::Rectangle & rBox,const css::drawing::framework::BorderType eBorderType) const1029cdf0e10cSrcweir awt::Rectangle RendererPaneStyle::RemoveBorder (
1030cdf0e10cSrcweir     const awt::Rectangle& rBox,
1031cdf0e10cSrcweir     const css::drawing::framework::BorderType eBorderType) const
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir     const BorderSize* pBorderSize = NULL;
1034cdf0e10cSrcweir     switch (eBorderType)
1035cdf0e10cSrcweir     {
1036cdf0e10cSrcweir         case drawing::framework::BorderType_INNER_BORDER:
1037cdf0e10cSrcweir             pBorderSize = &maInnerBorderSize;
1038cdf0e10cSrcweir             break;
1039cdf0e10cSrcweir         case drawing::framework::BorderType_OUTER_BORDER:
1040cdf0e10cSrcweir             pBorderSize = &maOuterBorderSize;
1041cdf0e10cSrcweir             break;
1042cdf0e10cSrcweir         case drawing::framework::BorderType_TOTAL_BORDER:
1043cdf0e10cSrcweir             pBorderSize = &maTotalBorderSize;
1044cdf0e10cSrcweir             break;
1045cdf0e10cSrcweir         default:
1046cdf0e10cSrcweir             return rBox;
1047cdf0e10cSrcweir     }
1048cdf0e10cSrcweir     return awt::Rectangle (
1049cdf0e10cSrcweir         rBox.X + pBorderSize->mnLeft,
1050cdf0e10cSrcweir         rBox.Y + pBorderSize->mnTop,
1051cdf0e10cSrcweir         rBox.Width - pBorderSize->mnLeft - pBorderSize->mnRight,
1052cdf0e10cSrcweir         rBox.Height - pBorderSize->mnTop - pBorderSize->mnBottom);
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 
GetFont(const Reference<rendering::XCanvas> & rxCanvas) const1058cdf0e10cSrcweir const Reference<rendering::XCanvasFont> RendererPaneStyle::GetFont (
1059cdf0e10cSrcweir     const Reference<rendering::XCanvas>& rxCanvas) const
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir     if (mpFont.get() != NULL)
1062cdf0e10cSrcweir         mpFont->PrepareFont(rxCanvas);
1063cdf0e10cSrcweir     return mpFont->mxFont;
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir 
UpdateBorderSizes(void)1069cdf0e10cSrcweir void RendererPaneStyle::UpdateBorderSizes (void)
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir     maTotalBorderSize.mnLeft = maInnerBorderSize.mnLeft + maOuterBorderSize.mnLeft;
1072cdf0e10cSrcweir     maTotalBorderSize.mnTop = maInnerBorderSize.mnTop + maOuterBorderSize.mnTop;
1073cdf0e10cSrcweir     maTotalBorderSize.mnRight = maInnerBorderSize.mnRight + maOuterBorderSize.mnRight;
1074cdf0e10cSrcweir     maTotalBorderSize.mnBottom = maInnerBorderSize.mnBottom + maOuterBorderSize.mnBottom;
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir 
GetBitmap(const::boost::shared_ptr<PresenterTheme> & rpTheme,const OUString & rsStyleName,const OUString & rsBitmapName)1080cdf0e10cSrcweir SharedBitmapDescriptor RendererPaneStyle::GetBitmap(
1081cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterTheme>& rpTheme,
1082cdf0e10cSrcweir     const OUString& rsStyleName,
1083cdf0e10cSrcweir     const OUString& rsBitmapName)
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir     SharedBitmapDescriptor pDescriptor (rpTheme->GetBitmap(rsStyleName, rsBitmapName));
1086cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
1087cdf0e10cSrcweir         return pDescriptor;
1088cdf0e10cSrcweir     else
1089cdf0e10cSrcweir         return mpEmpty;
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir } // end of anonymous namespace
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir } } // end of namespace ::sd::presenter
1098