1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <cppcanvas/canvas.hxx>
34 namespace com::sun::star::rendering
49 /** Init render state from OutDevState
51 This method initializes the given render state object,
52 sets up the transformation and the clip from the
55 void initRenderState( css::rendering::RenderState
& renderState
,
56 const ::cppcanvas::internal::OutDevState
& outdevState
);
58 /** Calc output offset relative to baseline
60 The XCanvas API always renders text relative to its
61 baseline. This method calculates an offset in logical
62 coordinates, depending on the OutDevState's
63 textReferencePoint and the font currently set, to offset
64 the text from the baseline.
67 State to take textReferencePoint from
70 VDev to obtain font metrics from.
72 ::Size
getBaselineOffset( const ::cppcanvas::internal::OutDevState
& outdevState
,
73 const VirtualDevice
& rVDev
);
75 /** Construct a matrix that converts from logical to pixel
78 This method calculates a matrix that approximates the
79 VirtualDevice's LogicToPixel conversion (disregarding any
80 offset components, thus the 'linear' in the method name -
81 the returned matrix is guaranteed to be linear).
84 This matrix will receive the calculated transform, and is
85 also returned from this method.
87 @return the calculated transformation matrix.
89 ::basegfx::B2DHomMatrix
& calcLogic2PixelLinearTransform( ::basegfx::B2DHomMatrix
& o_rMatrix
,
90 const VirtualDevice
& rVDev
);
92 /** Construct a matrix that converts from logical to pixel
95 This method calculates a matrix that approximates the
96 VirtualDevice's LogicToPixel conversion.
99 This matrix will receive the calculated transform, and is
100 also returned from this method.
102 @return the calculated transformation matrix.
104 ::basegfx::B2DHomMatrix
& calcLogic2PixelAffineTransform( ::basegfx::B2DHomMatrix
& o_rMatrix
,
105 const VirtualDevice
& rVDev
);
107 /** This method modifies the clip, to cancel the given
110 As the clip is relative to the render state
111 transformation, offsetting or scaling the render state
112 must modify the clip, to keep it at the same position
113 relative to the primitive at hand
115 @param o_rRenderState
116 Render state to change the clip in
119 Input state. Is used to retrieve the original clip from
122 The clip is offsetted by the negative of this value.
125 The clip is inversely scaled by this value (if given)
128 The clip is inversely rotated by this value (if given)
130 @return true, if the clip has changed, false if not
132 bool modifyClip( css::rendering::RenderState
& o_rRenderState
,
133 const struct ::cppcanvas::internal::OutDevState
& rOutdevState
,
134 const CanvasSharedPtr
& rCanvas
,
135 const ::basegfx::B2DPoint
& rOffset
,
136 const ::basegfx::B2DVector
* pScaling
,
137 const double* pRotation
);
141 TextLineInfo( const double& rLineHeight
,
142 const double& rOverlineHeight
,
143 const double& rOverlineOffset
,
144 const double& rUnderlineOffset
,
145 const double& rStrikeoutOffset
,
146 sal_Int8 nOverlineStyle
,
147 sal_Int8 nUnderlineStyle
,
148 sal_Int8 nStrikeoutStyle
) :
149 mnLineHeight( rLineHeight
),
150 mnOverlineHeight( rOverlineHeight
),
151 mnOverlineOffset( rOverlineOffset
),
152 mnUnderlineOffset( rUnderlineOffset
),
153 mnStrikeoutOffset( rStrikeoutOffset
),
154 mnOverlineStyle( nOverlineStyle
),
155 mnUnderlineStyle( nUnderlineStyle
),
156 mnStrikeoutStyle( nStrikeoutStyle
)
161 double mnOverlineHeight
;
162 double mnOverlineOffset
;
163 double mnUnderlineOffset
;
164 double mnStrikeoutOffset
;
165 sal_Int8 mnOverlineStyle
;
166 sal_Int8 mnUnderlineStyle
;
167 sal_Int8 mnStrikeoutStyle
;
170 /** Transform given bounds to device coordinate system.
172 ::basegfx::B2DRange
calcDevicePixelBounds( const ::basegfx::B2DRange
& rBounds
,
173 const css::rendering::ViewState
& viewState
,
174 const css::rendering::RenderState
& renderState
);
176 /** Generate text underline/strikeout info struct from OutDev
179 TextLineInfo
createTextLineInfo( const ::VirtualDevice
& rVDev
,
180 const ::cppcanvas::internal::OutDevState
& rState
);
182 /** Create a poly-polygon representing the given combination
183 of overline, strikeout and underline.
186 Offset in X direction, where the underline starts
189 Width of the line of text to overline/strikeout/underline
192 Common info needed for overline/strikeout/underline generation
194 ::basegfx::B2DPolyPolygon
createTextLinesPolyPolygon( const double& rStartOffset
,
195 const double& rLineWidth
,
196 const TextLineInfo
& rTextLineInfo
);
198 ::basegfx::B2DPolyPolygon
createTextLinesPolyPolygon( const ::basegfx::B2DPoint
& rStartPos
,
199 const double& rLineWidth
,
200 const TextLineInfo
& rTextLineInfo
);
202 void createTextLinesPolyPolygon( const double& rStartOffset
,
203 const double& rLineWidth
,
204 const TextLineInfo
& rTextLineInfo
,
205 ::basegfx::B2DPolyPolygon
& rOverlinePolyPoly
,
206 ::basegfx::B2DPolyPolygon
& rUnderlinePolyPoly
,
207 ::basegfx::B2DPolyPolygon
& rStrikeoutPolyPoly
);
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */