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