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,
161 const OUString& rsPaneBorderStyleName,
162 const css::awt::Rectangle& rRectangle,
163 drawing::framework::BorderType eBorderType)
169 return AddBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
173 const OUString& rsPaneBorderStyleName,
174 const css::awt::Rectangle& rRectangle,
175 drawing::framework::BorderType eBorderType)
181 return RemoveBorder(rsPaneBorderStyleName, rRectangle, eBorderType);
185 const OUString& rsPaneBorderStyleName,
186 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
187 const css::awt::Rectangle& rOuterBorderRectangle,
188 const css::awt::Rectangle& rRepaintArea,
189 const OUString& rsTitle)
194 if (rRepaintArea.X >= rOuterBorderRectangle.X+rOuterBorderRectangle.Width
195 || rRepaintArea.Y >= rOuterBorderRectangle.Y+rOuterBorderRectangle.Height
196 || rRepaintArea.X+rRepaintArea.Width <= rOuterBorderRectangle.X
197 || rRepaintArea.Y+rRepaintArea.Height <= rOuterBorderRectangle.Y)
209 rOuterBorderRectangle,
210 rsPaneBorderStyleName);
213 rOuterBorderRectangle,
215 rsPaneBorderStyleName);
219 const OUString& rsPaneBorderStyleName,
220 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
221 const css::awt::Rectangle& rOuterBorderRectangle,
222 const css::awt::Rectangle& rRepaintArea,
223 const OUString& rsTitle,
224 const css::awt::Point& rCalloutAnchor)
229 if (rRepaintArea.X >= rOuterBorderRectangle.X+rOuterBorderRectangle.Width
230 || rRepaintArea.Y >= rOuterBorderRectangle.Y+rOuterBorderRectangle.Height
231 || rRepaintArea.X+rRepaintArea.Width <= rOuterBorderRectangle.X
232 || rRepaintArea.Y+rRepaintArea.Height <= rOuterBorderRectangle.Y)
244 rOuterBorderRectangle,
245 rsPaneBorderStyleName);
249 rOuterBorderRectangle,
251 rsPaneBorderStyleName);
255 const OUString& rsPaneBorderStyleName)
261 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
262 mpRenderer->GetRendererPaneStyle(rsPaneBorderStyleName));
263 if (pRendererPaneStyle !=
nullptr && pRendererPaneStyle->mpBottomCallout)
267 pRendererPaneStyle->mpBottomCallout->mnHeight
268 - pRendererPaneStyle->mpBottomCallout->mnYHotSpot);
272 return awt::Point(0,0);
278 bool bModified (
false);
288 mpTheme->ProvideCanvas(rxCanvas);
328 const OUString& rsPaneURL,
329 const awt::Rectangle& rInnerBox,
330 const css::drawing::framework::BorderType eBorderType)
const
334 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
mpRenderer->GetRendererPaneStyle(rsPaneURL));
335 if (pRendererPaneStyle !=
nullptr)
336 return pRendererPaneStyle->AddBorder(rInnerBox, eBorderType);
342 const OUString& rsPaneURL,
343 const css::awt::Rectangle& rOuterBox,
344 const css::drawing::framework::BorderType eBorderType)
const
348 const std::shared_ptr<RendererPaneStyle> pRendererPaneStyle(
mpRenderer->GetRendererPaneStyle(rsPaneURL));
349 if (pRendererPaneStyle !=
nullptr)
350 return pRendererPaneStyle->RemoveBorder(rOuterBox, eBorderType);
357 if (rBHelper.bDisposed || rBHelper.bInDispose)
359 throw lang::DisposedException (
360 "PresenterPaneBorderPainter object has already been disposed",
361 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(
this)));
369 const std::shared_ptr<PresenterTheme>& rpTheme)
371 maRendererPaneStyles(),
374 maViewState(
geometry::AffineMatrix2D(1,0,0, 0,1,0), nullptr),
379 Reference<lang::XMultiComponentFactory>
xFactory (rxContext->getServiceManager());
383 xFactory->createInstanceWithContext(
384 "com.sun.star.comp.Draw.PresenterHelper",
399 const OUString& rsTitle,
400 const awt::Rectangle& rBBox,
401 const awt::Rectangle& rUpdateBox,
402 const OUString& rsPaneURL)
408 std::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneURL));
409 if (pStyle ==
nullptr)
412 awt::Rectangle aOuterBox (rBBox);
413 awt::Rectangle aCenterBox (
414 pStyle->RemoveBorder(aOuterBox, drawing::framework::BorderType_OUTER_BORDER));
415 awt::Rectangle aInnerBox (
416 pStyle->RemoveBorder(aOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
429 PaintBitmap(aCenterBox, rUpdateBox, 0,-1,
430 pTopLeft->mnXOffset, pTopRight->mnXOffset,
true, pTop);
431 PaintBitmap(aCenterBox, rUpdateBox, -1,0,
432 pTopLeft->mnYOffset, pBottomLeft->mnYOffset,
true, pLeft);
433 PaintBitmap(aCenterBox, rUpdateBox, +1,0,
434 pTopRight->mnYOffset, pBottomRight->mnYOffset,
true, pRight);
435 if (mbHasCallout && pStyle->mpBottomCallout->GetNormalBitmap().is())
437 const sal_Int32 nCalloutWidth (pStyle->mpBottomCallout->mnWidth);
438 sal_Int32 nCalloutX (maCalloutAnchor.X - pStyle->mpBottomCallout->mnXHotSpot
439 - (aCenterBox.X - aOuterBox.X));
440 if (nCalloutX < pBottomLeft->mnXOffset + aCenterBox.X)
441 nCalloutX = pBottomLeft->mnXOffset + aCenterBox.X;
442 if (nCalloutX > pBottomRight->mnXOffset + aCenterBox.X + aCenterBox.Width)
443 nCalloutX = pBottomRight->mnXOffset + aCenterBox.X + aCenterBox.Width;
445 PaintBitmap(aCenterBox, rUpdateBox, 0,+1, nCalloutX,0,
false, pStyle->mpBottomCallout);
447 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
448 pBottomLeft->mnXOffset, nCalloutX-aCenterBox.Width,
true, pBottom);
449 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
450 nCalloutX+nCalloutWidth, pBottomRight->mnXOffset,
true, pBottom);
455 PaintBitmap(aCenterBox, rUpdateBox, 0,+1,
456 pBottomLeft->mnXOffset, pBottomRight->mnXOffset,
true, pBottom);
460 PaintBitmap(aCenterBox, rUpdateBox, -1,-1, 0,0,
false, pTopLeft);
461 PaintBitmap(aCenterBox, rUpdateBox, +1,-1, 0,0,
false, pTopRight);
462 PaintBitmap(aCenterBox, rUpdateBox, -1,+1, 0,0,
false, pBottomLeft);
463 PaintBitmap(aCenterBox, rUpdateBox, +1,+1, 0,0,
false, pBottomRight);
466 PaintTitle(rsTitle, pStyle, rUpdateBox, aOuterBox, aInnerBox);
469 Reference<rendering::XSpriteCanvas> xSpriteCanvas (
mxCanvas, UNO_QUERY);
470 if (xSpriteCanvas.is())
471 xSpriteCanvas->updateScreen(
false);
475 const OUString& rsTitle,
476 const std::shared_ptr<RendererPaneStyle>& rpStyle,
477 const awt::Rectangle& rUpdateBox,
478 const awt::Rectangle& rOuterBox,
479 const awt::Rectangle& rInnerBox)
484 if (rsTitle.isEmpty())
487 Reference<rendering::XCanvasFont> xFont (rpStyle->GetFont(
mxCanvas));
491 rendering::StringContext aContext (
494 rsTitle.getLength());
495 Reference<rendering::XTextLayout> xLayout (xFont->createTextLayout(
497 rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
503 geometry::RealRectangle2D aBox (xLayout->queryTextBounds());
504 const double nTextHeight = aBox.Y2 - aBox.Y1;
505 const double nTextWidth = aBox.X1 + aBox.X2;
506 const sal_Int32 nTitleBarHeight = rInnerBox.Y - rOuterBox.Y - 1;
507 double nY = rOuterBox.Y + (nTitleBarHeight - nTextHeight) / 2 - aBox.Y1;
508 if (nY >= rInnerBox.Y)
509 nY = rInnerBox.Y - 1;
511 switch (rpStyle->meFontAnchor)
513 case RendererPaneStyle::Anchor::Left:
516 case RendererPaneStyle::Anchor::Right:
517 nX = rInnerBox.X + rInnerBox.Width - nTextWidth;
520 nX = rInnerBox.X + (rInnerBox.Width - nTextWidth)/2;
523 nX += rpStyle->mnFontXOffset;
524 nY += rpStyle->mnFontYOffset;
526 if (rUpdateBox.X >= nX+nTextWidth
527 || rUpdateBox.Y >= nY+nTextHeight
528 || rUpdateBox.X+rUpdateBox.Width <= nX
529 || rUpdateBox.Y+rUpdateBox.Height <= nY)
534 rendering::RenderState aRenderState(
535 geometry::AffineMatrix2D(1,0,nX, 0,1,nY),
538 rendering::CompositeOperation::SOURCE);
542 rpStyle->mpFont->mnColor);
550 std::shared_ptr<RendererPaneStyle>
553 OSL_ASSERT(
mpTheme !=
nullptr);
555 RendererPaneStyleContainer::const_iterator iStyle (maRendererPaneStyles.find(rsResourceURL));
556 if (iStyle == maRendererPaneStyles.end())
558 OUString sPaneStyleName (
"DefaultRendererPaneStyle");
561 const OUString sStyleName (
mpTheme->GetStyleName(rsResourceURL));
562 if (!sStyleName.isEmpty())
563 sPaneStyleName = sStyleName;
566 auto pStyle = std::make_shared<RendererPaneStyle>(
mpTheme,sPaneStyleName);
567 iStyle = maRendererPaneStyles.emplace(rsResourceURL, pStyle).first;
569 if (iStyle != maRendererPaneStyles.end())
570 return iStyle->second;
572 return std::shared_ptr<RendererPaneStyle>();
576 const awt::Point& rCalloutAnchor)
579 maCalloutAnchor = rCalloutAnchor;
583 const awt::Rectangle& rBox,
584 const awt::Rectangle& rUpdateBox,
585 const sal_Int32 nXPosition,
586 const sal_Int32 nYPosition,
587 const sal_Int32 nStartOffset,
588 const sal_Int32 nEndOffset,
596 if (rpBitmap->mnWidth<=0 || rpBitmap->mnHeight<=0)
599 Reference<rendering::XBitmap> xBitmap = rpBitmap->GetNormalBitmap();
606 sal_Int32 nW = rpBitmap->mnWidth;
607 sal_Int32 nH = rpBitmap->mnHeight;
610 nX = rBox.X - rpBitmap->mnWidth + rpBitmap->mnXOffset;
612 else if (nXPosition > 0)
614 nX = rBox.X + rBox.Width + rpBitmap->mnXOffset;
618 nX = rBox.X + nStartOffset;
620 nW = rBox.Width - nStartOffset + nEndOffset;
625 nY = rBox.Y - rpBitmap->mnHeight + rpBitmap->mnYOffset;
627 else if (nYPosition > 0)
629 nY = rBox.Y + rBox.Height + rpBitmap->mnYOffset;
633 nY = rBox.Y + nStartOffset;
635 nH = rBox.Height - nStartOffset + nEndOffset;
639 if (nX >= rUpdateBox.X + rUpdateBox.Width
640 || nX+nW <= rUpdateBox.X
641 || nY >= rUpdateBox.Y + rUpdateBox.Height
642 || nY+nH <= rUpdateBox.Y)
673 rendering::RenderState aRenderState (
674 geometry::AffineMatrix2D(
675 double(nW)/rpBitmap->mnWidth, 0, nX,
676 0,
double(nH)/rpBitmap->mnHeight, nY),
679 rendering::CompositeOperation::OVER);
689 const awt::Rectangle& rUpdateBox,
690 const awt::Rectangle& rOuterBox,
691 const OUString& rsPaneStyleName)
693 mxViewStateClip =
nullptr;
694 maViewState.Clip =
nullptr;
699 std::shared_ptr<RendererPaneStyle> pStyle (GetRendererPaneStyle(rsPaneStyleName));
700 if (pStyle ==
nullptr)
708 awt::Rectangle aInnerBox (
709 pStyle->RemoveBorder(rOuterBox, drawing::framework::BorderType_TOTAL_BORDER));
710 ::std::vector<awt::Rectangle> aRectangles;
716 if (mxViewStateClip.is())
717 mxViewStateClip->setFillRule(rendering::FillRule_EVEN_ODD);
719 maViewState.Clip = mxViewStateClip;
726 BorderSize::BorderSize()
736 RendererPaneStyle::RendererPaneStyle (
737 const std::shared_ptr<PresenterTheme>& rpTheme,
738 const OUString& rsStyleName)
757 if (rpTheme ==
nullptr)
760 mpTopLeft = GetBitmap(rpTheme, rsStyleName,
"TopLeft");
761 mpTop = GetBitmap(rpTheme, rsStyleName,
"Top");
762 mpTopRight = GetBitmap(rpTheme, rsStyleName,
"TopRight");
763 mpLeft = GetBitmap(rpTheme, rsStyleName,
"Left");
764 mpRight = GetBitmap(rpTheme, rsStyleName,
"Right");
765 mpBottomLeft = GetBitmap(rpTheme, rsStyleName,
"BottomLeft");
766 mpBottom = GetBitmap(rpTheme, rsStyleName,
"Bottom");
767 mpBottomRight = GetBitmap(rpTheme, rsStyleName,
"BottomRight");
771 mpFont = rpTheme->GetFont(rsStyleName);
773 OUString sAnchor (
"Left");
776 sAnchor =
mpFont->msAnchor;
781 if ( sAnchor ==
"Left" )
783 else if ( sAnchor ==
"Right" )
791 ::std::vector<sal_Int32> aInnerBorder (rpTheme->GetBorderSize(rsStyleName,
false));
792 OSL_ASSERT(aInnerBorder.size()==4);
798 ::std::vector<sal_Int32> aOuterBorder (rpTheme->GetBorderSize(rsStyleName,
true));
799 OSL_ASSERT(aOuterBorder.size()==4);
805 catch(beans::UnknownPropertyException&)
813 awt::Rectangle RendererPaneStyle::AddBorder (
814 const awt::Rectangle& rBox,
815 const drawing::framework::BorderType eBorderType)
const
817 const BorderSize* pBorderSize =
nullptr;
820 case drawing::framework::BorderType_INNER_BORDER:
823 case drawing::framework::BorderType_OUTER_BORDER:
826 case drawing::framework::BorderType_TOTAL_BORDER:
832 return awt::Rectangle (
833 rBox.X - pBorderSize->mnLeft,
834 rBox.Y - pBorderSize->mnTop,
835 rBox.Width + pBorderSize->mnLeft + pBorderSize->mnRight,
836 rBox.Height + pBorderSize->mnTop + pBorderSize->mnBottom);
839 awt::Rectangle RendererPaneStyle::RemoveBorder (
840 const awt::Rectangle& rBox,
841 const css::drawing::framework::BorderType eBorderType)
const
843 const BorderSize* pBorderSize =
nullptr;
846 case drawing::framework::BorderType_INNER_BORDER:
849 case drawing::framework::BorderType_OUTER_BORDER:
852 case drawing::framework::BorderType_TOTAL_BORDER:
858 return awt::Rectangle (
859 rBox.X + pBorderSize->mnLeft,
860 rBox.Y + pBorderSize->mnTop,
861 rBox.Width - pBorderSize->mnLeft - pBorderSize->mnRight,
862 rBox.Height - pBorderSize->mnTop - pBorderSize->mnBottom);
865 Reference<rendering::XCanvasFont> RendererPaneStyle::GetFont (
866 const Reference<rendering::XCanvas>& rxCanvas)
const
870 mpFont->PrepareFont(rxCanvas);
873 return Reference<rendering::XCanvasFont>();
876 void RendererPaneStyle::UpdateBorderSizes()
885 const std::shared_ptr<PresenterTheme>& rpTheme,
886 const OUString& rsStyleName,
887 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
Reference< drawing::XPresenterHelper > mxPresenterHelper
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
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)
virtual ~PresenterPaneBorderPainter() override
void SetTheme(const std::shared_ptr< PresenterTheme > &rpTheme)
awt::Point maCalloutAnchor
Reference< XSingleServiceFactory > xFactory
SharedBitmapDescriptor mpRight
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
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)