LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/engine/slide - slideimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 342 0.0 %
Date: 2012-12-27 Functions: 0 44 0.0 %
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             : 
      21             : #include <osl/diagnose.hxx>
      22             : #include <canvas/debug.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : #include <canvas/canvastools.hxx>
      25             : #include <cppcanvas/basegfxfactory.hxx>
      26             : 
      27             : #include <basegfx/matrix/b2dhommatrix.hxx>
      28             : #include <basegfx/point/b2dpoint.hxx>
      29             : #include <basegfx/polygon/b2dpolygon.hxx>
      30             : #include <basegfx/polygon/b2dpolygontools.hxx>
      31             : #include <basegfx/numeric/ftools.hxx>
      32             : 
      33             : #include <com/sun/star/awt/SystemPointer.hpp>
      34             : #include <com/sun/star/container/XIndexAccess.hpp>
      35             : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
      36             : #include <com/sun/star/beans/XPropertySet.hpp>
      37             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      38             : #include <com/sun/star/awt/Rectangle.hpp>
      39             : #include <com/sun/star/presentation/ParagraphTarget.hpp>
      40             : #include <com/sun/star/presentation/EffectNodeType.hpp>
      41             : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
      42             : #include <com/sun/star/animations/XTargetPropertiesCreator.hpp>
      43             : #include <com/sun/star/drawing/TextAnimationKind.hpp>
      44             : 
      45             : #include <animations/animationnodehelper.hxx>
      46             : 
      47             : #include <cppuhelper/exc_hlp.hxx>
      48             : #include <comphelper/anytostring.hxx>
      49             : 
      50             : #include "slide.hxx"
      51             : #include "slideshowcontext.hxx"
      52             : #include "slideanimations.hxx"
      53             : #include "doctreenode.hxx"
      54             : #include "screenupdater.hxx"
      55             : #include "cursormanager.hxx"
      56             : #include "shapeimporter.hxx"
      57             : #include "slideshowexceptions.hxx"
      58             : #include "eventqueue.hxx"
      59             : #include "activitiesqueue.hxx"
      60             : #include "layermanager.hxx"
      61             : #include "shapemanagerimpl.hxx"
      62             : #include "usereventqueue.hxx"
      63             : #include "userpaintoverlay.hxx"
      64             : #include "event.hxx"
      65             : #include "tools.hxx"
      66             : 
      67             : #include <o3tl/compat_functional.hxx>
      68             : 
      69             : #include <boost/bind.hpp>
      70             : #include <iterator>
      71             : #include <algorithm>
      72             : #include <functional>
      73             : #include <iostream>
      74             : 
      75             : using namespace ::com::sun::star;
      76             : 
      77             : // -----------------------------------------------------------------------------
      78             : 
      79             : namespace slideshow
      80             : {
      81             : namespace internal
      82             : {
      83             : namespace
      84             : {
      85             : 
      86             : class SlideImpl : public Slide,
      87             :                   public CursorManager,
      88             :                   public ViewEventHandler,
      89             :                   public ::osl::DebugBase<SlideImpl>
      90             : {
      91             : public:
      92             :     SlideImpl( const uno::Reference<drawing::XDrawPage>&         xDrawPage,
      93             :                const uno::Reference<drawing::XDrawPagesSupplier>&    xDrawPages,
      94             :                const uno::Reference<animations::XAnimationNode>& xRootNode,
      95             :                EventQueue&                                       rEventQueue,
      96             :                EventMultiplexer&                                 rEventMultiplexer,
      97             :                ScreenUpdater&                                    rScreenUpdater,
      98             :                ActivitiesQueue&                                  rActivitiesQueue,
      99             :                UserEventQueue&                                   rUserEventQueue,
     100             :                CursorManager&                                    rCursorManager,
     101             :                const UnoViewContainer&                           rViewContainer,
     102             :                const uno::Reference<uno::XComponentContext>&     xContext,
     103             :                const ShapeEventListenerMap&                      rShapeListenerMap,
     104             :                const ShapeCursorMap&                             rShapeCursorMap,
     105             :                const PolyPolygonVector&                          rPolyPolygonVector,
     106             :                RGBColor const&                                   rUserPaintColor,
     107             :                double                                            dUserPaintStrokeWidth,
     108             :                bool                                              bUserPaintEnabled,
     109             :                bool                                              bIntrinsicAnimationsAllowed,
     110             :                bool                                              bDisableAnimationZOrder );
     111             : 
     112             :     ~SlideImpl();
     113             : 
     114             : 
     115             :     // Disposable interface
     116             :     // -------------------------------------------------------------------
     117             : 
     118             :     virtual void dispose();
     119             : 
     120             : 
     121             :     // Slide interface
     122             :     // -------------------------------------------------------------------
     123             : 
     124             :     virtual bool prefetch();
     125             :     virtual bool show( bool );
     126             :     virtual void hide();
     127             : 
     128             :     virtual basegfx::B2ISize getSlideSize() const;
     129             :     virtual uno::Reference<drawing::XDrawPage > getXDrawPage() const;
     130             :     virtual uno::Reference<animations::XAnimationNode> getXAnimationNode() const;
     131             :     virtual PolyPolygonVector getPolygons();
     132             :     virtual void drawPolygons() const;
     133             :     virtual bool isPaintOverlayActive() const;
     134             :     virtual void enablePaintOverlay();
     135             :     virtual void disablePaintOverlay();
     136             :     virtual void update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth );
     137             : 
     138             : 
     139             :     // TODO(F2): Rework SlideBitmap to no longer be based on XBitmap,
     140             :     // but on canvas-independent basegfx bitmaps
     141             :     virtual SlideBitmapSharedPtr getCurrentSlideBitmap( const UnoViewSharedPtr& rView ) const;
     142             : 
     143             : 
     144             : private:
     145             :     // ViewEventHandler
     146             :     virtual void viewAdded( const UnoViewSharedPtr& rView );
     147             :     virtual void viewRemoved( const UnoViewSharedPtr& rView );
     148             :     virtual void viewChanged( const UnoViewSharedPtr& rView );
     149             :     virtual void viewsChanged();
     150             : 
     151             :     // CursorManager
     152             :     virtual bool requestCursor( sal_Int16 nCursorShape );
     153             :     virtual void resetCursor();
     154             : 
     155             :     void activatePaintOverlay();
     156             :     void deactivatePaintOverlay();
     157             : 
     158             :     /** Query whether the slide has animations at all
     159             : 
     160             :         If the slide doesn't have animations, show() displays
     161             :         only static content. If an event is registered with
     162             :         registerSlideEndEvent(), this event will be
     163             :         immediately activated at the end of the show() method.
     164             : 
     165             :         @return true, if this slide has animations, false
     166             :         otherwise
     167             :     */
     168             :     bool isAnimated();
     169             : 
     170             :     /// Set all Shapes to their initial attributes for slideshow
     171             :     bool applyInitialShapeAttributes( const ::com::sun::star::uno::Reference<
     172             :                                       ::com::sun::star::animations::XAnimationNode >& xRootAnimationNode );
     173             : 
     174             :     /// Renders current slide content to bitmap
     175             :     SlideBitmapSharedPtr createCurrentSlideBitmap(
     176             :         const UnoViewSharedPtr& rView,
     177             :         ::basegfx::B2ISize const & rSlideSize ) const;
     178             : 
     179             :     /// Prefetch all shapes (not the animations)
     180             :     bool loadShapes();
     181             : 
     182             :     /// Retrieve slide size from XDrawPage
     183             :     basegfx::B2ISize getSlideSizeImpl() const;
     184             : 
     185             :     /// Prefetch show, but don't call applyInitialShapeAttributes()
     186             :     bool implPrefetchShow();
     187             : 
     188             :     /// Query the rectangle covered by the slide
     189             :     ::basegfx::B2DRectangle getSlideRect() const;
     190             : 
     191             :     /// Start GIF and other intrinsic shape animations
     192             :     void endIntrinsicAnimations();
     193             : 
     194             :     /// End GIF and other intrinsic shape animations
     195             :     void startIntrinsicAnimations();
     196             : 
     197             :     /// Add Polygons to the member maPolygons
     198             :     void addPolygons(PolyPolygonVector aPolygons);
     199             : 
     200             :     // Types
     201             :     // =====
     202             : 
     203             :     enum SlideAnimationState
     204             :     {
     205             :         CONSTRUCTING_STATE=0,
     206             :         INITIAL_STATE=1,
     207             :         SHOWING_STATE=2,
     208             :         FINAL_STATE=3,
     209             :         SlideAnimationState_NUM_ENTRIES=4
     210             :     };
     211             : 
     212             :     typedef std::vector< SlideBitmapSharedPtr > VectorOfSlideBitmaps;
     213             :     /** Vector of slide bitmaps.
     214             : 
     215             :         Since the bitmap content is sensitive to animation
     216             :         effects, we have an inner vector containing a distinct
     217             :         bitmap for each of the SlideAnimationStates.
     218             :     */
     219             :     typedef ::std::vector< std::pair< UnoViewSharedPtr,
     220             :                                       VectorOfSlideBitmaps > > VectorOfVectorOfSlideBitmaps;
     221             : 
     222             : 
     223             :     // Member variables
     224             :     // ================
     225             : 
     226             :     /// The page model object
     227             :     uno::Reference< drawing::XDrawPage >                mxDrawPage;
     228             :     uno::Reference< drawing::XDrawPagesSupplier >       mxDrawPagesSupplier;
     229             :     uno::Reference< animations::XAnimationNode >        mxRootNode;
     230             : 
     231             :     LayerManagerSharedPtr                               mpLayerManager;
     232             :     boost::shared_ptr<ShapeManagerImpl>                 mpShapeManager;
     233             :     boost::shared_ptr<SubsettableShapeManager>          mpSubsettableShapeManager;
     234             : 
     235             :     /// Contains common objects needed throughout the slideshow
     236             :     SlideShowContext                                    maContext;
     237             : 
     238             :     /// parent cursor manager
     239             :     CursorManager&                                      mrCursorManager;
     240             : 
     241             :     /// Handles the animation and event generation for us
     242             :     SlideAnimations                                     maAnimations;
     243             :     PolyPolygonVector                                   maPolygons;
     244             : 
     245             :     RGBColor                                            maUserPaintColor;
     246             :     double                                              mdUserPaintStrokeWidth;
     247             :     UserPaintOverlaySharedPtr                           mpPaintOverlay;
     248             : 
     249             :     /// Bitmaps with slide content at various states
     250             :     mutable VectorOfVectorOfSlideBitmaps                maSlideBitmaps;
     251             : 
     252             :     SlideAnimationState                                 meAnimationState;
     253             : 
     254             :     const basegfx::B2ISize                              maSlideSize;
     255             : 
     256             :     sal_Int16                                           mnCurrentCursor;
     257             : 
     258             :     /// True, when intrinsic shape animations are allowed
     259             :     bool                                                mbIntrinsicAnimationsAllowed;
     260             : 
     261             :     /// True, when user paint overlay is enabled
     262             :     bool                                                mbUserPaintOverlayEnabled;
     263             : 
     264             :     /// True, if initial load of all page shapes succeeded
     265             :     bool                                                mbShapesLoaded;
     266             : 
     267             :     /// True, if initial load of all animation info succeeded
     268             :     bool                                                mbShowLoaded;
     269             : 
     270             :     /** True, if this slide is not static.
     271             : 
     272             :         If this slide has animated content, this variable will
     273             :         be true, and false otherwise.
     274             :     */
     275             :     bool                                                mbHaveAnimations;
     276             : 
     277             :     /** True, if this slide has a main animation sequence.
     278             : 
     279             :         If this slide has animation content, which in turn has
     280             :         a main animation sequence (which must be fully run
     281             :         before EventMultiplexer::notifySlideAnimationsEnd() is
     282             :         called), this member is true.
     283             :     */
     284             :     bool                                                mbMainSequenceFound;
     285             : 
     286             :     /// When true, show() was called. Slide hidden oherwise.
     287             :     bool                                                mbActive;
     288             : 
     289             :     ///When true, enablePaintOverlay was called and mbUserPaintOverlay = true
     290             :     bool                                                mbPaintOverlayActive;
     291             : };
     292             : 
     293             : 
     294             : //////////////////////////////////////////////////////////////////////////////////
     295             : 
     296             : 
     297             : class SlideRenderer
     298             : {
     299             : public:
     300           0 :     explicit SlideRenderer( SlideImpl& rSlide ) :
     301           0 :         mrSlide( rSlide )
     302             :     {
     303           0 :     }
     304             : 
     305           0 :     void operator()( const UnoViewSharedPtr& rView )
     306             :     {
     307             :         // fully clear view content to background color
     308           0 :         rView->clearAll();
     309             : 
     310           0 :         SlideBitmapSharedPtr         pBitmap( mrSlide.getCurrentSlideBitmap( rView ) );
     311           0 :         ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() );
     312             : 
     313           0 :         const ::basegfx::B2DHomMatrix   aViewTransform( rView->getTransformation() );
     314           0 :         const ::basegfx::B2DPoint       aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() );
     315             : 
     316             :         // setup a canvas with device coordinate space, the slide
     317             :         // bitmap already has the correct dimension.
     318           0 :         ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas( pCanvas->clone() );
     319           0 :         pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
     320             : 
     321             :         // render at given output position
     322           0 :         pBitmap->move( aOutPosPixel );
     323             : 
     324             :         // clear clip (might have been changed, e.g. from comb
     325             :         // transition)
     326           0 :         pBitmap->clip( ::basegfx::B2DPolyPolygon() );
     327           0 :         pBitmap->draw( pDevicePixelCanvas );
     328           0 :     }
     329             : 
     330             : private:
     331             :     SlideImpl& mrSlide;
     332             : };
     333             : 
     334             : 
     335             : //////////////////////////////////////////////////////////////////////////////////
     336             : 
     337             : 
     338           0 : SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >&           xDrawPage,
     339             :                       const uno::Reference<drawing::XDrawPagesSupplier>&    xDrawPages,
     340             :                       const uno::Reference< animations::XAnimationNode >&   xRootNode,
     341             :                       EventQueue&                                           rEventQueue,
     342             :                       EventMultiplexer&                                     rEventMultiplexer,
     343             :                       ScreenUpdater&                                        rScreenUpdater,
     344             :                       ActivitiesQueue&                                      rActivitiesQueue,
     345             :                       UserEventQueue&                                       rUserEventQueue,
     346             :                       CursorManager&                                        rCursorManager,
     347             :                       const UnoViewContainer&                               rViewContainer,
     348             :                       const uno::Reference< uno::XComponentContext >&       xComponentContext,
     349             :                       const ShapeEventListenerMap&                          rShapeListenerMap,
     350             :                       const ShapeCursorMap&                                 rShapeCursorMap,
     351             :                       const PolyPolygonVector&                              rPolyPolygonVector,
     352             :                       RGBColor const&                                       aUserPaintColor,
     353             :                       double                                                dUserPaintStrokeWidth,
     354             :                       bool                                                  bUserPaintEnabled,
     355             :                       bool                                                  bIntrinsicAnimationsAllowed,
     356             :                       bool                                                  bDisableAnimationZOrder ) :
     357             :     mxDrawPage( xDrawPage ),
     358             :     mxDrawPagesSupplier( xDrawPages ),
     359             :     mxRootNode( xRootNode ),
     360             :     mpLayerManager( new LayerManager(
     361             :                         rViewContainer,
     362             :                         getSlideRect(),
     363           0 :                         bDisableAnimationZOrder) ),
     364             :     mpShapeManager( new ShapeManagerImpl(
     365             :                         rEventMultiplexer,
     366             :                         mpLayerManager,
     367             :                         rCursorManager,
     368             :                         rShapeListenerMap,
     369           0 :                         rShapeCursorMap)),
     370             :     mpSubsettableShapeManager( mpShapeManager ),
     371             :     maContext( mpSubsettableShapeManager,
     372             :                rEventQueue,
     373             :                rEventMultiplexer,
     374             :                rScreenUpdater,
     375             :                rActivitiesQueue,
     376             :                rUserEventQueue,
     377             :                *this,
     378             :                rViewContainer,
     379             :                xComponentContext ),
     380             :     mrCursorManager( rCursorManager ),
     381             :     maAnimations( maContext,
     382             :                   basegfx::B2DSize( getSlideSizeImpl() ) ),
     383             :     maPolygons(rPolyPolygonVector),
     384             :     maUserPaintColor(aUserPaintColor),
     385             :     mdUserPaintStrokeWidth(dUserPaintStrokeWidth),
     386             :     mpPaintOverlay(),
     387             :     maSlideBitmaps(),
     388             :     meAnimationState( CONSTRUCTING_STATE ),
     389             :     maSlideSize(getSlideSizeImpl()),
     390             :     mnCurrentCursor( awt::SystemPointer::ARROW ),
     391             :     mbIntrinsicAnimationsAllowed( bIntrinsicAnimationsAllowed ),
     392             :     mbUserPaintOverlayEnabled(bUserPaintEnabled),
     393             :     mbShapesLoaded( false ),
     394             :     mbShowLoaded( false ),
     395             :     mbHaveAnimations( false ),
     396             :     mbMainSequenceFound( false ),
     397             :     mbActive( false ),
     398           0 :     mbPaintOverlayActive( false )
     399             : {
     400             :     // clone already existing views for slide bitmaps
     401             :     std::for_each( rViewContainer.begin(),
     402             :                    rViewContainer.end(),
     403             :                    boost::bind( &SlideImpl::viewAdded,
     404             :                                 this,
     405           0 :                                 _1 ));
     406             : 
     407             :     // register screen update (LayerManager needs to signal pending
     408             :     // updates)
     409           0 :     maContext.mrScreenUpdater.addViewUpdate(mpShapeManager);
     410           0 : }
     411             : 
     412           0 : void SlideImpl::update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth )
     413             : {
     414           0 :     maUserPaintColor = aUserPaintColor;
     415           0 :     mdUserPaintStrokeWidth = dUserPaintStrokeWidth;
     416           0 :     mbUserPaintOverlayEnabled = bUserPaintEnabled;
     417           0 : }
     418             : 
     419           0 : SlideImpl::~SlideImpl()
     420             : {
     421           0 :     if( mpShapeManager )
     422             :     {
     423           0 :         maContext.mrScreenUpdater.removeViewUpdate(mpShapeManager);
     424           0 :         mpShapeManager->dispose();
     425             : 
     426             :         // TODO(Q3): Make sure LayerManager (and thus Shapes) dies
     427             :         // first, because SlideShowContext has SubsettableShapeManager
     428             :         // as reference member.
     429           0 :         mpLayerManager.reset();
     430             :     }
     431           0 : }
     432             : 
     433           0 : void SlideImpl::dispose()
     434             : {
     435           0 :     maSlideBitmaps.clear();
     436           0 :     mpPaintOverlay.reset();
     437           0 :     maAnimations.dispose();
     438           0 :     maContext.dispose();
     439             : 
     440           0 :     if( mpShapeManager )
     441             :     {
     442           0 :         maContext.mrScreenUpdater.removeViewUpdate(mpShapeManager);
     443           0 :         mpShapeManager->dispose();
     444             :     }
     445             : 
     446             :     // TODO(Q3): Make sure LayerManager (and thus Shapes) dies first,
     447             :     // because SlideShowContext has SubsettableShapeManager as
     448             :     // reference member.
     449           0 :     mpLayerManager.reset();
     450           0 :     mpSubsettableShapeManager.reset();
     451           0 :     mpShapeManager.reset();
     452           0 :     mxRootNode.clear();
     453           0 :     mxDrawPage.clear();
     454           0 :     mxDrawPagesSupplier.clear();
     455           0 : }
     456             : 
     457           0 : bool SlideImpl::prefetch()
     458             : {
     459           0 :     if( !mxRootNode.is() )
     460           0 :         return false;
     461             : 
     462           0 :     return applyInitialShapeAttributes(mxRootNode);
     463             : }
     464             : 
     465           0 : bool SlideImpl::show( bool bSlideBackgoundPainted )
     466             : {
     467             :     // ---------------------------------------------------------------
     468             : 
     469           0 :     if( mbActive )
     470           0 :         return true; // already active
     471             : 
     472           0 :     if( !mpShapeManager || !mpLayerManager )
     473           0 :         return false; // disposed
     474             : 
     475             :     // ---------------------------------------------------------------
     476             : 
     477             :     // set initial shape attributes (e.g. hide shapes that have
     478             :     // 'appear' effect set)
     479           0 :     if( !applyInitialShapeAttributes(mxRootNode) )
     480           0 :         return false;
     481             : 
     482             :     // ---------------------------------------------------------------
     483             : 
     484             :     // activate and take over view - clears view, if necessary
     485           0 :     mbActive = true;
     486           0 :     requestCursor( mnCurrentCursor );
     487             : 
     488             :     // enable shape management & event broadcasting for shapes of this
     489             :     // slide. Also enables LayerManager to record updates. Currently,
     490             :     // never let LayerManager render initial slide content, use
     491             :     // buffered slide bitmaps instead.
     492           0 :     mpShapeManager->activate( true );
     493             : 
     494             :     // ---------------------------------------------------------------
     495             : 
     496             :     // render slide to screen, if requested
     497           0 :     if( !bSlideBackgoundPainted )
     498             :     {
     499             :         std::for_each(maContext.mrViewContainer.begin(),
     500             :                       maContext.mrViewContainer.end(),
     501           0 :                       boost::mem_fn(&View::clearAll));
     502             : 
     503             :         std::for_each( maContext.mrViewContainer.begin(),
     504             :                        maContext.mrViewContainer.end(),
     505           0 :                        SlideRenderer(*this) );
     506           0 :         maContext.mrScreenUpdater.notifyUpdate();
     507             :     }
     508             : 
     509             :     // ---------------------------------------------------------------
     510             : 
     511             :     // fire up animations
     512           0 :     const bool bIsAnimated( isAnimated() );
     513           0 :     if( bIsAnimated )
     514           0 :         maAnimations.start(); // feeds initial events into queue
     515             : 
     516             :     // NOTE: this looks slightly weird, but is indeed correct:
     517             :     // as isAnimated() might return false, _although_ there is
     518             :     // a main sequence (because the animation nodes don't
     519             :     // contain any executable effects), we gotta check both
     520             :     // conditions here.
     521           0 :     if( !bIsAnimated || !mbMainSequenceFound )
     522             :     {
     523             :         // manually trigger a slide animation end event (we don't have
     524             :         // animations at all, or we don't have a main animation
     525             :         // sequence, but if we had, it'd end now). Note that having
     526             :         // animations alone does not matter here, as only main
     527             :         // sequence animations prevents showing the next slide on
     528             :         // nextEvent().
     529           0 :         maContext.mrEventMultiplexer.notifySlideAnimationsEnd();
     530             :     }
     531             : 
     532             :     // enable shape-intrinsic animations (drawing layer animations or
     533             :     // GIF animations)
     534           0 :     if( mbIntrinsicAnimationsAllowed )
     535           0 :         startIntrinsicAnimations();
     536             : 
     537             :     // ---------------------------------------------------------------
     538             : 
     539             :     // enable paint overlay, if maUserPaintColor is valid
     540           0 :     activatePaintOverlay();
     541             : 
     542             :     // ---------------------------------------------------------------
     543             : 
     544             :     // from now on, animations might be showing
     545           0 :     meAnimationState = SHOWING_STATE;
     546             : 
     547           0 :     return true;
     548             : }
     549             : 
     550           0 : void SlideImpl::hide()
     551             : {
     552           0 :     if( !mbActive || !mpShapeManager )
     553           0 :         return; // already hidden/disposed
     554             : 
     555             :     // ---------------------------------------------------------------
     556             : 
     557             :     // from now on, all animations are stopped
     558           0 :     meAnimationState = FINAL_STATE;
     559             : 
     560             :     // ---------------------------------------------------------------
     561             : 
     562             :     // disable user paint overlay under all circumstances,
     563             :     // this slide now ceases to be active.
     564           0 :     deactivatePaintOverlay();
     565             : 
     566             :     // ---------------------------------------------------------------
     567             : 
     568             :     // switch off all shape-intrinsic animations.
     569           0 :     endIntrinsicAnimations();
     570             : 
     571             :     // force-end all SMIL animations, too
     572           0 :     maAnimations.end();
     573             : 
     574             :     // ---------------------------------------------------------------
     575             : 
     576             :     // disable shape management & event broadcasting for shapes of this
     577             :     // slide. Also disables LayerManager.
     578           0 :     mpShapeManager->deactivate();
     579             : 
     580             :     // vanish from view
     581           0 :     resetCursor();
     582           0 :     mbActive = false;
     583             : 
     584             :     // ---------------------------------------------------------------
     585             : }
     586             : 
     587           0 : basegfx::B2ISize SlideImpl::getSlideSize() const
     588             : {
     589           0 :     return maSlideSize;
     590             : }
     591             : 
     592           0 : uno::Reference<drawing::XDrawPage > SlideImpl::getXDrawPage() const
     593             : {
     594           0 :     return mxDrawPage;
     595             : }
     596             : 
     597           0 : uno::Reference<animations::XAnimationNode> SlideImpl::getXAnimationNode() const
     598             : {
     599           0 :     return mxRootNode;
     600             : }
     601             : 
     602           0 : PolyPolygonVector SlideImpl::getPolygons()
     603             : {
     604           0 :     if(mbPaintOverlayActive)
     605           0 :         maPolygons = mpPaintOverlay->getPolygons();
     606           0 :     return maPolygons;
     607             : }
     608             : 
     609           0 : SlideBitmapSharedPtr SlideImpl::getCurrentSlideBitmap( const UnoViewSharedPtr& rView ) const
     610             : {
     611             :     // search corresponding entry in maSlideBitmaps (which
     612             :     // contains the views as the key)
     613           0 :     VectorOfVectorOfSlideBitmaps::iterator       aIter;
     614           0 :     const VectorOfVectorOfSlideBitmaps::iterator aEnd( maSlideBitmaps.end() );
     615           0 :     if( (aIter=std::find_if( maSlideBitmaps.begin(),
     616             :                              aEnd,
     617             :                              boost::bind(
     618             :                                  std::equal_to<UnoViewSharedPtr>(),
     619             :                                  rView,
     620             :                                  // select view:
     621             :                                  boost::bind(
     622             :                                      o3tl::select1st<VectorOfVectorOfSlideBitmaps::value_type>(),
     623           0 :                                      _1 )))) == aEnd )
     624             :     {
     625             :         // corresponding view not found - maybe view was not
     626             :         // added to Slide?
     627           0 :         ENSURE_OR_THROW( false,
     628             :                           "SlideImpl::getInitialSlideBitmap(): view does not "
     629             :                           "match any of the added ones" );
     630             :     }
     631             : 
     632             :     // ensure that the show is loaded
     633           0 :     if( !mbShowLoaded )
     634             :     {
     635             :         // only prefetch and init shapes when not done already
     636             :         // (otherwise, at least applyInitialShapeAttributes() will be
     637             :         // called twice for initial slide rendering). Furthermore,
     638             :         // applyInitialShapeAttributes() _always_ performs
     639             :         // initializations, which would be highly unwanted during a
     640             :         // running show. OTOH, a slide whose mbShowLoaded is false is
     641             :         // guaranteed not be running a show.
     642             : 
     643             :         // set initial shape attributes (e.g. hide 'appear' effect
     644             :         // shapes)
     645           0 :         if( !const_cast<SlideImpl*>(this)->applyInitialShapeAttributes( mxRootNode ) )
     646           0 :             ENSURE_OR_THROW(false,
     647             :                              "SlideImpl::getCurrentSlideBitmap(): Cannot "
     648             :                              "apply initial attributes");
     649             :     }
     650             : 
     651           0 :     SlideBitmapSharedPtr&     rBitmap( aIter->second.at( meAnimationState ));
     652             :     const ::basegfx::B2ISize& rSlideSize(
     653           0 :         getSlideSizePixel( ::basegfx::B2DSize( getSlideSize() ),
     654           0 :                            rView ));
     655             : 
     656             :     // is the bitmap valid (actually existent, and of correct
     657             :     // size)?
     658           0 :     if( !rBitmap || rBitmap->getSize() != rSlideSize )
     659             :     {
     660             :         // no bitmap there yet, or wrong size - create one
     661           0 :         rBitmap = createCurrentSlideBitmap(rView, rSlideSize);
     662             :     }
     663             : 
     664           0 :     return rBitmap;
     665             : }
     666             : 
     667             : 
     668             : // private methods
     669             : //--------------------------------------------------------------------------------------------------------------
     670             : 
     671             : 
     672           0 : void SlideImpl::viewAdded( const UnoViewSharedPtr& rView )
     673             : {
     674             :     maSlideBitmaps.push_back(
     675             :         std::make_pair( rView,
     676           0 :                         VectorOfSlideBitmaps(SlideAnimationState_NUM_ENTRIES) ));
     677             : 
     678           0 :     if( mpLayerManager )
     679           0 :         mpLayerManager->viewAdded( rView );
     680           0 : }
     681             : 
     682           0 : void SlideImpl::viewRemoved( const UnoViewSharedPtr& rView )
     683             : {
     684           0 :     if( mpLayerManager )
     685           0 :         mpLayerManager->viewRemoved( rView );
     686             : 
     687           0 :     const VectorOfVectorOfSlideBitmaps::iterator aEnd( maSlideBitmaps.end() );
     688             :     maSlideBitmaps.erase(
     689             :         std::remove_if( maSlideBitmaps.begin(),
     690             :                         aEnd,
     691             :                         boost::bind(
     692             :                             std::equal_to<UnoViewSharedPtr>(),
     693             :                             rView,
     694             :                             // select view:
     695             :                             boost::bind(
     696             :                                 o3tl::select1st<VectorOfVectorOfSlideBitmaps::value_type>(),
     697             :                                 _1 ))),
     698           0 :         aEnd );
     699           0 : }
     700             : 
     701           0 : void SlideImpl::viewChanged( const UnoViewSharedPtr& rView )
     702             : {
     703             :     // nothing to do for the Slide - getCurrentSlideBitmap() lazily
     704             :     // handles bitmap resizes
     705           0 :     if( mbActive && mpLayerManager )
     706           0 :         mpLayerManager->viewChanged(rView);
     707           0 : }
     708             : 
     709           0 : void SlideImpl::viewsChanged()
     710             : {
     711             :     // nothing to do for the Slide - getCurrentSlideBitmap() lazily
     712             :     // handles bitmap resizes
     713           0 :     if( mbActive && mpLayerManager )
     714           0 :         mpLayerManager->viewsChanged();
     715           0 : }
     716             : 
     717           0 : bool SlideImpl::requestCursor( sal_Int16 nCursorShape )
     718             : {
     719           0 :     mnCurrentCursor = nCursorShape;
     720           0 :     return mrCursorManager.requestCursor(mnCurrentCursor);
     721             : }
     722             : 
     723           0 : void SlideImpl::resetCursor()
     724             : {
     725           0 :     mnCurrentCursor = awt::SystemPointer::ARROW;
     726           0 :     mrCursorManager.resetCursor();
     727           0 : }
     728             : 
     729           0 : bool SlideImpl::isAnimated()
     730             : {
     731             :     // prefetch, but don't apply initial shape attributes
     732           0 :     if( !implPrefetchShow() )
     733           0 :         return false;
     734             : 
     735           0 :     return mbHaveAnimations && maAnimations.isAnimated();
     736             : }
     737             : 
     738           0 : SlideBitmapSharedPtr SlideImpl::createCurrentSlideBitmap( const UnoViewSharedPtr&   rView,
     739             :                                                           const ::basegfx::B2ISize& rBmpSize ) const
     740             : {
     741           0 :     ENSURE_OR_THROW( rView && rView->getCanvas(),
     742             :                       "SlideImpl::createCurrentSlideBitmap(): Invalid view" );
     743           0 :     ENSURE_OR_THROW( mpLayerManager,
     744             :                       "SlideImpl::createCurrentSlideBitmap(): Invalid layer manager" );
     745           0 :     ENSURE_OR_THROW( mbShowLoaded,
     746             :                       "SlideImpl::createCurrentSlideBitmap(): No show loaded" );
     747             : 
     748           0 :     ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() );
     749             : 
     750             :     // create a bitmap of appropriate size
     751             :     ::cppcanvas::BitmapSharedPtr pBitmap(
     752           0 :         ::cppcanvas::BaseGfxFactory::getInstance().createBitmap(
     753             :             pCanvas,
     754           0 :             rBmpSize ) );
     755             : 
     756           0 :     ENSURE_OR_THROW( pBitmap,
     757             :                       "SlideImpl::createCurrentSlideBitmap(): Cannot create page bitmap" );
     758             : 
     759           0 :     ::cppcanvas::BitmapCanvasSharedPtr pBitmapCanvas( pBitmap->getBitmapCanvas() );
     760             : 
     761           0 :     ENSURE_OR_THROW( pBitmapCanvas,
     762             :                       "SlideImpl::createCurrentSlideBitmap(): Cannot create page bitmap canvas" );
     763             : 
     764             :     // apply linear part of destination canvas transformation (linear means in this context:
     765             :     // transformation without any translational components)
     766           0 :     ::basegfx::B2DHomMatrix aLinearTransform( rView->getTransformation() );
     767           0 :     aLinearTransform.set( 0, 2, 0.0 );
     768           0 :     aLinearTransform.set( 1, 2, 0.0 );
     769           0 :     pBitmapCanvas->setTransformation( aLinearTransform );
     770             : 
     771             :     // output all shapes to bitmap
     772           0 :     initSlideBackground( pBitmapCanvas, rBmpSize );
     773           0 :     mpLayerManager->renderTo( pBitmapCanvas );
     774             : 
     775           0 :     return SlideBitmapSharedPtr( new SlideBitmap( pBitmap ) );
     776             : }
     777             : 
     778             : namespace
     779             : {
     780           0 :     class MainSequenceSearcher
     781             :     {
     782             :     public:
     783           0 :         MainSequenceSearcher()
     784           0 :         {
     785           0 :             maSearchKey.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "node-type" ) );
     786           0 :             maSearchKey.Value <<= presentation::EffectNodeType::MAIN_SEQUENCE;
     787           0 :         }
     788             : 
     789           0 :         void operator()( const uno::Reference< animations::XAnimationNode >& xChildNode )
     790             :         {
     791           0 :             uno::Sequence< beans::NamedValue > aUserData( xChildNode->getUserData() );
     792             : 
     793           0 :             if( findNamedValue( aUserData, maSearchKey ) )
     794             :             {
     795           0 :                 maMainSequence = xChildNode;
     796           0 :             }
     797           0 :         }
     798             : 
     799           0 :         uno::Reference< animations::XAnimationNode > getMainSequence() const
     800             :         {
     801           0 :             return maMainSequence;
     802             :         }
     803             : 
     804             :     private:
     805             :         beans::NamedValue                               maSearchKey;
     806             :         uno::Reference< animations::XAnimationNode >    maMainSequence;
     807             :     };
     808             : }
     809             : 
     810           0 : bool SlideImpl::implPrefetchShow()
     811             : {
     812           0 :     if( mbShowLoaded )
     813           0 :         return true;
     814             : 
     815           0 :     ENSURE_OR_RETURN_FALSE( mxDrawPage.is(),
     816             :                        "SlideImpl::implPrefetchShow(): Invalid draw page" );
     817           0 :     ENSURE_OR_RETURN_FALSE( mpLayerManager,
     818             :                        "SlideImpl::implPrefetchShow(): Invalid layer manager" );
     819             : 
     820             :     // fetch desired page content
     821             :     // ==========================
     822             : 
     823           0 :     if( !loadShapes() )
     824           0 :         return false;
     825             : 
     826             :     // New animations framework: import the shape effect info
     827             :     // ======================================================
     828             : 
     829             :     try
     830             :     {
     831           0 :         if( mxRootNode.is() )
     832             :         {
     833           0 :             if( !maAnimations.importAnimations( mxRootNode ) )
     834             :             {
     835             :                 OSL_FAIL( "SlideImpl::implPrefetchShow(): have animation nodes, "
     836             :                             "but import animations failed." );
     837             : 
     838             :                 // could not import animation framework,
     839             :                 // _although_ some animation nodes are there -
     840             :                 // this is an error (not finding animations at
     841             :                 // all is okay - might be a static slide)
     842           0 :                 return false;
     843             :             }
     844             : 
     845             :             // now check whether we've got a main sequence (if
     846             :             // not, we must manually call
     847             :             // EventMultiplexer::notifySlideAnimationsEnd()
     848             :             // above, as e.g. interactive sequences alone
     849             :             // don't block nextEvent() from issuing the next
     850             :             // slide)
     851           0 :             MainSequenceSearcher aSearcher;
     852           0 :             if( ::anim::for_each_childNode( mxRootNode, aSearcher ) )
     853           0 :                 mbMainSequenceFound = aSearcher.getMainSequence().is();
     854             : 
     855             :             // import successfully done
     856           0 :             mbHaveAnimations = true;
     857             :         }
     858             :     }
     859           0 :     catch( uno::RuntimeException& )
     860             :     {
     861           0 :         throw;
     862             :     }
     863           0 :     catch( uno::Exception& )
     864             :     {
     865             :         OSL_FAIL(
     866             :             rtl::OUStringToOString(
     867             :                 comphelper::anyToString(cppu::getCaughtException()),
     868             :                 RTL_TEXTENCODING_UTF8).getStr() );
     869             :         // TODO(E2): Error handling. For now, bail out
     870             :     }
     871             : 
     872           0 :     mbShowLoaded = true;
     873             : 
     874           0 :     return true;
     875             : }
     876             : 
     877           0 : void SlideImpl::enablePaintOverlay()
     878             : {
     879           0 :     if( !mbUserPaintOverlayEnabled || !mbPaintOverlayActive )
     880             :     {
     881           0 :         mbUserPaintOverlayEnabled = true;
     882           0 :         activatePaintOverlay();
     883             :     }
     884           0 : }
     885             : 
     886           0 : void SlideImpl::disablePaintOverlay()
     887             : {
     888           0 : }
     889             : 
     890           0 : void SlideImpl::activatePaintOverlay()
     891             : {
     892           0 :     if( mbUserPaintOverlayEnabled || !maPolygons.empty() )
     893             :     {
     894             :         mpPaintOverlay = UserPaintOverlay::create( maUserPaintColor,
     895             :                                                    mdUserPaintStrokeWidth,
     896             :                                                    maContext,
     897             :                                                    maPolygons,
     898           0 :                                                    mbUserPaintOverlayEnabled );
     899           0 :         mbPaintOverlayActive = true;
     900             :     }
     901           0 : }
     902             : 
     903           0 : void SlideImpl::drawPolygons() const
     904             : {
     905           0 :     if( mpPaintOverlay  )
     906           0 :         mpPaintOverlay->drawPolygons();
     907           0 : }
     908             : 
     909           0 : void SlideImpl::addPolygons(PolyPolygonVector aPolygons)
     910             : {
     911           0 :     if(!aPolygons.empty())
     912             :     {
     913           0 :         for( PolyPolygonVector::iterator aIter=aPolygons.begin(),
     914           0 :                  aEnd=aPolygons.end();
     915             :              aIter!=aEnd;
     916             :              ++aIter )
     917             :         {
     918           0 :             maPolygons.push_back(*aIter);
     919             :         }
     920             :     }
     921           0 : }
     922             : 
     923           0 : bool SlideImpl::isPaintOverlayActive() const
     924             : {
     925           0 :     return mbPaintOverlayActive;
     926             : }
     927             : 
     928           0 : void SlideImpl::deactivatePaintOverlay()
     929             : {
     930           0 :     if(mbPaintOverlayActive)
     931           0 :         maPolygons = mpPaintOverlay->getPolygons();
     932             : 
     933           0 :     mpPaintOverlay.reset();
     934           0 :     mbPaintOverlayActive = false;
     935           0 : }
     936             : 
     937           0 : ::basegfx::B2DRectangle SlideImpl::getSlideRect() const
     938             : {
     939           0 :     const basegfx::B2ISize slideSize( getSlideSizeImpl() );
     940             :     return ::basegfx::B2DRectangle(0.0,0.0,
     941           0 :                                    slideSize.getX(),
     942           0 :                                    slideSize.getY());
     943             : }
     944             : 
     945           0 : void SlideImpl::endIntrinsicAnimations()
     946             : {
     947           0 :     mpSubsettableShapeManager->notifyIntrinsicAnimationsDisabled();
     948           0 : }
     949             : 
     950           0 : void SlideImpl::startIntrinsicAnimations()
     951             : {
     952           0 :     mpSubsettableShapeManager->notifyIntrinsicAnimationsEnabled();
     953           0 : }
     954             : 
     955           0 : bool SlideImpl::applyInitialShapeAttributes(
     956             :     const uno::Reference< animations::XAnimationNode >& xRootAnimationNode )
     957             : {
     958           0 :     if( !implPrefetchShow() )
     959           0 :         return false;
     960             : 
     961           0 :     if( !xRootAnimationNode.is() )
     962             :     {
     963           0 :         meAnimationState = INITIAL_STATE;
     964             : 
     965           0 :         return true; // no animations - no attributes to apply -
     966             :                      // succeeded
     967             :     }
     968             : 
     969           0 :     uno::Reference< animations::XTargetPropertiesCreator > xPropsCreator;
     970             : 
     971             :     try
     972             :     {
     973           0 :         ENSURE_OR_RETURN_FALSE( maContext.mxComponentContext.is(),
     974             :                            "SlideImpl::applyInitialShapeAttributes(): Invalid component context" );
     975             : 
     976             :         uno::Reference<lang::XMultiComponentFactory> xFac(
     977           0 :             maContext.mxComponentContext->getServiceManager() );
     978             : 
     979             :         xPropsCreator.set(
     980           0 :             xFac->createInstanceWithContext(
     981             :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     982             :                                      "com.sun.star.animations.TargetPropertiesCreator") ),
     983           0 :                 maContext.mxComponentContext ),
     984           0 :             uno::UNO_QUERY_THROW );
     985             :     }
     986           0 :     catch( uno::RuntimeException& )
     987             :     {
     988           0 :         throw;
     989             :     }
     990           0 :     catch( uno::Exception& )
     991             :     {
     992             :         OSL_FAIL(
     993             :             rtl::OUStringToOString(
     994             :                 comphelper::anyToString(cppu::getCaughtException()),
     995             :                 RTL_TEXTENCODING_UTF8).getStr() );
     996             : 
     997             :         // could not determine initial shape attributes - this
     998             :         // is an error, as some effects might then be plainly
     999             :         // invisible
    1000           0 :         ENSURE_OR_RETURN_FALSE( false,
    1001             :                            "SlideImpl::applyInitialShapeAttributes(): "
    1002             :                            "couldn't create TargetPropertiesCreator." );
    1003             :     }
    1004             : 
    1005             :     uno::Sequence< animations::TargetProperties > aProps(
    1006           0 :         xPropsCreator->createInitialTargetProperties( xRootAnimationNode ) );
    1007             : 
    1008             :     // apply extracted values to our shapes
    1009           0 :     const ::std::size_t nSize( aProps.getLength() );
    1010           0 :     for( ::std::size_t i=0; i<nSize; ++i )
    1011             :     {
    1012           0 :         sal_Int16                         nParaIndex( -1 );
    1013           0 :         uno::Reference< drawing::XShape > xShape( aProps[i].Target,
    1014           0 :                                                   uno::UNO_QUERY );
    1015             : 
    1016           0 :         if( !xShape.is() )
    1017             :         {
    1018             :             // not a shape target. Maybe a ParagraphTarget?
    1019           0 :             presentation::ParagraphTarget aParaTarget;
    1020             : 
    1021           0 :             if( (aProps[i].Target >>= aParaTarget) )
    1022             :             {
    1023             :                 // yep, ParagraphTarget found - extract shape
    1024             :                 // and index
    1025           0 :                 xShape = aParaTarget.Shape;
    1026           0 :                 nParaIndex = aParaTarget.Paragraph;
    1027           0 :             }
    1028             :         }
    1029             : 
    1030           0 :         if( xShape.is() )
    1031             :         {
    1032           0 :             ShapeSharedPtr pShape( mpLayerManager->lookupShape( xShape ) );
    1033             : 
    1034           0 :             if( !pShape )
    1035             :             {
    1036             :                 OSL_FAIL( "SlideImpl::applyInitialShapeAttributes(): no shape found for given target" );
    1037           0 :                 continue;
    1038             :             }
    1039             : 
    1040             :             AttributableShapeSharedPtr pAttrShape(
    1041           0 :                 ::boost::dynamic_pointer_cast< AttributableShape >( pShape ) );
    1042             : 
    1043           0 :             if( !pAttrShape )
    1044             :             {
    1045             :                 OSL_FAIL( "SlideImpl::applyInitialShapeAttributes(): shape found does not "
    1046             :                             "implement AttributableShape interface" );
    1047           0 :                 continue;
    1048             :             }
    1049             : 
    1050           0 :             if( nParaIndex != -1 )
    1051             :             {
    1052             :                 // our target is a paragraph subset, thus look
    1053             :                 // this up first.
    1054           0 :                 const DocTreeNodeSupplier& rNodeSupplier( pAttrShape->getTreeNodeSupplier() );
    1055             : 
    1056           0 :                 if( rNodeSupplier.getNumberOfTreeNodes(
    1057           0 :                         DocTreeNode::NODETYPE_LOGICAL_PARAGRAPH ) <= nParaIndex )
    1058             :                 {
    1059             :                     OSL_FAIL( "SlideImpl::applyInitialShapeAttributes(): shape found does not "
    1060             :                                 "provide a subset for requested paragraph index" );
    1061           0 :                     continue;
    1062             :                 }
    1063             : 
    1064           0 :                 pAttrShape = pAttrShape->getSubset(
    1065             :                     rNodeSupplier.getTreeNode(
    1066             :                         nParaIndex,
    1067           0 :                         DocTreeNode::NODETYPE_LOGICAL_PARAGRAPH ) );
    1068             : 
    1069           0 :                 if( !pAttrShape )
    1070             :                 {
    1071             :                     OSL_FAIL( "SlideImpl::applyInitialShapeAttributes(): shape found does not "
    1072             :                                 "provide a subset for requested paragraph index" );
    1073           0 :                     continue;
    1074             :                 }
    1075             :             }
    1076             : 
    1077           0 :             const uno::Sequence< beans::NamedValue >& rShapeProps( aProps[i].Properties );
    1078           0 :             const ::std::size_t nShapePropSize( rShapeProps.getLength() );
    1079           0 :             for( ::std::size_t j=0; j<nShapePropSize; ++j )
    1080             :             {
    1081           0 :                 bool bVisible=false;
    1082           0 :                 if( rShapeProps[j].Name.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("visibility")) &&
    1083             :                     extractValue( bVisible,
    1084           0 :                                   rShapeProps[j].Value,
    1085             :                                   pShape,
    1086           0 :                                   ::basegfx::B2DSize( getSlideSize() ) ))
    1087             :                 {
    1088           0 :                     pAttrShape->setVisibility( bVisible );
    1089             :                 }
    1090             :                 else
    1091             :                 {
    1092             :                     OSL_FAIL( "SlideImpl::applyInitialShapeAttributes(): Unexpected "
    1093             :                                 "(and unimplemented) property encountered" );
    1094             :                 }
    1095           0 :             }
    1096             :         }
    1097           0 :     }
    1098             : 
    1099           0 :     meAnimationState = INITIAL_STATE;
    1100             : 
    1101           0 :     return true;
    1102             : }
    1103             : 
    1104           0 : bool SlideImpl::loadShapes()
    1105             : {
    1106           0 :     if( mbShapesLoaded )
    1107           0 :         return true;
    1108             : 
    1109           0 :     ENSURE_OR_RETURN_FALSE( mxDrawPage.is(),
    1110             :                        "SlideImpl::loadShapes(): Invalid draw page" );
    1111           0 :     ENSURE_OR_RETURN_FALSE( mpLayerManager,
    1112             :                        "SlideImpl::loadShapes(): Invalid layer manager" );
    1113             : 
    1114             :     // fetch desired page content
    1115             :     // ==========================
    1116             : 
    1117             :     // also take master page content
    1118           0 :     uno::Reference< drawing::XDrawPage > xMasterPage;
    1119           0 :     uno::Reference< drawing::XShapes >   xMasterPageShapes;
    1120           0 :     sal_Int32                            nCurrCount(0);
    1121             : 
    1122             :     uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( mxDrawPage,
    1123           0 :                                                                     uno::UNO_QUERY );
    1124           0 :     if( xMasterPageTarget.is() )
    1125             :     {
    1126           0 :         xMasterPage = xMasterPageTarget->getMasterPage();
    1127             :         xMasterPageShapes.set( xMasterPage,
    1128           0 :                                uno::UNO_QUERY );
    1129             : 
    1130           0 :         if( xMasterPage.is() && xMasterPageShapes.is() )
    1131             :         {
    1132             :             // TODO(P2): maybe cache master pages here (or treat the
    1133             :             // masterpage as a single metafile. At least currently,
    1134             :             // masterpages do not contain animation effects)
    1135             :             try
    1136             :             {
    1137             :                 // load the masterpage shapes
    1138             :                 // -------------------------------------------------------------------------
    1139             :                 ShapeImporter aMPShapesFunctor( xMasterPage,
    1140             :                                                 mxDrawPage,
    1141             :                                                 mxDrawPagesSupplier,
    1142             :                                                 maContext,
    1143             :                                                 0, /* shape num starts at 0 */
    1144           0 :                                                 true );
    1145             : 
    1146             :                 mpLayerManager->addShape(
    1147           0 :                     aMPShapesFunctor.importBackgroundShape() );
    1148             : 
    1149           0 :                 while( !aMPShapesFunctor.isImportDone() )
    1150             :                 {
    1151             :                     ShapeSharedPtr const& rShape(
    1152           0 :                         aMPShapesFunctor.importShape() );
    1153           0 :                     if( rShape )
    1154           0 :                         mpLayerManager->addShape( rShape );
    1155           0 :                 }
    1156           0 :                 addPolygons(aMPShapesFunctor.getPolygons());
    1157             : 
    1158           0 :                 nCurrCount = static_cast<sal_Int32>(aMPShapesFunctor.getImportedShapesCount());
    1159             :             }
    1160           0 :             catch( uno::RuntimeException& )
    1161             :             {
    1162           0 :                 throw;
    1163             :             }
    1164           0 :             catch( ShapeLoadFailedException& )
    1165             :             {
    1166             :                 // TODO(E2): Error handling. For now, bail out
    1167             :                 OSL_FAIL( "SlideImpl::loadShapes(): caught ShapeLoadFailedException" );
    1168           0 :                 return false;
    1169             : 
    1170             :             }
    1171           0 :             catch( uno::Exception& )
    1172             :             {
    1173             :                 OSL_FAIL( rtl::OUStringToOString(
    1174             :                                 comphelper::anyToString( cppu::getCaughtException() ),
    1175             :                                 RTL_TEXTENCODING_UTF8 ).getStr() );
    1176             : 
    1177           0 :                 return false;
    1178             :             }
    1179             :         }
    1180             :     }
    1181             : 
    1182             :     try
    1183             :     {
    1184             :         // load the normal page shapes
    1185             :         // -------------------------------------------------------------------------
    1186             : 
    1187             :         ShapeImporter aShapesFunctor( mxDrawPage,
    1188             :                                       mxDrawPage,
    1189             :                                       mxDrawPagesSupplier,
    1190             :                                       maContext,
    1191             :                                       nCurrCount,
    1192           0 :                                       false );
    1193             : 
    1194           0 :         while( !aShapesFunctor.isImportDone() )
    1195             :         {
    1196             :             ShapeSharedPtr const& rShape(
    1197           0 :                 aShapesFunctor.importShape() );
    1198           0 :             if( rShape )
    1199           0 :                 mpLayerManager->addShape( rShape );
    1200           0 :         }
    1201           0 :         addPolygons(aShapesFunctor.getPolygons());
    1202             :     }
    1203           0 :     catch( uno::RuntimeException& )
    1204             :     {
    1205           0 :         throw;
    1206             :     }
    1207           0 :     catch( ShapeLoadFailedException& )
    1208             :     {
    1209             :         // TODO(E2): Error handling. For now, bail out
    1210             :         OSL_FAIL( "SlideImpl::loadShapes(): caught ShapeLoadFailedException" );
    1211           0 :         return false;
    1212             :     }
    1213           0 :     catch( uno::Exception& )
    1214             :     {
    1215             :         OSL_FAIL( rtl::OUStringToOString(
    1216             :                         comphelper::anyToString( cppu::getCaughtException() ),
    1217             :                         RTL_TEXTENCODING_UTF8 ).getStr() );
    1218             : 
    1219           0 :         return false;
    1220             :     }
    1221             : 
    1222           0 :     mbShapesLoaded = true;
    1223             : 
    1224           0 :     return true;
    1225             : }
    1226             : 
    1227           0 : basegfx::B2ISize SlideImpl::getSlideSizeImpl() const
    1228             : {
    1229             :     uno::Reference< beans::XPropertySet > xPropSet(
    1230           0 :         mxDrawPage, uno::UNO_QUERY_THROW );
    1231             : 
    1232           0 :     sal_Int32 nDocWidth = 0;
    1233           0 :     sal_Int32 nDocHeight = 0;
    1234           0 :     xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nDocWidth;
    1235           0 :     xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) ) >>= nDocHeight;
    1236             : 
    1237           0 :     return basegfx::B2ISize( nDocWidth, nDocHeight );
    1238             : }
    1239             : 
    1240             : } // namespace
    1241             : 
    1242             : 
    1243           0 : SlideSharedPtr createSlide( const uno::Reference< drawing::XDrawPage >&         xDrawPage,
    1244             :                             const uno::Reference<drawing::XDrawPagesSupplier>&  xDrawPages,
    1245             :                             const uno::Reference< animations::XAnimationNode >& xRootNode,
    1246             :                             EventQueue&                                         rEventQueue,
    1247             :                             EventMultiplexer&                                   rEventMultiplexer,
    1248             :                             ScreenUpdater&                                      rScreenUpdater,
    1249             :                             ActivitiesQueue&                                    rActivitiesQueue,
    1250             :                             UserEventQueue&                                     rUserEventQueue,
    1251             :                             CursorManager&                                      rCursorManager,
    1252             :                             const UnoViewContainer&                             rViewContainer,
    1253             :                             const uno::Reference< uno::XComponentContext >&     xComponentContext,
    1254             :                             const ShapeEventListenerMap&                        rShapeListenerMap,
    1255             :                             const ShapeCursorMap&                               rShapeCursorMap,
    1256             :                             const PolyPolygonVector&                            rPolyPolygonVector,
    1257             :                             RGBColor const&                                     rUserPaintColor,
    1258             :                             double                                              dUserPaintStrokeWidth,
    1259             :                             bool                                                bUserPaintEnabled,
    1260             :                             bool                                                bIntrinsicAnimationsAllowed,
    1261             :                             bool                                                bDisableAnimationZOrder )
    1262             : {
    1263             :     boost::shared_ptr<SlideImpl> pRet( new SlideImpl( xDrawPage, xDrawPages, xRootNode, rEventQueue,
    1264             :                                                       rEventMultiplexer, rScreenUpdater,
    1265             :                                                       rActivitiesQueue, rUserEventQueue,
    1266             :                                                       rCursorManager, rViewContainer,
    1267             :                                                       xComponentContext, rShapeListenerMap,
    1268             :                                                       rShapeCursorMap, rPolyPolygonVector, rUserPaintColor,
    1269             :                                                       dUserPaintStrokeWidth, bUserPaintEnabled,
    1270             :                                                       bIntrinsicAnimationsAllowed,
    1271           0 :                                                       bDisableAnimationZOrder ));
    1272             : 
    1273           0 :     rEventMultiplexer.addViewHandler( pRet );
    1274             : 
    1275           0 :     return pRet;
    1276             : }
    1277             : 
    1278             : } // namespace internal
    1279           0 : } // namespace slideshow
    1280             : 
    1281             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10