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