LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/slideshow - slideshowviewimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 331 0.3 %
Date: 2012-12-27 Functions: 2 42 4.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10