LCOV - code coverage report
Current view: top level - sd/source/ui/slideshow - slideshowviewimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 330 0.0 %
Date: 2012-08-25 Functions: 0 40 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 560 0.0 %

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

Generated by: LCOV version 1.10