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 <slideshowviewimpl.hxx>
21 : #include <slideshowimpl.hxx>
22 : #include <osl/mutex.hxx>
23 :
24 : #include <com/sun/star/awt/Pointer.hpp>
25 : #include <com/sun/star/beans/XPropertySet.hpp>
26 :
27 : #include <basegfx/polygon/b2dpolygon.hxx>
28 : #include <basegfx/polygon/b2dpolygontools.hxx>
29 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
30 :
31 : #include <cppcanvas/vclfactory.hxx>
32 : #include <cppcanvas/basegfxfactory.hxx>
33 :
34 :
35 : using ::com::sun::star::uno::UNO_QUERY;
36 : using ::com::sun::star::uno::XInterface;
37 : using ::com::sun::star::uno::Reference;
38 : using ::com::sun::star::uno::WeakReference;
39 : using ::com::sun::star::uno::RuntimeException;
40 : using ::com::sun::star::lang::XComponent;
41 : using ::com::sun::star::uno::Exception;
42 : using ::com::sun::star::presentation::XSlideShow;
43 : using ::com::sun::star::presentation::XSlideShowView;
44 : using ::com::sun::star::presentation::XShapeEventListener;
45 : using ::com::sun::star::presentation::XSlideShowListener;
46 : using ::comphelper::ImplementationReference;
47 :
48 : using namespace ::com::sun::star;
49 :
50 : namespace sd
51 : {
52 :
53 : ///////////////////////////////////////////////////////////////////////
54 : // SlideShowViewListeners
55 : ///////////////////////////////////////////////////////////////////////
56 :
57 0 : SlideShowViewListeners::SlideShowViewListeners( ::osl::Mutex& rMutex )
58 0 : : mrMutex( rMutex )
59 : {
60 0 : }
61 :
62 0 : void SlideShowViewListeners::addListener( const Reference< util::XModifyListener >& _rxListener )
63 : {
64 0 : ::osl::MutexGuard aGuard( mrMutex );
65 :
66 0 : WeakReference< util::XModifyListener > xWeak( _rxListener );
67 0 : if( std::find( maListeners.begin(), maListeners.end(), xWeak ) == maListeners.end() )
68 0 : maListeners.push_back( xWeak );
69 0 : }
70 :
71 0 : void SlideShowViewListeners::removeListener( const Reference< util::XModifyListener >& _rxListener )
72 : {
73 0 : ::osl::MutexGuard aGuard( mrMutex );
74 :
75 0 : WeakReference< util::XModifyListener > xWeak( _rxListener );
76 0 : ViewListenerVector::iterator aIter( std::find( maListeners.begin(), maListeners.end(), xWeak ) );
77 0 : if( aIter != maListeners.end() )
78 0 : maListeners.erase( aIter );
79 0 : }
80 :
81 0 : bool SlideShowViewListeners::notify( const lang::EventObject& _rEvent ) throw( com::sun::star::uno::Exception )
82 : {
83 0 : ::osl::MutexGuard aGuard( mrMutex );
84 :
85 0 : ViewListenerVector::iterator aIter( maListeners.begin() );
86 0 : while( aIter != maListeners.end() )
87 : {
88 0 : Reference< util::XModifyListener > xListener( (*aIter) );
89 0 : if( xListener.is() )
90 : {
91 0 : xListener->modified( _rEvent );
92 0 : ++aIter;
93 : }
94 : else
95 : {
96 0 : aIter = maListeners.erase( aIter );
97 : }
98 0 : }
99 0 : return true;
100 : }
101 :
102 0 : void SlideShowViewListeners::disposing( const lang::EventObject& _rEventSource )
103 : {
104 0 : ::osl::MutexGuard aGuard( mrMutex );
105 :
106 0 : ViewListenerVector::iterator aIter( maListeners.begin() );
107 0 : while( aIter != maListeners.end() )
108 : {
109 0 : Reference< util::XModifyListener > xListener( (*aIter++) );
110 0 : if( xListener.is() )
111 0 : xListener->disposing( _rEventSource );
112 0 : }
113 :
114 0 : maListeners.clear();
115 0 : }
116 :
117 : ///////////////////////////////////////////////////////////////////////
118 : // SlideShowViewPaintListeners
119 : ///////////////////////////////////////////////////////////////////////
120 :
121 0 : SlideShowViewPaintListeners::SlideShowViewPaintListeners( ::osl::Mutex& rMutex )
122 0 : : SlideShowViewPaintListeners_Base( rMutex )
123 : {
124 0 : }
125 :
126 0 : bool SlideShowViewPaintListeners::implTypedNotify( const Reference< awt::XPaintListener >& rListener,
127 : const awt::PaintEvent& rEvent ) throw( uno::Exception )
128 : {
129 0 : rListener->windowPaint( rEvent );
130 0 : return true; // continue calling listeners
131 : }
132 :
133 : ///////////////////////////////////////////////////////////////////////
134 : // SlideShowViewMouseListeners
135 : ///////////////////////////////////////////////////////////////////////
136 :
137 0 : SlideShowViewMouseListeners::SlideShowViewMouseListeners( ::osl::Mutex& rMutex ) :
138 0 : SlideShowViewMouseListeners_Base( rMutex )
139 : {
140 0 : }
141 :
142 0 : bool SlideShowViewMouseListeners::implTypedNotify( const Reference< awt::XMouseListener >& rListener,
143 : const WrappedMouseEvent& rEvent ) throw( uno::Exception )
144 : {
145 0 : switch( rEvent.meType )
146 : {
147 : case WrappedMouseEvent::PRESSED:
148 0 : rListener->mousePressed( rEvent.maEvent );
149 0 : break;
150 :
151 : case WrappedMouseEvent::RELEASED:
152 0 : rListener->mouseReleased( rEvent.maEvent );
153 0 : break;
154 :
155 : case WrappedMouseEvent::ENTERED:
156 0 : rListener->mouseEntered( rEvent.maEvent );
157 0 : break;
158 :
159 : case WrappedMouseEvent::EXITED:
160 0 : rListener->mouseExited( rEvent.maEvent );
161 0 : break;
162 : }
163 :
164 0 : return true; // continue calling listeners
165 : }
166 :
167 : ///////////////////////////////////////////////////////////////////////
168 : // SlideShowViewMouseMotionListeners
169 : ///////////////////////////////////////////////////////////////////////
170 :
171 0 : SlideShowViewMouseMotionListeners::SlideShowViewMouseMotionListeners( ::osl::Mutex& rMutex ) :
172 0 : SlideShowViewMouseMotionListeners_Base( rMutex )
173 : {
174 0 : }
175 :
176 0 : bool SlideShowViewMouseMotionListeners::implTypedNotify( const Reference< awt::XMouseMotionListener >& rListener,
177 : const WrappedMouseMotionEvent& rEvent ) throw( uno::Exception )
178 : {
179 0 : switch( rEvent.meType )
180 : {
181 : case WrappedMouseMotionEvent::DRAGGED:
182 0 : rListener->mouseDragged( rEvent.maEvent );
183 0 : break;
184 :
185 : case WrappedMouseMotionEvent::MOVED:
186 0 : rListener->mouseMoved( rEvent.maEvent );
187 0 : break;
188 : }
189 :
190 0 : return true; // continue calling listeners
191 : }
192 :
193 : ///////////////////////////////////////////////////////////////////////
194 : // SlideShowView
195 : ///////////////////////////////////////////////////////////////////////
196 :
197 0 : SlideShowView::SlideShowView( ShowWindow& rOutputWindow,
198 : SdDrawDocument* pDoc,
199 : AnimationMode eAnimationMode,
200 : SlideshowImpl* pSlideShow,
201 : bool bFullScreen )
202 : : SlideShowView_Base( m_aMutex ),
203 0 : mpCanvas( ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas( rOutputWindow ) ),
204 : mxWindow( VCLUnoHelper::GetInterface( &rOutputWindow ), uno::UNO_QUERY_THROW ),
205 : mxWindowPeer( mxWindow, uno::UNO_QUERY_THROW ),
206 : mxPointer(),
207 : mpSlideShow( pSlideShow ),
208 : mrOutputWindow( rOutputWindow ),
209 0 : mpViewListeners( new SlideShowViewListeners( m_aMutex ) ),
210 0 : mpPaintListeners( new SlideShowViewPaintListeners( m_aMutex ) ),
211 0 : mpMouseListeners( new SlideShowViewMouseListeners( m_aMutex ) ),
212 0 : mpMouseMotionListeners( new SlideShowViewMouseMotionListeners( m_aMutex ) ),
213 : mpDoc( pDoc ),
214 : mbIsMouseMotionListener( false ),
215 : meAnimationMode( eAnimationMode ),
216 : mbFirstPaint( true ),
217 : mbFullScreen( bFullScreen ),
218 0 : mbMousePressedEaten( false )
219 : {
220 0 : init();
221 0 : }
222 :
223 : /// Dispose all internal references
224 0 : void SAL_CALL SlideShowView::dispose() throw (RuntimeException)
225 : {
226 0 : ::osl::MutexGuard aGuard( m_aMutex );
227 :
228 0 : mpSlideShow = 0;
229 :
230 : // deregister listeners
231 0 : if( mxWindow.is() )
232 : {
233 0 : mxWindow->removeWindowListener( this );
234 0 : mxWindow->removeMouseListener( this );
235 :
236 0 : if( mbIsMouseMotionListener )
237 0 : mxWindow->removeMouseMotionListener( this );
238 : }
239 :
240 0 : mpCanvas.reset();
241 0 : mxWindow.clear();
242 :
243 : // clear all listener containers
244 0 : disposing( lang::EventObject() );
245 :
246 : // call base
247 0 : WeakComponentImplHelperBase::dispose();
248 0 : }
249 :
250 : /// Disposing our broadcaster
251 0 : void SAL_CALL SlideShowView::disposing( const lang::EventObject& ) throw(RuntimeException)
252 : {
253 0 : ::osl::MutexGuard aGuard( m_aMutex );
254 :
255 : // notify all listeners that _we_ are going down (send a disposing()),
256 : // then delete listener containers:
257 0 : lang::EventObject const evt( static_cast<OWeakObject *>(this) );
258 0 : if (mpViewListeners.get() != 0) {
259 0 : mpViewListeners->disposing( evt );
260 0 : mpViewListeners.reset();
261 : }
262 0 : if (mpPaintListeners.get() != 0) {
263 0 : mpPaintListeners->disposing( evt );
264 0 : mpPaintListeners.reset();
265 : }
266 0 : if (mpMouseListeners.get() != 0) {
267 0 : mpMouseListeners->disposing( evt );
268 0 : mpMouseListeners.reset();
269 : }
270 0 : if (mpMouseMotionListeners.get() != 0) {
271 0 : mpMouseMotionListeners->disposing( evt );
272 0 : mpMouseMotionListeners.reset();
273 0 : }
274 0 : }
275 :
276 0 : void SAL_CALL SlideShowView::paint( const awt::PaintEvent& e ) throw (RuntimeException)
277 : {
278 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
279 :
280 0 : if( mbFirstPaint )
281 : {
282 0 : mbFirstPaint = false;
283 0 : SlideshowImpl* pSlideShow = mpSlideShow;
284 0 : aGuard.clear();
285 0 : if( pSlideShow )
286 0 : pSlideShow->onFirstPaint();
287 : }
288 : else
289 : {
290 : // Change event source, to enable listeners to match event
291 : // with view
292 0 : awt::PaintEvent aEvent( e );
293 0 : aEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
294 0 : mpPaintListeners->notify( aEvent );
295 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
296 0 : }
297 0 : }
298 :
299 : // XSlideShowView methods
300 0 : Reference< rendering::XSpriteCanvas > SAL_CALL SlideShowView::getCanvas( ) throw (RuntimeException)
301 : {
302 0 : ::osl::MutexGuard aGuard( m_aMutex );
303 :
304 0 : return mpCanvas.get() ? mpCanvas->getUNOSpriteCanvas() : Reference< rendering::XSpriteCanvas >();
305 : }
306 :
307 0 : void SAL_CALL SlideShowView::clear() throw (::com::sun::star::uno::RuntimeException)
308 : {
309 : // paint background in black
310 0 : ::osl::MutexGuard aGuard( m_aMutex );
311 0 : SolarMutexGuard aSolarGuard;
312 :
313 : // fill the bounds rectangle in black
314 : // ----------------------------------
315 :
316 0 : const Size aWindowSize( mrOutputWindow.GetSizePixel() );
317 :
318 : ::basegfx::B2DPolygon aPoly( ::basegfx::tools::createPolygonFromRect(
319 : ::basegfx::B2DRectangle(0.0,0.0,
320 0 : aWindowSize.Width(),
321 0 : aWindowSize.Height() ) ) );
322 : ::cppcanvas::PolyPolygonSharedPtr pPolyPoly(
323 0 : ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( mpCanvas, aPoly ) );
324 :
325 0 : if( pPolyPoly.get() )
326 : {
327 0 : pPolyPoly->setRGBAFillColor( 0x000000FFU );
328 0 : pPolyPoly->draw();
329 0 : }
330 0 : }
331 :
332 0 : geometry::AffineMatrix2D SAL_CALL SlideShowView::getTransformation( ) throw (RuntimeException)
333 : {
334 0 : ::osl::MutexGuard aGuard( m_aMutex );
335 0 : SolarMutexGuard aSolarGuard;
336 :
337 0 : const Size& rTmpSize( mrOutputWindow.GetSizePixel() );
338 :
339 0 : if (rTmpSize.Width()<=0 || rTmpSize.Height()<=0)
340 : {
341 0 : return geometry::AffineMatrix2D (1,0,0,0,1,0);
342 : }
343 :
344 0 : const Size aWindowSize( mrOutputWindow.GetSizePixel() );
345 0 : Size aOutputSize( aWindowSize );
346 :
347 0 : if( meAnimationMode != ANIMATIONMODE_SHOW )
348 : {
349 0 : aOutputSize.Width() = (long)( aOutputSize.Width() / 1.03 );
350 0 : aOutputSize.Height() = (long)( aOutputSize.Height() / 1.03 );
351 : }
352 :
353 0 : SdPage* pP = mpDoc->GetSdPage( 0, PK_STANDARD );
354 0 : Size aPageSize( pP->GetSize() );
355 :
356 0 : const double page_ratio = (double)aPageSize.Width() / (double)aPageSize.Height();
357 0 : const double output_ratio = (double)aOutputSize.Width() / (double)aOutputSize.Height();
358 :
359 0 : if( page_ratio > output_ratio )
360 : {
361 0 : aOutputSize.Height() = ( aOutputSize.Width() * aPageSize.Height() ) / aPageSize.Width();
362 : }
363 0 : else if( page_ratio < output_ratio )
364 : {
365 0 : aOutputSize.Width() = ( aOutputSize.Height() * aPageSize.Width() ) / aPageSize.Height();
366 : }
367 :
368 0 : Point aOutputOffset( ( aWindowSize.Width() - aOutputSize.Width() ) >> 1,
369 0 : ( aWindowSize.Height() - aOutputSize.Height() ) >> 1 );
370 :
371 : // Reduce available width by one, as the slides might actually
372 : // render one pixel wider and higher as aPageSize below specifies
373 : // (when shapes of page size have visible border lines)
374 0 : aOutputSize.Width() --;
375 0 : aOutputSize.Height() --;
376 :
377 0 : maPresentationArea = Rectangle( aOutputOffset, aOutputSize );
378 0 : mrOutputWindow.SetPresentationArea( maPresentationArea );
379 :
380 : // scale presentation into available window rect (minus 10%); center in the window
381 : const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
382 0 : aOutputSize.Width(), aOutputSize.Height(), aOutputOffset.X(), aOutputOffset.Y()));
383 :
384 0 : geometry::AffineMatrix2D aRes;
385 :
386 0 : return ::basegfx::unotools::affineMatrixFromHomMatrix( aRes, aMatrix );
387 : }
388 :
389 0 : void SAL_CALL SlideShowView::addTransformationChangedListener( const Reference< util::XModifyListener >& xListener ) throw (RuntimeException)
390 : {
391 0 : ::osl::MutexGuard aGuard( m_aMutex );
392 :
393 0 : if( mpViewListeners.get() )
394 0 : mpViewListeners->addListener( xListener );
395 0 : }
396 :
397 0 : void SAL_CALL SlideShowView::removeTransformationChangedListener( const Reference< util::XModifyListener >& xListener ) throw (RuntimeException)
398 : {
399 0 : ::osl::MutexGuard aGuard( m_aMutex );
400 :
401 0 : if( mpViewListeners.get() )
402 0 : mpViewListeners->removeListener( xListener );
403 0 : }
404 :
405 0 : void SAL_CALL SlideShowView::addPaintListener( const Reference< awt::XPaintListener >& xListener ) throw (RuntimeException)
406 : {
407 0 : ::osl::MutexGuard aGuard( m_aMutex );
408 :
409 0 : if( mpPaintListeners.get() )
410 0 : mpPaintListeners->addTypedListener( xListener );
411 0 : }
412 :
413 0 : void SAL_CALL SlideShowView::removePaintListener( const Reference< awt::XPaintListener >& xListener ) throw (RuntimeException)
414 : {
415 0 : ::osl::MutexGuard aGuard( m_aMutex );
416 :
417 0 : if( mpPaintListeners.get() )
418 0 : mpPaintListeners->removeTypedListener( xListener );
419 0 : }
420 :
421 0 : void SAL_CALL SlideShowView::addMouseListener( const Reference< awt::XMouseListener >& xListener ) throw (RuntimeException)
422 : {
423 0 : ::osl::MutexGuard aGuard( m_aMutex );
424 :
425 0 : if( mpMouseListeners.get() )
426 0 : mpMouseListeners->addTypedListener( xListener );
427 0 : }
428 :
429 0 : void SAL_CALL SlideShowView::removeMouseListener( const Reference< awt::XMouseListener >& xListener ) throw (RuntimeException)
430 : {
431 0 : ::osl::MutexGuard aGuard( m_aMutex );
432 :
433 0 : if( mpMouseListeners.get() )
434 0 : mpMouseListeners->removeTypedListener( xListener );
435 0 : }
436 :
437 0 : void SAL_CALL SlideShowView::addMouseMotionListener( const Reference< awt::XMouseMotionListener >& xListener ) throw (RuntimeException)
438 : {
439 0 : ::osl::MutexGuard aGuard( m_aMutex );
440 :
441 0 : if( !mbIsMouseMotionListener && mxWindow.is() )
442 : {
443 : // delay motion event registration, until we really
444 : // need it
445 0 : mbIsMouseMotionListener = true;
446 0 : mxWindow->addMouseMotionListener( this );
447 : }
448 :
449 0 : if( mpMouseMotionListeners.get() )
450 0 : mpMouseMotionListeners->addTypedListener( xListener );
451 0 : }
452 :
453 0 : void SAL_CALL SlideShowView::removeMouseMotionListener( const Reference< awt::XMouseMotionListener >& xListener ) throw (RuntimeException)
454 : {
455 0 : ::osl::MutexGuard aGuard( m_aMutex );
456 :
457 0 : if( mpMouseMotionListeners.get() )
458 0 : mpMouseMotionListeners->removeTypedListener( xListener );
459 :
460 : // TODO(P1): Might be nice to deregister for mouse motion
461 : // events, when the last listener is gone.
462 0 : }
463 :
464 0 : void SAL_CALL SlideShowView::setMouseCursor( sal_Int16 nPointerShape ) throw (RuntimeException)
465 : {
466 0 : ::osl::MutexGuard aGuard( m_aMutex );
467 :
468 : // forward to window
469 0 : if( mxPointer.is() )
470 0 : mxPointer->setType( nPointerShape );
471 :
472 0 : if( mxWindowPeer.is() )
473 0 : mxWindowPeer->setPointer( mxPointer );
474 0 : }
475 :
476 0 : awt::Rectangle SAL_CALL SlideShowView::getCanvasArea( ) throw (RuntimeException)
477 : {
478 0 : awt::Rectangle aRectangle;
479 :
480 0 : if( mxWindow.is() )
481 0 : return mxWindow->getPosSize();
482 :
483 0 : aRectangle.X = aRectangle.Y = aRectangle.Width = aRectangle.Height = 0;
484 :
485 0 : return aRectangle;
486 : }
487 :
488 0 : void SlideShowView::updateimpl( ::osl::ClearableMutexGuard& rGuard, SlideshowImpl* pSlideShow )
489 : {
490 0 : if( pSlideShow )
491 : {
492 0 : ::rtl::Reference< SlideshowImpl > aSLGuard( pSlideShow );
493 :
494 0 : if( mbFirstPaint )
495 : {
496 0 : mbFirstPaint = false;
497 0 : SlideshowImpl* pTmpSlideShow = mpSlideShow;
498 0 : rGuard.clear();
499 0 : if( pTmpSlideShow )
500 0 : pTmpSlideShow->onFirstPaint();
501 : } else
502 0 : rGuard.clear();
503 :
504 0 : pSlideShow->startUpdateTimer();
505 : }
506 0 : }
507 :
508 : // XWindowListener methods
509 0 : void SAL_CALL SlideShowView::windowResized( const awt::WindowEvent& e ) throw (RuntimeException)
510 : {
511 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
512 :
513 0 : if( mpViewListeners.get() )
514 : {
515 : // Change event source, to enable listeners to match event
516 : // with view
517 0 : awt::WindowEvent aEvent( e );
518 0 : aEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
519 :
520 0 : mpViewListeners->notify( aEvent );
521 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
522 0 : }
523 0 : }
524 :
525 0 : void SAL_CALL SlideShowView::windowMoved( const awt::WindowEvent& ) throw (RuntimeException)
526 : {
527 : // ignored
528 0 : }
529 :
530 0 : void SAL_CALL SlideShowView::windowShown( const lang::EventObject& ) throw (RuntimeException)
531 : {
532 : // ignored
533 0 : }
534 :
535 0 : void SAL_CALL SlideShowView::windowHidden( const lang::EventObject& ) throw (RuntimeException)
536 : {
537 : // ignored
538 0 : }
539 :
540 : // XMouseListener implementation
541 0 : void SAL_CALL SlideShowView::mousePressed( const awt::MouseEvent& e ) throw (uno::RuntimeException)
542 : {
543 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
544 0 : if( mpSlideShow && mpSlideShow->isInputFreezed() )
545 : {
546 0 : mbMousePressedEaten = true;
547 : }
548 : else
549 : {
550 0 : mbMousePressedEaten = false;
551 :
552 : // Change event source, to enable listeners to match event
553 : // with view
554 0 : WrappedMouseEvent aEvent;
555 0 : aEvent.meType = WrappedMouseEvent::PRESSED;
556 0 : aEvent.maEvent = e;
557 0 : aEvent.maEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
558 :
559 0 : if( mpMouseListeners.get() )
560 0 : mpMouseListeners->notify( aEvent );
561 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
562 0 : }
563 0 : }
564 :
565 0 : void SAL_CALL SlideShowView::mouseReleased( const awt::MouseEvent& e ) throw (uno::RuntimeException)
566 : {
567 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
568 0 : if( mbMousePressedEaten )
569 : {
570 : // if mouse button down was ignored, also ignore mouse button up
571 0 : mbMousePressedEaten = false;
572 : }
573 0 : else if( mpSlideShow && !mpSlideShow->isInputFreezed() )
574 : {
575 : // Change event source, to enable listeners to match event
576 : // with view
577 0 : WrappedMouseEvent aEvent;
578 0 : aEvent.meType = WrappedMouseEvent::RELEASED;
579 0 : aEvent.maEvent = e;
580 0 : aEvent.maEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
581 :
582 0 : if( mpMouseListeners.get() )
583 0 : mpMouseListeners->notify( aEvent );
584 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
585 0 : }
586 0 : }
587 :
588 0 : void SAL_CALL SlideShowView::mouseEntered( const awt::MouseEvent& e ) throw (uno::RuntimeException)
589 : {
590 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
591 :
592 : // Change event source, to enable listeners to match event
593 : // with view
594 0 : WrappedMouseEvent aEvent;
595 0 : aEvent.meType = WrappedMouseEvent::ENTERED;
596 0 : aEvent.maEvent = e;
597 0 : aEvent.maEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
598 :
599 0 : if( mpMouseListeners.get() )
600 0 : mpMouseListeners->notify( aEvent );
601 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
602 0 : }
603 :
604 0 : void SAL_CALL SlideShowView::mouseExited( const awt::MouseEvent& e ) throw (uno::RuntimeException)
605 : {
606 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
607 :
608 : // Change event source, to enable listeners to match event
609 : // with view
610 0 : WrappedMouseEvent aEvent;
611 0 : aEvent.meType = WrappedMouseEvent::EXITED;
612 0 : aEvent.maEvent = e;
613 0 : aEvent.maEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
614 :
615 0 : if( mpMouseListeners.get() )
616 0 : mpMouseListeners->notify( aEvent );
617 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
618 0 : }
619 :
620 : // XMouseMotionListener implementation
621 0 : void SAL_CALL SlideShowView::mouseDragged( const awt::MouseEvent& e ) throw (uno::RuntimeException)
622 : {
623 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
624 :
625 : // Change event source, to enable listeners to match event
626 : // with view
627 0 : WrappedMouseMotionEvent aEvent;
628 0 : aEvent.meType = WrappedMouseMotionEvent::DRAGGED;
629 0 : aEvent.maEvent = e;
630 0 : aEvent.maEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
631 :
632 0 : if( mpMouseMotionListeners.get() )
633 0 : mpMouseMotionListeners->notify( aEvent );
634 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
635 0 : }
636 :
637 0 : void SAL_CALL SlideShowView::mouseMoved( const awt::MouseEvent& e ) throw (uno::RuntimeException)
638 : {
639 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
640 :
641 : // Change event source, to enable listeners to match event
642 : // with view
643 0 : WrappedMouseMotionEvent aEvent;
644 0 : aEvent.meType = WrappedMouseMotionEvent::MOVED;
645 0 : aEvent.maEvent = e;
646 0 : aEvent.maEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
647 :
648 0 : if( mpMouseMotionListeners.get() )
649 0 : mpMouseMotionListeners->notify( aEvent );
650 0 : updateimpl( aGuard, mpSlideShow ); // warning: clears guard!
651 0 : }
652 :
653 0 : void SlideShowView::init()
654 : {
655 0 : mxWindow->addWindowListener( this );
656 0 : mxWindow->addMouseListener( this );
657 :
658 0 : mxPointer = awt::Pointer::create( ::comphelper::getProcessComponentContext() );
659 :
660 0 : getTransformation();
661 :
662 : // #i48939# only switch on kind of hacky scroll optimisation, when
663 : // running fullscreen. this minimizes the probability that other
664 : // windows partially cover the show.
665 0 : if( mbFullScreen )
666 : {
667 : try
668 : {
669 0 : Reference< beans::XPropertySet > xCanvasProps( getCanvas(),
670 0 : uno::UNO_QUERY_THROW );
671 0 : xCanvasProps->setPropertyValue("UnsafeScrolling",
672 0 : uno::makeAny( true ) );
673 : }
674 0 : catch( uno::Exception& )
675 : {
676 : }
677 : }
678 0 : }
679 :
680 33 : } // namespace ::sd
681 :
682 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|