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