LibreOffice Module sdext (master)  1
PresenterHelpView.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <vcl/settings.hxx>
21 #include "PresenterHelpView.hxx"
22 #include "PresenterButton.hxx"
25 #include <com/sun/star/awt/XWindowPeer.hpp>
26 #include <com/sun/star/container/XNameAccess.hpp>
27 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
28 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
29 #include <com/sun/star/rendering/CompositeOperation.hpp>
30 #include <com/sun/star/rendering/TextDirection.hpp>
31 #include <com/sun/star/util/Color.hpp>
32 #include <algorithm>
33 #include <numeric>
34 #include <string_view>
35 #include <vector>
36 
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::drawing::framework;
40 using ::std::vector;
41 
42 namespace sdext::presenter {
43 
44 namespace {
45  const sal_Int32 gnHorizontalGap (20);
46  const sal_Int32 gnVerticalBorder (30);
47  const sal_Int32 gnVerticalButtonPadding (12);
48 
49  class LineDescriptor
50  {
51  public:
52  LineDescriptor();
53  void AddPart (
54  std::u16string_view rsLine,
55  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont);
56  bool IsEmpty() const;
57 
58  OUString msLine;
59  geometry::RealSize2D maSize;
61 
62  void CalculateSize (const css::uno::Reference<css::rendering::XCanvasFont>& rxFont);
63  };
64 
65  class LineDescriptorList
66  {
67  public:
68  LineDescriptorList (
69  const OUString& rsText,
70  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
71  const sal_Int32 nMaximalWidth);
72 
73  void Update (
74  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
75  const sal_Int32 nMaximalWidth);
76 
77  double Paint(
78  const Reference<rendering::XCanvas>& rxCanvas,
79  const geometry::RealRectangle2D& rBBox,
80  const bool bFlushLeft,
81  const rendering::ViewState& rViewState,
82  rendering::RenderState& rRenderState,
83  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont) const;
84  double GetHeight() const;
85 
86  private:
87  const OUString msText;
88  std::shared_ptr<vector<LineDescriptor> > mpLineDescriptors;
89 
90  static void SplitText (const OUString& rsText, vector<OUString>& rTextParts);
91  void FormatText (
92  const vector<OUString>& rTextParts,
93  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
94  const sal_Int32 nMaximalWidth);
95  };
96 
97  class Block
98  {
99  public:
100  Block (
101  const OUString& rsLeftText,
102  const OUString& rsRightText,
103  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
104  const sal_Int32 nMaximalWidth);
105  Block(const Block&) = delete;
106  Block& operator=(const Block&) = delete;
107  void Update (
108  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
109  const sal_Int32 nMaximalWidth);
110 
111  LineDescriptorList maLeft;
112  LineDescriptorList maRight;
113  };
114 } // end of anonymous namespace
115 
116 class PresenterHelpView::TextContainer : public vector<std::shared_ptr<Block> >
117 {
118 };
119 
121  const Reference<uno::XComponentContext>& rxContext,
122  const Reference<XResourceId>& rxViewId,
123  const Reference<frame::XController>& rxController,
124  const ::rtl::Reference<PresenterController>& rpPresenterController)
126  mxComponentContext(rxContext),
127  mxViewId(rxViewId),
128  mxPane(),
129  mxWindow(),
130  mxCanvas(),
131  mpPresenterController(rpPresenterController),
132  mpFont(),
133  mpTextContainer(),
134  mpCloseButton(),
135  mnSeparatorY(0),
136  mnMaximalWidth(0)
137 {
138  try
139  {
140  // Get the content window via the pane anchor.
141  Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
142  Reference<XConfigurationController> xCC (
143  xCM->getConfigurationController(), UNO_SET_THROW);
144  mxPane.set(xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
145 
146  mxWindow = mxPane->getWindow();
147  ProvideCanvas();
148 
149  mxWindow->addWindowListener(this);
150  mxWindow->addPaintListener(this);
151  Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
152  if (xPeer.is())
153  xPeer->setBackground(util::Color(0xff000000));
154  mxWindow->setVisible(true);
155 
156  if (mpPresenterController.is())
157  {
158  mpFont = mpPresenterController->GetViewFont(mxViewId->getResourceURL());
159  if (mpFont)
160  {
161  mpFont->PrepareFont(mxCanvas);
162  }
163  }
164 
165  // Create the close button.
169  mpPresenterController->GetTheme(),
170  mxWindow,
171  mxCanvas,
172  "HelpViewCloser");
173 
174  ReadHelpStrings();
175  Resize();
176  }
177  catch (RuntimeException&)
178  {
179  mxViewId = nullptr;
180  mxWindow = nullptr;
181  throw;
182  }
183 }
184 
186 {
187 }
188 
190 {
191  mxViewId = nullptr;
192 
193  if (mpCloseButton.is())
194  {
195  Reference<lang::XComponent> xComponent (
196  static_cast<XWeak*>(mpCloseButton.get()), UNO_QUERY);
197  mpCloseButton = nullptr;
198  if (xComponent.is())
199  xComponent->dispose();
200  }
201 
202  if (mxWindow.is())
203  {
204  mxWindow->removeWindowListener(this);
205  mxWindow->removePaintListener(this);
206  }
207 }
208 
209 //----- lang::XEventListener --------------------------------------------------
210 
211 void SAL_CALL PresenterHelpView::disposing (const lang::EventObject& rEventObject)
212 {
213  if (rEventObject.Source == mxCanvas)
214  {
215  mxCanvas = nullptr;
216  }
217  else if (rEventObject.Source == mxWindow)
218  {
219  mxWindow = nullptr;
220  dispose();
221  }
222 }
223 
224 //----- XWindowListener -------------------------------------------------------
225 
226 void SAL_CALL PresenterHelpView::windowResized (const awt::WindowEvent&)
227 {
228  ThrowIfDisposed();
229  Resize();
230 }
231 
232 void SAL_CALL PresenterHelpView::windowMoved (const awt::WindowEvent&)
233 {
234  ThrowIfDisposed();
235 }
236 
237 void SAL_CALL PresenterHelpView::windowShown (const lang::EventObject&)
238 {
239  ThrowIfDisposed();
240  Resize();
241 }
242 
243 void SAL_CALL PresenterHelpView::windowHidden (const lang::EventObject&)
244 {
245  ThrowIfDisposed();
246 }
247 
248 //----- XPaintListener --------------------------------------------------------
249 
250 void SAL_CALL PresenterHelpView::windowPaint (const css::awt::PaintEvent& rEvent)
251 {
252  Paint(rEvent.UpdateRect);
253 }
254 
255 void PresenterHelpView::Paint (const awt::Rectangle& rUpdateBox)
256 {
257  ProvideCanvas();
258  if ( ! mxCanvas.is())
259  return;
260 
261  // Clear background.
262  const awt::Rectangle aWindowBox (mxWindow->getPosSize());
263  mpPresenterController->GetCanvasHelper()->Paint(
264  mpPresenterController->GetViewBackground(mxViewId->getResourceURL()),
265  mxCanvas,
266  rUpdateBox,
267  awt::Rectangle(0,0,aWindowBox.Width,aWindowBox.Height),
268  awt::Rectangle());
269 
270  // Paint vertical divider.
271 
272  rendering::ViewState aViewState(
273  geometry::AffineMatrix2D(1,0,0, 0,1,0),
274  PresenterGeometryHelper::CreatePolygon(rUpdateBox, mxCanvas->getDevice()));
275 
276  rendering::RenderState aRenderState (
277  geometry::AffineMatrix2D(1,0,0, 0,1,0),
278  nullptr,
279  Sequence<double>(4),
280  rendering::CompositeOperation::SOURCE);
281  PresenterCanvasHelper::SetDeviceColor(aRenderState, mpFont->mnColor);
282 
283  mxCanvas->drawLine(
284  geometry::RealPoint2D((aWindowBox.Width/2.0), gnVerticalBorder),
285  geometry::RealPoint2D((aWindowBox.Width/2.0), mnSeparatorY - gnVerticalBorder),
286  aViewState,
287  aRenderState);
288 
289  // Paint the horizontal separator.
290  mxCanvas->drawLine(
291  geometry::RealPoint2D(0, mnSeparatorY),
292  geometry::RealPoint2D(aWindowBox.Width, mnSeparatorY),
293  aViewState,
294  aRenderState);
295 
296  // Paint text.
297  double nY (gnVerticalBorder);
298  for (const auto& rxBlock : *mpTextContainer)
299  {
300  sal_Int32 LeftX1 = gnHorizontalGap;
301  sal_Int32 LeftX2 = aWindowBox.Width/2 - gnHorizontalGap;
302  sal_Int32 RightX1 = aWindowBox.Width/2 + gnHorizontalGap;
303  sal_Int32 RightX2 = aWindowBox.Width - gnHorizontalGap;
304  /* check whether RTL interface or not
305  then replace the windowbox position */
307  {
308  LeftX1 = aWindowBox.Width/2 + gnHorizontalGap;
309  LeftX2 = aWindowBox.Width - gnHorizontalGap;
310  RightX1 = gnHorizontalGap;
311  RightX2 = aWindowBox.Width/2 - gnHorizontalGap;
312  }
313  const double nLeftHeight (
314  rxBlock->maLeft.Paint(mxCanvas,
315  geometry::RealRectangle2D(
316  LeftX1,
317  nY,
318  LeftX2,
319  aWindowBox.Height - gnVerticalBorder),
320  false,
321  aViewState,
322  aRenderState,
323  mpFont->mxFont));
324  const double nRightHeight (
325  rxBlock->maRight.Paint(mxCanvas,
326  geometry::RealRectangle2D(
327  RightX1,
328  nY,
329  RightX2,
330  aWindowBox.Height - gnVerticalBorder),
331  true,
332  aViewState,
333  aRenderState,
334  mpFont->mxFont));
335 
336  nY += ::std::max(nLeftHeight,nRightHeight);
337  }
338 
339  Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
340  if (xSpriteCanvas.is())
341  xSpriteCanvas->updateScreen(false);
342 }
343 
345 {
346  mpTextContainer.reset(new TextContainer);
347  PresenterConfigurationAccess aConfiguration (
349  "/org.openoffice.Office.PresenterScreen/",
352  aConfiguration.GetConfigurationNode("PresenterScreenSettings/HelpView/HelpStrings"),
353  UNO_QUERY);
355  xStrings,
356  [this](OUString const&, uno::Reference<beans::XPropertySet> const& xProps)
357  {
358  return this->ProcessString(xProps);
359  });
360 }
361 
363  const Reference<beans::XPropertySet>& rsProperties)
364 {
365  if ( ! rsProperties.is())
366  return;
367 
368  OUString sLeftText;
369  PresenterConfigurationAccess::GetProperty(rsProperties, "Left") >>= sLeftText;
370  OUString sRightText;
371  PresenterConfigurationAccess::GetProperty(rsProperties, "Right") >>= sRightText;
372  mpTextContainer->push_back(
373  std::make_shared<Block>(
374  sLeftText, sRightText, mpFont->mxFont, mnMaximalWidth));
375 }
376 
378 {
379  if (!mpFont)
380  return;
381 
382  sal_Int32 nBestSize (6);
383 
384  // Scaling down and then reformatting can cause the text to be too large
385  // still. So do this again and again until the text size is
386  // small enough. Restrict the number of loops.
387  for (int nLoopCount=0; nLoopCount<5; ++nLoopCount)
388  {
389  double nY = std::accumulate(mpTextContainer->begin(), mpTextContainer->end(), double(0),
390  [](const double& sum, const std::shared_ptr<Block>& rxBlock) {
391  return sum + std::max(
392  rxBlock->maLeft.GetHeight(),
393  rxBlock->maRight.GetHeight());
394  });
395 
396  const double nHeightDifference (nY - (mnSeparatorY-gnVerticalBorder));
397  if (nHeightDifference <= 0 && nHeightDifference > -50)
398  {
399  // We have found a good font size that is large and leaves not
400  // too much space below the help text.
401  return;
402  }
403 
404  // Use a simple linear transformation to calculate initial guess of
405  // a size that lets all help text be shown inside the window.
406  const double nScale (double(mnSeparatorY-gnVerticalBorder) / nY);
407  if (nScale > 1.0 && nScale < 1.05)
408  break;
409 
410  sal_Int32 nFontSizeGuess (sal_Int32(mpFont->mnSize * nScale));
411  if (nHeightDifference<=0 && mpFont->mnSize>nBestSize)
412  nBestSize = mpFont->mnSize;
413  mpFont->mnSize = nFontSizeGuess;
414  mpFont->mxFont = nullptr;
415  mpFont->PrepareFont(mxCanvas);
416 
417  // Reformat blocks.
418  for (auto& rxBlock : *mpTextContainer)
419  rxBlock->Update(mpFont->mxFont, mnMaximalWidth);
420  }
421 
422  if (nBestSize != mpFont->mnSize)
423  {
424  mpFont->mnSize = nBestSize;
425  mpFont->mxFont = nullptr;
426  mpFont->PrepareFont(mxCanvas);
427 
428  // Reformat blocks.
429  for (auto& rxBlock : *mpTextContainer)
430  {
431  rxBlock->Update(mpFont->mxFont, mnMaximalWidth);
432  }
433  }
434 }
435 
436 //----- XResourceId -----------------------------------------------------------
437 
438 Reference<XResourceId> SAL_CALL PresenterHelpView::getResourceId()
439 {
440  ThrowIfDisposed();
441  return mxViewId;
442 }
443 
445 {
446  return false;
447 }
448 
449 
451 {
452  if ( ! mxCanvas.is() && mxPane.is())
453  {
454  mxCanvas = mxPane->getCanvas();
455  if ( ! mxCanvas.is())
456  return;
457  Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
458  if (xComponent.is())
459  xComponent->addEventListener(static_cast<awt::XPaintListener*>(this));
460 
461  if (mpCloseButton.is())
462  mpCloseButton->SetCanvas(mxCanvas, mxWindow);
463  }
464 }
465 
467 {
468  if (!(mpCloseButton && mxWindow.is()))
469  return;
470 
471  const awt::Rectangle aWindowBox (mxWindow->getPosSize());
472  mnMaximalWidth = (mxWindow->getPosSize().Width - 4*gnHorizontalGap) / 2;
473 
474  // Place vertical separator.
475  mnSeparatorY = aWindowBox.Height
476  - mpCloseButton->GetSize().Height - gnVerticalButtonPadding;
477 
478  mpCloseButton->SetCenter(geometry::RealPoint2D(
479  aWindowBox.Width/2.0,
480  aWindowBox.Height - mpCloseButton->GetSize().Height/2.0));
481 
482  CheckFontSize();
483 }
484 
486 {
487  if (rBHelper.bDisposed || rBHelper.bInDispose)
488  {
489  throw lang::DisposedException (
490  "PresenterHelpView has been already disposed",
491  static_cast<uno::XWeak*>(this));
492  }
493 }
494 
495 //===== LineDescriptor =========================================================
496 
497 namespace {
498 
499 LineDescriptor::LineDescriptor()
500  : msLine(),
501  maSize(0,0),
503 {
504 }
505 
506 void LineDescriptor::AddPart (
507  std::u16string_view rsLine,
508  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont)
509 {
510  msLine += rsLine;
511 
512  CalculateSize(rxFont);
513 }
514 
515 bool LineDescriptor::IsEmpty() const
516 {
517  return msLine.isEmpty();
518 }
519 
520 void LineDescriptor::CalculateSize (
521  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont)
522 {
523  OSL_ASSERT(rxFont.is());
524 
525  rendering::StringContext aContext (msLine, 0, msLine.getLength());
526  Reference<rendering::XTextLayout> xLayout (
527  rxFont->createTextLayout(aContext, rendering::TextDirection::WEAK_LEFT_TO_RIGHT, 0));
528  const geometry::RealRectangle2D aTextBBox (xLayout->queryTextBounds());
529  maSize = css::geometry::RealSize2D(aTextBBox.X2 - aTextBBox.X1, aTextBBox.Y2 - aTextBBox.Y1);
530  mnVerticalOffset = aTextBBox.Y2;
531 }
532 
533 } // end of anonymous namespace
534 
535 //===== LineDescriptorList ====================================================
536 
537 namespace {
538 
539 LineDescriptorList::LineDescriptorList (
540  const OUString& rsText,
541  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
542  const sal_Int32 nMaximalWidth)
543  : msText(rsText)
544 {
545  Update(rxFont, nMaximalWidth);
546 }
547 
548 double LineDescriptorList::Paint(
549  const Reference<rendering::XCanvas>& rxCanvas,
550  const geometry::RealRectangle2D& rBBox,
551  const bool bFlushLeft,
552  const rendering::ViewState& rViewState,
553  rendering::RenderState& rRenderState,
554  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont) const
555 {
556  if ( ! rxCanvas.is())
557  return 0;
558 
559  double nY (rBBox.Y1);
560  for (const auto& rLine : *mpLineDescriptors)
561  {
562  double nX;
565  {
566  nX = rBBox.X1;
567  if ( ! bFlushLeft)
568  nX = rBBox.X2 - rLine.maSize.Width;
569  }
570  else
571  {
572  nX=rBBox.X2 - rLine.maSize.Width;
573  if ( ! bFlushLeft)
574  nX = rBBox.X1;
575  }
576  rRenderState.AffineTransform.m02 = nX;
577  rRenderState.AffineTransform.m12 = nY + rLine.maSize.Height - rLine.mnVerticalOffset;
578 
579  const rendering::StringContext aContext (rLine.msLine, 0, rLine.msLine.getLength());
580  Reference<rendering::XTextLayout> xLayout (
581  rxFont->createTextLayout(aContext, rendering::TextDirection::WEAK_LEFT_TO_RIGHT, 0));
582  rxCanvas->drawTextLayout (
583  xLayout,
584  rViewState,
585  rRenderState);
586 
587  nY += rLine.maSize.Height * 1.2;
588  }
589 
590  return nY - rBBox.Y1;
591 }
592 
593 double LineDescriptorList::GetHeight() const
594 {
595  return std::accumulate(mpLineDescriptors->begin(), mpLineDescriptors->end(), double(0),
596  [](const double& nHeight, const LineDescriptor& rLine) {
597  return nHeight + rLine.maSize.Height * 1.2;
598  });
599 }
600 
601 void LineDescriptorList::Update (
602  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
603  const sal_Int32 nMaximalWidth)
604 {
605  vector<OUString> aTextParts;
606  SplitText(msText, aTextParts);
607  FormatText(aTextParts, rxFont, nMaximalWidth);
608 }
609 
610 void LineDescriptorList::SplitText (
611  const OUString& rsText,
612  vector<OUString>& rTextParts)
613 {
614  const char cQuote ('\'');
615  const char cSeparator (',');
616 
617  sal_Int32 nIndex (0);
618  sal_Int32 nStart (0);
619  sal_Int32 nLength (rsText.getLength());
620  bool bIsQuoted (false);
621  while (nIndex < nLength)
622  {
623  const sal_Int32 nQuoteIndex (rsText.indexOf(cQuote, nIndex));
624  const sal_Int32 nSeparatorIndex (rsText.indexOf(cSeparator, nIndex));
625  if (nQuoteIndex>=0 && (nSeparatorIndex==-1 || nQuoteIndex<nSeparatorIndex))
626  {
627  bIsQuoted = !bIsQuoted;
628  nIndex = nQuoteIndex+1;
629  continue;
630  }
631 
632  const sal_Int32 nNextIndex = nSeparatorIndex;
633  if (nNextIndex < 0)
634  {
635  break;
636  }
637  else if ( ! bIsQuoted)
638  {
639  rTextParts.push_back(rsText.copy(nStart, nNextIndex-nStart));
640  nStart = nNextIndex + 1;
641  }
642  nIndex = nNextIndex+1;
643  }
644  if (nStart < nLength)
645  rTextParts.push_back(rsText.copy(nStart, nLength-nStart));
646 }
647 
648 void LineDescriptorList::FormatText (
649  const vector<OUString>& rTextParts,
650  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
651  const sal_Int32 nMaximalWidth)
652 {
653  LineDescriptor aLineDescriptor;
654 
655  mpLineDescriptors = std::make_shared<vector<LineDescriptor>>();
656 
657  vector<OUString>::const_iterator iPart (rTextParts.begin());
658  vector<OUString>::const_iterator iEnd (rTextParts.end());
659  while (iPart!=iEnd)
660  {
661  if (aLineDescriptor.IsEmpty())
662  {
663  // Avoid empty lines.
665  rxFont, *iPart).Width > nMaximalWidth)
666  {
667  const char cSpace (' ');
668 
669  sal_Int32 nIndex (0);
670  sal_Int32 nStart (0);
671  sal_Int32 nLength (iPart->getLength());
672  while (nIndex < nLength)
673  {
674  sal_Int32 nSpaceIndex (iPart->indexOf(cSpace, nIndex));
675  while (nSpaceIndex >= 0 && PresenterCanvasHelper::GetTextSize(
676  rxFont, iPart->copy(nStart, nSpaceIndex-nStart)).Width <= nMaximalWidth)
677  {
678  nIndex = nSpaceIndex;
679  nSpaceIndex = iPart->indexOf(cSpace, nIndex+1);
680  }
681 
682  if (nSpaceIndex < 0 && PresenterCanvasHelper::GetTextSize(
683  rxFont, iPart->copy(nStart, nLength-nStart)).Width <= nMaximalWidth)
684  {
685  nIndex = nLength;
686  }
687 
688  if (nIndex == nStart)
689  {
690  nIndex = nLength;
691  }
692 
693  aLineDescriptor.AddPart(iPart->subView(nStart, nIndex-nStart), rxFont);
694  if (nIndex != nLength)
695  {
696  mpLineDescriptors->push_back(aLineDescriptor);
697  aLineDescriptor = LineDescriptor();
698  }
699  nStart = nIndex;
700  }
701  }
702  else
703  {
704  aLineDescriptor.AddPart(*iPart, rxFont);
705  }
706  }
708  rxFont, aLineDescriptor.msLine+", "+*iPart).Width > nMaximalWidth)
709  {
710  aLineDescriptor.AddPart(u",", rxFont);
711  mpLineDescriptors->push_back(aLineDescriptor);
712  aLineDescriptor = LineDescriptor();
713  continue;
714  }
715  else
716  {
717  aLineDescriptor.AddPart(OUString(", "+*iPart), rxFont);
718  }
719  ++iPart;
720  }
721  if ( ! aLineDescriptor.IsEmpty())
722  {
723  mpLineDescriptors->push_back(aLineDescriptor);
724  }
725 }
726 
727 } // end of anonymous namespace
728 
729 //===== Block =================================================================
730 
731 namespace {
732 
733 Block::Block (
734  const OUString& rsLeftText,
735  const OUString& rsRightText,
736  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
737  const sal_Int32 nMaximalWidth)
738  : maLeft(rsLeftText, rxFont, nMaximalWidth),
739  maRight(rsRightText, rxFont, nMaximalWidth)
740 {
741 }
742 
743 void Block::Update (
744  const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
745  const sal_Int32 nMaximalWidth)
746 {
747  maLeft.Update(rxFont, nMaximalWidth);
748  maRight.Update(rxFont, nMaximalWidth);
749 }
750 
751 } // end of anonymous namespace
752 
753 } // end of namespace ::sdext::presenter
754 
755 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
Reference< rendering::XCanvas > mxCanvas
virtual css::uno::Reference< css::drawing::framework::XResourceId > SAL_CALL getResourceId() override
sal_Int32 nIndex
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...
osl::Mutex m_aMutex
css::uno::Reference< css::drawing::framework::XResourceId > mxViewId
cppu::WeakComponentImplHelper< css::drawing::framework::XView, css::awt::XWindowListener, css::awt::XPaintListener > PresenterHelpViewInterfaceBase
css::uno::Reference< css::awt::XWindow > mxWindow
css::uno::Reference< css::drawing::framework::XPane > mxPane
void Paint(const css::awt::Rectangle &rRedrawArea)
This class gives access to the configuration.
LineDescriptorList maLeft
void CheckFontSize()
Find a font size, so that all text can be displayed at the same time.
PresenterHelpView(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId, const css::uno::Reference< css::frame::XController > &rxController, const ::rtl::Reference< PresenterController > &rpPresenterController)
std::shared_ptr< vector< LineDescriptor > > mpLineDescriptors
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
css::uno::Reference< css::rendering::XCanvas > mxCanvas
std::unique_ptr< TextContainer > mpTextContainer
virtual sal_Bool SAL_CALL isAnchorOnly() override
LineDescriptorList maRight
css::uno::Any GetConfigurationNode(const OUString &rsPathToNode)
Return a configuration node below the root of the called object.
unsigned char sal_Bool
static bool GetLayoutRTL()
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
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)
PresenterTheme::SharedFontDescriptor mpFont
rtl::Reference< PresenterController > mpPresenterController
const OUString msText
::rtl::Reference< PresenterButton > mpCloseButton
static void SetDeviceColor(css::rendering::RenderState &rRenderState, const css::util::Color aColor)
static css::geometry::RealSize2D GetTextSize(const css::uno::Reference< css::rendering::XCanvasFont > &rxFont, const OUString &rsText)
virtual void SAL_CALL disposing() override
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
double mnVerticalOffset
PresenterTheme::SharedFontDescriptor mpFont
::rtl::Reference< PresenterController > mpPresenterController
OUString msLine
sal_Int32 nLength
void dispose()
const double gnVerticalBorder(5)
static::rtl::Reference< PresenterButton > Create(const css::uno::Reference< css::uno::XComponentContext > &rxComponentContext, const ::rtl::Reference< PresenterController > &rpPresenterController, const std::shared_ptr< PresenterTheme > &rpTheme, const css::uno::Reference< css::awt::XWindow > &rxParentWindow, const css::uno::Reference< css::rendering::XCanvas > &rxParentCanvas, const OUString &rsConfigurationName)
geometry::RealSize2D maSize
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
sal_uInt32 mnSize