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