1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
23 #include <osl/diagnose.hxx>
24 #include <com/sun/star/drawing/XShape.hpp>
26 #include "attributableshape.hxx"
27 #include "doctreenodesupplier.hxx"
28 #include "gdimtftools.hxx"
29 #include "viewshape.hxx"
30 #include "hyperlinkarea.hxx"
32 #include <boost/optional.hpp>
33 #include <boost/shared_ptr.hpp>
34 #include <boost/weak_ptr.hpp>
45 struct SlideShowContext
;
46 class DrawShapeSubsetting
;
48 typedef ::boost::shared_ptr
< DrawShape
> DrawShapeSharedPtr
;
50 /** This class is the representation of a draw document's
51 XShape, and implements the Shape, AnimatableShape, and
52 AttributableShape interfaces.
54 @attention this class is to be treated 'final', i.e. one
55 should not derive from it.
57 class DrawShape
: public AttributableShape
,
58 public DocTreeNodeSupplier
,
60 public ::osl::DebugBase
<DrawShape
>
63 /** Create a shape for the given XShape
66 The XShape to represent.
68 @param xContainingPage
69 The page that contains this shape. Needed for proper
70 import (currently, the UnoGraphicExporter needs this
74 Externally-determined shape priority (used e.g. for
75 paint ordering). This number _must be_ unique!
78 When true, the source of the shape metafile might be a
79 foreign application. The metafile is checked against
80 unsupported content, and, if necessary, returned as a
83 static DrawShapeSharedPtr
create(
84 const ::com::sun::star::uno::Reference
<
85 ::com::sun::star::drawing::XShape
>& xShape
,
86 const ::com::sun::star::uno::Reference
<
87 ::com::sun::star::drawing::XDrawPage
>& xContainingPage
,
90 const SlideShowContext
& rContext
); // throw ShapeLoadFailedException;
92 /** Create a shape for the given XShape and graphic content
95 The XShape to represent.
97 @param xContainingPage
98 The page that contains this shape. Needed for proper
99 import (currently, the UnoGraphicExporter needs this
103 Externally-determined shape priority (used e.g. for
104 paint ordering). This number _must be_ unique!
107 Graphic to display in the shape's bound rect. If this
108 Graphic contains animatable content, the created
109 DrawShape will register itself for intrinsic animation
112 static DrawShapeSharedPtr
create(
113 const ::com::sun::star::uno::Reference
<
114 ::com::sun::star::drawing::XShape
>& xShape
,
115 const ::com::sun::star::uno::Reference
<
116 ::com::sun::star::drawing::XDrawPage
>& xContainingPage
,
118 const Graphic
& rGraphic
,
119 const SlideShowContext
& rContext
); // throw ShapeLoadFailedException;
121 virtual ::com::sun::star::uno::Reference
<
122 ::com::sun::star::drawing::XShape
> getXShape() const SAL_OVERRIDE
;
124 virtual ~DrawShape();
127 // View layer methods
130 virtual void addViewLayer( const ViewLayerSharedPtr
& rNewLayer
,
131 bool bRedrawLayer
) SAL_OVERRIDE
;
132 virtual bool removeViewLayer( const ViewLayerSharedPtr
& rNewLayer
) SAL_OVERRIDE
;
133 virtual bool clearAllViewLayers() SAL_OVERRIDE
;
138 virtual ShapeAttributeLayerSharedPtr
createAttributeLayer() SAL_OVERRIDE
;
139 virtual bool revokeAttributeLayer( const ShapeAttributeLayerSharedPtr
& rLayer
) SAL_OVERRIDE
;
140 virtual ShapeAttributeLayerSharedPtr
getTopmostAttributeLayer() const SAL_OVERRIDE
;
141 virtual void setVisibility( bool bVisible
) SAL_OVERRIDE
;
142 virtual ::basegfx::B2DRectangle
getBounds() const SAL_OVERRIDE
;
143 virtual ::basegfx::B2DRectangle
getDomBounds() const SAL_OVERRIDE
;
144 virtual ::basegfx::B2DRectangle
getUpdateArea() const SAL_OVERRIDE
;
145 virtual bool isVisible() const SAL_OVERRIDE
;
146 virtual double getPriority() const SAL_OVERRIDE
;
152 virtual void enterAnimationMode() SAL_OVERRIDE
;
153 virtual void leaveAnimationMode() SAL_OVERRIDE
;
154 virtual bool isBackgroundDetached() const SAL_OVERRIDE
;
159 virtual bool update() const SAL_OVERRIDE
;
160 virtual bool render() const SAL_OVERRIDE
;
161 virtual bool isContentChanged() const SAL_OVERRIDE
;
163 // Sub item specialities
166 virtual const DocTreeNodeSupplier
& getTreeNodeSupplier() const SAL_OVERRIDE
;
167 virtual DocTreeNodeSupplier
& getTreeNodeSupplier() SAL_OVERRIDE
;
169 virtual DocTreeNode
getSubsetNode() const SAL_OVERRIDE
;
170 virtual AttributableShapeSharedPtr
getSubset( const DocTreeNode
& rTreeNode
) const SAL_OVERRIDE
;
171 virtual bool createSubset( AttributableShapeSharedPtr
& o_rSubset
,
172 const DocTreeNode
& rTreeNode
) SAL_OVERRIDE
;
173 virtual bool revokeSubset( const AttributableShapeSharedPtr
& rShape
) SAL_OVERRIDE
;
176 // DocTreeNodeSupplier methods
179 virtual sal_Int32
getNumberOfTreeNodes ( DocTreeNode::NodeType eNodeType
) const SAL_OVERRIDE
; // throw ShapeLoadFailedException;
180 virtual DocTreeNode
getTreeNode ( sal_Int32 nNodeIndex
,
181 DocTreeNode::NodeType eNodeType
) const SAL_OVERRIDE
; // throw ShapeLoadFailedException;
182 virtual sal_Int32
getNumberOfSubsetTreeNodes ( const DocTreeNode
& rParentNode
,
183 DocTreeNode::NodeType eNodeType
) const SAL_OVERRIDE
; // throw ShapeLoadFailedException;
184 virtual DocTreeNode
getSubsetTreeNode ( const DocTreeNode
& rParentNode
,
185 sal_Int32 nNodeIndex
,
186 DocTreeNode::NodeType eNodeType
) const SAL_OVERRIDE
; // throw ShapeLoadFailedException;
188 // HyperlinkArea methods
191 virtual HyperlinkRegions
getHyperlinkRegions() const SAL_OVERRIDE
;
192 virtual double getHyperlinkPriority() const SAL_OVERRIDE
;
195 // intrinsic animation methods
198 /** Display next frame of an intrinsic animation.
200 Used by IntrinsicAnimationActivity, to show the next
203 bool setIntrinsicAnimationFrame( ::std::size_t nCurrFrame
);
205 /** forces the drawshape to load and return a specially
206 crafted metafile, usable to display drawing layer text
209 GDIMetaFileSharedPtr
forceScrollTextMetaFile();
212 /** Create a shape for the given XShape
215 The XShape to represent.
217 @param xContainingPage
218 The page that contains this shape. Needed for proper
219 import (currently, the UnoGraphicExporter needs this
223 Externally-determined shape priority (used e.g. for
224 paint ordering). This number _must be_ unique!
226 @param bForeignSource
227 When true, the source of the shape metafile might be a
228 foreign application. The metafile is checked against
229 unsupported content, and, if necessary, returned as a
230 pre-rendererd bitmap.
232 DrawShape( const ::com::sun::star::uno::Reference
<
233 ::com::sun::star::drawing::XShape
>& xShape
,
234 const ::com::sun::star::uno::Reference
<
235 ::com::sun::star::drawing::XDrawPage
>& xContainingPage
,
238 const SlideShowContext
& rContext
); // throw ShapeLoadFailedException;
240 /** Create a shape for the given XShape and graphic content
243 The XShape to represent.
245 @param xContainingPage
246 The page that contains this shape. Needed for proper
247 import (currently, the UnoGraphicExporter needs this
251 Externally-determined shape priority (used e.g. for
252 paint ordering). This number _must be_ unique!
255 Graphic to display in the shape's bound rect. If this
256 Graphic contains animatable content, the created
257 DrawShape will register itself for intrinsic animation
260 DrawShape( const ::com::sun::star::uno::Reference
<
261 ::com::sun::star::drawing::XShape
>& xShape
,
262 const ::com::sun::star::uno::Reference
<
263 ::com::sun::star::drawing::XDrawPage
>& xContainingPage
,
265 const Graphic
& rGraphic
,
266 const SlideShowContext
& rContext
); // throw ShapeLoadFailedException;
268 /** Private copy constructor
270 Used to create subsetted shapes
272 DrawShape( const DrawShape
&, const DocTreeNode
& rTreeNode
, double nPrio
);
274 int getUpdateFlags() const;
275 bool implRender( int nUpdateFlags
) const;
276 void updateStateIds() const;
278 ViewShape::RenderArgs
getViewRenderArgs() const;
279 ::basegfx::B2DRectangle
getActualUnitShapeBounds() const;
281 bool hasIntrinsicAnimation() const;
282 bool hasHyperlinks() const;
283 void prepareHyperlinkIndices() const;
285 /// The associated XShape
286 ::com::sun::star::uno::Reference
<
287 ::com::sun::star::drawing::XShape
> mxShape
;
288 ::com::sun::star::uno::Reference
<
289 ::com::sun::star::drawing::XDrawPage
> mxPage
;
291 /** A vector of metafiles actually representing the Shape.
293 If this shape is not animated, only a single entry is
296 mutable VectorOfMtfAnimationFrames maAnimationFrames
;
297 ::std::size_t mnCurrFrame
;
299 /// Metafile of currently active frame (static for shapes w/o intrinsic animation)
300 mutable GDIMetaFileSharedPtr mpCurrMtf
;
302 /// loadflags of current meta file
303 mutable int mnCurrMtfLoadFlags
;
305 /// Contains the current shape bounds, in unit rect space
306 mutable ::boost::optional
<basegfx::B2DRectangle
> maCurrentShapeUnitBounds
;
308 // The attributes of this Shape
309 const double mnPriority
;
310 ::basegfx::B2DRectangle maBounds
; // always needed for rendering.
311 // for subset shapes, this member
312 // might change when views are
313 // added, as minimal bounds are
316 // Pointer to modifiable shape attributes
317 ShapeAttributeLayerSharedPtr mpAttributeLayer
; // only created lazily
319 // held here, to signal our destruction
320 boost::weak_ptr
<Activity
> mpIntrinsicAnimationActivity
;
322 // The attribute states, to detect attribute changes,
323 // without buffering and querying each single attribute
324 mutable State::StateId mnAttributeTransformationState
;
325 mutable State::StateId mnAttributeClipState
;
326 mutable State::StateId mnAttributeAlphaState
;
327 mutable State::StateId mnAttributePositionState
;
328 mutable State::StateId mnAttributeContentState
;
329 mutable State::StateId mnAttributeVisibilityState
;
331 /// the list of active view shapes (one for each registered view layer)
332 typedef ::std::vector
< ViewShapeSharedPtr
> ViewShapeVector
;
333 ViewShapeVector maViewShapes
;
335 ::com::sun::star::uno::Reference
<
336 ::com::sun::star::uno::XComponentContext
> mxComponentContext
;
338 /// hyperlink support
339 typedef ::std::pair
<sal_Int32
/* mtf start */,
340 sal_Int32
/* mtf end */> HyperlinkIndexPair
;
341 typedef ::std::vector
<HyperlinkIndexPair
> HyperlinkIndexPairVector
;
342 mutable HyperlinkIndexPairVector maHyperlinkIndices
;
343 mutable HyperlinkRegions maHyperlinkRegions
;
345 /// Delegated subset handling
346 mutable DrawShapeSubsetting maSubsetting
;
348 /// Whether this shape is currently in animation mode (value != 0)
349 int mnIsAnimatedCount
;
351 /// Number of times the bitmap animation shall loop
352 ::std::size_t mnAnimationLoopCount
;
354 /// Cycle mode for bitmap animation
355 CycleMode meCycleMode
;
357 /// Whether shape is visible (without attribute layers)
360 /// Whether redraw is necessary, regardless of state ids
361 mutable bool mbForceUpdate
;
363 /// Whether attribute layer was revoked (making a redraw necessary)
364 mutable bool mbAttributeLayerRevoked
;
366 /// whether a drawing layer animation has to be performed
367 bool mbDrawingLayerAnim
;
373 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
375 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */