LibreOffice Module slideshow (master) 1
drawshape.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
22
23#include <osl/diagnose.hxx>
24#include <com/sun/star/drawing/XShape.hpp>
25
26#include <attributableshape.hxx>
29#include "gdimtftools.hxx"
30#include "viewshape.hxx"
31#include <hyperlinkarea.hxx>
32
33#include <optional>
34#include <vector>
35
36class Graphic;
37
38namespace slideshow::internal
39 {
40 class Activity;
41 struct SlideShowContext;
42 class DrawShapeSubsetting;
43 class DrawShape;
44 typedef ::std::shared_ptr< DrawShape > DrawShapeSharedPtr;
45
55 public HyperlinkArea,
56 public ::osl::DebugBase<DrawShape>
57 {
58 public:
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;
85
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;
112
113 virtual css::uno::Reference< css::drawing::XShape > getXShape() const override;
114
115 virtual ~DrawShape() override;
116
117
118 // View layer methods
119
120
121 virtual void addViewLayer( const ViewLayerSharedPtr& rNewLayer,
122 bool bRedrawLayer ) override;
123 virtual bool removeViewLayer( const ViewLayerSharedPtr& rNewLayer ) override;
124 virtual void clearAllViewLayers() override;
125
126 // attribute methods
127
128
130 virtual bool revokeAttributeLayer( const ShapeAttributeLayerSharedPtr& rLayer ) 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;
138
139
140 // animation methods
141
142
143 virtual void enterAnimationMode() override;
144 virtual void leaveAnimationMode() override;
145 virtual bool isBackgroundDetached() const override;
146
147 // render methods
148
149
150 virtual bool update() const override;
151 virtual bool render() const override;
152 virtual bool isContentChanged() const override;
153
154 // Sub item specialities
155
156
157 virtual const DocTreeNodeSupplier& getTreeNodeSupplier() const override;
158 virtual DocTreeNodeSupplier& getTreeNodeSupplier() override;
159
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;
165
166
167 // DocTreeNodeSupplier methods
168
169
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;
178
179 // HyperlinkArea methods
180
181
182 virtual HyperlinkRegions getHyperlinkRegions() const override;
183 virtual double getHyperlinkPriority() const override;
184
185
186 // intrinsic animation methods
187
188
194 void setIntrinsicAnimationFrame( ::std::size_t nCurrFrame );
195
201
202 private:
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;
230
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;
256
261 DrawShape( const DrawShape&, const DocTreeNode& rTreeNode, double nPrio );
262
264 bool implRender( UpdateFlags nUpdateFlags ) const;
265 void updateStateIds() const;
266
269
270 bool hasIntrinsicAnimation() const;
271 bool hasHyperlinks() const;
272 void prepareHyperlinkIndices() const;
273
275 css::uno::Reference< css::drawing::XShape > mxShape;
276 css::uno::Reference< css::drawing::XDrawPage > mxPage;
277
284 ::std::size_t mnCurrFrame;
285
288
291
293 mutable ::std::optional<basegfx::B2DRectangle> maCurrentShapeUnitBounds;
294
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
302
303 // Pointer to modifiable shape attributes
305
306 // held here, to signal our destruction
307 std::weak_ptr<Activity> mpIntrinsicAnimationActivity;
308
309 // The attribute states, to detect attribute changes,
310 // without buffering and querying each single attribute
317
319 typedef ::std::vector< ViewShapeSharedPtr > ViewShapeVector;
321
322 css::uno::Reference< css::uno::XComponentContext> mxComponentContext;
323
325 typedef ::std::pair<sal_Int32 /* mtf start */,
326 sal_Int32 /* mtf end */> HyperlinkIndexPair;
327 typedef ::std::vector<HyperlinkIndexPair> HyperlinkIndexPairVector;
330
333
336
339
342
344 mutable bool mbForceUpdate;
345
348
351
354 };
355
356}
357
358#endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_DRAWSHAPE_HXX
359
360/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents an animatable shape, that can have its attributes changed.
Interface to retrieve DocTreeNodes from subsettable shapes.
This class represents kind of a DOM tree node for shape text.
Definition: doctreenode.hxx:45
NodeType
Type of shape entity represented by this node.
Definition: doctreenode.hxx:49
This class encapsulates the subsetting aspects of a DrawShape.
This class is the representation of a draw document's XShape, and implements the Shape,...
Definition: drawshape.hxx:57
State::StateId mnAttributeClipState
Definition: drawshape.hxx:312
HyperlinkIndexPairVector maHyperlinkIndices
Definition: drawshape.hxx:328
static DrawShapeSharedPtr create(const css::uno::Reference< css::drawing::XShape > &xShape, const css::uno::Reference< css::drawing::XDrawPage > &xContainingPage, double nPrio, const Graphic &rGraphic, const SlideShowContext &rContext)
Create a shape for the given XShape and graphic content.
virtual bool revokeSubset(const AttributableShapeSharedPtr &rShape) override
Revoke a previously generated shape subset.
Definition: drawshape.cxx:1154
css::uno::Reference< css::drawing::XDrawPage > mxPage
Definition: drawshape.hxx:276
::basegfx::B2DRectangle getActualUnitShapeBounds() const
Definition: drawshape.cxx:231
virtual bool isContentChanged() const override
Query whether shape content changed.
Definition: drawshape.cxx:707
virtual void addViewLayer(const ViewLayerSharedPtr &rNewLayer, bool bRedrawLayer) override
Add a new view layer.
Definition: drawshape.cxx:616
virtual void leaveAnimationMode() override
Notify the Shape that it is no longer animated.
Definition: drawshape.cxx:1022
void setIntrinsicAnimationFrame(::std::size_t nCurrFrame)
Display next frame of an intrinsic animation.
Definition: drawshape.cxx:834
sal_uInt32 mnAnimationLoopCount
Number of times the bitmap animation shall loop.
Definition: drawshape.hxx:338
bool mbDrawingLayerAnim
whether a drawing layer animation has to be performed
Definition: drawshape.hxx:350
int mnIsAnimatedCount
Whether this shape is currently in animation mode (value != 0)
Definition: drawshape.hxx:335
State::StateId mnAttributePositionState
Definition: drawshape.hxx:314
bool implRender(UpdateFlags nUpdateFlags) const
Definition: drawshape.cxx:128
virtual bool update() const override
Update the shape.
Definition: drawshape.cxx:685
static DrawShapeSharedPtr create(const css::uno::Reference< css::drawing::XShape > &xShape, const css::uno::Reference< css::drawing::XDrawPage > &xContainingPage, double nPrio, bool bForeignSource, const SlideShowContext &rContext)
Create a shape for the given XShape.
State::StateId mnAttributeAlphaState
Definition: drawshape.hxx:313
virtual bool isVisible() const override
Query whether the shape is visible at all.
Definition: drawshape.cxx:795
virtual double getPriority() const override
Get the shape priority.
Definition: drawshape.cxx:819
virtual void clearAllViewLayers() override
Withdraw all view layers at once.
Definition: drawshape.cxx:680
GDIMetaFileSharedPtr const & forceScrollTextMetaFile()
forces the drawshape to load and return a specially crafted metafile, usable to display drawing layer...
Definition: drawshape.cxx:61
virtual ShapeAttributeLayerSharedPtr createAttributeLayer() override
Create a new shape attribute layer.
Definition: drawshape.cxx:1042
virtual ::basegfx::B2DRectangle getUpdateArea() const override
Get the current shape update area.
Definition: drawshape.cxx:728
DrawShape(const css::uno::Reference< css::drawing::XShape > &xShape, const css::uno::Reference< css::drawing::XDrawPage > &xContainingPage, double nPrio, bool bForeignSource, const SlideShowContext &rContext)
Create a shape for the given XShape.
virtual DocTreeNode getTreeNode(sal_Int32 nNodeIndex, DocTreeNode::NodeType eNodeType) const override
Create DocTreeNode from shape.
Definition: drawshape.cxx:1204
mutable ::std::optional< basegfx::B2DRectangle > maCurrentShapeUnitBounds
Contains the current shape bounds, in unit rect space.
Definition: drawshape.hxx:293
::std::pair< sal_Int32, sal_Int32 > HyperlinkIndexPair
hyperlink support
Definition: drawshape.hxx:326
::std::vector< HyperlinkIndexPair > HyperlinkIndexPairVector
Definition: drawshape.hxx:327
std::weak_ptr< Activity > mpIntrinsicAnimationActivity
Definition: drawshape.hxx:307
virtual ::basegfx::B2DRectangle getDomBounds() const override
Get the DOM position and size of the shape.
Definition: drawshape.cxx:723
GDIMetaFileSharedPtr mpCurrMtf
Metafile of currently active frame (static for shapes w/o intrinsic animation)
Definition: drawshape.hxx:287
virtual void enterAnimationMode() override
Notify the Shape that an animation starts now.
Definition: drawshape.cxx:1006
bool mbIsVisible
Whether shape is visible (without attribute layers)
Definition: drawshape.hxx:341
DrawShape(const css::uno::Reference< css::drawing::XShape > &xShape, css::uno::Reference< css::drawing::XDrawPage > xContainingPage, double nPrio, const Graphic &rGraphic, const SlideShowContext &rContext)
Create a shape for the given XShape and graphic content.
virtual double getHyperlinkPriority() const override
Retrieve priority of link area.
Definition: drawshape.cxx:997
virtual const DocTreeNodeSupplier & getTreeNodeSupplier() const override
Retrieve interface for DocTreeNode creation.
Definition: drawshape.cxx:1090
virtual bool render() const override
Render the shape.
Definition: drawshape.cxx:697
virtual DocTreeNode getSubsetTreeNode(const DocTreeNode &rParentNode, sal_Int32 nNodeIndex, DocTreeNode::NodeType eNodeType) const override
Create DocTreeNode from shape subset.
Definition: drawshape.cxx:1221
ShapeAttributeLayerSharedPtr mpAttributeLayer
Definition: drawshape.hxx:304
int mnCurrMtfLoadFlags
loadflags of current meta file
Definition: drawshape.hxx:290
bool mbAttributeLayerRevoked
Whether attribute layer was revoked (making a redraw necessary)
Definition: drawshape.hxx:347
UpdateFlags getUpdateFlags() const
Definition: drawshape.cxx:172
DrawShapeSubsetting maSubsetting
Delegated subset handling.
Definition: drawshape.hxx:332
virtual bool createSubset(AttributableShapeSharedPtr &o_rSubset, const DocTreeNode &rTreeNode) override
Create a subset Shape.
Definition: drawshape.cxx:1112
VectorOfMtfAnimationFrames maAnimationFrames
A vector of metafiles actually representing the Shape.
Definition: drawshape.hxx:283
State::StateId mnAttributeTransformationState
Definition: drawshape.hxx:311
virtual bool revokeAttributeLayer(const ShapeAttributeLayerSharedPtr &rLayer) override
Revoke a previously generated attribute layer.
Definition: drawshape.cxx:1053
virtual HyperlinkRegions getHyperlinkRegions() const override
Request hyperlink-sensitive areas.
Definition: drawshape.cxx:917
State::StateId mnAttributeVisibilityState
Definition: drawshape.hxx:316
virtual DocTreeNode getSubsetNode() const override
Query the subset this shape displays.
Definition: drawshape.cxx:1100
css::uno::Reference< css::drawing::XShape > mxShape
The associated XShape.
Definition: drawshape.hxx:275
virtual void setVisibility(bool bVisible) override
Change default shape visibility.
Definition: drawshape.cxx:1081
ViewShape::RenderArgs getViewRenderArgs() const
Definition: drawshape.cxx:116
virtual AttributableShapeSharedPtr getSubset(const DocTreeNode &rTreeNode) const override
Query a subset Shape, if already existent at this object.
Definition: drawshape.cxx:1106
::basegfx::B2DRectangle maBounds
Definition: drawshape.hxx:297
::std::vector< ViewShapeSharedPtr > ViewShapeVector
the list of active view shapes (one for each registered view layer)
Definition: drawshape.hxx:319
virtual css::uno::Reference< css::drawing::XShape > getXShape() const override
Get the associated XShape of this shape.
Definition: drawshape.cxx:611
HyperlinkRegions maHyperlinkRegions
Definition: drawshape.hxx:329
virtual bool isBackgroundDetached() const override
Query whether the Shape is currently detached from the background.
Definition: drawshape.cxx:824
virtual ShapeAttributeLayerSharedPtr getTopmostAttributeLayer() const override
Get the topmost shape attribute layer (if any).
Definition: drawshape.cxx:1076
State::StateId mnAttributeContentState
Definition: drawshape.hxx:315
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
Definition: drawshape.hxx:322
virtual sal_Int32 getNumberOfTreeNodes(DocTreeNode::NodeType eNodeType) const override
Query number of tree nodes of the given type this shape contains.
Definition: drawshape.cxx:1199
bool mbForceUpdate
Whether redraw is necessary, regardless of state ids.
Definition: drawshape.hxx:344
virtual bool removeViewLayer(const ViewLayerSharedPtr &rNewLayer) override
Withdraw the shape from a view layer.
Definition: drawshape.cxx:651
bool mbContainsPageField
tdf#150402 whether mpCurrMtf contains any Text with a PageField ("FIELD_SEQ_BEGIN;PageField")
Definition: drawshape.hxx:353
virtual ~DrawShape() override
Definition: drawshape.cxx:595
void prepareHyperlinkIndices() const
Definition: drawshape.cxx:848
virtual sal_Int32 getNumberOfSubsetTreeNodes(const DocTreeNode &rParentNode, DocTreeNode::NodeType eNodeType) const override
Query number of tree nodes of the given type this subset contains.
Definition: drawshape.cxx:1215
virtual ::basegfx::B2DRectangle getBounds() const override
Get the current shape position and size.
Definition: drawshape.cxx:714
HyperlinkArea interface.
std::vector< HyperlinkRegion > HyperlinkRegions
::std::size_t StateId
Abstract, numerically encoded state ID.
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
std::shared_ptr< ViewLayer > ViewLayerSharedPtr
Definition: viewlayer.hxx:168
::std::shared_ptr< DrawShape > DrawShapeSharedPtr
Definition: drawshape.hxx:43
std::shared_ptr< GDIMetaFile > GDIMetaFileSharedPtr
Definition: tools.hxx:63
::std::vector< MtfAnimationFrame > VectorOfMtfAnimationFrames
Definition: gdimtftools.hxx:79
::std::shared_ptr< AttributableShape > AttributableShapeSharedPtr
Common arguments for slideshow objects.
UpdateFlags
Definition: viewshape.hxx:39