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