1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_DRAWSHAPE_HXX 25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_DRAWSHAPE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <osl/diagnose.hxx> 28cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include "attributableshape.hxx" 31cdf0e10cSrcweir #include "doctreenodesupplier.hxx" 32cdf0e10cSrcweir #include "gdimtftools.hxx" 33cdf0e10cSrcweir #include "viewshape.hxx" 34cdf0e10cSrcweir #include "hyperlinkarea.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <boost/optional.hpp> 37cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 38cdf0e10cSrcweir #include <boost/weak_ptr.hpp> 39cdf0e10cSrcweir #include <set> 40cdf0e10cSrcweir #include <vector> 41cdf0e10cSrcweir 42cdf0e10cSrcweir class Graphic; 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace slideshow 45cdf0e10cSrcweir { 46cdf0e10cSrcweir namespace internal 47cdf0e10cSrcweir { 48cdf0e10cSrcweir class Activity; 49cdf0e10cSrcweir struct SlideShowContext; 50cdf0e10cSrcweir class DrawShapeSubsetting; 51cdf0e10cSrcweir class DrawShape; 52cdf0e10cSrcweir typedef ::boost::shared_ptr< DrawShape > DrawShapeSharedPtr; 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** This class is the representation of a draw document's 55cdf0e10cSrcweir XShape, and implements the Shape, AnimatableShape, and 56cdf0e10cSrcweir AttributableShape interfaces. 57cdf0e10cSrcweir 58cdf0e10cSrcweir @attention this class is to be treated 'final', i.e. one 59cdf0e10cSrcweir should not derive from it. 60cdf0e10cSrcweir */ 61cdf0e10cSrcweir class DrawShape : public AttributableShape, 62cdf0e10cSrcweir public DocTreeNodeSupplier, 63cdf0e10cSrcweir public HyperlinkArea, 64cdf0e10cSrcweir public ::osl::DebugBase<DrawShape> 65cdf0e10cSrcweir { 66cdf0e10cSrcweir public: 67cdf0e10cSrcweir /** Create a shape for the given XShape 68cdf0e10cSrcweir 69cdf0e10cSrcweir @param xShape 70cdf0e10cSrcweir The XShape to represent. 71cdf0e10cSrcweir 72cdf0e10cSrcweir @param xContainingPage 73cdf0e10cSrcweir The page that contains this shape. Needed for proper 74cdf0e10cSrcweir import (currently, the UnoGraphicExporter needs this 75cdf0e10cSrcweir information). 76cdf0e10cSrcweir 77cdf0e10cSrcweir @param nPrio 78cdf0e10cSrcweir Externally-determined shape priority (used e.g. for 79cdf0e10cSrcweir paint ordering). This number _must be_ unique! 80cdf0e10cSrcweir 81cdf0e10cSrcweir @param bForeignSource 82cdf0e10cSrcweir When true, the source of the shape metafile might be a 83cdf0e10cSrcweir foreign application. The metafile is checked against 84cdf0e10cSrcweir unsupported content, and, if necessary, returned as a 85cdf0e10cSrcweir pre-rendererd bitmap. 86cdf0e10cSrcweir */ 87cdf0e10cSrcweir static DrawShapeSharedPtr create( 88cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 89cdf0e10cSrcweir ::com::sun::star::drawing::XShape >& xShape, 90cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 91cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xContainingPage, 92cdf0e10cSrcweir double nPrio, 93cdf0e10cSrcweir bool bForeignSource, 94cdf0e10cSrcweir const SlideShowContext& rContext ); // throw ShapeLoadFailedException; 95cdf0e10cSrcweir 96cdf0e10cSrcweir /** Create a shape for the given XShape and graphic content 97cdf0e10cSrcweir 98cdf0e10cSrcweir @param xShape 99cdf0e10cSrcweir The XShape to represent. 100cdf0e10cSrcweir 101cdf0e10cSrcweir @param xContainingPage 102cdf0e10cSrcweir The page that contains this shape. Needed for proper 103cdf0e10cSrcweir import (currently, the UnoGraphicExporter needs this 104cdf0e10cSrcweir information). 105cdf0e10cSrcweir 106cdf0e10cSrcweir @param nPrio 107cdf0e10cSrcweir Externally-determined shape priority (used e.g. for 108cdf0e10cSrcweir paint ordering). This number _must be_ unique! 109cdf0e10cSrcweir 110cdf0e10cSrcweir @param rGraphic 111cdf0e10cSrcweir Graphic to display in the shape's bound rect. If this 112cdf0e10cSrcweir Graphic contains animatable content, the created 113cdf0e10cSrcweir DrawShape will register itself for intrinsic animation 114cdf0e10cSrcweir events. 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir static DrawShapeSharedPtr create( 117cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 118cdf0e10cSrcweir ::com::sun::star::drawing::XShape >& xShape, 119cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 120cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xContainingPage, 121cdf0e10cSrcweir double nPrio, 122cdf0e10cSrcweir const Graphic& rGraphic, 123cdf0e10cSrcweir const SlideShowContext& rContext ); // throw ShapeLoadFailedException; 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 126cdf0e10cSrcweir ::com::sun::star::drawing::XShape > getXShape() const; 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual ~DrawShape(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir 131cdf0e10cSrcweir // View layer methods 132cdf0e10cSrcweir //------------------------------------------------------------------ 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual void addViewLayer( const ViewLayerSharedPtr& rNewLayer, 135cdf0e10cSrcweir bool bRedrawLayer ); 136cdf0e10cSrcweir virtual bool removeViewLayer( const ViewLayerSharedPtr& rNewLayer ); 137cdf0e10cSrcweir virtual bool clearAllViewLayers(); 138cdf0e10cSrcweir 139cdf0e10cSrcweir // attribute methods 140cdf0e10cSrcweir //------------------------------------------------------------------ 141cdf0e10cSrcweir 142cdf0e10cSrcweir virtual ShapeAttributeLayerSharedPtr createAttributeLayer(); 143cdf0e10cSrcweir virtual bool revokeAttributeLayer( const ShapeAttributeLayerSharedPtr& rLayer ); 144cdf0e10cSrcweir virtual ShapeAttributeLayerSharedPtr getTopmostAttributeLayer() const; 145cdf0e10cSrcweir virtual void setVisibility( bool bVisible ); 146cdf0e10cSrcweir virtual ::basegfx::B2DRectangle getBounds() const; 147cdf0e10cSrcweir virtual ::basegfx::B2DRectangle getDomBounds() const; 148cdf0e10cSrcweir virtual ::basegfx::B2DRectangle getUpdateArea() const; 149cdf0e10cSrcweir virtual bool isVisible() const; 150cdf0e10cSrcweir virtual double getPriority() const; 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153cdf0e10cSrcweir // animation methods 154cdf0e10cSrcweir //------------------------------------------------------------------ 155cdf0e10cSrcweir 156cdf0e10cSrcweir virtual void enterAnimationMode(); 157cdf0e10cSrcweir virtual void leaveAnimationMode(); 158cdf0e10cSrcweir virtual bool isBackgroundDetached() const; 159cdf0e10cSrcweir 160cdf0e10cSrcweir // render methods 161cdf0e10cSrcweir //------------------------------------------------------------------ 162cdf0e10cSrcweir 163cdf0e10cSrcweir virtual bool update() const; 164cdf0e10cSrcweir virtual bool render() const; 165cdf0e10cSrcweir virtual bool isContentChanged() const; 166cdf0e10cSrcweir 167cdf0e10cSrcweir // Sub item specialities 168cdf0e10cSrcweir //------------------------------------------------------------------ 169cdf0e10cSrcweir 170cdf0e10cSrcweir virtual const DocTreeNodeSupplier& getTreeNodeSupplier() const; 171cdf0e10cSrcweir virtual DocTreeNodeSupplier& getTreeNodeSupplier(); 172cdf0e10cSrcweir 173cdf0e10cSrcweir virtual DocTreeNode getSubsetNode() const; 174cdf0e10cSrcweir virtual AttributableShapeSharedPtr getSubset( const DocTreeNode& rTreeNode ) const; 175cdf0e10cSrcweir virtual bool createSubset( AttributableShapeSharedPtr& o_rSubset, 176cdf0e10cSrcweir const DocTreeNode& rTreeNode ); 177cdf0e10cSrcweir virtual bool revokeSubset( const AttributableShapeSharedPtr& rShape ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir 180cdf0e10cSrcweir // DocTreeNodeSupplier methods 181cdf0e10cSrcweir //------------------------------------------------------------------ 182cdf0e10cSrcweir 183cdf0e10cSrcweir virtual sal_Int32 getNumberOfTreeNodes ( DocTreeNode::NodeType eNodeType ) const; // throw ShapeLoadFailedException; 184cdf0e10cSrcweir virtual DocTreeNode getTreeNode ( sal_Int32 nNodeIndex, 185cdf0e10cSrcweir DocTreeNode::NodeType eNodeType ) const; // throw ShapeLoadFailedException; 186cdf0e10cSrcweir virtual sal_Int32 getNumberOfSubsetTreeNodes ( const DocTreeNode& rParentNode, 187cdf0e10cSrcweir DocTreeNode::NodeType eNodeType ) const; // throw ShapeLoadFailedException; 188cdf0e10cSrcweir virtual DocTreeNode getSubsetTreeNode ( const DocTreeNode& rParentNode, 189cdf0e10cSrcweir sal_Int32 nNodeIndex, 190cdf0e10cSrcweir DocTreeNode::NodeType eNodeType ) const; // throw ShapeLoadFailedException; 191cdf0e10cSrcweir 192cdf0e10cSrcweir // HyperlinkArea methods 193cdf0e10cSrcweir //------------------------------------------------------------------ 194cdf0e10cSrcweir 195cdf0e10cSrcweir virtual HyperlinkRegions getHyperlinkRegions() const; 196cdf0e10cSrcweir virtual double getHyperlinkPriority() const; 197cdf0e10cSrcweir 198cdf0e10cSrcweir 199cdf0e10cSrcweir // intrinsic animation methods 200cdf0e10cSrcweir //------------------------------------------------------------------ 201cdf0e10cSrcweir 202cdf0e10cSrcweir /** Display next frame of an intrinsic animation. 203cdf0e10cSrcweir 204cdf0e10cSrcweir Used by IntrinsicAnimationActivity, to show the next 205cdf0e10cSrcweir animation frame. 206cdf0e10cSrcweir */ 207cdf0e10cSrcweir bool setIntrinsicAnimationFrame( ::std::size_t nCurrFrame ); 208cdf0e10cSrcweir 209cdf0e10cSrcweir /** forces the drawshape to load and return a specially 210cdf0e10cSrcweir crafted metafile, usable to display drawing layer text 211cdf0e10cSrcweir animations. 212cdf0e10cSrcweir */ 213cdf0e10cSrcweir GDIMetaFileSharedPtr forceScrollTextMetaFile(); 214cdf0e10cSrcweir 215cdf0e10cSrcweir private: 216cdf0e10cSrcweir /** Create a shape for the given XShape 217cdf0e10cSrcweir 218cdf0e10cSrcweir @param xShape 219cdf0e10cSrcweir The XShape to represent. 220cdf0e10cSrcweir 221cdf0e10cSrcweir @param xContainingPage 222cdf0e10cSrcweir The page that contains this shape. Needed for proper 223cdf0e10cSrcweir import (currently, the UnoGraphicExporter needs this 224cdf0e10cSrcweir information). 225cdf0e10cSrcweir 226cdf0e10cSrcweir @param nPrio 227cdf0e10cSrcweir Externally-determined shape priority (used e.g. for 228cdf0e10cSrcweir paint ordering). This number _must be_ unique! 229cdf0e10cSrcweir 230cdf0e10cSrcweir @param bForeignSource 231cdf0e10cSrcweir When true, the source of the shape metafile might be a 232cdf0e10cSrcweir foreign application. The metafile is checked against 233cdf0e10cSrcweir unsupported content, and, if necessary, returned as a 234cdf0e10cSrcweir pre-rendererd bitmap. 235cdf0e10cSrcweir */ 236cdf0e10cSrcweir DrawShape( const ::com::sun::star::uno::Reference< 237cdf0e10cSrcweir ::com::sun::star::drawing::XShape >& xShape, 238cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 239cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xContainingPage, 240cdf0e10cSrcweir double nPrio, 241cdf0e10cSrcweir bool bForeignSource, 242cdf0e10cSrcweir const SlideShowContext& rContext ); // throw ShapeLoadFailedException; 243cdf0e10cSrcweir 244cdf0e10cSrcweir /** Create a shape for the given XShape and graphic content 245cdf0e10cSrcweir 246cdf0e10cSrcweir @param xShape 247cdf0e10cSrcweir The XShape to represent. 248cdf0e10cSrcweir 249cdf0e10cSrcweir @param xContainingPage 250cdf0e10cSrcweir The page that contains this shape. Needed for proper 251cdf0e10cSrcweir import (currently, the UnoGraphicExporter needs this 252cdf0e10cSrcweir information). 253cdf0e10cSrcweir 254cdf0e10cSrcweir @param nPrio 255cdf0e10cSrcweir Externally-determined shape priority (used e.g. for 256cdf0e10cSrcweir paint ordering). This number _must be_ unique! 257cdf0e10cSrcweir 258cdf0e10cSrcweir @param rGraphic 259cdf0e10cSrcweir Graphic to display in the shape's bound rect. If this 260cdf0e10cSrcweir Graphic contains animatable content, the created 261cdf0e10cSrcweir DrawShape will register itself for intrinsic animation 262cdf0e10cSrcweir events. 263cdf0e10cSrcweir */ 264cdf0e10cSrcweir DrawShape( const ::com::sun::star::uno::Reference< 265cdf0e10cSrcweir ::com::sun::star::drawing::XShape >& xShape, 266cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 267cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xContainingPage, 268cdf0e10cSrcweir double nPrio, 269cdf0e10cSrcweir const Graphic& rGraphic, 270cdf0e10cSrcweir const SlideShowContext& rContext ); // throw ShapeLoadFailedException; 271cdf0e10cSrcweir 272cdf0e10cSrcweir /** Private copy constructor 273cdf0e10cSrcweir 274cdf0e10cSrcweir Used to create subsetted shapes 275cdf0e10cSrcweir */ 276cdf0e10cSrcweir DrawShape( const DrawShape&, const DocTreeNode& rTreeNode, double nPrio ); 277cdf0e10cSrcweir 278cdf0e10cSrcweir int getUpdateFlags() const; 279cdf0e10cSrcweir bool implRender( int nUpdateFlags ) const; 280cdf0e10cSrcweir void updateStateIds() const; 281cdf0e10cSrcweir 282cdf0e10cSrcweir ViewShape::RenderArgs getViewRenderArgs() const; 283cdf0e10cSrcweir ::basegfx::B2DRectangle getActualUnitShapeBounds() const; 284cdf0e10cSrcweir 285cdf0e10cSrcweir void ensureVerboseMtfComments() const; 286cdf0e10cSrcweir bool hasIntrinsicAnimation() const; 287cdf0e10cSrcweir bool hasHyperlinks() const; 288cdf0e10cSrcweir void prepareHyperlinkIndices() const; 289cdf0e10cSrcweir 290cdf0e10cSrcweir /// The associated XShape 291cdf0e10cSrcweir ::com::sun::star::uno::Reference< 292cdf0e10cSrcweir ::com::sun::star::drawing::XShape > mxShape; 293cdf0e10cSrcweir ::com::sun::star::uno::Reference< 294cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage > mxPage; 295cdf0e10cSrcweir 296cdf0e10cSrcweir /** A vector of metafiles actually representing the Shape. 297cdf0e10cSrcweir 298cdf0e10cSrcweir If this shape is not animated, only a single entry is 299cdf0e10cSrcweir available. 300cdf0e10cSrcweir */ 301cdf0e10cSrcweir mutable VectorOfMtfAnimationFrames maAnimationFrames; 302cdf0e10cSrcweir ::std::size_t mnCurrFrame; 303cdf0e10cSrcweir 304cdf0e10cSrcweir /// Metafile of currently active frame (static for shapes w/o intrinsic animation) 305cdf0e10cSrcweir mutable GDIMetaFileSharedPtr mpCurrMtf; 306cdf0e10cSrcweir 307cdf0e10cSrcweir /// loadflags of current meta file 308cdf0e10cSrcweir mutable int mnCurrMtfLoadFlags; 309cdf0e10cSrcweir 310cdf0e10cSrcweir /// Contains the current shape bounds, in unit rect space 311cdf0e10cSrcweir mutable ::boost::optional<basegfx::B2DRectangle> maCurrentShapeUnitBounds; 312cdf0e10cSrcweir 313cdf0e10cSrcweir // The attributes of this Shape 314cdf0e10cSrcweir const double mnPriority; 315cdf0e10cSrcweir ::basegfx::B2DRectangle maBounds; // always needed for rendering. 316cdf0e10cSrcweir // for subset shapes, this member 317cdf0e10cSrcweir // might change when views are 318cdf0e10cSrcweir // added, as minimal bounds are 319cdf0e10cSrcweir // calculated 320cdf0e10cSrcweir 321cdf0e10cSrcweir // Pointer to modifiable shape attributes 322cdf0e10cSrcweir ShapeAttributeLayerSharedPtr mpAttributeLayer; // only created lazily 323cdf0e10cSrcweir 324cdf0e10cSrcweir // held here, to signal our destruction 325cdf0e10cSrcweir boost::weak_ptr<Activity> mpIntrinsicAnimationActivity; 326cdf0e10cSrcweir 327cdf0e10cSrcweir // The attribute states, to detect attribute changes, 328cdf0e10cSrcweir // without buffering and querying each single attribute 329cdf0e10cSrcweir mutable State::StateId mnAttributeTransformationState; 330cdf0e10cSrcweir mutable State::StateId mnAttributeClipState; 331cdf0e10cSrcweir mutable State::StateId mnAttributeAlphaState; 332cdf0e10cSrcweir mutable State::StateId mnAttributePositionState; 333cdf0e10cSrcweir mutable State::StateId mnAttributeContentState; 334cdf0e10cSrcweir mutable State::StateId mnAttributeVisibilityState; 335cdf0e10cSrcweir 336cdf0e10cSrcweir /// the list of active view shapes (one for each registered view layer) 337cdf0e10cSrcweir typedef ::std::vector< ViewShapeSharedPtr > ViewShapeVector; 338cdf0e10cSrcweir ViewShapeVector maViewShapes; 339cdf0e10cSrcweir 340cdf0e10cSrcweir ::com::sun::star::uno::Reference< 341cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext> mxComponentContext; 342cdf0e10cSrcweir 343cdf0e10cSrcweir /// hyperlink support 344cdf0e10cSrcweir typedef ::std::pair<sal_Int32 /* mtf start */, 345cdf0e10cSrcweir sal_Int32 /* mtf end */> HyperlinkIndexPair; 346cdf0e10cSrcweir typedef ::std::vector<HyperlinkIndexPair> HyperlinkIndexPairVector; 347cdf0e10cSrcweir mutable HyperlinkIndexPairVector maHyperlinkIndices; 348cdf0e10cSrcweir mutable HyperlinkRegions maHyperlinkRegions; 349cdf0e10cSrcweir 350cdf0e10cSrcweir /// Delegated subset handling 351cdf0e10cSrcweir mutable DrawShapeSubsetting maSubsetting; 352cdf0e10cSrcweir 353cdf0e10cSrcweir /// Whether this shape is currently in animation mode (value != 0) 354cdf0e10cSrcweir int mnIsAnimatedCount; 355cdf0e10cSrcweir 356cdf0e10cSrcweir /// Number of times the bitmap animation shall loop 357cdf0e10cSrcweir ::std::size_t mnAnimationLoopCount; 358cdf0e10cSrcweir 359cdf0e10cSrcweir /// Cycle mode for bitmap animation 360cdf0e10cSrcweir CycleMode meCycleMode; 361cdf0e10cSrcweir 362cdf0e10cSrcweir /// Whether shape is visible (without attribute layers) 363cdf0e10cSrcweir bool mbIsVisible; 364cdf0e10cSrcweir 365cdf0e10cSrcweir /// Whether redraw is necessary, regardless of state ids 366cdf0e10cSrcweir mutable bool mbForceUpdate; 367cdf0e10cSrcweir 368cdf0e10cSrcweir /// Whether attribute layer was revoked (making a redraw necessary) 369cdf0e10cSrcweir mutable bool mbAttributeLayerRevoked; 370cdf0e10cSrcweir 371cdf0e10cSrcweir /// whether a drawing layer animation has to be performed 372cdf0e10cSrcweir bool mbDrawingLayerAnim; 373cdf0e10cSrcweir 374cdf0e10cSrcweir }; 375cdf0e10cSrcweir } 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_DRAWSHAPE_HXX */ 379