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