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