1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CPPCANVAS_RENDERER_MTFTOOLS_HXX
30 #define _CPPCANVAS_RENDERER_MTFTOOLS_HXX
33 #include <cppcanvas/canvas.hxx>
45 namespace com
{ namespace sun
{ namespace star
{ namespace rendering
60 /** Init render state from OutDevState
62 This method initializes the given render state object,
63 sets up the transformation and the clip from the
66 void initRenderState( ::com::sun::star::rendering::RenderState
& renderState
,
67 const ::cppcanvas::internal::OutDevState
& outdevState
);
69 /** Calc output offset relative to baseline
71 The XCanvas API always renders text relative to its
72 baseline. This method calculates an offset in logical
73 coordinates, depending on the OutDevState's
74 textReferencePoint and the font currently set, to offset
75 the text from the baseline.
78 State to take textReferencePoint from
81 VDev to obtain font metrics from.
83 ::Size
getBaselineOffset( const ::cppcanvas::internal::OutDevState
& outdevState
,
84 const VirtualDevice
& rVDev
);
86 /** Construct a matrix that converts from logical to pixel
89 This method calculates a matrix that approximates the
90 VirtualDevice's LogicToPixel conversion (disregarding any
91 offset components, thus the 'linear' in the method name -
92 the returned matrix is guaranteed to be linear).
95 This matrix will receive the calculated transform, and is
96 also returned from this method.
98 @return the calculated transformation matrix.
100 ::basegfx::B2DHomMatrix
& calcLogic2PixelLinearTransform( ::basegfx::B2DHomMatrix
& o_rMatrix
,
101 const VirtualDevice
& rVDev
);
103 /** Construct a matrix that converts from logical to pixel
106 This method calculates a matrix that approximates the
107 VirtualDevice's LogicToPixel conversion.
110 This matrix will receive the calculated transform, and is
111 also returned from this method.
113 @return the calculated transformation matrix.
115 ::basegfx::B2DHomMatrix
& calcLogic2PixelAffineTransform( ::basegfx::B2DHomMatrix
& o_rMatrix
,
116 const VirtualDevice
& rVDev
);
118 /** This method modifies the clip, to cancel the given
121 As the clip is relative to the render state
122 transformation, offsetting or scaling the render state
123 must modify the clip, to keep it at the same position
124 relative to the primitive at hand
126 @param o_rRenderState
127 Render state to change the clip in
130 Input state. Is used to retrieve the original clip from
133 The clip is offsetted by the negative of this value.
136 The clip is inversely scaled by this value (if given)
139 The clip is inversely rotated by this value (if given)
141 @return true, if the clip has changed, false if not
143 bool modifyClip( ::com::sun::star::rendering::RenderState
& o_rRenderState
,
144 const struct ::cppcanvas::internal::OutDevState
& rOutdevState
,
145 const CanvasSharedPtr
& rCanvas
,
146 const ::basegfx::B2DPoint
& rOffset
,
147 const ::basegfx::B2DVector
* pScaling
,
148 const double* pRotation
);
152 TextLineInfo( const double& rLineHeight
,
153 const double& rOverlineHeight
,
154 const double& rOverlineOffset
,
155 const double& rUnderlineOffset
,
156 const double& rStrikeoutOffset
,
157 sal_Int8 nOverlineStyle
,
158 sal_Int8 nUnderlineStyle
,
159 sal_Int8 nStrikeoutStyle
) :
160 mnLineHeight( rLineHeight
),
161 mnOverlineHeight( rOverlineHeight
),
162 mnOverlineOffset( rOverlineOffset
),
163 mnUnderlineOffset( rUnderlineOffset
),
164 mnStrikeoutOffset( rStrikeoutOffset
),
165 mnOverlineStyle( nOverlineStyle
),
166 mnUnderlineStyle( nUnderlineStyle
),
167 mnStrikeoutStyle( nStrikeoutStyle
)
172 double mnOverlineHeight
;
173 double mnOverlineOffset
;
174 double mnUnderlineOffset
;
175 double mnStrikeoutOffset
;
176 sal_Int8 mnOverlineStyle
;
177 sal_Int8 mnUnderlineStyle
;
178 sal_Int8 mnStrikeoutStyle
;
181 /** Transform given bounds to device coordinate system.
183 ::basegfx::B2DRange
calcDevicePixelBounds( const ::basegfx::B2DRange
& rBounds
,
184 const ::com::sun::star::rendering::ViewState
& viewState
,
185 const ::com::sun::star::rendering::RenderState
& renderState
);
187 /** Generate text underline/strikeout info struct from OutDev
190 TextLineInfo
createTextLineInfo( const ::VirtualDevice
& rVDev
,
191 const ::cppcanvas::internal::OutDevState
& rState
);
193 /** Create a poly-polygon representing the given combination
194 of overline, strikeout and underline.
197 Offset in X direction, where the underline starts
200 Width of the line of text to overline/strikeout/underline
203 Common info needed for overline/strikeout/underline generation
205 ::basegfx::B2DPolyPolygon
createTextLinesPolyPolygon( const double& rStartOffset
,
206 const double& rLineWidth
,
207 const TextLineInfo
& rTextLineInfo
);
209 ::basegfx::B2DPolyPolygon
createTextLinesPolyPolygon( const ::basegfx::B2DPoint rStartPos
,
210 const double& rLineWidth
,
211 const TextLineInfo
& rTextLineInfo
);
215 #endif /* _CPPCANVAS_RENDERER_MTFTOOLS_HXX */
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */