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