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>
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;
87 void UpdateBorderSizes();
89 const std::shared_ptr<PresenterTheme>& rpTheme,
90 const OUString& rsStyleName,
91 const OUString& rsBitmapName);
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);
120 const awt::Point& rCalloutAnchor);
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,
147 const Reference<XComponentContext>& rxContext)
160 const OUString& rsPaneBorderStyleName,
161 const css::awt::Rectangle& rRectangle,
162 drawing::framework::BorderType eBorderType)
168 return AddBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
172 const OUString& rsPaneBorderStyleName,
173 const css::awt::Rectangle& rRectangle,
174 drawing::framework::BorderType eBorderType)
180 return RemoveBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
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)
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)
208 rOuterBorderRectangle,
209 rsPaneBorderStyleName);
212 rOuterBorderRectangle,
214 rsPaneBorderStyleName);
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)
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)
243 rOuterBorderRectangle,
244 rsPaneBorderStyleName);
248 rOuterBorderRectangle,
250 rsPaneBorderStyleName);
254 const OUString& rsPaneBorderStyleName)
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);
277 bool bModified (
false);
287 mpTheme->ProvideCanvas(rxCanvas);
327 const OUString& rsPaneURL,
328 const awt::Rectangle& rInnerBox,
329 const css::drawing::framework::BorderType eBorderType)
const
333 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
mpRenderer->GetRendererPaneStyle(rsPaneURL));
334 if (pRendererPaneStyle !=
nullptr)
335 return pRendererPaneStyle->AddBorder(rInnerBox, eBorderType);
341 const OUString& rsPaneURL,
342 const css::awt::Rectangle& rOuterBox,
343 const css::drawing::framework::BorderType eBorderType)
const
347 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
mpRenderer->GetRendererPaneStyle(rsPaneURL));
348 if (pRendererPaneStyle !=
nullptr)
349 return pRendererPaneStyle->RemoveBorder(rOuterBox, eBorderType);
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)));
367 const Reference<XComponentContext>& rxContext,
368 std::shared_ptr<PresenterTheme> xTheme)
370 maViewState(geometry::AffineMatrix2D(1,0,0, 0,1,0), nullptr),
373 Reference<lang::XMultiComponentFactory>
xFactory (rxContext->getServiceManager());
377 xFactory->createInstanceWithContext(
378 "com.sun.star.comp.Draw.PresenterHelper",
393 const OUString& rsTitle,
394 const awt::Rectangle& rBBox,
395 const awt::Rectangle& rUpdateBox,
396 const OUString& rsPaneURL)
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));
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;
439 PaintBitmap(aCenterBox, rUpdateBox, 0,+1, nCalloutX,0,
false, pStyle->mpBottomCallout);
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);
449 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
450 pBottomLeft->mnXOffset, pBottomRight->mnXOffset,
true, pBottom);
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);
463 Reference<rendering::XSpriteCanvas> xSpriteCanvas (
mxCanvas, UNO_QUERY);
464 if (xSpriteCanvas.is())
465 xSpriteCanvas->updateScreen(
false);
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)
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,
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;
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);
536 rpStyle->mpFont->mnColor);
544std::shared_ptr<RendererPaneStyle>
547 OSL_ASSERT(
mpTheme !=
nullptr);
549 RendererPaneStyleContainer::const_iterator iStyle (maRendererPaneStyles.find(rsResourceURL));
550 if (iStyle == maRendererPaneStyles.end())
552 OUString sPaneStyleName (
"DefaultRendererPaneStyle");
555 const OUString sStyleName (
mpTheme->GetStyleName(rsResourceURL));
556 if (!sStyleName.isEmpty())
557 sPaneStyleName = sStyleName;
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>();
570 const awt::Point& rCalloutAnchor)
573 maCalloutAnchor = rCalloutAnchor;
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,
590 if (rpBitmap->mnWidth<=0 || rpBitmap->mnHeight<=0)
593 Reference<rendering::XBitmap> xBitmap = rpBitmap->GetNormalBitmap();
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;
633 if (nX >= rUpdateBox.X + rUpdateBox.Width
634 || nX+nW <= rUpdateBox.X
635 || nY >= rUpdateBox.Y + rUpdateBox.Height
636 || nY+nH <= rUpdateBox.Y)
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);
683 const awt::Rectangle& rUpdateBox,
684 const awt::Rectangle& rOuterBox,
685 const OUString& rsPaneStyleName)
687 mxViewStateClip =
nullptr;
688 maViewState.Clip =
nullptr;
693 std::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneStyleName));
694 if (pStyle ==
nullptr)
702 awt::Rectangle aInnerBox (
703 pStyle->RemoveBorder(rOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
704 ::std::vector<awt::Rectangle> aRectangles
712 if (mxViewStateClip.is())
713 mxViewStateClip->setFillRule(rendering::FillRule_EVEN_ODD);
715 maViewState.Clip = mxViewStateClip;
722BorderSize::BorderSize()
732RendererPaneStyle::RendererPaneStyle (
733 const std::shared_ptr<PresenterTheme>& rpTheme,
734 const OUString& rsStyleName)
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");
754 mpFont = rpTheme->GetFont(rsStyleName);
756 OUString sAnchor (
"Left");
759 sAnchor =
mpFont->msAnchor;
764 if ( sAnchor ==
"Left" )
766 else if ( sAnchor ==
"Right" )
774 ::std::vector<sal_Int32> aInnerBorder (rpTheme->GetBorderSize(rsStyleName,
false));
775 OSL_ASSERT(aInnerBorder.size()==4);
781 ::std::vector<sal_Int32> aOuterBorder (rpTheme->GetBorderSize(rsStyleName,
true));
782 OSL_ASSERT(aOuterBorder.size()==4);
788 catch(beans::UnknownPropertyException&)
796awt::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:
806 case drawing::framework::BorderType_OUTER_BORDER:
809 case drawing::framework::BorderType_TOTAL_BORDER:
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);
822awt::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:
832 case drawing::framework::BorderType_OUTER_BORDER:
835 case drawing::framework::BorderType_TOTAL_BORDER:
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);
848Reference<rendering::XCanvasFont> RendererPaneStyle::GetFont (
849 const Reference<rendering::XCanvas>& rxCanvas)
const
853 mpFont->PrepareFont(rxCanvas);
856 return Reference<rendering::XCanvasFont>();
859void RendererPaneStyle::UpdateBorderSizes()
868 const std::shared_ptr<PresenterTheme>& rpTheme,
869 const OUString& rsStyleName,
870 const OUString& rsBitmapName)
SharedBitmapDescriptor mpBottomRight
SharedBitmapDescriptor mpBottomCallout
SharedBitmapDescriptor mpLeft
BorderSize maTotalBorderSize
SharedBitmapDescriptor mpRight
SharedBitmapDescriptor mpTop
PresenterTheme::SharedFontDescriptor mpFont
BorderSize maInnerBorderSize
SharedBitmapDescriptor mpTopRight
SharedBitmapDescriptor mpEmpty
SharedBitmapDescriptor mpTopLeft
BorderSize maOuterBorderSize
SharedBitmapDescriptor mpBottomLeft
SharedBitmapDescriptor mpBottom
Reference< rendering::XCanvas > mxCanvas
There is one bitmap for the normal state, one for a mouse over effect and one to show that a button h...
static void SetDeviceColor(css::rendering::RenderState &rRenderState, const css::util::Color aColor)
static css::awt::Rectangle Intersection(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
static css::uno::Reference< css::rendering::XPolyPolygon2D > CreatePolygon(const css::awt::Rectangle &rBox, const css::uno::Reference< css::rendering::XGraphicDevice > &rxDevice)
std::shared_ptr< PresenterTheme > mpTheme
Reference< rendering::XPolyPolygon2D > mxViewStateClip
Reference< rendering::XCanvas > mxCanvas
void SetCanvas(const Reference< rendering::XCanvas > &rxCanvas)
std::shared_ptr< RendererPaneStyle > GetRendererPaneStyle(const OUString &rsResourceURL)
void PaintBorder(const OUString &rsTitle, const awt::Rectangle &rBBox, const awt::Rectangle &rUpdateBox, const OUString &rsPaneURL)
void SetupClipping(const awt::Rectangle &rUpdateBox, const awt::Rectangle &rOuterBox, const OUString &rsPaneStyleName)
awt::Point maCalloutAnchor
css::rendering::ViewState maViewState
void SetCalloutAnchor(const awt::Point &rCalloutAnchor)
void PaintTitle(const OUString &rsTitle, const std::shared_ptr< RendererPaneStyle > &rpStyle, const awt::Rectangle &rUpdateBox, const awt::Rectangle &rOuterBox, const awt::Rectangle &rInnerBox)
::std::map< OUString, std::shared_ptr< RendererPaneStyle > > RendererPaneStyleContainer
void PaintBitmap(const awt::Rectangle &rBox, const awt::Rectangle &rUpdateBox, const sal_Int32 nXPosition, const sal_Int32 nYPosition, const sal_Int32 nStartOffset, const sal_Int32 nEndOffset, const bool bExpand, const SharedBitmapDescriptor &rpBitmap)
Renderer(const Reference< XComponentContext > &rxContext, std::shared_ptr< PresenterTheme > xTheme)
Reference< drawing::XPresenterHelper > mxPresenterHelper
RendererPaneStyleContainer maRendererPaneStyles
PresenterPaneBorderPainter(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual css::awt::Point SAL_CALL getCalloutOffset(const OUString &rsPaneBorderStyleName) override
void ThrowIfDisposed() const
css::awt::Rectangle AddBorder(const OUString &rsPaneURL, const css::awt::Rectangle &rInnerBox, const css::drawing::framework::BorderType eBorderType) const
Transform the bounding box of the window content to the outer bounding box of the border that is pain...
std::unique_ptr< Renderer > mpRenderer
void SetTheme(const std::shared_ptr< PresenterTheme > &rpTheme)
css::awt::Rectangle RemoveBorder(const OUString &rsPaneURL, const css::awt::Rectangle &rOuterBox, const css::drawing::framework::BorderType eBorderType) const
Transform the outer bounding box of a window to the bounding box of the inner content area.
virtual void SAL_CALL paintBorder(const OUString &rsPaneBorderStyleName, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rOuterBorderRectangle, const css::awt::Rectangle &rRepaintArea, const OUString &rsTitle) override
virtual css::awt::Rectangle SAL_CALL removeBorder(const OUString &rsPaneBorderStyleName, const css::awt::Rectangle &rRectangle, css::drawing::framework::BorderType eBorderType) override
virtual ~PresenterPaneBorderPainter() override
virtual css::awt::Rectangle SAL_CALL addBorder(const OUString &rsPaneBorderStyleName, const css::awt::Rectangle &rRectangle, css::drawing::framework::BorderType eBorderType) override
std::shared_ptr< PresenterTheme > mpTheme
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual void SAL_CALL paintBorderWithCallout(const OUString &rsPaneBorderStyleName, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rOuterBorderRectangle, const css::awt::Rectangle &rRepaintArea, const OUString &rsTitle, const css::awt::Point &rCalloutAnchor) override
std::shared_ptr< FontDescriptor > SharedFontDescriptor
Reference< XSingleServiceFactory > xFactory
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
std::shared_ptr< T > make_shared(Args &&... args)
::cppu::WeakComponentImplHelper< css::drawing::framework::XPaneBorderPainter > PresenterPaneBorderPainterInterfaceBase
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)