Line data Source code
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 "PresenterNotesView.hxx"
21 : #include "PresenterButton.hxx"
22 : #include "PresenterCanvasHelper.hxx"
23 : #include "PresenterGeometryHelper.hxx"
24 : #include "PresenterPaintManager.hxx"
25 : #include "PresenterScrollBar.hxx"
26 : #include "PresenterTextView.hxx"
27 : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
28 : #include <com/sun/star/awt/Key.hpp>
29 : #include <com/sun/star/awt/KeyModifier.hpp>
30 : #include <com/sun/star/awt/PosSize.hpp>
31 : #include <com/sun/star/beans/XPropertySet.hpp>
32 : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
33 : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
34 : #include <com/sun/star/drawing/framework/XPane.hpp>
35 : #include <com/sun/star/lang/XServiceName.hpp>
36 : #include <com/sun/star/presentation/XPresentationPage.hpp>
37 : #include <com/sun/star/rendering/CompositeOperation.hpp>
38 : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
39 : #include <com/sun/star/text/XTextRange.hpp>
40 : #include <com/sun/star/util/XChangesBatch.hpp>
41 : #include <com/sun/star/container/XChild.hpp>
42 : #include <boost/bind.hpp>
43 : #include <set>
44 :
45 : using namespace ::com::sun::star;
46 : using namespace ::com::sun::star::uno;
47 : using namespace ::com::sun::star::drawing::framework;
48 : using ::rtl::OUString;
49 :
50 : #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
51 :
52 : static const sal_Int32 gnSpaceBelowSeparator (10);
53 : static const sal_Int32 gnSpaceAboveSeparator (10);
54 : static const sal_Int32 gnPartHeight (128);
55 : /** Maximal size of memory used for bitmaps which show the notes text.
56 : */
57 : static const sal_Int32 gnMaximalCacheSize (8*1024*1024);
58 : static const double gnLineScrollFactor (1.2);
59 :
60 : namespace sdext { namespace presenter {
61 :
62 : //===== PresenterNotesView ====================================================
63 :
64 0 : PresenterNotesView::PresenterNotesView (
65 : const Reference<XComponentContext>& rxComponentContext,
66 : const Reference<XResourceId>& rxViewId,
67 : const Reference<frame::XController>& rxController,
68 : const ::rtl::Reference<PresenterController>& rpPresenterController)
69 : : PresenterNotesViewInterfaceBase(m_aMutex),
70 : mxViewId(rxViewId),
71 : mpPresenterController(rpPresenterController),
72 : mxCanvas(),
73 : mxCurrentNotesPage(),
74 : mpScrollBar(),
75 : mxToolBarWindow(),
76 : mxToolBarCanvas(),
77 : mpToolBar(),
78 : mpCloseButton(),
79 : maSeparatorColor(0xffffff),
80 : mnSeparatorYLocation(0),
81 : maTextBoundingBox(),
82 : mpBackground(),
83 : mnTop(0),
84 : mpFont(),
85 0 : mpTextView()
86 : {
87 : try
88 : {
89 0 : Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
90 0 : Reference<XConfigurationController> xCC (xCM->getConfigurationController(), UNO_QUERY_THROW);
91 0 : Reference<XPane> xPane (xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
92 :
93 0 : mxParentWindow = xPane->getWindow();
94 0 : mxCanvas = xPane->getCanvas();
95 : mpTextView.reset(new PresenterTextView(
96 : rxComponentContext,
97 : mxCanvas,
98 0 : mpPresenterController->GetPaintManager()->GetInvalidator(mxParentWindow)));
99 :
100 0 : const OUString sResourceURL (mxViewId->getResourceURL());
101 : mpFont.reset(new PresenterTheme::FontDescriptor(
102 0 : rpPresenterController->GetViewFont(sResourceURL)));
103 0 : maSeparatorColor = mpFont->mnColor;
104 0 : mpTextView->SetFont(mpFont);
105 :
106 0 : CreateToolBar(rxComponentContext, rpPresenterController);
107 :
108 : mpCloseButton = PresenterButton::Create(
109 : rxComponentContext,
110 : mpPresenterController,
111 : mpPresenterController->GetTheme(),
112 : mxParentWindow,
113 : mxCanvas,
114 0 : A2S("NotesViewCloser"));
115 :
116 0 : if (mxParentWindow.is())
117 : {
118 0 : mxParentWindow->addWindowListener(this);
119 0 : mxParentWindow->addPaintListener(this);
120 0 : mxParentWindow->addKeyListener(this);
121 0 : mxParentWindow->setVisible(sal_True);
122 : }
123 :
124 : mpScrollBar = new PresenterVerticalScrollBar(
125 : rxComponentContext,
126 : mxParentWindow,
127 : mpPresenterController->GetPaintManager(),
128 0 : ::boost::bind(&PresenterNotesView::SetTop, this, _1));
129 : mpScrollBar->SetBackground(
130 0 : mpPresenterController->GetViewBackground(mxViewId->getResourceURL()));
131 :
132 0 : mpScrollBar->SetCanvas(mxCanvas);
133 :
134 0 : Layout();
135 : }
136 0 : catch (RuntimeException&)
137 : {
138 0 : PresenterNotesView::disposing();
139 0 : throw;
140 : }
141 0 : }
142 :
143 0 : PresenterNotesView::~PresenterNotesView (void)
144 : {
145 0 : }
146 :
147 0 : void SAL_CALL PresenterNotesView::disposing (void)
148 : {
149 0 : if (mxParentWindow.is())
150 : {
151 0 : mxParentWindow->removeWindowListener(this);
152 0 : mxParentWindow->removePaintListener(this);
153 0 : mxParentWindow->removeKeyListener(this);
154 0 : mxParentWindow = NULL;
155 : }
156 :
157 : // Dispose tool bar.
158 : {
159 0 : Reference<XComponent> xComponent (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
160 0 : mpToolBar = NULL;
161 0 : if (xComponent.is())
162 0 : xComponent->dispose();
163 : }
164 : {
165 0 : Reference<XComponent> xComponent (mxToolBarCanvas, UNO_QUERY);
166 0 : mxToolBarCanvas = NULL;
167 0 : if (xComponent.is())
168 0 : xComponent->dispose();
169 : }
170 : {
171 0 : Reference<XComponent> xComponent (mxToolBarWindow, UNO_QUERY);
172 0 : mxToolBarWindow = NULL;
173 0 : if (xComponent.is())
174 0 : xComponent->dispose();
175 : }
176 :
177 : // Dispose close button
178 : {
179 0 : Reference<XComponent> xComponent (static_cast<XWeak*>(mpCloseButton.get()), UNO_QUERY);
180 0 : mpCloseButton = NULL;
181 0 : if (xComponent.is())
182 0 : xComponent->dispose();
183 : }
184 :
185 : // Create the tool bar.
186 :
187 0 : mpScrollBar = NULL;
188 :
189 0 : mxViewId = NULL;
190 0 : }
191 :
192 0 : void PresenterNotesView::CreateToolBar (
193 : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
194 : const ::rtl::Reference<PresenterController>& rpPresenterController)
195 : {
196 0 : if (rpPresenterController.get() == NULL)
197 : return;
198 :
199 : Reference<drawing::XPresenterHelper> xPresenterHelper (
200 0 : rpPresenterController->GetPresenterHelper());
201 0 : if ( ! xPresenterHelper.is())
202 : return;
203 :
204 : // Create a new window as container of the tool bar.
205 0 : mxToolBarWindow = xPresenterHelper->createWindow(
206 : mxParentWindow,
207 : sal_False,
208 : sal_True,
209 : sal_False,
210 0 : sal_False);
211 0 : mxToolBarCanvas = xPresenterHelper->createSharedCanvas (
212 : Reference<rendering::XSpriteCanvas>(mxCanvas, UNO_QUERY),
213 : mxParentWindow,
214 : mxCanvas,
215 : mxParentWindow,
216 0 : mxToolBarWindow);
217 :
218 : // Create the tool bar.
219 : mpToolBar = new PresenterToolBar(
220 : rxContext,
221 : mxToolBarWindow,
222 : mxToolBarCanvas,
223 : rpPresenterController,
224 0 : PresenterToolBar::Left);
225 : mpToolBar->Initialize(
226 0 : A2S("PresenterScreenSettings/ToolBars/NotesToolBar"));
227 : }
228 :
229 0 : void PresenterNotesView::SetSlide (const Reference<drawing::XDrawPage>& rxNotesPage)
230 : {
231 : static const ::rtl::OUString sNotesShapeName (
232 0 : A2S("com.sun.star.presentation.NotesShape"));
233 : static const ::rtl::OUString sTextShapeName (
234 0 : A2S("com.sun.star.drawing.TextShape"));
235 :
236 0 : Reference<container::XIndexAccess> xIndexAccess (rxNotesPage, UNO_QUERY);
237 0 : if (xIndexAccess.is())
238 : {
239 0 : ::rtl::OUString sText;
240 :
241 : // Iterate over all shapes and find the one that holds the text.
242 0 : sal_Int32 nCount (xIndexAccess->getCount());
243 0 : for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
244 : {
245 :
246 : Reference<lang::XServiceName> xServiceName (
247 0 : xIndexAccess->getByIndex(nIndex), UNO_QUERY);
248 0 : if (xServiceName.is()
249 0 : && xServiceName->getServiceName().equals(sNotesShapeName))
250 : {
251 0 : Reference<text::XTextRange> xText (xServiceName, UNO_QUERY);
252 0 : if (xText.is())
253 : {
254 0 : sText += xText->getString();
255 0 : }
256 : }
257 : else
258 : {
259 : Reference<drawing::XShapeDescriptor> xShapeDescriptor (
260 0 : xIndexAccess->getByIndex(nIndex), UNO_QUERY);
261 0 : if (xShapeDescriptor.is())
262 : {
263 0 : ::rtl::OUString sType (xShapeDescriptor->getShapeType());
264 0 : if (sType.equals(sNotesShapeName) || sType.equals(sTextShapeName))
265 : {
266 : Reference<text::XTextRange> xText (
267 0 : xIndexAccess->getByIndex(nIndex), UNO_QUERY);
268 0 : if (xText.is())
269 : {
270 0 : sText += xText->getString();
271 0 : mpTextView->SetText(Reference<text::XText>(xText, UNO_QUERY));
272 0 : }
273 0 : }
274 0 : }
275 : }
276 0 : }
277 :
278 0 : Layout();
279 :
280 0 : if (mpScrollBar.get() != NULL)
281 : {
282 0 : mpScrollBar->SetThumbPosition(0, false);
283 0 : UpdateScrollBar();
284 : }
285 :
286 0 : Invalidate();
287 0 : }
288 0 : }
289 :
290 : //----- lang::XEventListener -------------------------------------------------
291 :
292 0 : void SAL_CALL PresenterNotesView::disposing (const lang::EventObject& rEventObject)
293 : throw (RuntimeException)
294 : {
295 0 : if (rEventObject.Source == mxParentWindow)
296 0 : mxParentWindow = NULL;
297 0 : }
298 :
299 : //----- XWindowListener -------------------------------------------------------
300 :
301 0 : void SAL_CALL PresenterNotesView::windowResized (const awt::WindowEvent& rEvent)
302 : throw (RuntimeException)
303 : {
304 : (void)rEvent;
305 0 : Layout();
306 0 : }
307 :
308 0 : void SAL_CALL PresenterNotesView::windowMoved (const awt::WindowEvent& rEvent)
309 : throw (RuntimeException)
310 : {
311 : (void)rEvent;
312 0 : }
313 :
314 0 : void SAL_CALL PresenterNotesView::windowShown (const lang::EventObject& rEvent)
315 : throw (RuntimeException)
316 : {
317 : (void)rEvent;
318 0 : }
319 :
320 0 : void SAL_CALL PresenterNotesView::windowHidden (const lang::EventObject& rEvent)
321 : throw (RuntimeException)
322 : {
323 : (void)rEvent;
324 0 : }
325 :
326 : //----- XPaintListener --------------------------------------------------------
327 :
328 0 : void SAL_CALL PresenterNotesView::windowPaint (const awt::PaintEvent& rEvent)
329 : throw (RuntimeException)
330 : {
331 0 : ThrowIfDisposed();
332 :
333 0 : if ( ! mbIsPresenterViewActive)
334 0 : return;
335 :
336 0 : ::osl::MutexGuard aSolarGuard (::osl::Mutex::getGlobalMutex());
337 0 : Paint(rEvent.UpdateRect);
338 : }
339 :
340 : //----- XResourceId -----------------------------------------------------------
341 :
342 0 : Reference<XResourceId> SAL_CALL PresenterNotesView::getResourceId (void)
343 : throw (RuntimeException)
344 : {
345 0 : return mxViewId;
346 : }
347 :
348 0 : sal_Bool SAL_CALL PresenterNotesView::isAnchorOnly (void)
349 : throw (RuntimeException)
350 : {
351 0 : return false;
352 : }
353 :
354 : //----- XDrawView -------------------------------------------------------------
355 :
356 0 : void SAL_CALL PresenterNotesView::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
357 : throw (RuntimeException)
358 : {
359 : // Get the associated notes page.
360 0 : mxCurrentNotesPage = NULL;
361 : try
362 : {
363 0 : Reference<presentation::XPresentationPage> xPresentationPage(rxSlide, UNO_QUERY);
364 0 : if (xPresentationPage.is())
365 0 : mxCurrentNotesPage = xPresentationPage->getNotesPage();
366 : }
367 0 : catch (RuntimeException&)
368 : {
369 : }
370 :
371 0 : SetSlide(mxCurrentNotesPage);
372 0 : }
373 :
374 0 : Reference<drawing::XDrawPage> SAL_CALL PresenterNotesView::getCurrentPage (void)
375 : throw (RuntimeException)
376 : {
377 0 : return NULL;
378 : }
379 :
380 : //----- XKeyListener ----------------------------------------------------------
381 :
382 0 : void SAL_CALL PresenterNotesView::keyPressed (const awt::KeyEvent& rEvent)
383 : throw (RuntimeException)
384 : {
385 0 : switch (rEvent.KeyCode)
386 : {
387 : case awt::Key::A:
388 0 : Scroll(-gnLineScrollFactor * mpFont->mnSize);
389 0 : break;
390 :
391 : case awt::Key::Y:
392 : case awt::Key::Z:
393 0 : Scroll(+gnLineScrollFactor * mpFont->mnSize);
394 0 : break;
395 :
396 : case awt::Key::S:
397 0 : ChangeFontSize(-1);
398 0 : break;
399 :
400 : case awt::Key::G:
401 0 : ChangeFontSize(+1);
402 0 : break;
403 :
404 : case awt::Key::H:
405 0 : if (mpTextView)
406 : mpTextView->MoveCaret(
407 : -1,
408 : (rEvent.Modifiers == awt::KeyModifier::SHIFT)
409 : ? cssa::AccessibleTextType::CHARACTER
410 0 : : cssa::AccessibleTextType::WORD);
411 0 : break;
412 :
413 : case awt::Key::L:
414 0 : if (mpTextView)
415 : mpTextView->MoveCaret(
416 : +1,
417 : (rEvent.Modifiers == awt::KeyModifier::SHIFT)
418 : ? cssa::AccessibleTextType::CHARACTER
419 0 : : cssa::AccessibleTextType::WORD);
420 0 : break;
421 : }
422 0 : }
423 :
424 0 : void SAL_CALL PresenterNotesView::keyReleased (const awt::KeyEvent& rEvent)
425 : throw (RuntimeException)
426 : {
427 : (void)rEvent;
428 0 : }
429 :
430 : //-----------------------------------------------------------------------------
431 :
432 0 : void PresenterNotesView::Layout (void)
433 : {
434 0 : if ( ! mxParentWindow.is())
435 0 : return;
436 :
437 0 : awt::Rectangle aWindowBox (mxParentWindow->getPosSize());
438 0 : geometry::RealRectangle2D aNewTextBoundingBox (0,0,aWindowBox.Width, aWindowBox.Height);
439 :
440 : // Size the tool bar and the horizontal separator above it.
441 0 : if (mxToolBarWindow.is())
442 : {
443 0 : const geometry::RealSize2D aToolBarSize (mpToolBar->GetMinimalSize());
444 0 : const sal_Int32 nToolBarHeight = sal_Int32(aToolBarSize.Height + 0.5);
445 0 : mxToolBarWindow->setPosSize(0, aWindowBox.Height - nToolBarHeight,
446 : sal_Int32(aToolBarSize.Width + 0.5), nToolBarHeight,
447 0 : awt::PosSize::POSSIZE);
448 0 : aNewTextBoundingBox.Y2 -= nToolBarHeight;
449 :
450 0 : mnSeparatorYLocation = aWindowBox.Height - nToolBarHeight - gnSpaceBelowSeparator;
451 0 : aNewTextBoundingBox.Y2 = mnSeparatorYLocation - gnSpaceAboveSeparator;
452 :
453 : // Place the close button.
454 0 : if (mpCloseButton.get() != NULL)
455 : mpCloseButton->SetCenter(geometry::RealPoint2D(
456 : (aWindowBox.Width + aToolBarSize.Width) / 2,
457 0 : aWindowBox.Height - aToolBarSize.Height/2));
458 : }
459 :
460 : // Check whether the vertical scroll bar is necessary.
461 0 : if (mpScrollBar.get() != NULL)
462 : {
463 0 : bool bShowVerticalScrollbar (false);
464 : try
465 : {
466 0 : const double nTextBoxHeight (aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1);
467 0 : const double nHeight (mpTextView->GetTotalTextHeight());
468 0 : if (nHeight > nTextBoxHeight)
469 : {
470 0 : bShowVerticalScrollbar = true;
471 0 : aNewTextBoundingBox.X2 -= mpScrollBar->GetSize();
472 : }
473 0 : mpScrollBar->SetTotalSize(nHeight);
474 : }
475 0 : catch(beans::UnknownPropertyException&)
476 : {
477 : OSL_ASSERT(false);
478 : }
479 :
480 0 : mpScrollBar->SetVisible(bShowVerticalScrollbar);
481 : mpScrollBar->SetPosSize(
482 : geometry::RealRectangle2D(
483 : aNewTextBoundingBox.X2,
484 : aNewTextBoundingBox.X1,
485 0 : aNewTextBoundingBox.X2 + mpScrollBar->GetSize(),
486 0 : aNewTextBoundingBox.Y2));
487 0 : if ( ! bShowVerticalScrollbar)
488 0 : mpScrollBar->SetThumbPosition(0, false);
489 :
490 0 : UpdateScrollBar();
491 : }
492 :
493 : // Has the text area has changed it position or size?
494 0 : if (aNewTextBoundingBox.X1 != maTextBoundingBox.X1
495 : || aNewTextBoundingBox.Y1 != maTextBoundingBox.Y1
496 : || aNewTextBoundingBox.X2 != maTextBoundingBox.X2
497 : || aNewTextBoundingBox.Y2 != maTextBoundingBox.Y2)
498 : {
499 0 : maTextBoundingBox = aNewTextBoundingBox;
500 :
501 : mpTextView->SetLocation(
502 : geometry::RealPoint2D(
503 : aNewTextBoundingBox.X1,
504 0 : aNewTextBoundingBox.Y1));
505 : mpTextView->SetSize(
506 : geometry::RealSize2D(
507 : aNewTextBoundingBox.X2 - aNewTextBoundingBox.X1,
508 0 : aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1));
509 : }
510 : }
511 :
512 0 : void PresenterNotesView::Paint (const awt::Rectangle& rUpdateBox)
513 : {
514 0 : if ( ! mxParentWindow.is())
515 0 : return;
516 0 : if ( ! mxCanvas.is())
517 0 : return;
518 :
519 0 : if (mpBackground.get() == NULL)
520 0 : mpBackground = mpPresenterController->GetViewBackground(mxViewId->getResourceURL());
521 :
522 0 : if (rUpdateBox.Y < maTextBoundingBox.Y2
523 : && rUpdateBox.X < maTextBoundingBox.X2)
524 : {
525 0 : PaintText(rUpdateBox);
526 : }
527 :
528 0 : mpTextView->Paint(rUpdateBox);
529 :
530 0 : if (rUpdateBox.Y + rUpdateBox.Height > maTextBoundingBox.Y2)
531 : {
532 0 : PaintToolBar(rUpdateBox);
533 : }
534 : }
535 :
536 0 : void PresenterNotesView::PaintToolBar (const awt::Rectangle& rUpdateBox)
537 : {
538 0 : awt::Rectangle aWindowBox (mxParentWindow->getPosSize());
539 :
540 : rendering::ViewState aViewState (
541 : geometry::AffineMatrix2D(1,0,0, 0,1,0),
542 0 : NULL);
543 : rendering::RenderState aRenderState(
544 : geometry::AffineMatrix2D(1,0,0, 0,1,0),
545 : NULL,
546 : Sequence<double>(4),
547 0 : rendering::CompositeOperation::SOURCE);
548 :
549 0 : if (mpBackground.get() != NULL)
550 : {
551 : // Paint the background.
552 : mpPresenterController->GetCanvasHelper()->Paint(
553 : mpBackground,
554 : mxCanvas,
555 : rUpdateBox,
556 : awt::Rectangle(0,sal_Int32(maTextBoundingBox.Y2),aWindowBox.Width,aWindowBox.Height),
557 0 : awt::Rectangle());
558 : }
559 :
560 : // Paint the horizontal separator.
561 : OSL_ASSERT(mxViewId.is());
562 0 : PresenterCanvasHelper::SetDeviceColor(aRenderState, maSeparatorColor);
563 :
564 0 : mxCanvas->drawLine(
565 : geometry::RealPoint2D(0,mnSeparatorYLocation),
566 : geometry::RealPoint2D(aWindowBox.Width,mnSeparatorYLocation),
567 : aViewState,
568 0 : aRenderState);
569 0 : }
570 :
571 0 : void PresenterNotesView::PaintText (const awt::Rectangle& rUpdateBox)
572 : {
573 : const awt::Rectangle aBox (PresenterGeometryHelper::Intersection(rUpdateBox,
574 0 : PresenterGeometryHelper::ConvertRectangle(maTextBoundingBox)));
575 :
576 0 : if (aBox.Width <= 0 || aBox.Height <= 0)
577 0 : return;
578 :
579 : rendering::ViewState aViewState (
580 : geometry::AffineMatrix2D(1,0,0, 0,1,0),
581 0 : PresenterGeometryHelper::CreatePolygon(aBox, mxCanvas->getDevice()));
582 : rendering::RenderState aRenderState(
583 : geometry::AffineMatrix2D(1,0,0, 0,1,0),
584 : NULL,
585 : Sequence<double>(3),
586 0 : rendering::CompositeOperation::SOURCE);
587 :
588 0 : if (mpBackground.get() != NULL)
589 : {
590 : // Paint the background.
591 : mpPresenterController->GetCanvasHelper()->Paint(
592 : mpBackground,
593 : mxCanvas,
594 : rUpdateBox,
595 : aBox,
596 0 : awt::Rectangle());
597 : }
598 :
599 0 : Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
600 0 : if (xSpriteCanvas.is())
601 0 : xSpriteCanvas->updateScreen(sal_False);
602 : }
603 :
604 0 : void PresenterNotesView::Invalidate (void)
605 : {
606 : mpPresenterController->GetPaintManager()->Invalidate(
607 : mxParentWindow,
608 0 : PresenterGeometryHelper::ConvertRectangle(maTextBoundingBox));
609 0 : }
610 :
611 0 : void PresenterNotesView::Scroll (const double rnDistance)
612 : {
613 : try
614 : {
615 0 : mnTop += rnDistance;
616 0 : mpTextView->SetOffset(0, mnTop);
617 :
618 0 : UpdateScrollBar();
619 0 : Invalidate();
620 : }
621 0 : catch (beans::UnknownPropertyException&)
622 : {}
623 0 : }
624 :
625 0 : void PresenterNotesView::SetTop (const double nTop)
626 : {
627 : try
628 : {
629 0 : mnTop = nTop;
630 0 : mpTextView->SetOffset(0, mnTop);
631 :
632 0 : UpdateScrollBar();
633 0 : Invalidate();
634 : }
635 0 : catch (beans::UnknownPropertyException&)
636 : {}
637 0 : }
638 :
639 0 : void PresenterNotesView::ChangeFontSize (const sal_Int32 nSizeChange)
640 : {
641 0 : const sal_Int32 nNewSize (mpFont->mnSize + nSizeChange);
642 0 : if (nNewSize > 5)
643 : {
644 0 : mpFont->mnSize = nNewSize;
645 0 : mpFont->mxFont = NULL;
646 0 : mpTextView->SetFont(mpFont);
647 :
648 0 : Layout();
649 0 : UpdateScrollBar();
650 0 : Invalidate();
651 :
652 : // Write the new font size to the configuration to make it persistent.
653 : try
654 : {
655 : const OUString sStyleName (mpPresenterController->GetTheme()->GetStyleName(
656 0 : mxViewId->getResourceURL()));
657 : ::boost::shared_ptr<PresenterConfigurationAccess> pConfiguration (
658 : mpPresenterController->GetTheme()->GetNodeForViewStyle(
659 0 : sStyleName));
660 0 : if (pConfiguration.get()==NULL || ! pConfiguration->IsValid())
661 0 : return;
662 :
663 0 : pConfiguration->GoToChild(A2S("Font"));
664 0 : pConfiguration->SetProperty(A2S("Size"), Any((sal_Int32)(nNewSize+0.5)));
665 0 : pConfiguration->CommitChanges();
666 : }
667 0 : catch (Exception&)
668 : {
669 : OSL_ASSERT(false);
670 : }
671 : }
672 : }
673 :
674 0 : ::boost::shared_ptr<PresenterTextView> PresenterNotesView::GetTextView (void) const
675 : {
676 0 : return mpTextView;
677 : }
678 :
679 0 : void PresenterNotesView::UpdateScrollBar (void)
680 : {
681 0 : if (mpScrollBar.get() != NULL)
682 : {
683 : try
684 : {
685 0 : mpScrollBar->SetTotalSize(mpTextView->GetTotalTextHeight());
686 : }
687 0 : catch(beans::UnknownPropertyException&)
688 : {
689 : OSL_ASSERT(false);
690 : }
691 :
692 0 : mpScrollBar->SetLineHeight(mpFont->mnSize*1.2);
693 0 : mpScrollBar->SetThumbPosition(mnTop, false);
694 :
695 0 : mpScrollBar->SetThumbSize(maTextBoundingBox.Y2 - maTextBoundingBox.Y1);
696 0 : mpScrollBar->CheckValues();
697 : }
698 0 : }
699 :
700 0 : void PresenterNotesView::ThrowIfDisposed (void)
701 : throw (::com::sun::star::lang::DisposedException)
702 : {
703 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
704 : {
705 : throw lang::DisposedException (
706 : A2S("PresenterNotesView object has already been disposed"),
707 0 : static_cast<uno::XWeak*>(this));
708 : }
709 0 : }
710 :
711 0 : } } // end of namespace ::sdext::presenter
712 :
713 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|