1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "PresenterPaneBorderPainter.hxx"
21 #include "PresenterCanvasHelper.hxx"
22 #include "PresenterGeometryHelper.hxx"
23 #include "PresenterTheme.hxx"
24 #include <com/sun/star/awt/Point.hpp>
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/drawing/XPresenterHelper.hpp>
27 #include <com/sun/star/rendering/CompositeOperation.hpp>
28 #include <com/sun/star/rendering/FillRule.hpp>
29 #include <com/sun/star/rendering/TextDirection.hpp>
30 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
36 using namespace ::com::sun::star
;
37 using namespace ::com::sun::star::uno
;
39 namespace sdext::presenter
{
52 class RendererPaneStyle
56 const std::shared_ptr
<PresenterTheme
>& rpTheme
,
57 const OUString
& rsStyleName
);
59 awt::Rectangle
AddBorder (
60 const awt::Rectangle
& rBox
,
61 drawing::framework::BorderType eBorderType
) const;
62 awt::Rectangle
RemoveBorder (
63 const awt::Rectangle
& rBox
,
64 drawing::framework::BorderType eBorderType
) const;
65 Reference
<rendering::XCanvasFont
> GetFont (
66 const Reference
<rendering::XCanvas
>& rxCanvas
) const;
68 SharedBitmapDescriptor mpTopLeft
;
69 SharedBitmapDescriptor mpTop
;
70 SharedBitmapDescriptor mpTopRight
;
71 SharedBitmapDescriptor mpLeft
;
72 SharedBitmapDescriptor mpRight
;
73 SharedBitmapDescriptor mpBottomLeft
;
74 SharedBitmapDescriptor mpBottom
;
75 SharedBitmapDescriptor mpBottomRight
;
76 SharedBitmapDescriptor mpBottomCallout
;
77 SharedBitmapDescriptor mpEmpty
;
78 PresenterTheme::SharedFontDescriptor mpFont
;
79 sal_Int32 mnFontXOffset
;
80 sal_Int32 mnFontYOffset
;
81 enum class Anchor
{ Left
, Right
, Center
};
83 BorderSize maInnerBorderSize
;
84 BorderSize maOuterBorderSize
;
85 BorderSize maTotalBorderSize
;
87 void UpdateBorderSizes();
88 SharedBitmapDescriptor
GetBitmap(
89 const std::shared_ptr
<PresenterTheme
>& rpTheme
,
90 const OUString
& rsStyleName
,
91 const OUString
& rsBitmapName
);
95 class PresenterPaneBorderPainter::Renderer
99 const Reference
<XComponentContext
>& rxContext
,
100 std::shared_ptr
<PresenterTheme
> xTheme
);
102 void SetCanvas (const Reference
<rendering::XCanvas
>& rxCanvas
);
104 const OUString
& rsTitle
,
105 const awt::Rectangle
& rBBox
,
106 const awt::Rectangle
& rUpdateBox
,
107 const OUString
& rsPaneURL
);
109 const OUString
& rsTitle
,
110 const std::shared_ptr
<RendererPaneStyle
>& rpStyle
,
111 const awt::Rectangle
& rUpdateBox
,
112 const awt::Rectangle
& rOuterBox
,
113 const awt::Rectangle
& rInnerBox
);
115 const awt::Rectangle
& rUpdateBox
,
116 const awt::Rectangle
& rOuterBox
,
117 const OUString
& rsPaneStyleName
);
118 std::shared_ptr
<RendererPaneStyle
> GetRendererPaneStyle (const OUString
& rsResourceURL
);
119 void SetCalloutAnchor (
120 const awt::Point
& rCalloutAnchor
);
123 std::shared_ptr
<PresenterTheme
> mpTheme
;
124 typedef ::std::map
<OUString
, std::shared_ptr
<RendererPaneStyle
> > RendererPaneStyleContainer
;
125 RendererPaneStyleContainer maRendererPaneStyles
;
126 Reference
<rendering::XCanvas
> mxCanvas
;
127 Reference
<drawing::XPresenterHelper
> mxPresenterHelper
;
128 css::rendering::ViewState maViewState
;
129 Reference
<rendering::XPolyPolygon2D
> mxViewStateClip
;
131 awt::Point maCalloutAnchor
;
134 const awt::Rectangle
& rBox
,
135 const awt::Rectangle
& rUpdateBox
,
136 const sal_Int32 nXPosition
,
137 const sal_Int32 nYPosition
,
138 const sal_Int32 nStartOffset
,
139 const sal_Int32 nEndOffset
,
141 const SharedBitmapDescriptor
& rpBitmap
);
144 // ===== PresenterPaneBorderPainter ===========================================
146 PresenterPaneBorderPainter::PresenterPaneBorderPainter (
147 const Reference
<XComponentContext
>& rxContext
)
148 : PresenterPaneBorderPainterInterfaceBase(m_aMutex
),
153 PresenterPaneBorderPainter::~PresenterPaneBorderPainter()
157 //----- XPaneBorderPainter ----------------------------------------------------
159 awt::Rectangle SAL_CALL
PresenterPaneBorderPainter::addBorder (
160 const OUString
& rsPaneBorderStyleName
,
161 const css::awt::Rectangle
& rRectangle
,
162 drawing::framework::BorderType eBorderType
)
168 return AddBorder(rsPaneBorderStyleName
, rRectangle
, eBorderType
);
171 awt::Rectangle SAL_CALL
PresenterPaneBorderPainter::removeBorder (
172 const OUString
& rsPaneBorderStyleName
,
173 const css::awt::Rectangle
& rRectangle
,
174 drawing::framework::BorderType eBorderType
)
180 return RemoveBorder(rsPaneBorderStyleName
, rRectangle
, eBorderType
);
183 void SAL_CALL
PresenterPaneBorderPainter::paintBorder (
184 const OUString
& rsPaneBorderStyleName
,
185 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
186 const css::awt::Rectangle
& rOuterBorderRectangle
,
187 const css::awt::Rectangle
& rRepaintArea
,
188 const OUString
& rsTitle
)
192 // Early reject paints completely outside the repaint area.
193 if (rRepaintArea
.X
>= rOuterBorderRectangle
.X
+rOuterBorderRectangle
.Width
194 || rRepaintArea
.Y
>= rOuterBorderRectangle
.Y
+rOuterBorderRectangle
.Height
195 || rRepaintArea
.X
+rRepaintArea
.Width
<= rOuterBorderRectangle
.X
196 || rRepaintArea
.Y
+rRepaintArea
.Height
<= rOuterBorderRectangle
.Y
)
200 ProvideTheme(rxCanvas
);
202 if (mpRenderer
== nullptr)
205 mpRenderer
->SetCanvas(rxCanvas
);
206 mpRenderer
->SetupClipping(
208 rOuterBorderRectangle
,
209 rsPaneBorderStyleName
);
210 mpRenderer
->PaintBorder(
212 rOuterBorderRectangle
,
214 rsPaneBorderStyleName
);
217 void SAL_CALL
PresenterPaneBorderPainter::paintBorderWithCallout (
218 const OUString
& rsPaneBorderStyleName
,
219 const css::uno::Reference
<css::rendering::XCanvas
>& rxCanvas
,
220 const css::awt::Rectangle
& rOuterBorderRectangle
,
221 const css::awt::Rectangle
& rRepaintArea
,
222 const OUString
& rsTitle
,
223 const css::awt::Point
& rCalloutAnchor
)
227 // Early reject paints completely outside the repaint area.
228 if (rRepaintArea
.X
>= rOuterBorderRectangle
.X
+rOuterBorderRectangle
.Width
229 || rRepaintArea
.Y
>= rOuterBorderRectangle
.Y
+rOuterBorderRectangle
.Height
230 || rRepaintArea
.X
+rRepaintArea
.Width
<= rOuterBorderRectangle
.X
231 || rRepaintArea
.Y
+rRepaintArea
.Height
<= rOuterBorderRectangle
.Y
)
235 ProvideTheme(rxCanvas
);
237 if (mpRenderer
== nullptr)
240 mpRenderer
->SetCanvas(rxCanvas
);
241 mpRenderer
->SetupClipping(
243 rOuterBorderRectangle
,
244 rsPaneBorderStyleName
);
245 mpRenderer
->SetCalloutAnchor(rCalloutAnchor
);
246 mpRenderer
->PaintBorder(
248 rOuterBorderRectangle
,
250 rsPaneBorderStyleName
);
253 awt::Point SAL_CALL
PresenterPaneBorderPainter::getCalloutOffset (
254 const OUString
& rsPaneBorderStyleName
)
258 if (mpRenderer
!= nullptr)
260 const std::shared_ptr
<RendererPaneStyle
> pRendererPaneStyle(
261 mpRenderer
->GetRendererPaneStyle(rsPaneBorderStyleName
));
262 if (pRendererPaneStyle
!= nullptr && pRendererPaneStyle
->mpBottomCallout
)
266 pRendererPaneStyle
->mpBottomCallout
->mnHeight
267 - pRendererPaneStyle
->mpBottomCallout
->mnYHotSpot
);
271 return awt::Point(0,0);
275 bool PresenterPaneBorderPainter::ProvideTheme (const Reference
<rendering::XCanvas
>& rxCanvas
)
277 bool bModified (false);
279 if ( ! mxContext
.is())
282 if (mpTheme
!= nullptr)
284 // Check if the theme already has a canvas.
285 if ( ! mpTheme
->HasCanvas())
287 mpTheme
->ProvideCanvas(rxCanvas
);
293 mpTheme
= std::make_shared
<PresenterTheme
>(mxContext
, rxCanvas
);
299 if (mpRenderer
== nullptr)
300 mpRenderer
.reset(new Renderer(mxContext
, mpTheme
));
302 mpRenderer
->SetCanvas(rxCanvas
);
308 void PresenterPaneBorderPainter::ProvideTheme()
310 if (mpTheme
== nullptr)
312 // Create a theme without bitmaps (no canvas => no bitmaps).
313 ProvideTheme(nullptr);
315 // When there already is a theme then without a canvas we can not
319 void PresenterPaneBorderPainter::SetTheme (const std::shared_ptr
<PresenterTheme
>& rpTheme
)
322 if (mpRenderer
== nullptr)
323 mpRenderer
.reset(new Renderer(mxContext
, mpTheme
));
326 awt::Rectangle
PresenterPaneBorderPainter::AddBorder (
327 const OUString
& rsPaneURL
,
328 const awt::Rectangle
& rInnerBox
,
329 const css::drawing::framework::BorderType eBorderType
) const
331 if (mpRenderer
!= nullptr)
333 const std::shared_ptr
<RendererPaneStyle
> pRendererPaneStyle(mpRenderer
->GetRendererPaneStyle(rsPaneURL
));
334 if (pRendererPaneStyle
!= nullptr)
335 return pRendererPaneStyle
->AddBorder(rInnerBox
, eBorderType
);
340 awt::Rectangle
PresenterPaneBorderPainter::RemoveBorder (
341 const OUString
& rsPaneURL
,
342 const css::awt::Rectangle
& rOuterBox
,
343 const css::drawing::framework::BorderType eBorderType
) const
345 if (mpRenderer
!= nullptr)
347 const std::shared_ptr
<RendererPaneStyle
> pRendererPaneStyle(mpRenderer
->GetRendererPaneStyle(rsPaneURL
));
348 if (pRendererPaneStyle
!= nullptr)
349 return pRendererPaneStyle
->RemoveBorder(rOuterBox
, eBorderType
);
354 void PresenterPaneBorderPainter::ThrowIfDisposed() const
356 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
358 throw lang::DisposedException (
359 "PresenterPaneBorderPainter object has already been disposed",
360 const_cast<uno::XWeak
*>(static_cast<const uno::XWeak
*>(this)));
364 //===== PresenterPaneBorderPainter::Renderer =====================================
366 PresenterPaneBorderPainter::Renderer::Renderer (
367 const Reference
<XComponentContext
>& rxContext
,
368 std::shared_ptr
<PresenterTheme
> xTheme
)
369 : mpTheme(std::move(xTheme
)),
370 maViewState(geometry::AffineMatrix2D(1,0,0, 0,1,0), nullptr),
373 Reference
<lang::XMultiComponentFactory
> xFactory (rxContext
->getServiceManager());
376 mxPresenterHelper
.set(
377 xFactory
->createInstanceWithContext(
378 "com.sun.star.comp.Draw.PresenterHelper",
384 void PresenterPaneBorderPainter::Renderer::SetCanvas (const Reference
<rendering::XCanvas
>& rxCanvas
)
386 if (mxCanvas
!= rxCanvas
)
392 void PresenterPaneBorderPainter::Renderer::PaintBorder (
393 const OUString
& rsTitle
,
394 const awt::Rectangle
& rBBox
,
395 const awt::Rectangle
& rUpdateBox
,
396 const OUString
& rsPaneURL
)
398 if ( ! mxCanvas
.is())
401 // Create the outer and inner border of the, ahm, border.
402 std::shared_ptr
<RendererPaneStyle
> pStyle (GetRendererPaneStyle(rsPaneURL
));
403 if (pStyle
== nullptr)
406 awt::Rectangle
aOuterBox (rBBox
);
407 awt::Rectangle
aCenterBox (
408 pStyle
->RemoveBorder(aOuterBox
, drawing::framework::BorderType_OUTER_BORDER
));
409 awt::Rectangle
aInnerBox (
410 pStyle
->RemoveBorder(aOuterBox
, drawing::framework::BorderType_TOTAL_BORDER
));
412 // Prepare references for all used bitmaps.
413 SharedBitmapDescriptor
pTop (pStyle
->mpTop
);
414 SharedBitmapDescriptor
pTopLeft (pStyle
->mpTopLeft
);
415 SharedBitmapDescriptor
pTopRight (pStyle
->mpTopRight
);
416 SharedBitmapDescriptor
pLeft (pStyle
->mpLeft
);
417 SharedBitmapDescriptor
pRight (pStyle
->mpRight
);
418 SharedBitmapDescriptor
pBottomLeft (pStyle
->mpBottomLeft
);
419 SharedBitmapDescriptor
pBottomRight (pStyle
->mpBottomRight
);
420 SharedBitmapDescriptor
pBottom (pStyle
->mpBottom
);
423 PaintBitmap(aCenterBox
, rUpdateBox
, 0,-1,
424 pTopLeft
->mnXOffset
, pTopRight
->mnXOffset
, true, pTop
);
425 PaintBitmap(aCenterBox
, rUpdateBox
, -1,0,
426 pTopLeft
->mnYOffset
, pBottomLeft
->mnYOffset
, true, pLeft
);
427 PaintBitmap(aCenterBox
, rUpdateBox
, +1,0,
428 pTopRight
->mnYOffset
, pBottomRight
->mnYOffset
, true, pRight
);
429 if (mbHasCallout
&& pStyle
->mpBottomCallout
->GetNormalBitmap().is())
431 const sal_Int32
nCalloutWidth (pStyle
->mpBottomCallout
->mnWidth
);
432 sal_Int32
nCalloutX (maCalloutAnchor
.X
- pStyle
->mpBottomCallout
->mnXHotSpot
433 - (aCenterBox
.X
- aOuterBox
.X
));
434 if (nCalloutX
< pBottomLeft
->mnXOffset
+ aCenterBox
.X
)
435 nCalloutX
= pBottomLeft
->mnXOffset
+ aCenterBox
.X
;
436 if (nCalloutX
> pBottomRight
->mnXOffset
+ aCenterBox
.X
+ aCenterBox
.Width
)
437 nCalloutX
= pBottomRight
->mnXOffset
+ aCenterBox
.X
+ aCenterBox
.Width
;
438 // Paint bottom callout.
439 PaintBitmap(aCenterBox
, rUpdateBox
, 0,+1, nCalloutX
,0, false, pStyle
->mpBottomCallout
);
440 // Paint regular bottom bitmap left and right.
441 PaintBitmap(aCenterBox
, rUpdateBox
, 0,+1,
442 pBottomLeft
->mnXOffset
, nCalloutX
-aCenterBox
.Width
, true, pBottom
);
443 PaintBitmap(aCenterBox
, rUpdateBox
, 0,+1,
444 nCalloutX
+nCalloutWidth
, pBottomRight
->mnXOffset
, true, pBottom
);
448 // Stretch the bottom bitmap over the full width.
449 PaintBitmap(aCenterBox
, rUpdateBox
, 0,+1,
450 pBottomLeft
->mnXOffset
, pBottomRight
->mnXOffset
, true, pBottom
);
453 // Paint the corners.
454 PaintBitmap(aCenterBox
, rUpdateBox
, -1,-1, 0,0, false, pTopLeft
);
455 PaintBitmap(aCenterBox
, rUpdateBox
, +1,-1, 0,0, false, pTopRight
);
456 PaintBitmap(aCenterBox
, rUpdateBox
, -1,+1, 0,0, false, pBottomLeft
);
457 PaintBitmap(aCenterBox
, rUpdateBox
, +1,+1, 0,0, false, pBottomRight
);
460 PaintTitle(rsTitle
, pStyle
, rUpdateBox
, aOuterBox
, aInnerBox
);
462 // In a double buffering environment request to make the changes visible.
463 Reference
<rendering::XSpriteCanvas
> xSpriteCanvas (mxCanvas
, UNO_QUERY
);
464 if (xSpriteCanvas
.is())
465 xSpriteCanvas
->updateScreen(false);
468 void PresenterPaneBorderPainter::Renderer::PaintTitle (
469 const OUString
& rsTitle
,
470 const std::shared_ptr
<RendererPaneStyle
>& rpStyle
,
471 const awt::Rectangle
& rUpdateBox
,
472 const awt::Rectangle
& rOuterBox
,
473 const awt::Rectangle
& rInnerBox
)
475 if ( ! mxCanvas
.is())
478 if (rsTitle
.isEmpty())
481 Reference
<rendering::XCanvasFont
> xFont (rpStyle
->GetFont(mxCanvas
));
485 rendering::StringContext
aContext (
488 rsTitle
.getLength());
489 Reference
<rendering::XTextLayout
> xLayout (xFont
->createTextLayout(
491 rendering::TextDirection::WEAK_LEFT_TO_RIGHT
,
496 /// this is responsible of the texts above the slide windows
497 geometry::RealRectangle2D
aBox (xLayout
->queryTextBounds());
498 const double nTextHeight
= aBox
.Y2
- aBox
.Y1
;
499 const double nTextWidth
= aBox
.X1
+ aBox
.X2
;
500 const sal_Int32 nTitleBarHeight
= rInnerBox
.Y
- rOuterBox
.Y
- 1;
501 double nY
= rOuterBox
.Y
+ (nTitleBarHeight
- nTextHeight
) / 2 - aBox
.Y1
;
502 if (nY
>= rInnerBox
.Y
)
503 nY
= rInnerBox
.Y
- 1;
505 switch (rpStyle
->meFontAnchor
)
507 case RendererPaneStyle::Anchor::Left
:
510 case RendererPaneStyle::Anchor::Right
:
511 nX
= rInnerBox
.X
+ rInnerBox
.Width
- nTextWidth
;
513 default: // RendererPaneStyle::Anchor::Center
514 nX
= rInnerBox
.X
+ (rInnerBox
.Width
- nTextWidth
)/2;
517 nX
+= rpStyle
->mnFontXOffset
;
518 nY
+= rpStyle
->mnFontYOffset
;
520 if (rUpdateBox
.X
>= nX
+nTextWidth
521 || rUpdateBox
.Y
>= nY
+nTextHeight
522 || rUpdateBox
.X
+rUpdateBox
.Width
<= nX
523 || rUpdateBox
.Y
+rUpdateBox
.Height
<= nY
)
528 rendering::RenderState
aRenderState(
529 geometry::AffineMatrix2D(1,0,nX
, 0,1,nY
),
532 rendering::CompositeOperation::SOURCE
);
534 PresenterCanvasHelper::SetDeviceColor(
536 rpStyle
->mpFont
->mnColor
);
538 mxCanvas
->drawTextLayout (
544 std::shared_ptr
<RendererPaneStyle
>
545 PresenterPaneBorderPainter::Renderer::GetRendererPaneStyle (const OUString
& rsResourceURL
)
547 OSL_ASSERT(mpTheme
!= nullptr);
549 RendererPaneStyleContainer::const_iterator
iStyle (maRendererPaneStyles
.find(rsResourceURL
));
550 if (iStyle
== maRendererPaneStyles
.end())
552 OUString
sPaneStyleName ("DefaultRendererPaneStyle");
554 // Get pane layout name for resource URL.
555 const OUString
sStyleName (mpTheme
->GetStyleName(rsResourceURL
));
556 if (!sStyleName
.isEmpty())
557 sPaneStyleName
= sStyleName
;
559 // Create a new pane style object and initialize it with bitmaps.
560 auto pStyle
= std::make_shared
<RendererPaneStyle
>(mpTheme
,sPaneStyleName
);
561 iStyle
= maRendererPaneStyles
.emplace(rsResourceURL
, pStyle
).first
;
563 if (iStyle
!= maRendererPaneStyles
.end())
564 return iStyle
->second
;
566 return std::shared_ptr
<RendererPaneStyle
>();
569 void PresenterPaneBorderPainter::Renderer::SetCalloutAnchor (
570 const awt::Point
& rCalloutAnchor
)
573 maCalloutAnchor
= rCalloutAnchor
;
576 void PresenterPaneBorderPainter::Renderer::PaintBitmap(
577 const awt::Rectangle
& rBox
,
578 const awt::Rectangle
& rUpdateBox
,
579 const sal_Int32 nXPosition
,
580 const sal_Int32 nYPosition
,
581 const sal_Int32 nStartOffset
,
582 const sal_Int32 nEndOffset
,
584 const SharedBitmapDescriptor
& rpBitmap
)
586 bool bUseCanvas (mxCanvas
.is());
590 if (rpBitmap
->mnWidth
<=0 || rpBitmap
->mnHeight
<=0)
593 Reference
<rendering::XBitmap
> xBitmap
= rpBitmap
->GetNormalBitmap();
597 // Calculate position, and for side bitmaps, the size.
600 sal_Int32 nW
= rpBitmap
->mnWidth
;
601 sal_Int32 nH
= rpBitmap
->mnHeight
;
604 nX
= rBox
.X
- rpBitmap
->mnWidth
+ rpBitmap
->mnXOffset
;
606 else if (nXPosition
> 0)
608 nX
= rBox
.X
+ rBox
.Width
+ rpBitmap
->mnXOffset
;
612 nX
= rBox
.X
+ nStartOffset
;
614 nW
= rBox
.Width
- nStartOffset
+ nEndOffset
;
619 nY
= rBox
.Y
- rpBitmap
->mnHeight
+ rpBitmap
->mnYOffset
;
621 else if (nYPosition
> 0)
623 nY
= rBox
.Y
+ rBox
.Height
+ rpBitmap
->mnYOffset
;
627 nY
= rBox
.Y
+ nStartOffset
;
629 nH
= rBox
.Height
- nStartOffset
+ nEndOffset
;
632 // Do not paint when bitmap area does not intersect with update box.
633 if (nX
>= rUpdateBox
.X
+ rUpdateBox
.Width
634 || nX
+nW
<= rUpdateBox
.X
635 || nY
>= rUpdateBox
.Y
+ rUpdateBox
.Height
636 || nY
+nH
<= rUpdateBox
.Y
)
642 Reference<rendering::XBitmap> xMaskedBitmap (
643 PresenterBitmapHelper::FillMaskedWithColor (
645 Reference<rendering::XIntegerBitmap>(xBitmap, UNO_QUERY),
646 rBitmap.mxMaskBitmap,
648 rBackgroundBitmap.maReplacementColor));
649 if (xMaskedBitmap.is())
650 xBitmap = xMaskedBitmap;
651 else if (rBitmap.mxMaskBitmap.is() && mxPresenterHelper.is())
653 const static sal_Int32 nOutsideMaskColor (0x00ff0000);
654 Reference<rendering::XIntegerBitmap> xMask (
655 mxPresenterHelper->createMask(
657 rBitmap.mxMaskBitmap,
660 xBitmap = mxPresenterHelper->applyBitmapMaskWithColor(
662 Reference<rendering::XIntegerBitmap>(xBitmap, UNO_QUERY),
664 rBackgroundBitmap.maReplacementColor);
667 rendering::RenderState
aRenderState (
668 geometry::AffineMatrix2D(
669 double(nW
)/rpBitmap
->mnWidth
, 0, nX
,
670 0, double(nH
)/rpBitmap
->mnHeight
, nY
),
673 rendering::CompositeOperation::OVER
);
676 mxCanvas
->drawBitmap(
682 void PresenterPaneBorderPainter::Renderer::SetupClipping (
683 const awt::Rectangle
& rUpdateBox
,
684 const awt::Rectangle
& rOuterBox
,
685 const OUString
& rsPaneStyleName
)
687 mxViewStateClip
= nullptr;
688 maViewState
.Clip
= nullptr;
690 if ( ! mxCanvas
.is())
693 std::shared_ptr
<RendererPaneStyle
> pStyle (GetRendererPaneStyle(rsPaneStyleName
));
694 if (pStyle
== nullptr)
696 mxViewStateClip
= PresenterGeometryHelper::CreatePolygon(
698 mxCanvas
->getDevice());
702 awt::Rectangle
aInnerBox (
703 pStyle
->RemoveBorder(rOuterBox
, drawing::framework::BorderType_TOTAL_BORDER
));
704 ::std::vector
<awt::Rectangle
> aRectangles
706 PresenterGeometryHelper::Intersection(rUpdateBox
, rOuterBox
),
707 PresenterGeometryHelper::Intersection(rUpdateBox
, aInnerBox
)
709 mxViewStateClip
= PresenterGeometryHelper::CreatePolygon(
711 mxCanvas
->getDevice());
712 if (mxViewStateClip
.is())
713 mxViewStateClip
->setFillRule(rendering::FillRule_EVEN_ODD
);
715 maViewState
.Clip
= mxViewStateClip
;
720 //===== BorderSize ============================================================
722 BorderSize::BorderSize()
730 //===== RendererPaneStyle ============================================================
732 RendererPaneStyle::RendererPaneStyle (
733 const std::shared_ptr
<PresenterTheme
>& rpTheme
,
734 const OUString
& rsStyleName
)
735 : mpEmpty(std::make_shared
<PresenterBitmapDescriptor
>()),
738 meFontAnchor(Anchor::Center
)
740 if (rpTheme
== nullptr)
743 mpTopLeft
= GetBitmap(rpTheme
, rsStyleName
, "TopLeft");
744 mpTop
= GetBitmap(rpTheme
, rsStyleName
, "Top");
745 mpTopRight
= GetBitmap(rpTheme
, rsStyleName
, "TopRight");
746 mpLeft
= GetBitmap(rpTheme
, rsStyleName
,"Left");
747 mpRight
= GetBitmap(rpTheme
, rsStyleName
, "Right");
748 mpBottomLeft
= GetBitmap(rpTheme
, rsStyleName
, "BottomLeft");
749 mpBottom
= GetBitmap(rpTheme
, rsStyleName
, "Bottom");
750 mpBottomRight
= GetBitmap(rpTheme
, rsStyleName
, "BottomRight");
751 mpBottomCallout
= GetBitmap(rpTheme
, rsStyleName
, "BottomCallout");
753 // Get font description.
754 mpFont
= rpTheme
->GetFont(rsStyleName
);
756 OUString
sAnchor ("Left");
759 sAnchor
= mpFont
->msAnchor
;
760 mnFontXOffset
= mpFont
->mnXOffset
;
761 mnFontYOffset
= mpFont
->mnYOffset
;
764 if ( sAnchor
== "Left" )
765 meFontAnchor
= Anchor::Left
;
766 else if ( sAnchor
== "Right" )
767 meFontAnchor
= Anchor::Right
;
769 meFontAnchor
= Anchor::Center
;
774 ::std::vector
<sal_Int32
> aInnerBorder (rpTheme
->GetBorderSize(rsStyleName
, false));
775 OSL_ASSERT(aInnerBorder
.size()==4);
776 maInnerBorderSize
.mnLeft
= aInnerBorder
[0];
777 maInnerBorderSize
.mnTop
= aInnerBorder
[1];
778 maInnerBorderSize
.mnRight
= aInnerBorder
[2];
779 maInnerBorderSize
.mnBottom
= aInnerBorder
[3];
781 ::std::vector
<sal_Int32
> aOuterBorder (rpTheme
->GetBorderSize(rsStyleName
, true));
782 OSL_ASSERT(aOuterBorder
.size()==4);
783 maOuterBorderSize
.mnLeft
= aOuterBorder
[0];
784 maOuterBorderSize
.mnTop
= aOuterBorder
[1];
785 maOuterBorderSize
.mnRight
= aOuterBorder
[2];
786 maOuterBorderSize
.mnBottom
= aOuterBorder
[3];
788 catch(beans::UnknownPropertyException
&)
796 awt::Rectangle
RendererPaneStyle::AddBorder (
797 const awt::Rectangle
& rBox
,
798 const drawing::framework::BorderType eBorderType
) const
800 const BorderSize
* pBorderSize
= nullptr;
803 case drawing::framework::BorderType_INNER_BORDER
:
804 pBorderSize
= &maInnerBorderSize
;
806 case drawing::framework::BorderType_OUTER_BORDER
:
807 pBorderSize
= &maOuterBorderSize
;
809 case drawing::framework::BorderType_TOTAL_BORDER
:
810 pBorderSize
= &maTotalBorderSize
;
815 return awt::Rectangle (
816 rBox
.X
- pBorderSize
->mnLeft
,
817 rBox
.Y
- pBorderSize
->mnTop
,
818 rBox
.Width
+ pBorderSize
->mnLeft
+ pBorderSize
->mnRight
,
819 rBox
.Height
+ pBorderSize
->mnTop
+ pBorderSize
->mnBottom
);
822 awt::Rectangle
RendererPaneStyle::RemoveBorder (
823 const awt::Rectangle
& rBox
,
824 const css::drawing::framework::BorderType eBorderType
) const
826 const BorderSize
* pBorderSize
= nullptr;
829 case drawing::framework::BorderType_INNER_BORDER
:
830 pBorderSize
= &maInnerBorderSize
;
832 case drawing::framework::BorderType_OUTER_BORDER
:
833 pBorderSize
= &maOuterBorderSize
;
835 case drawing::framework::BorderType_TOTAL_BORDER
:
836 pBorderSize
= &maTotalBorderSize
;
841 return awt::Rectangle (
842 rBox
.X
+ pBorderSize
->mnLeft
,
843 rBox
.Y
+ pBorderSize
->mnTop
,
844 rBox
.Width
- pBorderSize
->mnLeft
- pBorderSize
->mnRight
,
845 rBox
.Height
- pBorderSize
->mnTop
- pBorderSize
->mnBottom
);
848 Reference
<rendering::XCanvasFont
> RendererPaneStyle::GetFont (
849 const Reference
<rendering::XCanvas
>& rxCanvas
) const
853 mpFont
->PrepareFont(rxCanvas
);
854 return mpFont
->mxFont
;
856 return Reference
<rendering::XCanvasFont
>();
859 void RendererPaneStyle::UpdateBorderSizes()
861 maTotalBorderSize
.mnLeft
= maInnerBorderSize
.mnLeft
+ maOuterBorderSize
.mnLeft
;
862 maTotalBorderSize
.mnTop
= maInnerBorderSize
.mnTop
+ maOuterBorderSize
.mnTop
;
863 maTotalBorderSize
.mnRight
= maInnerBorderSize
.mnRight
+ maOuterBorderSize
.mnRight
;
864 maTotalBorderSize
.mnBottom
= maInnerBorderSize
.mnBottom
+ maOuterBorderSize
.mnBottom
;
867 SharedBitmapDescriptor
RendererPaneStyle::GetBitmap(
868 const std::shared_ptr
<PresenterTheme
>& rpTheme
,
869 const OUString
& rsStyleName
,
870 const OUString
& rsBitmapName
)
872 SharedBitmapDescriptor
pDescriptor (rpTheme
->GetBitmap(rsStyleName
, rsBitmapName
));
879 } // end of anonymous namespace
881 } // end of namespace ::sd::presenter
883 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */