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 "PresenterSlideShowView.hxx"
30 : :
31 : : #include "PresenterCanvasHelper.hxx"
32 : : #include "PresenterGeometryHelper.hxx"
33 : : #include "PresenterHelper.hxx"
34 : : #include "PresenterPaneContainer.hxx"
35 : : #include <com/sun/star/awt/InvalidateStyle.hpp>
36 : : #include <com/sun/star/awt/PosSize.hpp>
37 : : #include <com/sun/star/awt/WindowAttribute.hpp>
38 : : #include <com/sun/star/awt/XWindow.hpp>
39 : : #include <com/sun/star/awt/XWindow2.hpp>
40 : : #include <com/sun/star/awt/XWindowPeer.hpp>
41 : : #include <com/sun/star/beans/XPropertySet.hpp>
42 : : #include <com/sun/star/drawing/CanvasFeature.hpp>
43 : : #include <com/sun/star/drawing/XPresenterHelper.hpp>
44 : : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
45 : : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
46 : : #include <com/sun/star/rendering/CompositeOperation.hpp>
47 : : #include <com/sun/star/rendering/TextDirection.hpp>
48 : : #include <com/sun/star/rendering/TexturingMode.hpp>
49 : : #include <osl/mutex.hxx>
50 : :
51 : : using namespace ::com::sun::star;
52 : : using namespace ::com::sun::star::uno;
53 : : using namespace ::com::sun::star::drawing::framework;
54 : : using ::rtl::OUString;
55 : :
56 : : #define A2S(pString) (::rtl::OUString(pString))
57 : :
58 : : namespace sdext { namespace presenter {
59 : :
60 : : //===== PresenterSlideShowView ================================================
61 : :
62 : 0 : PresenterSlideShowView::PresenterSlideShowView (
63 : : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
64 : : const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
65 : : const css::uno::Reference<css::frame::XController>& rxController,
66 : : const ::rtl::Reference<PresenterController>& rpPresenterController)
67 : : : PresenterSlideShowViewInterfaceBase(m_aMutex),
68 : : mxComponentContext(rxContext),
69 : : mpPresenterController(rpPresenterController),
70 : : mxViewId(rxViewId),
71 : : mxController(rxController),
72 : : mxSlideShowController(PresenterHelper::GetSlideShowController(rxController)),
73 : : mxSlideShow(),
74 : : mxCanvas(),
75 : : mxViewCanvas(),
76 : : mxPointer(),
77 : : mxWindow(),
78 : : mxViewWindow(),
79 : : mxTopPane(),
80 : : mxPresenterHelper(),
81 : : mxBackgroundPolygon1(),
82 : : mxBackgroundPolygon2(),
83 : : mbIsViewAdded(false),
84 : : mnPageAspectRatio(28.0/21.0),
85 : : maBroadcaster(m_aMutex),
86 : : mpBackground(),
87 : : mbIsInModifyNotification(false),
88 : : mbIsForcedPaintPending(false),
89 : : mbIsPaintPending(true),
90 : : msClickToExitPresentationText(),
91 : : msClickToExitPresentationTitle(),
92 : : msTitleTemplate(),
93 : : mbIsEndSlideVisible(false),
94 [ # # ][ # # ]: 0 : mxCurrentSlide()
[ # # ][ # # ]
[ # # ]
95 : : {
96 [ # # ]: 0 : if (mpPresenterController.get() != NULL)
97 : : {
98 [ # # ]: 0 : mnPageAspectRatio = mpPresenterController->GetSlideAspectRatio();
99 [ # # ][ # # ]: 0 : mpBackground = mpPresenterController->GetViewBackground(mxViewId->getResourceURL());
[ # # ][ # # ]
[ # # ]
100 : : }
101 : 0 : }
102 : :
103 : 0 : void PresenterSlideShowView::LateInit (void)
104 : : {
105 : : mxSlideShow = Reference<presentation::XSlideShow> (
106 [ # # ][ # # ]: 0 : mxSlideShowController->getSlideShow(), UNO_QUERY_THROW);
[ # # ][ # # ]
107 [ # # ]: 0 : Reference<lang::XComponent> xSlideShowComponent (mxSlideShow, UNO_QUERY);
108 [ # # ]: 0 : if (xSlideShowComponent.is())
109 [ # # ][ # # ]: 0 : xSlideShowComponent->addEventListener(static_cast<awt::XWindowListener*>(this));
[ # # ]
110 : :
111 : : Reference<lang::XMultiComponentFactory> xFactory (
112 [ # # ][ # # ]: 0 : mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
[ # # ]
113 [ # # ]: 0 : mxPresenterHelper.set (xFactory->createInstanceWithContext(
114 : : OUString("com.sun.star.comp.Draw.PresenterHelper"),
115 : 0 : mxComponentContext),
116 [ # # ][ # # ]: 0 : UNO_QUERY_THROW);
117 : :
118 : : // Use view id and controller to retrieve window and canvas from
119 : : // configuration controller.
120 [ # # ]: 0 : Reference<XControllerManager> xCM (mxController, UNO_QUERY_THROW);
121 [ # # ][ # # ]: 0 : Reference<XConfigurationController> xCC (xCM->getConfigurationController());
122 : :
123 [ # # ]: 0 : if (xCC.is())
124 : : {
125 [ # # ][ # # ]: 0 : mxTopPane.set(xCC->getResource(mxViewId->getAnchor()->getAnchor()), UNO_QUERY);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
126 : :
127 [ # # ][ # # ]: 0 : Reference<XPane> xPane (xCC->getResource(mxViewId->getAnchor()), UNO_QUERY_THROW);
[ # # ][ # # ]
[ # # ]
128 : :
129 [ # # ][ # # ]: 0 : mxWindow = xPane->getWindow();
[ # # ]
130 [ # # ][ # # ]: 0 : mxCanvas = xPane->getCanvas();
[ # # ]
131 : :
132 [ # # ]: 0 : if (mxWindow.is())
133 : : {
134 [ # # ][ # # ]: 0 : mxWindow->addPaintListener(this);
[ # # ]
135 [ # # ][ # # ]: 0 : mxWindow->addWindowListener(this);
[ # # ]
136 : : }
137 : :
138 : : // The window does not have to paint a background. We do
139 : : // that ourself.
140 [ # # ]: 0 : Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY);
141 [ # # ]: 0 : if (xPeer.is())
142 [ # # ][ # # ]: 0 : xPeer->setBackground(util::Color(0xff000000));
143 : : }
144 : :
145 : : // Create a window for the actual slide show view. It is places
146 : : // centered and with maximal size inside the pane.
147 [ # # ][ # # ]: 0 : mxViewWindow = CreateViewWindow(mxWindow);
148 : :
149 [ # # ][ # # ]: 0 : mxViewCanvas = CreateViewCanvas(mxViewWindow);
150 : :
151 [ # # ]: 0 : if (mxViewWindow.is())
152 : : {
153 : : // Register listeners at window.
154 [ # # ][ # # ]: 0 : mxViewWindow->addPaintListener(this);
[ # # ]
155 [ # # ][ # # ]: 0 : mxViewWindow->addMouseListener(this);
[ # # ]
156 [ # # ][ # # ]: 0 : mxViewWindow->addMouseMotionListener(this);
[ # # ]
157 : : }
158 : :
159 [ # # ]: 0 : if (mxViewWindow.is())
160 [ # # ]: 0 : Resize();
161 : :
162 [ # # ]: 0 : if (mxWindow.is())
163 [ # # ][ # # ]: 0 : mxWindow->setVisible(sal_True);
164 : :
165 : : // Add the new slide show view to the slide show.
166 [ # # ][ # # ]: 0 : if (mxSlideShow.is() && ! mbIsViewAdded)
[ # # ]
167 : : {
168 [ # # ]: 0 : impl_addAndConfigureView();
169 : 0 : mbIsViewAdded = true;
170 : : }
171 : :
172 : : // Read text for one past last slide.
173 : : PresenterConfigurationAccess aConfiguration (
174 : : mxComponentContext,
175 : : PresenterConfigurationAccess::msPresenterScreenRootName,
176 [ # # ]: 0 : PresenterConfigurationAccess::READ_ONLY);
177 : : aConfiguration.GetConfigurationNode(
178 : : A2S("Presenter/Views/CurrentSlidePreview/"
179 : : "Strings/ClickToExitPresentationText/String"))
180 [ # # ]: 0 : >>= msClickToExitPresentationText;
181 : : aConfiguration.GetConfigurationNode(
182 : : A2S("Presenter/Views/CurrentSlidePreview/"
183 : : "Strings/ClickToExitPresentationTitle/String"))
184 [ # # ][ # # ]: 0 : >>= msClickToExitPresentationTitle;
185 : 0 : }
186 : :
187 [ # # ][ # # ]: 0 : PresenterSlideShowView::~PresenterSlideShowView (void)
[ # # ][ # # ]
188 : : {
189 [ # # ]: 0 : }
190 : :
191 : 0 : void PresenterSlideShowView::disposing (void)
192 : : {
193 : : // Tell all listeners that we are disposed.
194 [ # # ]: 0 : lang::EventObject aEvent;
195 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
196 : :
197 : : ::cppu::OInterfaceContainerHelper* pIterator
198 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<lang::XEventListener>*)NULL));
199 [ # # ]: 0 : if (pIterator != NULL)
200 [ # # ]: 0 : pIterator->disposeAndClear(aEvent);
201 : :
202 : : // Do this for
203 : : // XPaintListener, XModifyListener,XMouseListener,XMouseMotionListener,XWindowListener?
204 : :
205 [ # # ]: 0 : if (mxWindow.is())
206 : : {
207 [ # # ][ # # ]: 0 : mxWindow->removePaintListener(this);
[ # # ]
208 [ # # ][ # # ]: 0 : mxWindow->removeMouseListener(this);
[ # # ]
209 [ # # ][ # # ]: 0 : mxWindow->removeMouseMotionListener(this);
[ # # ]
210 [ # # ][ # # ]: 0 : mxWindow->removeWindowListener(this);
[ # # ]
211 [ # # ]: 0 : mxWindow = NULL;
212 : : }
213 [ # # ]: 0 : mxSlideShowController = NULL;
214 [ # # ]: 0 : mxSlideShow = NULL;
215 [ # # ]: 0 : if (mxViewCanvas.is())
216 : : {
217 [ # # ]: 0 : Reference<XComponent> xComponent (mxViewCanvas, UNO_QUERY);
218 [ # # ]: 0 : mxViewCanvas = NULL;
219 [ # # ]: 0 : if (xComponent.is())
220 [ # # ][ # # ]: 0 : xComponent->dispose();
221 : : }
222 [ # # ]: 0 : if (mxViewWindow.is())
223 : : {
224 [ # # ]: 0 : Reference<XComponent> xComponent (mxViewWindow, UNO_QUERY);
225 [ # # ]: 0 : mxViewWindow = NULL;
226 [ # # ]: 0 : if (xComponent.is())
227 [ # # ][ # # ]: 0 : xComponent->dispose();
228 : : }
229 [ # # ]: 0 : if (mxPointer.is())
230 : : {
231 [ # # ]: 0 : Reference<XComponent> xComponent (mxPointer, UNO_QUERY);
232 [ # # ]: 0 : mxPointer = NULL;
233 [ # # ]: 0 : if (xComponent.is())
234 [ # # ][ # # ]: 0 : xComponent->dispose();
235 : : }
236 [ # # ]: 0 : if (mxBackgroundPolygon1.is())
237 : : {
238 [ # # ]: 0 : Reference<XComponent> xComponent (mxBackgroundPolygon1, UNO_QUERY);
239 [ # # ]: 0 : mxBackgroundPolygon1 = NULL;
240 [ # # ]: 0 : if (xComponent.is())
241 [ # # ][ # # ]: 0 : xComponent->dispose();
242 : : }
243 [ # # ]: 0 : if (mxBackgroundPolygon2.is())
244 : : {
245 [ # # ]: 0 : Reference<XComponent> xComponent (mxBackgroundPolygon2, UNO_QUERY);
246 [ # # ]: 0 : mxBackgroundPolygon2 = NULL;
247 [ # # ]: 0 : if (xComponent.is())
248 [ # # ][ # # ]: 0 : xComponent->dispose();
249 : : }
250 : :
251 [ # # ]: 0 : mxComponentContext = NULL;
252 [ # # ]: 0 : mpPresenterController = NULL;
253 [ # # ]: 0 : mxViewId = NULL;
254 [ # # ]: 0 : mxController = NULL;
255 [ # # ]: 0 : mxCanvas = NULL;
256 [ # # ]: 0 : mpBackground.reset();
257 : 0 : msClickToExitPresentationText = OUString();
258 : 0 : msClickToExitPresentationTitle = OUString();
259 : 0 : msTitleTemplate = OUString();
260 [ # # ][ # # ]: 0 : mxCurrentSlide = NULL;
261 : 0 : }
262 : :
263 : : //----- XDrawView -------------------------------------------------------------
264 : :
265 : 0 : void SAL_CALL PresenterSlideShowView::setCurrentPage (
266 : : const css::uno::Reference<css::drawing::XDrawPage>& rxSlide)
267 : : throw (css::uno::RuntimeException)
268 : : {
269 : 0 : mxCurrentSlide = rxSlide;
270 [ # # ][ # # ]: 0 : if (mpPresenterController.get() != NULL
[ # # # #
# # ]
271 : 0 : && mxSlideShowController.is()
272 [ # # ][ # # ]: 0 : && ! mpPresenterController->GetCurrentSlide().is()
[ # # ]
273 [ # # ][ # # ]: 0 : && ! mxSlideShowController->isPaused())
274 : : {
275 : 0 : mbIsEndSlideVisible = true;
276 [ # # ]: 0 : Reference<awt::XWindowPeer> xPeer (mxViewWindow, UNO_QUERY);
277 [ # # ]: 0 : if (xPeer.is())
278 [ # # ][ # # ]: 0 : xPeer->invalidate(awt::InvalidateStyle::NOTRANSPARENT);
279 : :
280 : : // For the end slide we use a special title, without the (n of m)
281 : : // part. Save the title template for the case that the user goes
282 : : // backwards.
283 : : PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
284 [ # # ][ # # ]: 0 : mpPresenterController->GetPaneContainer()->FindViewURL(mxViewId->getResourceURL()));
[ # # ][ # # ]
285 [ # # ]: 0 : if (pDescriptor.get() != NULL)
286 : : {
287 : 0 : msTitleTemplate = pDescriptor->msTitleTemplate;
288 : 0 : pDescriptor->msTitleTemplate = msClickToExitPresentationTitle;
289 [ # # ]: 0 : mpPresenterController->UpdatePaneTitles();
290 [ # # ]: 0 : }
291 : : }
292 [ # # ]: 0 : else if (mbIsEndSlideVisible)
293 : : {
294 : 0 : mbIsEndSlideVisible = false;
295 : :
296 : : // Restore the title template.
297 : : PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
298 [ # # ][ # # ]: 0 : mpPresenterController->GetPaneContainer()->FindViewURL(mxViewId->getResourceURL()));
[ # # ][ # # ]
299 [ # # ]: 0 : if (pDescriptor.get() != NULL)
300 : : {
301 : 0 : pDescriptor->msTitleTemplate = msTitleTemplate;
302 : 0 : pDescriptor->msTitle = OUString();
303 [ # # ]: 0 : mpPresenterController->UpdatePaneTitles();
304 [ # # ]: 0 : }
305 : : }
306 : 0 : }
307 : :
308 : 0 : css::uno::Reference<css::drawing::XDrawPage> SAL_CALL PresenterSlideShowView::getCurrentPage (void)
309 : : throw (css::uno::RuntimeException)
310 : : {
311 : 0 : return mxCurrentSlide;
312 : : }
313 : :
314 : : //----- CachablePresenterView -------------------------------------------------
315 : :
316 : 0 : void PresenterSlideShowView::ReleaseView (void)
317 : : {
318 [ # # ][ # # ]: 0 : if (mxSlideShow.is() && mbIsViewAdded)
[ # # ]
319 : : {
320 [ # # ]: 0 : mxSlideShow->removeView(this);
321 : 0 : mbIsViewAdded = false;
322 : : }
323 : 0 : }
324 : :
325 : : //----- XSlideShowView --------------------------------------------------------
326 : :
327 : 0 : Reference<rendering::XSpriteCanvas> SAL_CALL PresenterSlideShowView::getCanvas (void)
328 : : throw (RuntimeException)
329 : : {
330 : 0 : ThrowIfDisposed();
331 : :
332 : 0 : return Reference<rendering::XSpriteCanvas>(mxViewCanvas, UNO_QUERY);
333 : : }
334 : :
335 : 0 : void SAL_CALL PresenterSlideShowView::clear (void)
336 : : throw (RuntimeException)
337 : : {
338 : 0 : ThrowIfDisposed();
339 : 0 : mbIsForcedPaintPending = false;
340 : 0 : mbIsPaintPending = false;
341 : :
342 [ # # ][ # # ]: 0 : if (mxViewCanvas.is() && mxViewWindow.is())
[ # # ]
343 : : {
344 : : // Create a polygon for the window outline.
345 [ # # ][ # # ]: 0 : awt::Rectangle aViewWindowBox (mxViewWindow->getPosSize());
346 : : Reference<rendering::XPolyPolygon2D> xPolygon (PresenterGeometryHelper::CreatePolygon(
347 : : awt::Rectangle(0,0, aViewWindowBox.Width,aViewWindowBox.Height),
348 [ # # ][ # # ]: 0 : mxViewCanvas->getDevice()));
[ # # ]
349 : :
350 : : rendering::ViewState aViewState (
351 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
352 [ # # ][ # # ]: 0 : NULL);
353 : 0 : double aColor[4] = {0,0,0,0};
354 : : rendering::RenderState aRenderState(
355 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
356 : : NULL,
357 : : Sequence<double>(aColor,4),
358 [ # # ][ # # ]: 0 : rendering::CompositeOperation::SOURCE);
[ # # ][ # # ]
359 [ # # ][ # # ]: 0 : mxViewCanvas->fillPolyPolygon(xPolygon, aViewState, aRenderState);
[ # # ][ # # ]
360 : : }
361 : 0 : }
362 : :
363 : 0 : geometry::AffineMatrix2D SAL_CALL PresenterSlideShowView::getTransformation (void)
364 : : throw (RuntimeException)
365 : : {
366 : 0 : ThrowIfDisposed();
367 : :
368 [ # # ]: 0 : if (mxViewWindow.is())
369 : : {
370 : : // When the mbIsInModifyNotification is set then a slightly modifed
371 : : // version of the transformation is returned in order to get past
372 : : // optimizations the avoid updates when the transformation is
373 : : // unchanged (when the window size changes then due to the constant
374 : : // aspect ratio the size of the preview may remain the same while
375 : : // the position changes. The position, however, is repesented by
376 : : // the position of the view window. This transformation is given
377 : : // relative to the view window and therefore does not contain the
378 : : // position.)
379 [ # # ][ # # ]: 0 : const awt::Rectangle aWindowBox = mxViewWindow->getPosSize();
380 : : return geometry::AffineMatrix2D(
381 : : aWindowBox.Width-1, 0, (mbIsInModifyNotification ? 1 : 0),
382 [ # # ]: 0 : 0, aWindowBox.Height-1, 0);
383 : : }
384 : : else
385 : : {
386 : 0 : return geometry::AffineMatrix2D(1,0,0, 0,1,0);
387 : : }
388 : : }
389 : :
390 : 0 : void SAL_CALL PresenterSlideShowView::addTransformationChangedListener(
391 : : const Reference<util::XModifyListener>& rxListener)
392 : : throw (RuntimeException)
393 : : {
394 : 0 : ThrowIfDisposed();
395 : : maBroadcaster.addListener(
396 : 0 : getCppuType((Reference<util::XModifyListener>*)NULL),
397 : 0 : rxListener);
398 : 0 : }
399 : :
400 : 0 : void SAL_CALL PresenterSlideShowView::removeTransformationChangedListener(
401 : : const Reference<util::XModifyListener>& rxListener)
402 : : throw (RuntimeException)
403 : : {
404 : 0 : ThrowIfDisposed();
405 : : maBroadcaster.removeListener(
406 : 0 : getCppuType((Reference<util::XModifyListener>*)NULL),
407 : 0 : rxListener);
408 : 0 : }
409 : :
410 : 0 : void SAL_CALL PresenterSlideShowView::addPaintListener(
411 : : const Reference<awt::XPaintListener>& rxListener)
412 : : throw (RuntimeException)
413 : : {
414 : 0 : ThrowIfDisposed();
415 : : maBroadcaster.addListener(
416 : 0 : getCppuType((Reference<awt::XPaintListener>*)NULL),
417 : 0 : rxListener);
418 : 0 : }
419 : :
420 : 0 : void SAL_CALL PresenterSlideShowView::removePaintListener(
421 : : const Reference<awt::XPaintListener>& rxListener)
422 : : throw (RuntimeException)
423 : : {
424 : 0 : ThrowIfDisposed();
425 : : maBroadcaster.removeListener(
426 : 0 : getCppuType((Reference<awt::XPaintListener>*)NULL),
427 : 0 : rxListener);
428 : 0 : }
429 : :
430 : 0 : void SAL_CALL PresenterSlideShowView::addMouseListener(
431 : : const Reference<awt::XMouseListener>& rxListener)
432 : : throw (RuntimeException)
433 : : {
434 : 0 : ThrowIfDisposed();
435 : : maBroadcaster.addListener(
436 : 0 : getCppuType((Reference<awt::XMouseListener>*)NULL),
437 : 0 : rxListener);
438 : 0 : }
439 : :
440 : 0 : void SAL_CALL PresenterSlideShowView::removeMouseListener(
441 : : const Reference<awt::XMouseListener>& rxListener)
442 : : throw (RuntimeException)
443 : : {
444 : 0 : ThrowIfDisposed();
445 : : maBroadcaster.removeListener(
446 : 0 : getCppuType((Reference<awt::XMouseListener>*)NULL),
447 : 0 : rxListener);
448 : 0 : }
449 : :
450 : 0 : void SAL_CALL PresenterSlideShowView::addMouseMotionListener(
451 : : const Reference<awt::XMouseMotionListener>& rxListener)
452 : : throw (RuntimeException)
453 : : {
454 : 0 : ThrowIfDisposed();
455 : : maBroadcaster.addListener(
456 : 0 : getCppuType((Reference<awt::XMouseMotionListener>*)NULL),
457 : 0 : rxListener);
458 : 0 : }
459 : :
460 : 0 : void SAL_CALL PresenterSlideShowView::removeMouseMotionListener(
461 : : const Reference<awt::XMouseMotionListener>& rxListener)
462 : : throw (RuntimeException)
463 : : {
464 : 0 : ThrowIfDisposed();
465 : : maBroadcaster.removeListener(
466 : 0 : getCppuType((Reference<awt::XMouseMotionListener>*)NULL),
467 : 0 : rxListener);
468 : 0 : }
469 : :
470 : 0 : void SAL_CALL PresenterSlideShowView::setMouseCursor(::sal_Int16 nPointerShape)
471 : : throw (RuntimeException)
472 : : {
473 [ # # ]: 0 : ThrowIfDisposed();
474 : :
475 : : // Create a pointer when it does not yet exist.
476 [ # # ]: 0 : if ( ! mxPointer.is())
477 : : {
478 : : Reference<lang::XMultiServiceFactory> xFactory (
479 [ # # ]: 0 : mxComponentContext, UNO_QUERY);
480 [ # # ]: 0 : if (xFactory.is())
481 : : mxPointer = Reference<awt::XPointer>(
482 [ # # ]: 0 : xFactory->createInstance(OUString("com.sun.star.awt.Pointer")),
483 [ # # ][ # # ]: 0 : UNO_QUERY);
[ # # ]
484 : : }
485 : :
486 : : // Set the pointer to the given shape and the window(peer) to the
487 : : // pointer.
488 [ # # ]: 0 : Reference<awt::XWindowPeer> xPeer (mxViewWindow, UNO_QUERY);
489 [ # # ][ # # ]: 0 : if (mxPointer.is() && xPeer.is())
[ # # ]
490 : : {
491 [ # # ][ # # ]: 0 : mxPointer->setType(nPointerShape);
492 [ # # ][ # # ]: 0 : xPeer->setPointer(mxPointer);
493 : 0 : }
494 : 0 : }
495 : :
496 : 0 : awt::Rectangle SAL_CALL PresenterSlideShowView::getCanvasArea( ) throw (RuntimeException)
497 : : {
498 [ # # ][ # # ]: 0 : if( mxViewWindow.is() && mxTopPane.is() )
[ # # ]
499 [ # # ][ # # ]: 0 : return mxPresenterHelper->getWindowExtentsRelative( mxViewWindow, mxTopPane->getWindow() );
[ # # ][ # # ]
500 : :
501 : 0 : awt::Rectangle aRectangle;
502 : :
503 : 0 : aRectangle.X = aRectangle.Y = aRectangle.Width = aRectangle.Height = 0;
504 : :
505 : 0 : return aRectangle;
506 : : }
507 : :
508 : : //----- lang::XEventListener --------------------------------------------------
509 : :
510 : 0 : void SAL_CALL PresenterSlideShowView::disposing (const lang::EventObject& rEvent)
511 : : throw (RuntimeException)
512 : : {
513 [ # # ]: 0 : if (rEvent.Source == mxViewWindow)
514 : 0 : mxViewWindow = NULL;
515 [ # # ]: 0 : else if (rEvent.Source == mxSlideShow)
516 : 0 : mxSlideShow = NULL;
517 : 0 : }
518 : :
519 : : //----- XPaintListener --------------------------------------------------------
520 : :
521 : 0 : void SAL_CALL PresenterSlideShowView::windowPaint (const awt::PaintEvent& rEvent)
522 : : throw (RuntimeException)
523 : : {
524 : : // Deactivated views must not be painted.
525 [ # # ]: 0 : if ( ! mbIsPresenterViewActive)
526 : : return;
527 : :
528 [ # # ][ # # ]: 0 : awt::Rectangle aViewWindowBox (mxViewWindow->getPosSize());
529 [ # # ][ # # ]: 0 : if (aViewWindowBox.Width <= 0 || aViewWindowBox.Height <= 0)
530 : : return;
531 : :
532 [ # # ][ # # ]: 0 : if (rEvent.Source == mxWindow)
533 [ # # ]: 0 : PaintOuterWindow(rEvent.UpdateRect);
534 [ # # ]: 0 : else if (mbIsEndSlideVisible)
535 [ # # ]: 0 : PaintEndSlide(rEvent.UpdateRect);
536 : : else
537 [ # # ]: 0 : PaintInnerWindow(rEvent);
538 : : }
539 : :
540 : : //----- XMouseListener --------------------------------------------------------
541 : :
542 : 0 : void SAL_CALL PresenterSlideShowView::mousePressed (const awt::MouseEvent& rEvent)
543 : : throw (RuntimeException)
544 : : {
545 [ # # ]: 0 : awt::MouseEvent aEvent (rEvent);
546 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
547 : : ::cppu::OInterfaceContainerHelper* pIterator
548 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XMouseListener>*)NULL));
549 [ # # ]: 0 : if (pIterator != NULL)
550 : : {
551 [ # # ]: 0 : pIterator->notifyEach(&awt::XMouseListener::mousePressed, aEvent);
552 : : }
553 : :
554 : : // Only when the end slide is displayed we forward the mouse event to
555 : : // the PresenterController so that it switches to the next slide and
556 : : // ends the presentation.
557 [ # # ]: 0 : if (mbIsEndSlideVisible)
558 [ # # ]: 0 : if (mpPresenterController.get() != NULL)
559 [ # # ][ # # ]: 0 : mpPresenterController->HandleMouseClick(rEvent);
560 : 0 : }
561 : :
562 : 0 : void SAL_CALL PresenterSlideShowView::mouseReleased (const awt::MouseEvent& rEvent)
563 : : throw (RuntimeException)
564 : : {
565 [ # # ]: 0 : awt::MouseEvent aEvent (rEvent);
566 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
567 : : ::cppu::OInterfaceContainerHelper* pIterator
568 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XMouseListener>*)NULL));
569 [ # # ]: 0 : if (pIterator != NULL)
570 : : {
571 [ # # ]: 0 : pIterator->notifyEach(&awt::XMouseListener::mouseReleased, aEvent);
572 [ # # ]: 0 : }
573 : 0 : }
574 : :
575 : 0 : void SAL_CALL PresenterSlideShowView::mouseEntered (const awt::MouseEvent& rEvent)
576 : : throw (RuntimeException)
577 : : {
578 [ # # ]: 0 : awt::MouseEvent aEvent (rEvent);
579 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
580 : : ::cppu::OInterfaceContainerHelper* pIterator
581 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XMouseListener>*)NULL));
582 [ # # ]: 0 : if (pIterator != NULL)
583 : : {
584 [ # # ]: 0 : pIterator->notifyEach(&awt::XMouseListener::mouseEntered, aEvent);
585 [ # # ]: 0 : }
586 : 0 : }
587 : :
588 : 0 : void SAL_CALL PresenterSlideShowView::mouseExited (const awt::MouseEvent& rEvent)
589 : : throw (RuntimeException)
590 : : {
591 [ # # ]: 0 : awt::MouseEvent aEvent (rEvent);
592 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
593 : : ::cppu::OInterfaceContainerHelper* pIterator
594 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XMouseListener>*)NULL));
595 [ # # ]: 0 : if (pIterator != NULL)
596 : : {
597 [ # # ]: 0 : pIterator->notifyEach(&awt::XMouseListener::mouseExited, aEvent);
598 [ # # ]: 0 : }
599 : 0 : }
600 : :
601 : : //----- XMouseMotionListener --------------------------------------------------
602 : :
603 : 0 : void SAL_CALL PresenterSlideShowView::mouseDragged (const awt::MouseEvent& rEvent)
604 : : throw (RuntimeException)
605 : : {
606 [ # # ]: 0 : awt::MouseEvent aEvent (rEvent);
607 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
608 : : ::cppu::OInterfaceContainerHelper* pIterator
609 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XMouseMotionListener>*)NULL));
610 [ # # ]: 0 : if (pIterator != NULL)
611 : : {
612 [ # # ]: 0 : pIterator->notifyEach(&awt::XMouseMotionListener::mouseDragged, aEvent);
613 [ # # ]: 0 : }
614 : 0 : }
615 : :
616 : 0 : void SAL_CALL PresenterSlideShowView::mouseMoved (const awt::MouseEvent& rEvent)
617 : : throw (RuntimeException)
618 : : {
619 [ # # ]: 0 : awt::MouseEvent aEvent (rEvent);
620 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
621 : : ::cppu::OInterfaceContainerHelper* pIterator
622 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XMouseMotionListener>*)NULL));
623 [ # # ]: 0 : if (pIterator != NULL)
624 : : {
625 [ # # ]: 0 : pIterator->notifyEach(&awt::XMouseMotionListener::mouseMoved, aEvent);
626 [ # # ]: 0 : }
627 : 0 : }
628 : :
629 : : //----- XWindowListener -------------------------------------------------------
630 : :
631 : 0 : void SAL_CALL PresenterSlideShowView::windowResized (const awt::WindowEvent& rEvent)
632 : : throw (RuntimeException)
633 : : {
634 : : (void)rEvent;
635 : :
636 [ # # ]: 0 : ThrowIfDisposed();
637 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
638 : :
639 [ # # ][ # # ]: 0 : Resize();
640 : 0 : }
641 : :
642 : 0 : void SAL_CALL PresenterSlideShowView::windowMoved (const awt::WindowEvent& rEvent)
643 : : throw (RuntimeException)
644 : : {
645 : : (void)rEvent;
646 [ # # ]: 0 : if ( ! mbIsPaintPending)
647 : 0 : mbIsForcedPaintPending = true;
648 : 0 : }
649 : :
650 : 0 : void SAL_CALL PresenterSlideShowView::windowShown (const lang::EventObject& rEvent)
651 : : throw (RuntimeException)
652 : : {
653 : : (void)rEvent;
654 : 0 : Resize();
655 : 0 : }
656 : :
657 : 0 : void SAL_CALL PresenterSlideShowView::windowHidden (const lang::EventObject& rEvent)
658 : : throw (RuntimeException)
659 : : {
660 : : (void)rEvent;
661 : 0 : }
662 : :
663 : : //----- XView -----------------------------------------------------------------
664 : :
665 : 0 : Reference<XResourceId> SAL_CALL PresenterSlideShowView::getResourceId (void)
666 : : throw(RuntimeException)
667 : : {
668 : 0 : return mxViewId;
669 : : }
670 : :
671 : 0 : sal_Bool SAL_CALL PresenterSlideShowView::isAnchorOnly (void)
672 : : throw (RuntimeException)
673 : : {
674 : 0 : return false;
675 : : }
676 : :
677 : : //----- CachablePresenterView -------------------------------------------------
678 : :
679 : 0 : void PresenterSlideShowView::ActivatePresenterView (void)
680 : : {
681 [ # # ][ # # ]: 0 : if (mxSlideShow.is() && ! mbIsViewAdded)
[ # # ]
682 : : {
683 : 0 : impl_addAndConfigureView();
684 : 0 : mbIsViewAdded = true;
685 : : }
686 : 0 : }
687 : :
688 : 0 : void PresenterSlideShowView::DeactivatePresenterView (void)
689 : : {
690 [ # # ][ # # ]: 0 : if (mxSlideShow.is() && mbIsViewAdded)
[ # # ]
691 : : {
692 [ # # ]: 0 : mxSlideShow->removeView(this);
693 : 0 : mbIsViewAdded = false;
694 : : }
695 : 0 : }
696 : :
697 : : //-----------------------------------------------------------------------------
698 : :
699 : 0 : void PresenterSlideShowView::PaintOuterWindow (const awt::Rectangle& rRepaintBox)
700 : : {
701 [ # # ]: 0 : if ( ! mxCanvas.is())
702 : : return;
703 : :
704 [ # # ]: 0 : if (mpBackground.get() == NULL)
705 : : return;
706 : :
707 : : const rendering::ViewState aViewState(
708 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
709 [ # # ][ # # ]: 0 : PresenterGeometryHelper::CreatePolygon(rRepaintBox, mxCanvas->getDevice()));
[ # # ][ # # ]
710 : :
711 : : rendering::RenderState aRenderState (
712 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
713 : : NULL,
714 : : Sequence<double>(4),
715 [ # # ][ # # ]: 0 : rendering::CompositeOperation::SOURCE);
[ # # ][ # # ]
716 : :
717 [ # # ]: 0 : Reference<rendering::XBitmap> xBackgroundBitmap (mpBackground->GetNormalBitmap());
718 [ # # ]: 0 : if (xBackgroundBitmap.is())
719 : : {
720 [ # # ]: 0 : Sequence<rendering::Texture> aTextures (1);
721 [ # # ][ # # ]: 0 : const geometry::IntegerSize2D aBitmapSize(xBackgroundBitmap->getSize());
722 [ # # ]: 0 : aTextures[0] = rendering::Texture (
723 : : geometry::AffineMatrix2D(
724 : : aBitmapSize.Width,0,0,
725 : : 0,aBitmapSize.Height,0),
726 : : 1,
727 : : 0,
728 : : xBackgroundBitmap,
729 : : NULL,
730 : : NULL,
731 : : rendering::StrokeAttributes(),
732 : : rendering::TexturingMode::REPEAT,
733 [ # # ][ # # ]: 0 : rendering::TexturingMode::REPEAT);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
734 : :
735 [ # # ]: 0 : if (mxBackgroundPolygon1.is())
736 [ # # ]: 0 : mxCanvas->fillTexturedPolyPolygon(
737 : : mxBackgroundPolygon1,
738 : : aViewState,
739 : : aRenderState,
740 [ # # ]: 0 : aTextures);
741 [ # # ]: 0 : if (mxBackgroundPolygon2.is())
742 [ # # ]: 0 : mxCanvas->fillTexturedPolyPolygon(
743 : : mxBackgroundPolygon2,
744 : : aViewState,
745 : : aRenderState,
746 [ # # ][ # # ]: 0 : aTextures);
747 : : }
748 : : else
749 : : {
750 [ # # ]: 0 : PresenterCanvasHelper::SetDeviceColor(aRenderState, mpBackground->maReplacementColor);
751 : :
752 [ # # ]: 0 : if (mxBackgroundPolygon1.is())
753 [ # # ][ # # ]: 0 : mxCanvas->fillPolyPolygon(mxBackgroundPolygon1, aViewState, aRenderState);
754 [ # # ]: 0 : if (mxBackgroundPolygon2.is())
755 [ # # ][ # # ]: 0 : mxCanvas->fillPolyPolygon(mxBackgroundPolygon2, aViewState, aRenderState);
756 [ # # ][ # # ]: 0 : }
757 : : }
758 : :
759 : 0 : void PresenterSlideShowView::PaintEndSlide (const awt::Rectangle& rRepaintBox)
760 : : {
761 [ # # ]: 0 : if ( ! mxCanvas.is())
762 : 0 : return;
763 : :
764 : : const rendering::ViewState aViewState(
765 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
766 [ # # ][ # # ]: 0 : PresenterGeometryHelper::CreatePolygon(rRepaintBox, mxCanvas->getDevice()));
[ # # ][ # # ]
767 : :
768 : : rendering::RenderState aRenderState (
769 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
770 : : NULL,
771 : : Sequence<double>(4),
772 [ # # ][ # # ]: 0 : rendering::CompositeOperation::SOURCE);
[ # # ][ # # ]
773 [ # # ]: 0 : PresenterCanvasHelper::SetDeviceColor(aRenderState, util::Color(0x00000000));
774 [ # # ]: 0 : mxCanvas->fillPolyPolygon(
775 [ # # ][ # # ]: 0 : PresenterGeometryHelper::CreatePolygon(mxViewWindow->getPosSize(), mxCanvas->getDevice()),
776 : : aViewState,
777 [ # # ][ # # ]: 0 : aRenderState);
[ # # ][ # # ]
778 : :
779 : : do
780 : : {
781 [ # # ]: 0 : if (mpPresenterController.get() == NULL)
782 : : break;
783 [ # # ]: 0 : ::boost::shared_ptr<PresenterTheme> pTheme (mpPresenterController->GetTheme());
784 [ # # ]: 0 : if (pTheme.get() == NULL)
785 : : break;
786 : :
787 [ # # ][ # # ]: 0 : const OUString sViewStyle (pTheme->GetStyleName(mxViewId->getResourceURL()));
[ # # ]
788 [ # # ]: 0 : PresenterTheme::SharedFontDescriptor pFont (pTheme->GetFont(sViewStyle));
789 [ # # ]: 0 : if (pFont.get() == NULL)
790 : : break;
791 : :
792 [ # # ]: 0 : PresenterCanvasHelper::SetDeviceColor(aRenderState, util::Color(0x00ffffff));
793 : 0 : aRenderState.AffineTransform.m02 = 20;
794 : 0 : aRenderState.AffineTransform.m12 = 40;
795 : : const rendering::StringContext aContext (
796 : 0 : msClickToExitPresentationText, 0, msClickToExitPresentationText.getLength());
797 [ # # ]: 0 : pFont->PrepareFont(mxCanvas);
798 [ # # ]: 0 : mxCanvas->drawText(
799 : : aContext,
800 : 0 : pFont->mxFont,
801 : : aViewState,
802 : : aRenderState,
803 [ # # ][ # # ]: 0 : rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
[ # # ][ # # ]
[ # # ][ # # ]
804 : : }
805 : : while (false);
806 : :
807 : : // Finally, in double buffered environments, request the changes to be
808 : : // made visible.
809 [ # # ]: 0 : Reference<rendering::XSpriteCanvas> mxSpriteCanvas (mxCanvas, UNO_QUERY);
810 [ # # ]: 0 : if (mxSpriteCanvas.is())
811 [ # # ][ # # ]: 0 : mxSpriteCanvas->updateScreen(sal_True);
[ # # ][ # # ]
812 : : }
813 : :
814 : 0 : void PresenterSlideShowView::PaintInnerWindow (const awt::PaintEvent& rEvent)
815 : : {
816 : : // Forward window paint to listeners.
817 [ # # ]: 0 : awt::PaintEvent aEvent (rEvent);
818 [ # # ]: 0 : aEvent.Source = static_cast<XWeak*>(this);
819 : : ::cppu::OInterfaceContainerHelper* pIterator
820 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<awt::XPaintListener>*)NULL));
821 [ # # ]: 0 : if (pIterator != NULL)
822 : : {
823 [ # # ]: 0 : pIterator->notifyEach(&awt::XPaintListener::windowPaint, aEvent);
824 : : }
825 : :
826 [ # # ]: 0 : if (mbIsForcedPaintPending)
827 [ # # ]: 0 : ForceRepaint();
828 : :
829 : : // Finally, in double buffered environments, request the changes to be
830 : : // made visible.
831 [ # # ]: 0 : Reference<rendering::XSpriteCanvas> mxSpriteCanvas (mxCanvas, UNO_QUERY);
832 [ # # ]: 0 : if (mxSpriteCanvas.is())
833 [ # # ][ # # ]: 0 : mxSpriteCanvas->updateScreen(sal_True);
[ # # ]
834 : 0 : }
835 : :
836 : 0 : Reference<awt::XWindow> PresenterSlideShowView::CreateViewWindow (
837 : : const Reference<awt::XWindow>& rxParentWindow) const
838 : : {
839 : 0 : Reference<awt::XWindow> xViewWindow;
840 : : try
841 : : {
842 [ # # ][ # # ]: 0 : Reference<lang::XMultiComponentFactory> xFactory (mxComponentContext->getServiceManager());
843 [ # # ]: 0 : if ( ! xFactory.is())
844 : : return xViewWindow;
845 : :
846 : : Reference<awt::XToolkit> xToolkit (
847 [ # # ]: 0 : xFactory->createInstanceWithContext(
848 : : OUString("com.sun.star.awt.Toolkit"),
849 : 0 : mxComponentContext),
850 [ # # ][ # # ]: 0 : UNO_QUERY_THROW);
851 : : awt::WindowDescriptor aWindowDescriptor (
852 : : awt::WindowClass_CONTAINER,
853 : : OUString(),
854 : : Reference<awt::XWindowPeer>(rxParentWindow,UNO_QUERY_THROW),
855 : : -1, // parent index not available
856 : : awt::Rectangle(0,0,10,10),
857 : : awt::WindowAttribute::SIZEABLE
858 : : | awt::WindowAttribute::MOVEABLE
859 [ # # ][ # # ]: 0 : | awt::WindowAttribute::NODECORATION);
860 : : xViewWindow = Reference<awt::XWindow>(
861 [ # # ][ # # ]: 0 : xToolkit->createWindow(aWindowDescriptor),UNO_QUERY_THROW);
[ # # ][ # # ]
862 : :
863 : : // Make the background transparent. The slide show paints its own background.
864 [ # # ]: 0 : Reference<awt::XWindowPeer> xPeer (xViewWindow, UNO_QUERY_THROW);
865 [ # # ]: 0 : if (xPeer.is())
866 : : {
867 [ # # ][ # # ]: 0 : xPeer->setBackground(0xff000000);
868 : : }
869 : :
870 [ # # ][ # # ]: 0 : xViewWindow->setVisible(sal_True);
[ # # ][ # # ]
[ # # ]
871 : : }
872 [ # # ]: 0 : catch (RuntimeException&)
873 : : {
874 : : }
875 : 0 : return xViewWindow;
876 : : }
877 : :
878 : 0 : Reference<rendering::XCanvas> PresenterSlideShowView::CreateViewCanvas (
879 : : const Reference<awt::XWindow>& rxViewWindow) const
880 : : {
881 : : // Create a canvas for the view window.
882 : 0 : return mxPresenterHelper->createSharedCanvas(
883 [ # # ]: 0 : Reference<rendering::XSpriteCanvas>(mxTopPane->getCanvas(), UNO_QUERY),
884 [ # # ]: 0 : mxTopPane->getWindow(),
885 [ # # ]: 0 : mxTopPane->getCanvas(),
886 : 0 : mxTopPane->getWindow(),
887 [ # # ][ # # ]: 0 : rxViewWindow);
[ # # ][ # # ]
[ # # ]
888 : : }
889 : :
890 : 0 : void PresenterSlideShowView::Resize (void)
891 : : {
892 [ # # ][ # # ]: 0 : if ( ! mxWindow.is() || ! mxViewWindow.is())
[ # # ]
893 : 0 : return;
894 : :
895 [ # # ][ # # ]: 0 : const awt::Rectangle aWindowBox (mxWindow->getPosSize());
896 : 0 : awt::Rectangle aViewWindowBox;
897 [ # # ]: 0 : if (aWindowBox.Height > 0)
898 : : {
899 : : const double nWindowAspectRatio (
900 : 0 : double(aWindowBox.Width) / double(aWindowBox.Height));
901 [ # # ]: 0 : if (nWindowAspectRatio > mnPageAspectRatio)
902 : : {
903 : : // Slides will be painted with the full parent window height.
904 : 0 : aViewWindowBox.Width = sal_Int32(aWindowBox.Height * mnPageAspectRatio + 0.5);
905 : 0 : aViewWindowBox.Height = aWindowBox.Height;
906 : 0 : aViewWindowBox.X = (aWindowBox.Width - aViewWindowBox.Width) / 2;
907 : 0 : aViewWindowBox.Y = 0;
908 : : }
909 : : else
910 : : {
911 : : // Slides will be painted with the full parent window width.
912 : 0 : aViewWindowBox.Width = aWindowBox.Width;
913 : 0 : aViewWindowBox.Height = sal_Int32(aWindowBox.Width / mnPageAspectRatio + 0.5);
914 : 0 : aViewWindowBox.X = 0;
915 : 0 : aViewWindowBox.Y = (aWindowBox.Height - aViewWindowBox.Height) / 2;
916 : : }
917 [ # # ]: 0 : mxViewWindow->setPosSize(
918 : : aViewWindowBox.X,
919 : : aViewWindowBox.Y,
920 : : aViewWindowBox.Width,
921 : : aViewWindowBox.Height,
922 [ # # ]: 0 : awt::PosSize::POSSIZE);
923 : : }
924 : :
925 : : // Clear the background polygon so that on the next paint it is created
926 : : // for the new size.
927 [ # # ]: 0 : CreateBackgroundPolygons();
928 : :
929 : : // Notify listeners that the transformation that maps the view into the
930 : : // window has changed.
931 [ # # ][ # # ]: 0 : lang::EventObject aEvent (static_cast<XWeak*>(this));
932 : : ::cppu::OInterfaceContainerHelper* pIterator
933 [ # # ][ # # ]: 0 : = maBroadcaster.getContainer(getCppuType((Reference<util::XModifyListener>*)NULL));
934 [ # # ]: 0 : if (pIterator != NULL)
935 : : {
936 [ # # ]: 0 : pIterator->notifyEach(&util::XModifyListener::modified, aEvent);
937 : : }
938 : :
939 : : // Due to constant aspect ratio resizing may lead a preview that changes
940 : : // its position but not its size. This invalidates the back buffer and
941 : : // we have to enforce a complete repaint.
942 [ # # ]: 0 : if ( ! mbIsPaintPending)
943 [ # # ]: 0 : mbIsForcedPaintPending = true;
944 : : }
945 : :
946 : 0 : void PresenterSlideShowView::ForceRepaint (void)
947 : : {
948 [ # # ][ # # ]: 0 : if (mxSlideShow.is() && mbIsViewAdded)
[ # # ]
949 : : {
950 [ # # ]: 0 : mxSlideShow->removeView(this);
951 : 0 : impl_addAndConfigureView();
952 : : }
953 : 0 : }
954 : :
955 : 0 : void PresenterSlideShowView::CreateBackgroundPolygons (void)
956 : : {
957 [ # # ][ # # ]: 0 : const awt::Rectangle aWindowBox (mxWindow->getPosSize());
958 [ # # ][ # # ]: 0 : const awt::Rectangle aViewWindowBox (mxViewWindow->getPosSize());
959 [ # # ][ # # ]: 0 : if (aWindowBox.Height == aViewWindowBox.Height && aWindowBox.Width == aViewWindowBox.Width)
960 : : {
961 [ # # ]: 0 : mxBackgroundPolygon1 = NULL;
962 [ # # ]: 0 : mxBackgroundPolygon2 = NULL;
963 : : }
964 [ # # ]: 0 : else if (aWindowBox.Height == aViewWindowBox.Height)
965 : : {
966 : : // Paint two boxes to the left and right of the view window.
967 : : mxBackgroundPolygon1 = PresenterGeometryHelper::CreatePolygon(
968 : : awt::Rectangle(
969 : : 0,
970 : : 0,
971 : : aViewWindowBox.X,
972 : : aWindowBox.Height),
973 [ # # ][ # # ]: 0 : mxCanvas->getDevice());
[ # # ][ # # ]
974 : : mxBackgroundPolygon2 = PresenterGeometryHelper::CreatePolygon(
975 : : awt::Rectangle(
976 : : aViewWindowBox.X + aViewWindowBox.Width,
977 : : 0,
978 : : aWindowBox.Width - aViewWindowBox.X - aViewWindowBox.Width,
979 : : aWindowBox.Height),
980 [ # # ][ # # ]: 0 : mxCanvas->getDevice());
[ # # ][ # # ]
981 : : }
982 : : else
983 : : {
984 : : // Paint two boxes above and below the view window.
985 : : mxBackgroundPolygon1 = PresenterGeometryHelper::CreatePolygon(
986 : : awt::Rectangle(
987 : : 0,
988 : : 0,
989 : : aWindowBox.Width,
990 : : aViewWindowBox.Y),
991 [ # # ][ # # ]: 0 : mxCanvas->getDevice());
[ # # ][ # # ]
992 : : mxBackgroundPolygon2 = PresenterGeometryHelper::CreatePolygon(
993 : : awt::Rectangle(
994 : : 0,
995 : : aViewWindowBox.Y + aViewWindowBox.Height,
996 : : aWindowBox.Width,
997 : : aWindowBox.Height - aViewWindowBox.Y - aViewWindowBox.Height),
998 [ # # ][ # # ]: 0 : mxCanvas->getDevice());
[ # # ][ # # ]
999 : : }
1000 : 0 : }
1001 : :
1002 : 0 : void PresenterSlideShowView::ThrowIfDisposed (void)
1003 : : throw (::com::sun::star::lang::DisposedException)
1004 : : {
1005 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
1006 : : {
1007 : : throw lang::DisposedException (
1008 : : OUString("PresenterSlideShowView object has already been disposed"),
1009 [ # # ][ # # ]: 0 : static_cast<uno::XWeak*>(this));
1010 : : }
1011 : 0 : }
1012 : :
1013 : 0 : void PresenterSlideShowView::impl_addAndConfigureView()
1014 : : {
1015 [ # # ]: 0 : Reference<presentation::XSlideShowView> xView (this);
1016 [ # # ][ # # ]: 0 : mxSlideShow->addView(xView);
1017 : : // Prevent embeded sounds being played twice at the same time by
1018 : : // disabling sound for the new slide show view.
1019 : 0 : beans::PropertyValue aProperty;
1020 : 0 : aProperty.Name = A2S("IsSoundEnabled");
1021 [ # # ]: 0 : Sequence<Any> aValues (2);
1022 [ # # ][ # # ]: 0 : aValues[0] <<= xView;
1023 [ # # ][ # # ]: 0 : aValues[1] <<= sal_False;
1024 [ # # ]: 0 : aProperty.Value <<= aValues;
1025 [ # # ][ # # ]: 0 : mxSlideShow->setProperty(aProperty);
[ # # ]
1026 : 0 : }
1027 : :
1028 : : } } // end of namespace ::sd::presenter
1029 : :
1030 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|