1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CPPCANVAS_RENDERER_HXX 25 #define _CPPCANVAS_RENDERER_HXX 26 27 #include <sal/types.h> 28 #include <rtl/ustring.hxx> 29 30 #include <boost/shared_ptr.hpp> 31 #include <boost/optional.hpp> 32 #include <basegfx/matrix/b2dhommatrix.hxx> 33 #include <cppcanvas/canvasgraphic.hxx> 34 #include <cppcanvas/color.hxx> 35 36 namespace basegfx 37 { 38 class B2DRange; 39 } 40 41 /* Definition of Renderer interface */ 42 43 namespace cppcanvas 44 { 45 46 class Renderer : public virtual CanvasGraphic 47 { 48 public: 49 /** Render subset of metafile to given canvas 50 51 This method renders the given subset of the content to the 52 associated canvas. 53 54 @param nStartIndex 55 The index of the first action to be rendered (the indices 56 correspond roughly to the action indices of the 57 originating GDIMetaFile. Note, although, that certain 58 actions, e.g. text, accounts for more than one index: a 59 text produces as many addressable indices as it has 60 characters). 61 62 @param nEndIndex 63 The index of the first action _not_ painted anymore, 64 i.e. the action after the last action rendered (the 65 indices correspond roughly to the action indices of the 66 originating GDIMetaFile. Note, although, that certain 67 actions, e.g. text, accounts for more than one index: a 68 text produces as many addressable indices as it has 69 characters). 70 71 @return whether the rendering finished successfully. 72 */ 73 virtual bool drawSubset( sal_Int32 nStartIndex, 74 sal_Int32 nEndIndex ) const = 0; 75 76 /** Query bounding box of metafile subset 77 78 This method queries the actual bounding box of the given 79 subset, when rendered on the associated canvas. 80 81 @param nStartIndex 82 The index of the first action to be rendered (the indices 83 correspond roughly to the action indices of the 84 originating GDIMetaFile. Note, although, that certain 85 actions, e.g. text, accounts for more than one index: a 86 text produces as many addressable indices as it has 87 characters). 88 89 @param nEndIndex 90 The index of the first action _not_ painted anymore, 91 i.e. the action after the last action rendered (the 92 indices correspond roughly to the action indices of the 93 originating GDIMetaFile. Note, although, that certain 94 actions, e.g. text, accounts for more than one index: a 95 text produces as many addressable indices as it has 96 characters). 97 98 @return the bounding box of the specified subset 99 */ 100 virtual ::basegfx::B2DRange getSubsetArea( sal_Int32 nStartIndex, 101 sal_Int32 nEndIndex ) const = 0; 102 103 /** Parameters for the Renderer 104 */ 105 struct Parameters 106 { 107 /// Optionally forces the fill color attribute for all actions 108 ::boost::optional< Color::IntSRGBA > maFillColor; 109 110 /// Optionally forces the line color attribute for all actions 111 ::boost::optional< Color::IntSRGBA > maLineColor; 112 113 /// Optionally forces the text color attribute for all actions 114 ::boost::optional< Color::IntSRGBA > maTextColor; 115 116 /// Optionally forces the given fontname for all text actions 117 ::boost::optional< ::rtl::OUString > maFontName; 118 119 /** Optionally transforms all text output actions with the 120 given matrix (in addition to the overall canvas 121 transformation). 122 123 Note that the matrix given here is applied to the unit 124 rect coordinate system, i.e. the metafile is assumed 125 to be contained in the unit rect. 126 */ 127 ::boost::optional< ::basegfx::B2DHomMatrix > maTextTransformation; 128 129 /// Optionally forces the given font weight for all text actions 130 ::boost::optional< sal_Int8 > maFontWeight; 131 132 /// Optionally forces the given font letter form (italics etc.) for all text actions 133 ::boost::optional< sal_Int8 > maFontLetterForm; 134 135 /// Optionally forces the given font proportion (condensed, monospaced etc.) for all text actions 136 ::boost::optional< sal_Int8 > maFontProportion; 137 138 /// Optionally forces underlining for all text actions 139 ::boost::optional< bool > maFontUnderline; 140 }; 141 }; 142 143 typedef ::boost::shared_ptr< ::cppcanvas::Renderer > RendererSharedPtr; 144 } 145 146 #endif /* _CPPCANVAS_RENDERER_HXX */ 147