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 .
20 #ifndef INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_MTFTOOLS_HXX
21 #define INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_MTFTOOLS_HXX
24 #include <cppcanvas/canvas.hxx>
35 namespace com
{ namespace sun
{ namespace star
{ namespace rendering
50 /** Init render state from OutDevState
52 This method initializes the given render state object,
53 sets up the transformation and the clip from the
56 void initRenderState( ::com::sun::star::rendering::RenderState
& renderState
,
57 const ::cppcanvas::internal::OutDevState
& outdevState
);
59 /** Calc output offset relative to baseline
61 The XCanvas API always renders text relative to its
62 baseline. This method calculates an offset in logical
63 coordinates, depending on the OutDevState's
64 textReferencePoint and the font currently set, to offset
65 the text from the baseline.
68 State to take textReferencePoint from
71 VDev to obtain font metrics from.
73 ::Size
getBaselineOffset( const ::cppcanvas::internal::OutDevState
& outdevState
,
74 const VirtualDevice
& rVDev
);
76 /** Construct a matrix that converts from logical to pixel
79 This method calculates a matrix that approximates the
80 VirtualDevice's LogicToPixel conversion (disregarding any
81 offset components, thus the 'linear' in the method name -
82 the returned matrix is guaranteed to be linear).
85 This matrix will receive the calculated transform, and is
86 also returned from this method.
88 @return the calculated transformation matrix.
90 ::basegfx::B2DHomMatrix
& calcLogic2PixelLinearTransform( ::basegfx::B2DHomMatrix
& o_rMatrix
,
91 const VirtualDevice
& rVDev
);
93 /** Construct a matrix that converts from logical to pixel
96 This method calculates a matrix that approximates the
97 VirtualDevice's LogicToPixel conversion.
100 This matrix will receive the calculated transform, and is
101 also returned from this method.
103 @return the calculated transformation matrix.
105 ::basegfx::B2DHomMatrix
& calcLogic2PixelAffineTransform( ::basegfx::B2DHomMatrix
& o_rMatrix
,
106 const VirtualDevice
& rVDev
);
108 /** This method modifies the clip, to cancel the given
111 As the clip is relative to the render state
112 transformation, offsetting or scaling the render state
113 must modify the clip, to keep it at the same position
114 relative to the primitive at hand
116 @param o_rRenderState
117 Render state to change the clip in
120 Input state. Is used to retrieve the original clip from
123 The clip is offsetted by the negative of this value.
126 The clip is inversely scaled by this value (if given)
129 The clip is inversely rotated by this value (if given)
131 @return true, if the clip has changed, false if not
133 bool modifyClip( ::com::sun::star::rendering::RenderState
& o_rRenderState
,
134 const struct ::cppcanvas::internal::OutDevState
& rOutdevState
,
135 const CanvasSharedPtr
& rCanvas
,
136 const ::basegfx::B2DPoint
& rOffset
,
137 const ::basegfx::B2DVector
* pScaling
,
138 const double* pRotation
);
142 TextLineInfo( const double& rLineHeight
,
143 const double& rOverlineHeight
,
144 const double& rOverlineOffset
,
145 const double& rUnderlineOffset
,
146 const double& rStrikeoutOffset
,
147 sal_Int8 nOverlineStyle
,
148 sal_Int8 nUnderlineStyle
,
149 sal_Int8 nStrikeoutStyle
) :
150 mnLineHeight( rLineHeight
),
151 mnOverlineHeight( rOverlineHeight
),
152 mnOverlineOffset( rOverlineOffset
),
153 mnUnderlineOffset( rUnderlineOffset
),
154 mnStrikeoutOffset( rStrikeoutOffset
),
155 mnOverlineStyle( nOverlineStyle
),
156 mnUnderlineStyle( nUnderlineStyle
),
157 mnStrikeoutStyle( nStrikeoutStyle
)
162 double mnOverlineHeight
;
163 double mnOverlineOffset
;
164 double mnUnderlineOffset
;
165 double mnStrikeoutOffset
;
166 sal_Int8 mnOverlineStyle
;
167 sal_Int8 mnUnderlineStyle
;
168 sal_Int8 mnStrikeoutStyle
;
171 /** Transform given bounds to device coordinate system.
173 ::basegfx::B2DRange
calcDevicePixelBounds( const ::basegfx::B2DRange
& rBounds
,
174 const ::com::sun::star::rendering::ViewState
& viewState
,
175 const ::com::sun::star::rendering::RenderState
& renderState
);
177 /** Generate text underline/strikeout info struct from OutDev
180 TextLineInfo
createTextLineInfo( const ::VirtualDevice
& rVDev
,
181 const ::cppcanvas::internal::OutDevState
& rState
);
183 /** Create a poly-polygon representing the given combination
184 of overline, strikeout and underline.
187 Offset in X direction, where the underline starts
190 Width of the line of text to overline/strikeout/underline
193 Common info needed for overline/strikeout/underline generation
195 ::basegfx::B2DPolyPolygon
createTextLinesPolyPolygon( const double& rStartOffset
,
196 const double& rLineWidth
,
197 const TextLineInfo
& rTextLineInfo
);
199 ::basegfx::B2DPolyPolygon
createTextLinesPolyPolygon( const ::basegfx::B2DPoint
& rStartPos
,
200 const double& rLineWidth
,
201 const TextLineInfo
& rTextLineInfo
);
205 #endif // INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_MTFTOOLS_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */