| 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 |
#pragma once |
| 21 |
|
| 22 |
#include <sal/types.h> |
| 23 |
|
| 24 |
namespace basegfx |
| 25 |
{ |
| 26 |
class B2DHomMatrix; |
| 27 |
class B2DRange; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
/* Definition of Action interface */ |
| 32 |
|
| 33 |
namespace cppcanvas::internal |
| 34 |
{ |
| 35 |
/** Interface for internal render actions |
| 36 |
|
| 37 |
This interface is implemented by all objects generated |
| 38 |
from the metafile renderer, and corresponds roughly to the |
| 39 |
VCL meta action. |
| 40 |
*/ |
| 41 |
class Action |
| 42 |
{ |
| 43 |
public: |
| 44 |
/** Used for rendering action subsets |
| 45 |
|
| 46 |
There are several cases where an Action might have |
| 47 |
subsettable content, e.g. text, or referenced |
| 48 |
metafiles, like the transparent action. |
| 49 |
|
| 50 |
Generally, at the metafile renderer, all actions are |
| 51 |
'flattened' out, i.e. a meta action rendering the |
| 52 |
string "Hello" counts five indices, and a transparent |
| 53 |
action containing a metafile with 100 actions counts |
| 54 |
at least 100 indices (contained transparency or text |
| 55 |
actions recursively add to this value). From the |
| 56 |
outside, the subset to render is referenced via this |
| 57 |
flat index range |
| 58 |
*/ |
| 59 |
struct Subset |
| 60 |
{ |
| 61 |
/** Denotes start of the subset. |
| 62 |
|
| 63 |
The index given here specifies the first subaction |
| 64 |
to render. |
| 65 |
*/ |
| 66 |
sal_Int32 mnSubsetBegin; |
| 67 |
|
| 68 |
/** Denotes end of the subset |
| 69 |
|
| 70 |
The index given here specifies the first subaction |
| 71 |
<em>not<em> to render, i.e. one action behind the |
| 72 |
subset to be rendered |
| 73 |
*/ |
| 74 |
sal_Int32 mnSubsetEnd; |
| 75 |
}; |
| 76 |
|
| 77 |
virtual ~Action() {} |
| 78 |
|
| 79 |
/** Render this action to the associated canvas |
| 80 |
|
| 81 |
@param rTransformation |
| 82 |
Transformation matrix to apply before rendering |
| 83 |
|
| 84 |
@return true, if rendering was successful. If |
| 85 |
rendering failed, false is returned. |
| 86 |
*/ |
| 87 |
virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0; |
| 88 |
|
| 89 |
/** Render the given part of the action to the associated |
| 90 |
canvas. |
| 91 |
|
| 92 |
@param rTransformation |
| 93 |
Transformation matrix to apply before rendering |
| 94 |
|
| 95 |
@param rSubset |
| 96 |
Subset of the action to render. See Subset description |
| 97 |
for index semantics. |
| 98 |
|
| 99 |
@return true, if rendering was successful. If the |
| 100 |
specified subset is invalid for this action, or if |
| 101 |
rendering failed for other reasons, false is returned. |
| 102 |
*/ |
| 103 |
virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation, |
| 104 |
const Subset& rSubset ) const = 0; |
| 105 |
|
| 106 |
/** Query bounds of this action on the associated canvas |
| 107 |
|
| 108 |
@param rTransformation |
| 109 |
Transformation matrix to apply |
| 110 |
|
| 111 |
@return the bounds for this action in device |
| 112 |
coordinate space. |
| 113 |
*/ |
| 114 |
virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0; |
| 115 |
|
| 116 |
/** Query bounds for the given part of the action on the |
| 117 |
associated canvas. |
| 118 |
|
| 119 |
@param rTransformation |
| 120 |
Transformation matrix to apply. |
| 121 |
|
| 122 |
@param rSubset |
| 123 |
Subset of the action to query. See Subset description |
| 124 |
for index semantics. |
| 125 |
|
| 126 |
@return the bounds for the given subset in device |
| 127 |
coordinate space. |
| 128 |
*/ |
| 129 |
virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation, |
| 130 |
const Subset& rSubset ) const = 0; |
| 131 |
|
| 132 |
/** Query action count. |
| 133 |
|
| 134 |
This method returns the number of subset actions |
| 135 |
contained in this action. The render( Subset ) method |
| 136 |
must accept subset ranges up to the value returned |
| 137 |
here. |
| 138 |
|
| 139 |
@return the number of subset actions |
| 140 |
*/ |
| 141 |
virtual sal_Int32 getActionCount() const = 0; |
| 142 |
}; |
| 143 |
} |
| 144 |
|
| 145 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |