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