Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / cppcanvas / source / inc / action.hxx
blobaa63ffce01bdb0cffa9d5584fc19c129850f2de8
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_CPPCANVAS_SOURCE_INC_ACTION_HXX
21 #define INCLUDED_CPPCANVAS_SOURCE_INC_ACTION_HXX
23 #include <sal/types.h>
24 #include <memory>
26 namespace basegfx
28 class B2DHomMatrix;
29 class B2DRange;
33 /* Definition of Action interface */
35 namespace cppcanvas
37 namespace internal
39 /** Interface for internal render actions
41 This interface is implemented by all objects generated
42 from the metafile renderer, and corresponds roughly to the
43 VCL meta action.
45 class Action
47 public:
48 /** Used for rendering action subsets
50 There are several cases where an Action might have
51 subsettable content, e.g. text, or referenced
52 metafiles, like the transparent action.
54 Generally, at the metafile renderer, all actions are
55 'flattened' out, i.e. a meta action rendering the
56 string "Hello" counts five indices, and a transparent
57 action containing a metafile with 100 actions counts
58 at least 100 indices (contained transparency or text
59 actions recursively add to this value). From the
60 outside, the subset to render is referenced via this
61 flat index range
63 struct Subset
65 /** Denotes start of the subset.
67 The index given here specifies the first subaction
68 to render.
70 sal_Int32 mnSubsetBegin;
72 /** Denotes end of the subset
74 The index given here specifies the first subaction
75 <em>not<em> to render, i.e. one action behind the
76 subset to be rendered
78 sal_Int32 mnSubsetEnd;
81 virtual ~Action() {}
83 /** Render this action to the associated canvas
85 @param rTransformation
86 Transformation matrix to apply before rendering
88 @return true, if rendering was successful. If
89 rendering failed, false is returned.
91 virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
93 /** Render the given part of the action to the associated
94 canvas.
96 @param rTransformation
97 Transformation matrix to apply before rendering
99 @param rSubset
100 Subset of the action to render. See Subset description
101 for index semantics.
103 @return true, if rendering was successful. If the
104 specified subset is invalid for this action, or if
105 rendering failed for other reasons, false is returned.
107 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
108 const Subset& rSubset ) const = 0;
110 /** Query bounds of this action on the associated canvas
112 @param rTransformation
113 Transformation matrix to apply
115 @return the bounds for this action in device
116 coordinate space.
118 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
120 /** Query bounds for the given part of the action on the
121 associated canvas.
123 @param rTransformation
124 Transformation matrix to apply.
126 @param rSubset
127 Subset of the action to query. See Subset description
128 for index semantics.
130 @return the bounds for the given subset in device
131 coordinate space.
133 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
134 const Subset& rSubset ) const = 0;
136 /** Query action count.
138 This method returns the number of subset actions
139 contained in this action. The render( Subset ) method
140 must accept subset ranges up to the value returned
141 here.
143 @return the number of subset actions
145 virtual sal_Int32 getActionCount() const = 0;
148 typedef std::shared_ptr< Action > ActionSharedPtr;
153 #endif // INCLUDED_CPPCANVAS_SOURCE_INC_ACTION_HXX
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */