android: Update app-specific/MIME type icons
[LibreOffice.git] / slideshow / source / engine / shapes / drawshape.hxx
blob6c71d151b6fab2e0b5164dabc77b994858387004
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "drawshapesubsetting.hxx"
29 #include "gdimtftools.hxx"
30 #include "viewshape.hxx"
31 #include <hyperlinkarea.hxx>
33 #include <optional>
34 #include <vector>
36 class Graphic;
38 namespace slideshow::internal
40 class Activity;
41 struct SlideShowContext;
42 class DrawShapeSubsetting;
43 class DrawShape;
44 typedef ::std::shared_ptr< DrawShape > DrawShapeSharedPtr;
46 /** This class is the representation of a draw document's
47 XShape, and implements the Shape, AnimatableShape, and
48 AttributableShape interfaces.
50 @attention this class is to be treated 'final', i.e. one
51 should not derive from it.
53 class DrawShape : public AttributableShape,
54 public DocTreeNodeSupplier,
55 public HyperlinkArea,
56 public ::osl::DebugBase<DrawShape>
58 public:
59 /** Create a shape for the given XShape
61 @param xShape
62 The XShape to represent.
64 @param xContainingPage
65 The page that contains this shape. Needed for proper
66 import (currently, the UnoGraphicExporter needs this
67 information).
69 @param nPrio
70 Externally-determined shape priority (used e.g. for
71 paint ordering). This number _must be_ unique!
73 @param bForeignSource
74 When true, the source of the shape metafile might be a
75 foreign application. The metafile is checked against
76 unsupported content, and, if necessary, returned as a
77 pre-rendered bitmap.
79 static DrawShapeSharedPtr create(
80 const css::uno::Reference< css::drawing::XShape >& xShape,
81 const css::uno::Reference< css::drawing::XDrawPage >& xContainingPage,
82 double nPrio,
83 bool bForeignSource,
84 const SlideShowContext& rContext ); // throw ShapeLoadFailedException;
86 /** Create a shape for the given XShape and graphic content
88 @param xShape
89 The XShape to represent.
91 @param xContainingPage
92 The page that contains this shape. Needed for proper
93 import (currently, the UnoGraphicExporter needs this
94 information).
96 @param nPrio
97 Externally-determined shape priority (used e.g. for
98 paint ordering). This number _must be_ unique!
100 @param rGraphic
101 Graphic to display in the shape's bound rect. If this
102 Graphic contains animatable content, the created
103 DrawShape will register itself for intrinsic animation
104 events.
106 static DrawShapeSharedPtr create(
107 const css::uno::Reference< css::drawing::XShape >& xShape,
108 const css::uno::Reference< css::drawing::XDrawPage >& xContainingPage,
109 double nPrio,
110 const Graphic& rGraphic,
111 const SlideShowContext& rContext ); // throw ShapeLoadFailedException;
113 virtual css::uno::Reference< css::drawing::XShape > getXShape() const override;
115 virtual ~DrawShape() override;
118 // View layer methods
121 virtual void addViewLayer( const ViewLayerSharedPtr& rNewLayer,
122 bool bRedrawLayer ) override;
123 virtual bool removeViewLayer( const ViewLayerSharedPtr& rNewLayer ) override;
124 virtual void clearAllViewLayers() override;
126 // attribute methods
129 virtual ShapeAttributeLayerSharedPtr createAttributeLayer() override;
130 virtual bool revokeAttributeLayer( const ShapeAttributeLayerSharedPtr& rLayer ) override;
131 virtual ShapeAttributeLayerSharedPtr getTopmostAttributeLayer() const override;
132 virtual void setVisibility( bool bVisible ) override;
133 virtual ::basegfx::B2DRectangle getBounds() const override;
134 virtual ::basegfx::B2DRectangle getDomBounds() const override;
135 virtual ::basegfx::B2DRectangle getUpdateArea() const override;
136 virtual bool isVisible() const override;
137 virtual double getPriority() const override;
140 // animation methods
143 virtual void enterAnimationMode() override;
144 virtual void leaveAnimationMode() override;
145 virtual bool isBackgroundDetached() const override;
147 // render methods
150 virtual bool update() const override;
151 virtual bool render() const override;
152 virtual bool isContentChanged() const override;
154 // Sub item specialities
157 virtual const DocTreeNodeSupplier& getTreeNodeSupplier() const override;
158 virtual DocTreeNodeSupplier& getTreeNodeSupplier() override;
160 virtual DocTreeNode getSubsetNode() const override;
161 virtual AttributableShapeSharedPtr getSubset( const DocTreeNode& rTreeNode ) const override;
162 virtual bool createSubset( AttributableShapeSharedPtr& o_rSubset,
163 const DocTreeNode& rTreeNode ) override;
164 virtual bool revokeSubset( const AttributableShapeSharedPtr& rShape ) override;
167 // DocTreeNodeSupplier methods
170 virtual sal_Int32 getNumberOfTreeNodes ( DocTreeNode::NodeType eNodeType ) const override; // throw ShapeLoadFailedException;
171 virtual DocTreeNode getTreeNode ( sal_Int32 nNodeIndex,
172 DocTreeNode::NodeType eNodeType ) const override; // throw ShapeLoadFailedException;
173 virtual sal_Int32 getNumberOfSubsetTreeNodes ( const DocTreeNode& rParentNode,
174 DocTreeNode::NodeType eNodeType ) const override; // throw ShapeLoadFailedException;
175 virtual DocTreeNode getSubsetTreeNode ( const DocTreeNode& rParentNode,
176 sal_Int32 nNodeIndex,
177 DocTreeNode::NodeType eNodeType ) const override; // throw ShapeLoadFailedException;
179 // HyperlinkArea methods
182 virtual HyperlinkRegions getHyperlinkRegions() const override;
183 virtual double getHyperlinkPriority() const override;
186 // intrinsic animation methods
189 /** Display next frame of an intrinsic animation.
191 Used by IntrinsicAnimationActivity, to show the next
192 animation frame.
194 void setIntrinsicAnimationFrame( ::std::size_t nCurrFrame );
196 /** forces the drawshape to load and return a specially
197 crafted metafile, usable to display drawing layer text
198 animations.
200 GDIMetaFileSharedPtr const & forceScrollTextMetaFile();
202 private:
203 /** Create a shape for the given XShape
205 @param xShape
206 The XShape to represent.
208 @param xContainingPage
209 The page that contains this shape. Needed for proper
210 import (currently, the UnoGraphicExporter needs this
211 information).
213 @param nPrio
214 Externally-determined shape priority (used e.g. for
215 paint ordering). This number _must be_ unique!
217 @param bForeignSource
218 When true, the source of the shape metafile might be a
219 foreign application. The metafile is checked against
220 unsupported content, and, if necessary, returned as a
221 pre-rendered bitmap.
223 DrawShape( const css::uno::Reference<
224 css::drawing::XShape >& xShape,
225 const css::uno::Reference<
226 css::drawing::XDrawPage >& xContainingPage,
227 double nPrio,
228 bool bForeignSource,
229 const SlideShowContext& rContext ); // throw ShapeLoadFailedException;
231 /** Create a shape for the given XShape and graphic content
233 @param xShape
234 The XShape to represent.
236 @param xContainingPage
237 The page that contains this shape. Needed for proper
238 import (currently, the UnoGraphicExporter needs this
239 information).
241 @param nPrio
242 Externally-determined shape priority (used e.g. for
243 paint ordering). This number _must be_ unique!
245 @param rGraphic
246 Graphic to display in the shape's bound rect. If this
247 Graphic contains animatable content, the created
248 DrawShape will register itself for intrinsic animation
249 events.
251 DrawShape( const css::uno::Reference< css::drawing::XShape >& xShape,
252 css::uno::Reference< css::drawing::XDrawPage > xContainingPage,
253 double nPrio,
254 const Graphic& rGraphic,
255 const SlideShowContext& rContext ); // throw ShapeLoadFailedException;
257 /** Private copy constructor
259 Used to create subsetted shapes
261 DrawShape( const DrawShape&, const DocTreeNode& rTreeNode, double nPrio );
263 UpdateFlags getUpdateFlags() const;
264 bool implRender( UpdateFlags nUpdateFlags ) const;
265 void updateStateIds() const;
267 ViewShape::RenderArgs getViewRenderArgs() const;
268 ::basegfx::B2DRectangle getActualUnitShapeBounds() const;
270 bool hasIntrinsicAnimation() const;
271 bool hasHyperlinks() const;
272 void prepareHyperlinkIndices() const;
274 /// The associated XShape
275 css::uno::Reference< css::drawing::XShape > mxShape;
276 css::uno::Reference< css::drawing::XDrawPage > mxPage;
278 /** A vector of metafiles actually representing the Shape.
280 If this shape is not animated, only a single entry is
281 available.
283 mutable VectorOfMtfAnimationFrames maAnimationFrames;
284 ::std::size_t mnCurrFrame;
286 /// Metafile of currently active frame (static for shapes w/o intrinsic animation)
287 mutable GDIMetaFileSharedPtr mpCurrMtf;
289 /// loadflags of current meta file
290 mutable int mnCurrMtfLoadFlags;
292 /// Contains the current shape bounds, in unit rect space
293 mutable ::std::optional<basegfx::B2DRectangle> maCurrentShapeUnitBounds;
295 // The attributes of this Shape
296 const double mnPriority;
297 ::basegfx::B2DRectangle maBounds; // always needed for rendering.
298 // for subset shapes, this member
299 // might change when views are
300 // added, as minimal bounds are
301 // calculated
303 // Pointer to modifiable shape attributes
304 ShapeAttributeLayerSharedPtr mpAttributeLayer; // only created lazily
306 // held here, to signal our destruction
307 std::weak_ptr<Activity> mpIntrinsicAnimationActivity;
309 // The attribute states, to detect attribute changes,
310 // without buffering and querying each single attribute
311 mutable State::StateId mnAttributeTransformationState;
312 mutable State::StateId mnAttributeClipState;
313 mutable State::StateId mnAttributeAlphaState;
314 mutable State::StateId mnAttributePositionState;
315 mutable State::StateId mnAttributeContentState;
316 mutable State::StateId mnAttributeVisibilityState;
318 /// the list of active view shapes (one for each registered view layer)
319 typedef ::std::vector< ViewShapeSharedPtr > ViewShapeVector;
320 ViewShapeVector maViewShapes;
322 css::uno::Reference< css::uno::XComponentContext> mxComponentContext;
324 /// hyperlink support
325 typedef ::std::pair<sal_Int32 /* mtf start */,
326 sal_Int32 /* mtf end */> HyperlinkIndexPair;
327 typedef ::std::vector<HyperlinkIndexPair> HyperlinkIndexPairVector;
328 mutable HyperlinkIndexPairVector maHyperlinkIndices;
329 mutable HyperlinkRegions maHyperlinkRegions;
331 /// Delegated subset handling
332 mutable DrawShapeSubsetting maSubsetting;
334 /// Whether this shape is currently in animation mode (value != 0)
335 int mnIsAnimatedCount;
337 /// Number of times the bitmap animation shall loop
338 sal_uInt32 mnAnimationLoopCount;
340 /// Whether shape is visible (without attribute layers)
341 bool mbIsVisible;
343 /// Whether redraw is necessary, regardless of state ids
344 mutable bool mbForceUpdate;
346 /// Whether attribute layer was revoked (making a redraw necessary)
347 mutable bool mbAttributeLayerRevoked;
349 /// whether a drawing layer animation has to be performed
350 bool mbDrawingLayerAnim;
352 /// tdf#150402 whether mpCurrMtf contains any Text with a PageField ("FIELD_SEQ_BEGIN;PageField")
353 mutable bool mbContainsPageField;
358 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
360 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */