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>
51 class RendererPaneStyle
55 const std::shared_ptr<PresenterTheme>& rpTheme,
56 const OUString& rsStyleName);
58 awt::Rectangle AddBorder (
59 const awt::Rectangle& rBox,
60 drawing::framework::BorderType eBorderType)
const;
61 awt::Rectangle RemoveBorder (
62 const awt::Rectangle& rBox,
63 drawing::framework::BorderType eBorderType)
const;
64 Reference<rendering::XCanvasFont>
GetFont (
65 const Reference<rendering::XCanvas>& rxCanvas)
const;
86 void UpdateBorderSizes();
88 const std::shared_ptr<PresenterTheme>& rpTheme,
89 const OUString& rsStyleName,
90 const OUString& rsBitmapName);
99 const std::shared_ptr<PresenterTheme>& rpTheme);
101 void SetCanvas (
const Reference<rendering::XCanvas>& rxCanvas);
103 const OUString& rsTitle,
104 const awt::Rectangle& rBBox,
105 const awt::Rectangle& rUpdateBox,
106 const OUString& rsPaneURL);
108 const OUString& rsTitle,
109 const std::shared_ptr<RendererPaneStyle>& rpStyle,
110 const awt::Rectangle& rUpdateBox,
111 const awt::Rectangle& rOuterBox,
112 const awt::Rectangle& rInnerBox);
114 const awt::Rectangle& rUpdateBox,
115 const awt::Rectangle& rOuterBox,
116 const OUString& rsPaneStyleName);
119 const awt::Point& rCalloutAnchor);
133 const awt::Rectangle& rBox,
134 const awt::Rectangle& rUpdateBox,
135 const sal_Int32 nXPosition,
136 const sal_Int32 nYPosition,
137 const sal_Int32 nStartOffset,
138 const sal_Int32 nEndOffset,
159 const OUString& rsPaneBorderStyleName,
160 const css::awt::Rectangle& rRectangle,
161 drawing::framework::BorderType eBorderType)
167 return AddBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
171 const OUString& rsPaneBorderStyleName,
172 const css::awt::Rectangle& rRectangle,
173 drawing::framework::BorderType eBorderType)
179 return RemoveBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
183 const OUString& rsPaneBorderStyleName,
184 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
185 const css::awt::Rectangle& rOuterBorderRectangle,
186 const css::awt::Rectangle& rRepaintArea,
187 const OUString& rsTitle)
192 if (rRepaintArea.X >= rOuterBorderRectangle.X+rOuterBorderRectangle.Width
193 || rRepaintArea.Y >= rOuterBorderRectangle.Y+rOuterBorderRectangle.Height
194 || rRepaintArea.X+rRepaintArea.Width <= rOuterBorderRectangle.X
195 || rRepaintArea.Y+rRepaintArea.Height <= rOuterBorderRectangle.Y)
207 rOuterBorderRectangle,
208 rsPaneBorderStyleName);
211 rOuterBorderRectangle,
213 rsPaneBorderStyleName);
217 const OUString& rsPaneBorderStyleName,
218 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
219 const css::awt::Rectangle& rOuterBorderRectangle,
220 const css::awt::Rectangle& rRepaintArea,
221 const OUString& rsTitle,
222 const css::awt::Point& rCalloutAnchor)
227 if (rRepaintArea.X >= rOuterBorderRectangle.X+rOuterBorderRectangle.Width
228 || rRepaintArea.Y >= rOuterBorderRectangle.Y+rOuterBorderRectangle.Height
229 || rRepaintArea.X+rRepaintArea.Width <= rOuterBorderRectangle.X
230 || rRepaintArea.Y+rRepaintArea.Height <= rOuterBorderRectangle.Y)
242 rOuterBorderRectangle,
243 rsPaneBorderStyleName);
247 rOuterBorderRectangle,
249 rsPaneBorderStyleName);
253 const OUString& rsPaneBorderStyleName)
259 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
260 mpRenderer->GetRendererPaneStyle(rsPaneBorderStyleName));
261 if (pRendererPaneStyle !=
nullptr && pRendererPaneStyle->mpBottomCallout)
265 pRendererPaneStyle->mpBottomCallout->mnHeight
266 - pRendererPaneStyle->mpBottomCallout->mnYHotSpot);
270 return awt::Point(0,0);
276 bool bModified (
false);
286 mpTheme->ProvideCanvas(rxCanvas);
326 const OUString& rsPaneURL,
327 const awt::Rectangle& rInnerBox,
328 const css::drawing::framework::BorderType eBorderType)
const
332 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
mpRenderer->GetRendererPaneStyle(rsPaneURL));
333 if (pRendererPaneStyle !=
nullptr)
334 return pRendererPaneStyle->AddBorder(rInnerBox, eBorderType);
340 const OUString& rsPaneURL,
341 const css::awt::Rectangle& rOuterBox,
342 const css::drawing::framework::BorderType eBorderType)
const
346 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
mpRenderer->GetRendererPaneStyle(rsPaneURL));
347 if (pRendererPaneStyle !=
nullptr)
348 return pRendererPaneStyle->RemoveBorder(rOuterBox, eBorderType);
355 if (rBHelper.bDisposed || rBHelper.bInDispose)
357 throw lang::DisposedException (
358 "PresenterPaneBorderPainter object has already been disposed",
359 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(
this)));
367 const std::shared_ptr<PresenterTheme>& rpTheme)
369 maViewState(
geometry::AffineMatrix2D(1,0,0, 0,1,0), nullptr),
372 Reference<lang::XMultiComponentFactory>
xFactory (rxContext->getServiceManager());
376 xFactory->createInstanceWithContext(
377 "com.sun.star.comp.Draw.PresenterHelper",
392 const OUString& rsTitle,
393 const awt::Rectangle& rBBox,
394 const awt::Rectangle& rUpdateBox,
395 const OUString& rsPaneURL)
401 std::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneURL));
402 if (pStyle ==
nullptr)
405 awt::Rectangle aOuterBox (rBBox);
406 awt::Rectangle aCenterBox (
407 pStyle->RemoveBorder(aOuterBox, drawing::framework::BorderType_OUTER_BORDER));
408 awt::Rectangle aInnerBox (
409 pStyle->RemoveBorder(aOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
422 PaintBitmap(aCenterBox, rUpdateBox, 0,-1,
423 pTopLeft->mnXOffset, pTopRight->mnXOffset,
true, pTop);
424 PaintBitmap(aCenterBox, rUpdateBox, -1,0,
425 pTopLeft->mnYOffset, pBottomLeft->mnYOffset,
true, pLeft);
426 PaintBitmap(aCenterBox, rUpdateBox, +1,0,
427 pTopRight->mnYOffset, pBottomRight->mnYOffset,
true, pRight);
428 if (mbHasCallout && pStyle->mpBottomCallout->GetNormalBitmap().is())
430 const sal_Int32 nCalloutWidth (pStyle->mpBottomCallout->mnWidth);
431 sal_Int32 nCalloutX (maCalloutAnchor.X - pStyle->mpBottomCallout->mnXHotSpot
432 - (aCenterBox.X - aOuterBox.X));
433 if (nCalloutX < pBottomLeft->mnXOffset + aCenterBox.X)
434 nCalloutX = pBottomLeft->mnXOffset + aCenterBox.X;
435 if (nCalloutX > pBottomRight->mnXOffset + aCenterBox.X + aCenterBox.Width)
436 nCalloutX = pBottomRight->mnXOffset + aCenterBox.X + aCenterBox.Width;
438 PaintBitmap(aCenterBox, rUpdateBox, 0,+1, nCalloutX,0,
false, pStyle->mpBottomCallout);
440 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
441 pBottomLeft->mnXOffset, nCalloutX-aCenterBox.Width,
true, pBottom);
442 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
443 nCalloutX+nCalloutWidth, pBottomRight->mnXOffset,
true, pBottom);
448 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
449 pBottomLeft->mnXOffset, pBottomRight->mnXOffset,
true, pBottom);
453 PaintBitmap(aCenterBox, rUpdateBox, -1,-1, 0,0,
false, pTopLeft);
454 PaintBitmap(aCenterBox, rUpdateBox, +1,-1, 0,0,
false, pTopRight);
455 PaintBitmap(aCenterBox, rUpdateBox, -1,+1, 0,0,
false, pBottomLeft);
456 PaintBitmap(aCenterBox, rUpdateBox, +1,+1, 0,0,
false, pBottomRight);
459 PaintTitle(rsTitle, pStyle, rUpdateBox, aOuterBox, aInnerBox);
462 Reference<rendering::XSpriteCanvas> xSpriteCanvas (
mxCanvas, UNO_QUERY);
463 if (xSpriteCanvas.is())
464 xSpriteCanvas->updateScreen(
false);
468 const OUString& rsTitle,
469 const std::shared_ptr<RendererPaneStyle>& rpStyle,
470 const awt::Rectangle& rUpdateBox,
471 const awt::Rectangle& rOuterBox,
472 const awt::Rectangle& rInnerBox)
477 if (rsTitle.isEmpty())
480 Reference<rendering::XCanvasFont> xFont (rpStyle->GetFont(
mxCanvas));
484 rendering::StringContext aContext (
487 rsTitle.getLength());
488 Reference<rendering::XTextLayout> xLayout (xFont->createTextLayout(
490 rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
496 geometry::RealRectangle2D aBox (xLayout->queryTextBounds());
497 const double nTextHeight = aBox.Y2 - aBox.Y1;
498 const double nTextWidth = aBox.X1 + aBox.X2;
499 const sal_Int32 nTitleBarHeight = rInnerBox.Y - rOuterBox.Y - 1;
500 double nY = rOuterBox.Y + (nTitleBarHeight - nTextHeight) / 2 - aBox.Y1;
501 if (nY >= rInnerBox.Y)
502 nY = rInnerBox.Y - 1;
504 switch (rpStyle->meFontAnchor)
506 case RendererPaneStyle::Anchor::Left:
509 case RendererPaneStyle::Anchor::Right:
510 nX = rInnerBox.X + rInnerBox.Width - nTextWidth;
513 nX = rInnerBox.X + (rInnerBox.Width - nTextWidth)/2;
516 nX += rpStyle->mnFontXOffset;
517 nY += rpStyle->mnFontYOffset;
519 if (rUpdateBox.X >= nX+nTextWidth
520 || rUpdateBox.Y >= nY+nTextHeight
521 || rUpdateBox.X+rUpdateBox.Width <= nX
522 || rUpdateBox.Y+rUpdateBox.Height <= nY)
527 rendering::RenderState aRenderState(
528 geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
531 rendering::CompositeOperation::SOURCE);
535 rpStyle->mpFont->mnColor);
543 std::shared_ptr<RendererPaneStyle>
546 OSL_ASSERT(
mpTheme !=
nullptr);
548 RendererPaneStyleContainer::const_iterator iStyle (maRendererPaneStyles.find(rsResourceURL));
549 if (iStyle == maRendererPaneStyles.end())
551 OUString sPaneStyleName (
"DefaultRendererPaneStyle");
554 const OUString sStyleName (
mpTheme->GetStyleName(rsResourceURL));
555 if (!sStyleName.isEmpty())
556 sPaneStyleName = sStyleName;
559 auto pStyle = std::make_shared<RendererPaneStyle>(
mpTheme,sPaneStyleName);
560 iStyle = maRendererPaneStyles.emplace(rsResourceURL, pStyle).first;
562 if (iStyle != maRendererPaneStyles.end())
563 return iStyle->second;
565 return std::shared_ptr<RendererPaneStyle>();
569 const awt::Point& rCalloutAnchor)
572 maCalloutAnchor = rCalloutAnchor;
576 const awt::Rectangle& rBox,
577 const awt::Rectangle& rUpdateBox,
578 const sal_Int32 nXPosition,
579 const sal_Int32 nYPosition,
580 const sal_Int32 nStartOffset,
581 const sal_Int32 nEndOffset,
589 if (rpBitmap->mnWidth<=0 || rpBitmap->mnHeight<=0)
592 Reference<rendering::XBitmap> xBitmap = rpBitmap->GetNormalBitmap();
599 sal_Int32 nW = rpBitmap->mnWidth;
600 sal_Int32 nH = rpBitmap->mnHeight;
603 nX = rBox.X - rpBitmap->mnWidth + rpBitmap->mnXOffset;
605 else if (nXPosition > 0)
607 nX = rBox.X + rBox.Width + rpBitmap->mnXOffset;
611 nX = rBox.X + nStartOffset;
613 nW = rBox.Width - nStartOffset + nEndOffset;
618 nY = rBox.Y - rpBitmap->mnHeight + rpBitmap->mnYOffset;
620 else if (nYPosition > 0)
622 nY = rBox.Y + rBox.Height + rpBitmap->mnYOffset;
626 nY = rBox.Y + nStartOffset;
628 nH = rBox.Height - nStartOffset + nEndOffset;
632 if (nX >= rUpdateBox.X + rUpdateBox.Width
633 || nX+nW <= rUpdateBox.X
634 || nY >= rUpdateBox.Y + rUpdateBox.Height
635 || nY+nH <= rUpdateBox.Y)
666 rendering::RenderState aRenderState (
667 geometry::AffineMatrix2D(
668 double(nW)/rpBitmap->mnWidth, 0, nX,
669 0,
double(nH)/rpBitmap->mnHeight, nY),
672 rendering::CompositeOperation::OVER);
682 const awt::Rectangle& rUpdateBox,
683 const awt::Rectangle& rOuterBox,
684 const OUString& rsPaneStyleName)
686 mxViewStateClip =
nullptr;
687 maViewState.Clip =
nullptr;
692 std::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneStyleName));
693 if (pStyle ==
nullptr)
701 awt::Rectangle aInnerBox (
702 pStyle->RemoveBorder(rOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
703 ::std::vector<awt::Rectangle> aRectangles
711 if (mxViewStateClip.is())
712 mxViewStateClip->setFillRule(rendering::FillRule_EVEN_ODD);
714 maViewState.Clip = mxViewStateClip;
721 BorderSize::BorderSize()
731 RendererPaneStyle::RendererPaneStyle (
732 const std::shared_ptr<PresenterTheme>& rpTheme,
733 const OUString& rsStyleName)
739 if (rpTheme ==
nullptr)
742 mpTopLeft = GetBitmap(rpTheme, rsStyleName,
"TopLeft");
743 mpTop = GetBitmap(rpTheme, rsStyleName,
"Top");
744 mpTopRight = GetBitmap(rpTheme, rsStyleName,
"TopRight");
745 mpLeft = GetBitmap(rpTheme, rsStyleName,
"Left");
746 mpRight = GetBitmap(rpTheme, rsStyleName,
"Right");
747 mpBottomLeft = GetBitmap(rpTheme, rsStyleName,
"BottomLeft");
748 mpBottom = GetBitmap(rpTheme, rsStyleName,
"Bottom");
749 mpBottomRight = GetBitmap(rpTheme, rsStyleName,
"BottomRight");
753 mpFont = rpTheme->GetFont(rsStyleName);
755 OUString sAnchor (
"Left");
758 sAnchor =
mpFont->msAnchor;
763 if ( sAnchor ==
"Left" )
765 else if ( sAnchor ==
"Right" )
773 ::std::vector<sal_Int32> aInnerBorder (rpTheme->GetBorderSize(rsStyleName,
false));
774 OSL_ASSERT(aInnerBorder.size()==4);
780 ::std::vector<sal_Int32> aOuterBorder (rpTheme->GetBorderSize(rsStyleName,
true));
781 OSL_ASSERT(aOuterBorder.size()==4);
787 catch(beans::UnknownPropertyException&)
795 awt::Rectangle RendererPaneStyle::AddBorder (
796 const awt::Rectangle& rBox,
797 const drawing::framework::BorderType eBorderType)
const
799 const BorderSize* pBorderSize =
nullptr;
802 case drawing::framework::BorderType_INNER_BORDER:
805 case drawing::framework::BorderType_OUTER_BORDER:
808 case drawing::framework::BorderType_TOTAL_BORDER:
814 return awt::Rectangle (
815 rBox.X - pBorderSize->mnLeft,
816 rBox.Y - pBorderSize->mnTop,
817 rBox.Width + pBorderSize->mnLeft + pBorderSize->mnRight,
818 rBox.Height + pBorderSize->mnTop + pBorderSize->mnBottom);
821 awt::Rectangle RendererPaneStyle::RemoveBorder (
822 const awt::Rectangle& rBox,
823 const css::drawing::framework::BorderType eBorderType)
const
825 const BorderSize* pBorderSize =
nullptr;
828 case drawing::framework::BorderType_INNER_BORDER:
831 case drawing::framework::BorderType_OUTER_BORDER:
834 case drawing::framework::BorderType_TOTAL_BORDER:
840 return awt::Rectangle (
841 rBox.X + pBorderSize->mnLeft,
842 rBox.Y + pBorderSize->mnTop,
843 rBox.Width - pBorderSize->mnLeft - pBorderSize->mnRight,
844 rBox.Height - pBorderSize->mnTop - pBorderSize->mnBottom);
847 Reference<rendering::XCanvasFont> RendererPaneStyle::GetFont (
848 const Reference<rendering::XCanvas>& rxCanvas)
const
852 mpFont->PrepareFont(rxCanvas);
855 return Reference<rendering::XCanvasFont>();
858 void RendererPaneStyle::UpdateBorderSizes()
867 const std::shared_ptr<PresenterTheme>& rpTheme,
868 const OUString& rsStyleName,
869 const OUString& rsBitmapName)
::cppu::WeakComponentImplHelper< css::drawing::framework::XPaneBorderPainter > PresenterPaneBorderPainterInterfaceBase
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...
SharedBitmapDescriptor mpBottomRight
std::shared_ptr< FontDescriptor > SharedFontDescriptor
BorderSize maOuterBorderSize
Reference< rendering::XPolyPolygon2D > mxViewStateClip
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
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
void SetCanvas(const Reference< rendering::XCanvas > &rxCanvas)
std::shared_ptr< T > make_shared(Args &&...args)
void ThrowIfDisposed() const
SharedBitmapDescriptor mpBottomLeft
std::shared_ptr< RendererPaneStyle > GetRendererPaneStyle(const OUString &rsResourceURL)
exports com.sun.star. geometry
::std::map< OUString, std::shared_ptr< RendererPaneStyle > > RendererPaneStyleContainer
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor
std::shared_ptr< PresenterTheme > mpTheme
SharedBitmapDescriptor mpTopLeft
SharedBitmapDescriptor mpLeft
SharedBitmapDescriptor mpTopRight
void SetCalloutAnchor(const awt::Point &rCalloutAnchor)
virtual css::awt::Rectangle SAL_CALL removeBorder(const OUString &rsPaneBorderStyleName, const css::awt::Rectangle &rRectangle, css::drawing::framework::BorderType eBorderType) override
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...
Renderer(const Reference< XComponentContext > &rxContext, const std::shared_ptr< PresenterTheme > &rpTheme)
Reference< rendering::XCanvas > mxCanvas
PresenterPaneBorderPainter(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
BorderSize maTotalBorderSize
SharedBitmapDescriptor mpEmpty
virtual css::awt::Point SAL_CALL getCalloutOffset(const OUString &rsPaneBorderStyleName) override
void SetupClipping(const awt::Rectangle &rUpdateBox, const awt::Rectangle &rOuterBox, const OUString &rsPaneStyleName)
css::rendering::ViewState maViewState
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
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
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...
static css::uno::Reference< css::rendering::XPolyPolygon2D > CreatePolygon(const css::awt::Rectangle &rBox, const css::uno::Reference< css::rendering::XGraphicDevice > &rxDevice)
void PaintTitle(const OUString &rsTitle, const std::shared_ptr< RendererPaneStyle > &rpStyle, const awt::Rectangle &rUpdateBox, const awt::Rectangle &rOuterBox, const awt::Rectangle &rInnerBox)
static css::awt::Rectangle Intersection(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
PresenterTheme::SharedFontDescriptor mpFont
css::uno::Reference< css::uno::XComponentContext > mxContext
Reference< drawing::XPresenterHelper > mxPresenterHelper
BorderSize maInnerBorderSize
static void SetDeviceColor(css::rendering::RenderState &rRenderState, const css::util::Color aColor)
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
virtual ~PresenterPaneBorderPainter() override
void SetTheme(const std::shared_ptr< PresenterTheme > &rpTheme)
awt::Point maCalloutAnchor
Reference< XSingleServiceFactory > xFactory
SharedBitmapDescriptor mpRight
RendererPaneStyleContainer maRendererPaneStyles
SharedBitmapDescriptor mpBottomCallout
std::unique_ptr< Renderer > mpRenderer
SharedBitmapDescriptor mpBottom
void PaintBorder(const OUString &rsTitle, const awt::Rectangle &rBBox, const awt::Rectangle &rUpdateBox, const OUString &rsPaneURL)
SharedBitmapDescriptor mpTop
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)
bool m_bDetectedRangeSegmentation false