crashtesting: assert on reimport of docx export of ooo102874-2.doc
[LibreOffice.git] / slideshow / source / inc / animatedsprite.hxx
blobf298aaa52fb35ca6a5ec7f1ac28ec91fa57a7a7c
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_INC_ANIMATEDSPRITE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_ANIMATEDSPRITE_HXX
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <basegfx/point/b2dpoint.hxx>
25 #include <basegfx/vector/b2dsize.hxx>
26 #include <basegfx/polygon/b2dpolypolygon.hxx>
28 #include "viewlayer.hxx"
30 #include <optional>
31 #include <memory>
34 /* Definition of AnimatedSprite class */
36 namespace slideshow::internal
38 /** This class provides the sprite for animated shapes.
40 Besides encapsulating the Canvas sprite for animated
41 shapes, this class also handles dynamic sprite resizing
42 and all the gory details of offset calculations and
43 rounding prevention.
45 class AnimatedSprite
47 public:
48 /** Create a new AnimatedSprite, for the given metafile
49 shape.
51 @param rViewLayer
52 The destination view layer, on which the animation should appear
54 @param rSpriteSizePixel
55 The overall size of the sprite in device coordinate
56 space, sufficient to display all transformations,
57 shape changes and clips.
59 @param nSpritePrio
60 Priority of the sprite. Must remain static over the
61 lifetime of this object
63 AnimatedSprite( ViewLayerSharedPtr xViewLayer,
64 const ::basegfx::B2DSize& rSpriteSizePixel,
65 double nSpritePrio );
66 AnimatedSprite(const AnimatedSprite&) = delete;
67 AnimatedSprite& operator=(const AnimatedSprite&) = delete;
69 /** Resize the sprite.
71 @param rSpriteSizePixel
72 The new size in pixel
74 void resize( const ::basegfx::B2DSize& rSpriteSizePixel );
76 /** Set an offset for the content output in pixel
78 This method offsets the output on the sprite content
79 canvas by the specified amount of device pixel (for
80 subsequent render operations).
82 void setPixelOffset( const ::basegfx::B2DSize& rPixelOffset );
84 /// Show the sprite
85 void show();
87 /// Hide the sprite
88 void hide();
90 /** Query the content canvas for the current sprite.
92 Note that this method must be called
93 <em>every time</em> something is rendered to the
94 sprite, because XCustomSprite does not guarantee the
95 validity of the canvas after a render operation.
97 Furthermore, the view transformation on the returned
98 canvas is already correctly setup, matching the
99 associated destination canvas.
101 ::cppcanvas::CanvasSharedPtr getContentCanvas() const;
103 /** Move the sprite in device pixel space.
105 If the sprite is not yet created, this method has no
106 effect.
108 void movePixel( const ::basegfx::B2DPoint& rNewPos );
110 /** Set the alpha value of the sprite.
112 If the sprite is not yet created, this method has no
113 effect.
115 void setAlpha( double rAlpha );
117 /** Set a sprite clip in user coordinate space.
119 If the sprite is not yet created, this method has no
120 effect.
122 void clip( const ::basegfx::B2DPolyPolygon& rClip );
124 /** Clears a sprite clip
126 If the sprite is not yet created, this method has no
127 effect.
129 void clip();
131 /** Set a sprite transformation.
133 If the sprite is not yet created, this method has no
134 effect.
136 void transform( const ::basegfx::B2DHomMatrix& rTransform );
138 private:
139 ViewLayerSharedPtr mpViewLayer;
141 ::cppcanvas::CustomSpriteSharedPtr mpSprite;
142 ::basegfx::B2DSize maEffectiveSpriteSizePixel;
143 ::basegfx::B2DSize maContentPixelOffset;
145 double mnSpritePrio;
146 double mnAlpha;
147 ::std::optional< ::basegfx::B2DPoint > maPosPixel;
148 ::std::optional< ::basegfx::B2DPolyPolygon > maClip;
150 bool mbSpriteVisible;
153 typedef ::std::shared_ptr< AnimatedSprite > AnimatedSpriteSharedPtr;
157 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_ANIMATEDSPRITE_HXX
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */