27#include <com/sun/star/awt/XWindowPeer.hpp>
28#include <com/sun/star/container/XNameAccess.hpp>
29#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
30#include <com/sun/star/rendering/CompositeOperation.hpp>
31#include <com/sun/star/rendering/TextDirection.hpp>
32#include <com/sun/star/util/Color.hpp>
46 const sal_Int32 gnHorizontalGap (20);
48 const sal_Int32 gnVerticalButtonPadding (12);
55 std::u16string_view rsLine,
56 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont);
63 void CalculateSize (
const css::uno::Reference<css::rendering::XCanvasFont>& rxFont);
66 class LineDescriptorList
71 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
72 const sal_Int32 nMaximalWidth);
75 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
76 const sal_Int32 nMaximalWidth);
79 const Reference<rendering::XCanvas>& rxCanvas,
80 const geometry::RealRectangle2D& rBBox,
81 const bool bFlushLeft,
82 const rendering::ViewState& rViewState,
83 rendering::RenderState& rRenderState,
84 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont)
const;
85 double GetHeight()
const;
91 static void SplitText (std::u16string_view rsText, vector<OUString>& rTextParts);
93 const vector<OUString>& rTextParts,
94 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
95 const sal_Int32 nMaximalWidth);
102 const OUString& rsLeftText,
103 const OUString& rsRightText,
104 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
105 const sal_Int32 nMaximalWidth);
106 Block(
const Block&) =
delete;
107 Block& operator=(
const Block&) =
delete;
109 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
110 const sal_Int32 nMaximalWidth);
122 const Reference<uno::XComponentContext>& rxContext,
123 const Reference<XResourceId>& rxViewId,
136 Reference<XConfigurationController> xCC (
137 rxController->getConfigurationController(), UNO_SET_THROW);
138 mxPane.set(xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
145 Reference<awt::XWindowPeer> xPeer (
mxWindow, UNO_QUERY);
147 xPeer->setBackground(util::Color(0xff000000));
192 xComponent->dispose();
197 mxWindow->removeWindowListener(
this);
198 mxWindow->removePaintListener(
this);
206 if (rEventObject.Source ==
mxCanvas)
210 else if (rEventObject.Source ==
mxWindow)
245 Paint(rEvent.UpdateRect);
255 const awt::Rectangle aWindowBox (
mxWindow->getPosSize());
260 awt::Rectangle(0,0,aWindowBox.Width,aWindowBox.Height),
265 rendering::ViewState aViewState(
266 geometry::AffineMatrix2D(1,0,0, 0,1,0),
269 rendering::RenderState aRenderState (
270 geometry::AffineMatrix2D(1,0,0, 0,1,0),
273 rendering::CompositeOperation::SOURCE);
293 sal_Int32 LeftX1 = gnHorizontalGap;
294 sal_Int32 LeftX2 = aWindowBox.Width/2 - gnHorizontalGap;
295 sal_Int32 RightX1 = aWindowBox.Width/2 + gnHorizontalGap;
296 sal_Int32 RightX2 = aWindowBox.Width - gnHorizontalGap;
301 LeftX1 = aWindowBox.Width/2 + gnHorizontalGap;
302 LeftX2 = aWindowBox.Width - gnHorizontalGap;
303 RightX1 = gnHorizontalGap;
304 RightX2 = aWindowBox.Width/2 - gnHorizontalGap;
306 const double nLeftHeight (
308 geometry::RealRectangle2D(
317 const double nRightHeight (
319 geometry::RealRectangle2D(
329 nY += ::std::max(nLeftHeight,nRightHeight);
332 Reference<rendering::XSpriteCanvas> xSpriteCanvas (
mxCanvas, UNO_QUERY);
333 if (xSpriteCanvas.is())
334 xSpriteCanvas->updateScreen(
false);
342 "/org.openoffice.Office.PresenterScreen/",
344 Reference<container::XNameAccess> xStrings (
349 [
this](OUString
const&, uno::Reference<beans::XPropertySet>
const& xProps)
356 const Reference<beans::XPropertySet>& rsProperties)
358 if ( ! rsProperties.is())
366 std::make_shared<Block>(
375 sal_Int32 nBestSize (6);
380 for (
int nLoopCount=0; nLoopCount<5; ++nLoopCount)
383 [](
const double& sum,
const std::shared_ptr<Block>& rxBlock) {
384 return sum + std::max(
385 rxBlock->maLeft.GetHeight(),
386 rxBlock->maRight.GetHeight());
390 if (nHeightDifference <= 0 && nHeightDifference > -50)
400 if (nScale > 1.0 && nScale < 1.05)
403 sal_Int32 nFontSizeGuess (sal_Int32(
mpFont->mnSize * nScale));
404 if (nHeightDifference<=0 && mpFont->
mnSize>nBestSize)
405 nBestSize =
mpFont->mnSize;
406 mpFont->mnSize = nFontSizeGuess;
415 if (nBestSize !=
mpFont->mnSize)
417 mpFont->mnSize = nBestSize;
450 Reference<lang::XComponent> xComponent (
mxCanvas, UNO_QUERY);
452 xComponent->addEventListener(
static_cast<awt::XPaintListener*
>(
this));
464 const awt::Rectangle aWindowBox (
mxWindow->getPosSize());
472 aWindowBox.Width/2.0,
480 if (rBHelper.bDisposed || rBHelper.bInDispose)
482 throw lang::DisposedException (
483 "PresenterHelpView has been already disposed",
484 static_cast<uno::XWeak*
>(
this));
492LineDescriptor::LineDescriptor()
498void LineDescriptor::AddPart (
499 std::u16string_view rsLine,
500 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont)
504 CalculateSize(rxFont);
507bool LineDescriptor::IsEmpty()
const
512void LineDescriptor::CalculateSize (
513 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont)
515 OSL_ASSERT(rxFont.is());
517 rendering::StringContext aContext (
msLine, 0,
msLine.getLength());
518 Reference<rendering::XTextLayout> xLayout (
519 rxFont->createTextLayout(aContext, rendering::TextDirection::WEAK_LEFT_TO_RIGHT, 0));
520 const geometry::RealRectangle2D aTextBBox (xLayout->queryTextBounds());
521 maSize = css::geometry::RealSize2D(aTextBBox.X2 - aTextBBox.X1, aTextBBox.Y2 - aTextBBox.Y1);
531LineDescriptorList::LineDescriptorList (
533 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
534 const sal_Int32 nMaximalWidth)
537 Update(rxFont, nMaximalWidth);
540double LineDescriptorList::Paint(
541 const Reference<rendering::XCanvas>& rxCanvas,
542 const geometry::RealRectangle2D& rBBox,
543 const bool bFlushLeft,
544 const rendering::ViewState& rViewState,
545 rendering::RenderState& rRenderState,
546 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont)
const
548 if ( ! rxCanvas.is())
551 double nY (rBBox.Y1);
560 nX = rBBox.X2 - rLine.maSize.Width;
564 nX=rBBox.X2 - rLine.maSize.Width;
568 rRenderState.AffineTransform.m02 = nX;
569 rRenderState.AffineTransform.m12 = nY + rLine.maSize.Height - rLine.mnVerticalOffset;
571 const rendering::StringContext aContext (rLine.msLine, 0, rLine.msLine.getLength());
572 Reference<rendering::XTextLayout> xLayout (
573 rxFont->createTextLayout(aContext, rendering::TextDirection::WEAK_LEFT_TO_RIGHT, 0));
574 rxCanvas->drawTextLayout (
579 nY += rLine.maSize.Height * 1.2;
582 return nY - rBBox.Y1;
585double LineDescriptorList::GetHeight()
const
588 [](
const double& nHeight,
const LineDescriptor& rLine) {
589 return nHeight + rLine.maSize.Height * 1.2;
593void LineDescriptorList::Update (
594 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
595 const sal_Int32 nMaximalWidth)
597 vector<OUString> aTextParts;
598 SplitText(
msText, aTextParts);
599 FormatText(aTextParts, rxFont, nMaximalWidth);
602void LineDescriptorList::SplitText (
603 std::u16string_view rsText,
604 vector<OUString>& rTextParts)
606 const char cQuote (
'\'');
607 const char cSeparator (
',');
611 size_t nLength (rsText.size());
612 bool bIsQuoted (
false);
613 while (nIndex < nLength)
615 const size_t nQuoteIndex (rsText.find(cQuote, nIndex));
616 const size_t nSeparatorIndex (rsText.find(cSeparator, nIndex));
617 if (nQuoteIndex != std::u16string_view::npos &&
618 (nSeparatorIndex == std::u16string_view::npos || nQuoteIndex<nSeparatorIndex))
620 bIsQuoted = !bIsQuoted;
625 const sal_Int32 nNextIndex = nSeparatorIndex;
630 else if ( ! bIsQuoted)
632 rTextParts.push_back(OUString(rsText.substr(nStart, nNextIndex-nStart)));
633 nStart = nNextIndex + 1;
637 if (nStart < nLength)
638 rTextParts.push_back(OUString(rsText.substr(nStart, nLength-nStart)));
641void LineDescriptorList::FormatText (
642 const vector<OUString>& rTextParts,
643 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
644 const sal_Int32 nMaximalWidth)
646 LineDescriptor aLineDescriptor;
650 vector<OUString>::const_iterator iPart (rTextParts.begin());
651 vector<OUString>::const_iterator iEnd (rTextParts.end());
654 if (aLineDescriptor.IsEmpty())
658 rxFont, *iPart).Width > nMaximalWidth)
660 const char cSpace (
' ');
663 sal_Int32 nStart (0);
664 sal_Int32
nLength (iPart->getLength());
665 while (nIndex < nLength)
667 sal_Int32 nSpaceIndex (iPart->indexOf(cSpace, nIndex));
669 rxFont, iPart->copy(nStart, nSpaceIndex-nStart)).Width <= nMaximalWidth)
672 nSpaceIndex = iPart->indexOf(cSpace, nIndex+1);
676 rxFont, iPart->copy(nStart, nLength-nStart)).Width <= nMaximalWidth)
681 if (nIndex == nStart)
686 aLineDescriptor.AddPart(iPart->subView(nStart, nIndex-nStart), rxFont);
687 if (nIndex != nLength)
690 aLineDescriptor = LineDescriptor();
697 aLineDescriptor.AddPart(*iPart, rxFont);
701 rxFont, aLineDescriptor.msLine+
", "+*iPart).Width > nMaximalWidth)
703 aLineDescriptor.AddPart(u
",", rxFont);
705 aLineDescriptor = LineDescriptor();
710 aLineDescriptor.AddPart(Concat2View(
", "+*iPart), rxFont);
714 if ( ! aLineDescriptor.IsEmpty())
727 const OUString& rsLeftText,
728 const OUString& rsRightText,
729 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
730 const sal_Int32 nMaximalWidth)
731 :
maLeft(rsLeftText, rxFont, nMaximalWidth),
732 maRight(rsRightText, rxFont, nMaximalWidth)
737 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
738 const sal_Int32 nMaximalWidth)
740 maLeft.Update(rxFont, nMaximalWidth);
741 maRight.Update(rxFont, nMaximalWidth);
std::shared_ptr< vector< LineDescriptor > > mpLineDescriptors
geometry::RealSize2D maSize
LineDescriptorList maRight
LineDescriptorList maLeft
rtl::Reference< PresenterController > mpPresenterController
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
static bool GetLayoutRTL()
static css::geometry::RealSize2D GetTextSize(const css::uno::Reference< css::rendering::XCanvasFont > &rxFont, const OUString &rsText)
static void SetDeviceColor(css::rendering::RenderState &rRenderState, const css::util::Color aColor)
This class gives access to the configuration.
css::uno::Any GetConfigurationNode(const OUString &rsPathToNode)
Return a configuration node below the root of the called object.
static css::uno::Any GetProperty(const css::uno::Reference< css::beans::XPropertySet > &rxProperties, const OUString &rsKey)
This method wraps a call to getPropertyValue() and returns an empty Any instead of throwing an except...
static void ForAll(const css::uno::Reference< css::container::XNameAccess > &rxContainer, const ::std::vector< OUString > &rArguments, const ItemProcessor &rProcessor)
Execute a functor for all elements of the given container.
static css::uno::Reference< css::rendering::XPolyPolygon2D > CreatePolygon(const css::awt::Rectangle &rBox, const css::uno::Reference< css::rendering::XGraphicDevice > &rxDevice)
void ProcessString(const css::uno::Reference< css::beans::XPropertySet > &rsProperties)
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
::rtl::Reference< PresenterButton > mpCloseButton
css::uno::Reference< css::awt::XWindow > mxWindow
css::uno::Reference< css::rendering::XCanvas > mxCanvas
virtual css::uno::Reference< css::drawing::framework::XResourceId > SAL_CALL getResourceId() override
PresenterTheme::SharedFontDescriptor mpFont
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
std::unique_ptr< TextContainer > mpTextContainer
void Paint(const css::awt::Rectangle &rRedrawArea)
virtual ~PresenterHelpView() override
virtual sal_Bool SAL_CALL isAnchorOnly() override
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override
css::uno::Reference< css::drawing::framework::XPane > mxPane
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
void CheckFontSize()
Find a font size, so that all text can be displayed at the same time.
css::uno::Reference< css::drawing::framework::XResourceId > mxViewId
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
::rtl::Reference< PresenterController > mpPresenterController
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
virtual void SAL_CALL disposing() override
PresenterHelpView(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId, const rtl::Reference<::sd::DrawController > &rxController, ::rtl::Reference< PresenterController > xPresenterController)
cppu::WeakComponentImplHelper< css::drawing::framework::XView, css::awt::XWindowListener, css::awt::XPaintListener > PresenterHelpViewInterfaceBase
const double gnVerticalBorder(5)