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