Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "svgfilter.hxx"
31 : : #include "svgfontexport.hxx"
32 : : #include "svgwriter.hxx"
33 : :
34 : : #include <vcl/unohelp.hxx>
35 : : #include <tools/helpers.hxx>
36 : :
37 : : #include <sax/tools/converter.hxx>
38 : :
39 : : #include <boost/shared_array.hpp>
40 : :
41 : : using ::rtl::OUString;
42 : :
43 : : // -----------
44 : : // - statics -
45 : : // -----------
46 : :
47 : : static const char aXMLElemG[] = "g";
48 : : static const char aXMLElemDefs[] = "defs";
49 : : static const char aXMLElemLine[] = "line";
50 : : static const char aXMLElemRect[] = "rect";
51 : : static const char aXMLElemEllipse[] = "ellipse";
52 : : static const char aXMLElemPath[] = "path";
53 : : static const char aXMLElemText[] = "text";
54 : : static const char aXMLElemImage[] = "image";
55 : : static const char aXMLElemMask[] = "mask";
56 : : static const char aXMLElemPattern[] = "pattern";
57 : : static const char aXMLElemLinearGradient[] = "linearGradient";
58 : : static const char aXMLElemRadialGradient[] = "radialGradient";
59 : : static const char aXMLElemStop[] = "stop";
60 : :
61 : : // -----------------------------------------------------------------------------
62 : :
63 : : static const char aXMLAttrTransform[] = "transform";
64 : : static const char aXMLAttrStyle[] = "style";
65 : : static const char aXMLAttrId[] = "id";
66 : : static const char aXMLAttrD[] = "d";
67 : : static const char aXMLAttrX[] = "x";
68 : : static const char aXMLAttrY[] = "y";
69 : : static const char aXMLAttrX1[] = "x1";
70 : : static const char aXMLAttrY1[] = "y1";
71 : : static const char aXMLAttrX2[] = "x2";
72 : : static const char aXMLAttrY2[] = "y2";
73 : : static const char aXMLAttrCX[] = "cx";
74 : : static const char aXMLAttrCY[] = "cy";
75 : : static const char aXMLAttrR[] = "r";
76 : : static const char aXMLAttrRX[] = "rx";
77 : : static const char aXMLAttrRY[] = "ry";
78 : : static const char aXMLAttrWidth[] = "width";
79 : : static const char aXMLAttrHeight[] = "height";
80 : : static const char aXMLAttrStroke[] = "stroke";
81 : : static const char aXMLAttrStrokeOpacity[] = "stroke-opacity";
82 : : static const char aXMLAttrStrokeWidth[] = "stroke-width";
83 : : static const char aXMLAttrStrokeDashArray[] = "stroke-dasharray";
84 : : static const char aXMLAttrFill[] = "fill";
85 : : static const char aXMLAttrFillOpacity[] = "fill-opacity";
86 : : static const char aXMLAttrFontFamily[] = "font-family";
87 : : static const char aXMLAttrFontSize[] = "font-size";
88 : : static const char aXMLAttrFontStyle[] = "font-style";
89 : : static const char aXMLAttrFontWeight[] = "font-weight";
90 : : static const char aXMLAttrTextDecoration[] = "text-decoration";
91 : : static const char aXMLAttrXLinkHRef[] = "xlink:href";
92 : : static const char aXMLAttrGradientUnits[] = "gradientUnits";
93 : : static const char aXMLAttrPatternUnits[] = "patternUnits";
94 : : static const char aXMLAttrOffset[] = "offset";
95 : : static const char aXMLAttrStopColor[] = "stop-color";
96 : :
97 : : // -----------------------------------------------------------------------------
98 : :
99 : : // ----------------------
100 : : // - SVGAttributeWriter -
101 : : // ----------------------
102 : :
103 : 0 : SVGAttributeWriter::SVGAttributeWriter( SVGExport& rExport, SVGFontExport& rFontExport ) :
104 : : mrExport( rExport ),
105 : : mrFontExport( rFontExport ),
106 : : mpElemFont( NULL ),
107 : 0 : mpElemPaint( NULL )
108 : : {
109 : 0 : }
110 : :
111 : : // -----------------------------------------------------------------------------
112 : :
113 : 0 : SVGAttributeWriter::~SVGAttributeWriter()
114 : : {
115 [ # # ][ # # ]: 0 : delete mpElemPaint;
116 [ # # ][ # # ]: 0 : delete mpElemFont;
117 [ # # ]: 0 : }
118 : :
119 : : // -----------------------------------------------------------------------------
120 : :
121 : 0 : double SVGAttributeWriter::ImplRound( double fValue, sal_Int32 nDecs )
122 : : {
123 : 0 : return( floor( fValue * pow( 10.0, (int)nDecs ) + 0.5 ) / pow( 10.0, (int)nDecs ) );
124 : : }
125 : :
126 : : // -----------------------------------------------------------------------------
127 : :
128 : 0 : void SVGAttributeWriter::ImplGetColorStr( const Color& rColor, ::rtl::OUString& rColorStr )
129 : : {
130 [ # # ]: 0 : if( rColor.GetTransparency() == 255 )
131 : 0 : rColorStr = B2UCONST( "none" );
132 : : else
133 : : {
134 : 0 : ::rtl::OUStringBuffer aStyle;
135 [ # # ]: 0 : aStyle.appendAscii( "rgb(" );
136 [ # # ]: 0 : aStyle.append( (sal_Int32) rColor.GetRed() );
137 [ # # ]: 0 : aStyle.appendAscii( "," );
138 [ # # ]: 0 : aStyle.append( (sal_Int32) rColor.GetGreen() );
139 [ # # ]: 0 : aStyle.appendAscii( "," );
140 [ # # ]: 0 : aStyle.append( (sal_Int32) rColor.GetBlue() );
141 [ # # ]: 0 : aStyle.appendAscii( ")" );
142 [ # # ]: 0 : rColorStr = aStyle.makeStringAndClear();
143 : : }
144 : 0 : }
145 : :
146 : : // -----------------------------------------------------------------------------
147 : :
148 : 0 : void SVGAttributeWriter::AddColorAttr( const char* pColorAttrName,
149 : : const char* pColorOpacityAttrName,
150 : : const Color& rColor )
151 : : {
152 : 0 : ::rtl::OUString aColor, aColorOpacity;
153 : :
154 [ # # ]: 0 : ImplGetColorStr( rColor, aColor );
155 : :
156 [ # # ][ # # ]: 0 : if( rColor.GetTransparency() > 0 && rColor.GetTransparency() < 255 )
[ # # ]
157 [ # # ]: 0 : aColorOpacity = ::rtl::OUString::valueOf( ImplRound( ( 255.0 - rColor.GetTransparency() ) / 255.0 ) );
158 : :
159 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, pColorAttrName, aColor );
160 : :
161 [ # # ][ # # ]: 0 : if( !aColorOpacity.isEmpty() && mrExport.IsUseOpacity() )
[ # # ][ # # ]
162 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, pColorOpacityAttrName, aColorOpacity );
163 : 0 : }
164 : :
165 : : // -----------------------------------------------------------------------------
166 : :
167 : 0 : void SVGAttributeWriter::AddPaintAttr( const Color& rLineColor, const Color& rFillColor,
168 : : const Rectangle* pObjBoundRect, const Gradient* pFillGradient )
169 : : {
170 : : // Fill
171 [ # # ][ # # ]: 0 : if( pObjBoundRect && pFillGradient )
172 : : {
173 : 0 : ::rtl::OUString aGradientId;
174 : :
175 [ # # ]: 0 : AddGradientDef( *pObjBoundRect, *pFillGradient, aGradientId );
176 : :
177 [ # # ]: 0 : if( !aGradientId.isEmpty() )
178 : : {
179 [ # # ]: 0 : ::rtl::OUString aGradientURL( B2UCONST( "url(#" ) );
180 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFill, ( aGradientURL += aGradientId ) += B2UCONST( ")" ) );
181 : 0 : }
182 : : }
183 : : else
184 : 0 : AddColorAttr( aXMLAttrFill, aXMLAttrFillOpacity, rFillColor );
185 : :
186 : : // Stroke
187 : 0 : AddColorAttr( aXMLAttrStroke, aXMLAttrStrokeOpacity, rLineColor );
188 : 0 : }
189 : :
190 : : // -----------------------------------------------------------------------------
191 : :
192 : 0 : void SVGAttributeWriter::AddGradientDef( const Rectangle& rObjRect, const Gradient& rGradient, ::rtl::OUString& rGradientId )
193 : : {
194 [ # # ][ # # : 0 : if( rObjRect.GetWidth() && rObjRect.GetHeight() &&
# # # # #
# # # ]
[ # # ]
195 : 0 : ( rGradient.GetStyle() == GradientStyle_LINEAR || rGradient.GetStyle() == GradientStyle_AXIAL ||
196 : 0 : rGradient.GetStyle() == GradientStyle_RADIAL || rGradient.GetStyle() == GradientStyle_ELLIPTICAL ) )
197 : : {
198 [ # # ]: 0 : SvXMLElementExport aDesc( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True );
199 : 0 : Color aStartColor( rGradient.GetStartColor() ), aEndColor( rGradient.GetEndColor() );
200 : 0 : sal_uInt16 nAngle = rGradient.GetAngle() % 3600;
201 [ # # ]: 0 : Point aObjRectCenter( rObjRect.Center() );
202 [ # # ]: 0 : Polygon aPoly( rObjRect );
203 : : static sal_Int32 nCurGradientId = 1;
204 : :
205 [ # # ]: 0 : aPoly.Rotate( aObjRectCenter, nAngle );
206 [ # # ]: 0 : Rectangle aRect( aPoly.GetBoundRect() );
207 : :
208 : : // adjust start/end colors with intensities
209 [ # # ]: 0 : aStartColor.SetRed( (sal_uInt8)( (long) aStartColor.GetRed() * rGradient.GetStartIntensity() ) / 100 );
210 [ # # ]: 0 : aStartColor.SetGreen( (sal_uInt8)( (long) aStartColor.GetGreen() * rGradient.GetStartIntensity() ) / 100 );
211 [ # # ]: 0 : aStartColor.SetBlue( (sal_uInt8)( (long) aStartColor.GetBlue() * rGradient.GetStartIntensity() ) / 100 );
212 : :
213 [ # # ]: 0 : aEndColor.SetRed( (sal_uInt8)( (long) aEndColor.GetRed() * rGradient.GetEndIntensity() ) / 100 );
214 [ # # ]: 0 : aEndColor.SetGreen( (sal_uInt8)( (long) aEndColor.GetGreen() * rGradient.GetEndIntensity() ) / 100 );
215 [ # # ]: 0 : aEndColor.SetBlue( (sal_uInt8)( (long) aEndColor.GetBlue() * rGradient.GetEndIntensity() ) / 100 );
216 : :
217 : : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId,
218 [ # # ][ # # ]: 0 : ( rGradientId = B2UCONST( "Gradient_" ) ) += ::rtl::OUString::valueOf( nCurGradientId++ ) );
219 : :
220 : : {
221 : 0 : ::std::auto_ptr< SvXMLElementExport > apGradient;
222 : 0 : ::rtl::OUString aColorStr;
223 : :
224 [ # # ][ # # ]: 0 : if( rGradient.GetStyle() == GradientStyle_LINEAR || rGradient.GetStyle() == GradientStyle_AXIAL )
[ # # ]
225 : : {
226 [ # # ]: 0 : Polygon aLinePoly( 2 );
227 : :
228 [ # # ]: 0 : aLinePoly[ 0 ] = Point( aObjRectCenter.X(), aRect.Top() );
229 [ # # ]: 0 : aLinePoly[ 1 ] = Point( aObjRectCenter.X(), aRect.Bottom() );
230 : :
231 [ # # ]: 0 : aLinePoly.Rotate( aObjRectCenter, nAngle );
232 : :
233 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, B2UCONST( "userSpaceOnUse" ) );
234 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, ::rtl::OUString::valueOf( aLinePoly[ 0 ].X() ) );
235 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, ::rtl::OUString::valueOf( aLinePoly[ 0 ].Y() ) );
236 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, ::rtl::OUString::valueOf( aLinePoly[ 1 ].X() ) );
237 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, ::rtl::OUString::valueOf( aLinePoly[ 1 ].Y() ) );
238 : :
239 [ # # ][ # # ]: 0 : apGradient.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemLinearGradient, sal_True, sal_True ) );
240 : :
241 : : // write stop values
242 : 0 : double fBorder = static_cast< double >( rGradient.GetBorder() ) *
243 [ # # ]: 0 : ( ( rGradient.GetStyle() == GradientStyle_AXIAL ) ? 0.005 : 0.01 );
244 : :
245 [ # # ][ # # ]: 0 : ImplGetColorStr( ( rGradient.GetStyle() == GradientStyle_AXIAL ) ? aEndColor : aStartColor, aColorStr );
246 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( fBorder ) );
247 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr );
248 : :
249 : : {
250 [ # # ][ # # ]: 0 : SvXMLElementExport aDesc2( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True );
251 : : }
252 : :
253 [ # # ]: 0 : if( rGradient.GetStyle() == GradientStyle_AXIAL )
254 : : {
255 [ # # ]: 0 : ImplGetColorStr( aStartColor, aColorStr );
256 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( 0.5 ) );
257 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr );
258 : :
259 : : {
260 [ # # ][ # # ]: 0 : SvXMLElementExport aDesc3( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True );
261 : : }
262 : : }
263 : :
264 [ # # ]: 0 : if( rGradient.GetStyle() != GradientStyle_AXIAL )
265 : 0 : fBorder = 0.0;
266 : :
267 [ # # ]: 0 : ImplGetColorStr( aEndColor, aColorStr );
268 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( ImplRound( 1.0 - fBorder ) ) );
269 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr );
270 : :
271 : : {
272 [ # # ][ # # ]: 0 : SvXMLElementExport aDesc4( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True );
273 [ # # ]: 0 : }
274 : : }
275 : : else
276 : : {
277 [ # # ]: 0 : const double fCenterX = rObjRect.Left() + rObjRect.GetWidth() * rGradient.GetOfsX() * 0.01;
278 [ # # ]: 0 : const double fCenterY = rObjRect.Top() + rObjRect.GetHeight() * rGradient.GetOfsY() * 0.01;
279 [ # # ][ # # ]: 0 : const double fRadius = sqrt( static_cast< double >( rObjRect.GetWidth() ) * rObjRect.GetWidth() +
280 [ # # ][ # # ]: 0 : rObjRect.GetHeight() * rObjRect.GetHeight() ) * 0.5;
281 : :
282 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, B2UCONST( "userSpaceOnUse" ) );
283 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, ::rtl::OUString::valueOf( ImplRound( fCenterX ) ) );
284 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, ::rtl::OUString::valueOf( ImplRound( fCenterY ) ) );
285 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrR, ::rtl::OUString::valueOf( ImplRound( fRadius ) ) );
286 : :
287 [ # # ][ # # ]: 0 : apGradient.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemRadialGradient, sal_True, sal_True ) );
288 : :
289 : : // write stop values
290 [ # # ]: 0 : ImplGetColorStr( aEndColor, aColorStr );
291 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( 0.0 ) );
292 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr );
293 : :
294 : : {
295 [ # # ][ # # ]: 0 : SvXMLElementExport aDesc5( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True );
296 : : }
297 : :
298 [ # # ]: 0 : ImplGetColorStr( aStartColor, aColorStr );
299 : : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset,
300 [ # # ][ # # ]: 0 : ::rtl::OUString::valueOf( ImplRound( 1.0 - rGradient.GetBorder() * 0.01 ) ) );
301 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr );
302 : :
303 : : {
304 [ # # ][ # # ]: 0 : SvXMLElementExport aDesc6( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True );
305 : : }
306 [ # # ]: 0 : }
307 [ # # ][ # # ]: 0 : }
308 : : }
309 : : else
310 : 0 : rGradientId = ::rtl::OUString();
311 : 0 : }
312 : :
313 : : // -----------------------------------------------------------------------------
314 : :
315 : 0 : void SVGAttributeWriter::SetFontAttr( const Font& rFont )
316 : : {
317 [ # # ][ # # ]: 0 : if( !mpElemFont || ( rFont != maCurFont ) )
[ # # ]
318 : : {
319 : 0 : ::rtl::OUString aFontStyle, aFontWeight, aTextDecoration;
320 : : sal_Int32 nFontWeight;
321 : :
322 [ # # ][ # # ]: 0 : delete mpElemPaint, mpElemPaint = NULL;
323 [ # # ][ # # ]: 0 : delete mpElemFont;
324 [ # # ]: 0 : maCurFont = rFont;
325 : :
326 : : // Font Family
327 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontFamily, mrFontExport.GetMappedFontName( rFont.GetName() ) );
[ # # ][ # # ]
328 : :
329 : : // Font Size
330 : : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontSize,
331 [ # # ][ # # ]: 0 : ::rtl::OUString::valueOf( rFont.GetHeight() ) + B2UCONST( "px" ) );
[ # # ]
332 : :
333 : : // Font Style
334 [ # # ][ # # ]: 0 : if( rFont.GetItalic() != ITALIC_NONE )
335 : : {
336 [ # # ][ # # ]: 0 : if( rFont.GetItalic() == ITALIC_OBLIQUE )
337 [ # # ]: 0 : aFontStyle = B2UCONST( "oblique" );
338 : : else
339 [ # # ]: 0 : aFontStyle = B2UCONST( "italic" );
340 : : }
341 : : else
342 [ # # ]: 0 : aFontStyle = B2UCONST( "normal" );
343 : :
344 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontStyle, aFontStyle );
345 : :
346 : : // Font Weight
347 [ # # ][ # # : 0 : switch( rFont.GetWeight() )
# # # # #
# # # # ]
348 : : {
349 : 0 : case WEIGHT_THIN: nFontWeight = 100; break;
350 : 0 : case WEIGHT_ULTRALIGHT: nFontWeight = 200; break;
351 : 0 : case WEIGHT_LIGHT: nFontWeight = 300; break;
352 : 0 : case WEIGHT_SEMILIGHT: nFontWeight = 400; break;
353 : 0 : case WEIGHT_NORMAL: nFontWeight = 400; break;
354 : 0 : case WEIGHT_MEDIUM: nFontWeight = 500; break;
355 : 0 : case WEIGHT_SEMIBOLD: nFontWeight = 600; break;
356 : 0 : case WEIGHT_BOLD: nFontWeight = 700; break;
357 : 0 : case WEIGHT_ULTRABOLD: nFontWeight = 800; break;
358 : 0 : case WEIGHT_BLACK: nFontWeight = 900; break;
359 : 0 : default: nFontWeight = 400; break;
360 : : }
361 : :
362 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontWeight, ::rtl::OUString::valueOf( nFontWeight ) );
363 : :
364 [ # # ][ # # ]: 0 : if( mrExport.IsUseNativeTextDecoration() )
365 : : {
366 [ # # ][ # # ]: 0 : if( rFont.GetUnderline() != UNDERLINE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE )
[ # # ][ # # ]
[ # # ]
367 : : {
368 [ # # ][ # # ]: 0 : if( rFont.GetUnderline() != UNDERLINE_NONE )
369 [ # # ]: 0 : aTextDecoration = B2UCONST( "underline " );
370 : :
371 [ # # ][ # # ]: 0 : if( rFont.GetStrikeout() != STRIKEOUT_NONE )
372 [ # # ]: 0 : aTextDecoration += B2UCONST( "line-through " );
373 : : }
374 : : else
375 [ # # ]: 0 : aTextDecoration = B2UCONST( "none" );
376 : :
377 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, aTextDecoration );
378 : : }
379 : :
380 [ # # ][ # # ]: 0 : mpElemFont = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True );
381 : : }
382 : 0 : }
383 : :
384 : : // -------------------
385 : : // - SVGActionWriter -
386 : : // -------------------
387 : :
388 : 0 : SVGActionWriter::SVGActionWriter( SVGExport& rExport, SVGFontExport& rFontExport ) :
389 : : mnCurGradientId( 1 ),
390 : : mnCurMaskId( 1 ),
391 : : mnCurPatternId( 1 ),
392 : : mrExport( rExport ),
393 : : mrFontExport( rFontExport ),
394 : : mpContext( NULL ),
395 : : mnInnerMtfCount( 0 ),
396 [ # # ][ # # ]: 0 : mbClipAttrChanged( sal_False )
397 : : {
398 [ # # ][ # # ]: 0 : mpVDev = new VirtualDevice;
399 [ # # ]: 0 : mpVDev->EnableOutput( sal_False );
400 [ # # ][ # # ]: 0 : maTargetMapMode = MAP_100TH_MM;
[ # # ]
401 : 0 : }
402 : :
403 : : // -----------------------------------------------------------------------------
404 : :
405 [ # # ][ # # ]: 0 : SVGActionWriter::~SVGActionWriter()
406 : : {
407 : : DBG_ASSERT( !mpContext, "Not all contexts are closed" );
408 [ # # ][ # # ]: 0 : delete mpVDev;
409 [ # # ]: 0 : }
410 : :
411 : : // -----------------------------------------------------------------------------
412 : :
413 : 0 : long SVGActionWriter::ImplMap( sal_Int32 nVal ) const
414 : : {
415 : 0 : Size aSz( nVal, nVal );
416 : :
417 [ # # ]: 0 : return( ImplMap( aSz, aSz ).Width() );
418 : : }
419 : :
420 : : // -----------------------------------------------------------------------------
421 : :
422 : 0 : Point& SVGActionWriter::ImplMap( const Point& rPt, Point& rDstPt ) const
423 : : {
424 : 0 : return( rDstPt = mpVDev->LogicToLogic( rPt, mpVDev->GetMapMode(), maTargetMapMode ) );
425 : : }
426 : :
427 : : // -----------------------------------------------------------------------------
428 : :
429 : 0 : Size& SVGActionWriter::ImplMap( const Size& rSz, Size& rDstSz ) const
430 : : {
431 : 0 : return( rDstSz = mpVDev->LogicToLogic( rSz, mpVDev->GetMapMode(), maTargetMapMode ) );
432 : : }
433 : :
434 : : // -----------------------------------------------------------------------------
435 : :
436 : 0 : Rectangle& SVGActionWriter::ImplMap( const Rectangle& rRect, Rectangle& rDstRect ) const
437 : : {
438 : 0 : Point aTL( rRect.TopLeft() );
439 [ # # ]: 0 : Size aSz( rRect.GetSize() );
440 : :
441 [ # # ][ # # ]: 0 : return( rDstRect = Rectangle( ImplMap( aTL, aTL ), ImplMap( aSz, aSz ) ) );
[ # # ]
442 : : }
443 : :
444 : :
445 : : // -----------------------------------------------------------------------------
446 : :
447 : 0 : Polygon& SVGActionWriter::ImplMap( const Polygon& rPoly, Polygon& rDstPoly ) const
448 : : {
449 [ # # ]: 0 : rDstPoly = Polygon( rPoly.GetSize() );
450 : :
451 [ # # ]: 0 : for( sal_uInt16 i = 0, nSize = rPoly.GetSize(); i < nSize; ++i )
452 : : {
453 : 0 : ImplMap( rPoly[ i ], rDstPoly[ i ] );
454 : 0 : rDstPoly.SetFlags( i, rPoly.GetFlags( i ) );
455 : : }
456 : :
457 : 0 : return( rDstPoly );
458 : : }
459 : :
460 : : // -----------------------------------------------------------------------------
461 : :
462 : 0 : PolyPolygon& SVGActionWriter::ImplMap( const PolyPolygon& rPolyPoly, PolyPolygon& rDstPolyPoly ) const
463 : : {
464 [ # # ]: 0 : Polygon aPoly;
465 : :
466 [ # # ][ # # ]: 0 : rDstPolyPoly = PolyPolygon();
[ # # ]
467 : :
468 [ # # ][ # # ]: 0 : for( sal_uInt16 i = 0, nCount = rPolyPoly.Count(); i < nCount; ++i )
469 : : {
470 [ # # ][ # # ]: 0 : rDstPolyPoly.Insert( ImplMap( rPolyPoly[ i ], aPoly ) );
[ # # ]
471 : : }
472 : :
473 [ # # ]: 0 : return( rDstPolyPoly );
474 : : }
475 : :
476 : : // -----------------------------------------------------------------------------
477 : :
478 : 0 : ::rtl::OUString SVGActionWriter::GetPathString( const PolyPolygon& rPolyPoly, sal_Bool bLine )
479 : : {
480 : 0 : ::rtl::OUString aPathData;
481 [ # # ]: 0 : const ::rtl::OUString aBlank( B2UCONST( " " ) );
482 [ # # ]: 0 : const ::rtl::OUString aComma( B2UCONST( "," ) );
483 : 0 : Point aPolyPoint;
484 : :
485 [ # # ][ # # ]: 0 : for( long i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ )
486 : : {
487 [ # # ]: 0 : const Polygon& rPoly = rPolyPoly[ (sal_uInt16) i ];
488 [ # # ]: 0 : sal_uInt16 n = 1, nSize = rPoly.GetSize();
489 : :
490 [ # # ]: 0 : if( nSize > 1 )
491 : : {
492 [ # # ]: 0 : aPathData += B2UCONST( "M " );
493 [ # # ]: 0 : aPathData += ::rtl::OUString::valueOf( ( aPolyPoint = rPoly[ 0 ] ).X() );
494 : 0 : aPathData += aComma;
495 : 0 : aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() );
496 : :
497 : 0 : sal_Char nCurrentMode = 0;
498 [ # # ]: 0 : while( n < nSize )
499 : : {
500 : 0 : aPathData += aBlank;
501 : :
502 [ # # ][ # # ]: 0 : if ( ( rPoly.GetFlags( n ) == POLY_CONTROL ) && ( ( n + 2 ) < nSize ) )
[ # # ][ # # ]
503 : : {
504 [ # # ]: 0 : if ( nCurrentMode != 'C' )
505 : : {
506 : 0 : nCurrentMode = 'C';
507 [ # # ]: 0 : aPathData += B2UCONST( "C " );
508 : : }
509 [ # # ]: 0 : for ( int j = 0; j < 3; j++ )
510 : : {
511 [ # # ]: 0 : if ( j )
512 : 0 : aPathData += aBlank;
513 [ # # ]: 0 : aPathData += ::rtl::OUString::valueOf( ( aPolyPoint = rPoly[ n++ ] ).X() );
514 : 0 : aPathData += aComma;
515 : 0 : aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() );
516 : : }
517 : : }
518 : : else
519 : : {
520 [ # # ]: 0 : if ( nCurrentMode != 'L' )
521 : : {
522 : 0 : nCurrentMode = 'L';
523 [ # # ]: 0 : aPathData += B2UCONST( "L " );
524 : : }
525 [ # # ]: 0 : aPathData += ::rtl::OUString::valueOf( ( aPolyPoint = rPoly[ n++ ] ).X() );
526 : 0 : aPathData += aComma;
527 : 0 : aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() );
528 : : }
529 : : }
530 : :
531 [ # # ]: 0 : if( !bLine )
532 [ # # ]: 0 : aPathData += B2UCONST( " Z" );
533 : :
534 [ # # ]: 0 : if( i < ( nCount - 1 ) )
535 : 0 : aPathData += aBlank;
536 : : }
537 : : }
538 : :
539 : 0 : return aPathData;
540 : : }
541 : :
542 : : // -----------------------------------------------------------------------------
543 : :
544 : 0 : void SVGActionWriter::ImplWriteLine( const Point& rPt1, const Point& rPt2,
545 : : const Color* pLineColor, sal_Bool bApplyMapping )
546 : : {
547 : 0 : Point aPt1, aPt2;
548 : :
549 [ # # ]: 0 : if( bApplyMapping )
550 : : {
551 [ # # ]: 0 : ImplMap( rPt1, aPt1 );
552 [ # # ]: 0 : ImplMap( rPt2, aPt2 );
553 : : }
554 : : else
555 : : {
556 : 0 : aPt1 = rPt1;
557 : 0 : aPt2 = rPt2;
558 : : }
559 : :
560 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, ::rtl::OUString::valueOf( aPt1.X() ) );
561 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, ::rtl::OUString::valueOf( aPt1.Y() ) );
562 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, ::rtl::OUString::valueOf( aPt2.X() ) );
563 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, ::rtl::OUString::valueOf( aPt2.Y() ) );
564 : :
565 : : if( pLineColor )
566 : : {
567 : : // !!! mrExport.AddAttribute( XML_NAMESPACE_NONE, ... )
568 : : OSL_FAIL( "SVGActionWriter::ImplWriteLine: Line color not implemented" );
569 : : }
570 : :
571 : : {
572 [ # # ][ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemLine, sal_True, sal_True );
573 : : }
574 : 0 : }
575 : :
576 : : // -----------------------------------------------------------------------------
577 : :
578 : 0 : void SVGActionWriter::ImplWriteRect( const Rectangle& rRect, long nRadX, long nRadY,
579 : : sal_Bool bApplyMapping )
580 : : {
581 [ # # ]: 0 : Rectangle aRect;
582 : :
583 [ # # ]: 0 : if( bApplyMapping )
584 [ # # ]: 0 : ImplMap( rRect, aRect );
585 : : else
586 : 0 : aRect = rRect;
587 : :
588 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aRect.Left() ) );
589 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aRect.Top() ) );
590 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, ::rtl::OUString::valueOf( aRect.GetWidth() ) );
591 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, ::rtl::OUString::valueOf( aRect.GetHeight() ) );
592 : :
593 [ # # ]: 0 : if( nRadX )
594 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadX ) : nRadX ) );
[ # # ]
595 : :
596 [ # # ]: 0 : if( nRadY )
597 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadY ) : nRadY ) );
[ # # ]
598 : :
599 : : {
600 [ # # ][ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemRect, sal_True, sal_True );
601 : : }
602 : 0 : }
603 : :
604 : : // -----------------------------------------------------------------------------
605 : :
606 : 0 : void SVGActionWriter::ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY,
607 : : sal_Bool bApplyMapping )
608 : : {
609 : 0 : Point aCenter;
610 : :
611 [ # # ]: 0 : if( bApplyMapping )
612 [ # # ]: 0 : ImplMap( rCenter, aCenter );
613 : : else
614 : 0 : aCenter = rCenter;
615 : :
616 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, ::rtl::OUString::valueOf( aCenter.X() ) );
617 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, ::rtl::OUString::valueOf( aCenter.Y() ) );
618 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadX ) : nRadX ) );
[ # # ]
619 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadY ) : nRadY ) );
[ # # ]
620 : :
621 : : {
622 [ # # ][ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemEllipse, sal_True, sal_True );
623 : : }
624 : 0 : }
625 : :
626 : : // -----------------------------------------------------------------------------
627 : :
628 : 0 : void SVGActionWriter::ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly,
629 : : sal_Bool bApplyMapping )
630 : : {
631 [ # # ]: 0 : PolyPolygon aPolyPoly;
632 : :
633 [ # # ]: 0 : if( bApplyMapping )
634 [ # # ]: 0 : ImplMap( rPolyPoly, aPolyPoly );
635 : : else
636 [ # # ]: 0 : aPolyPoly = rPolyPoly;
637 : :
638 : : // add path data attribute
639 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, GetPathString( aPolyPoly, bLineOnly ) );
640 : :
641 : : {
642 : : // write polyline/polygon element
643 [ # # ][ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemPath, sal_True, sal_True );
644 [ # # ]: 0 : }
645 : 0 : }
646 : :
647 : : // -----------------------------------------------------------------------------
648 : :
649 : 0 : void SVGActionWriter::ImplWriteShape( const SVGShapeDescriptor& rShape, sal_Bool bApplyMapping )
650 : : {
651 [ # # ]: 0 : PolyPolygon aPolyPoly;
652 : :
653 [ # # ]: 0 : if( bApplyMapping )
654 [ # # ]: 0 : ImplMap( rShape.maShapePolyPoly, aPolyPoly );
655 : : else
656 [ # # ]: 0 : aPolyPoly = rShape.maShapePolyPoly;
657 : :
658 [ # # ][ # # ]: 0 : const sal_Bool bLineOnly = ( rShape.maShapeFillColor == Color( COL_TRANSPARENT ) ) && ( !rShape.mapShapeGradient.get() );
[ # # ]
659 [ # # ]: 0 : Rectangle aBoundRect( aPolyPoly.GetBoundRect() );
660 : :
661 [ # # ]: 0 : mpContext->AddPaintAttr( rShape.maShapeLineColor, rShape.maShapeFillColor, &aBoundRect, rShape.mapShapeGradient.get() );
662 : :
663 [ # # ]: 0 : if( !rShape.maId.isEmpty() )
664 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, rShape.maId );
665 : :
666 [ # # ]: 0 : if( rShape.mnStrokeWidth )
667 : : {
668 [ # # ][ # # ]: 0 : sal_Int32 nStrokeWidth = ( bApplyMapping ? ImplMap( rShape.mnStrokeWidth ) : rShape.mnStrokeWidth );
669 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, ::rtl::OUString::valueOf( nStrokeWidth ) );
670 : : }
671 : :
672 [ # # ]: 0 : if( rShape.maDashArray.size() )
673 : : {
674 [ # # ]: 0 : const ::rtl::OUString aComma( B2UCONST( "," ) );
675 : 0 : ::rtl::OUString aDashArrayStr;
676 : :
677 [ # # ]: 0 : for( unsigned int k = 0; k < rShape.maDashArray.size(); ++k )
678 : : {
679 : : const sal_Int32 nDash = ( bApplyMapping ?
680 [ # # ]: 0 : ImplMap( FRound( rShape.maDashArray[ k ] ) ) :
681 [ # # # # ]: 0 : FRound( rShape.maDashArray[ k ] ) );
[ # # ]
682 : :
683 [ # # ]: 0 : if( k )
684 : 0 : aDashArrayStr += aComma;
685 : :
686 : 0 : aDashArrayStr += ::rtl::OUString::valueOf( nDash );
687 : : }
688 : :
689 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeDashArray, aDashArrayStr );
690 : : }
691 : :
692 [ # # ][ # # ]: 0 : ImplWritePolyPolygon( aPolyPoly, bLineOnly, sal_False );
693 : 0 : }
694 : :
695 : : // -----------------------------------------------------------------------------
696 : :
697 : 0 : void SVGActionWriter::ImplWritePattern( const PolyPolygon& rPolyPoly,
698 : : const Hatch* pHatch,
699 : : const Gradient* pGradient,
700 : : sal_uInt32 nWriteFlags )
701 : : {
702 [ # # ]: 0 : if( rPolyPoly.Count() )
703 : : {
704 [ # # ]: 0 : SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True );
705 : :
706 : 0 : ::rtl::OUString aPatternId;
707 [ # # ]: 0 : aPatternId += B2UCONST( "pattern" );
708 : 0 : aPatternId += OUString::valueOf( mnCurPatternId++ );
709 : :
710 : : {
711 [ # # ]: 0 : SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True );
712 : :
713 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aPatternId );
714 : :
715 [ # # ]: 0 : Rectangle aRect;
716 [ # # ][ # # ]: 0 : ImplMap( rPolyPoly.GetBoundRect(), aRect );
717 : :
718 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::valueOf( aRect.Left() ) );
719 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::valueOf( aRect.Top() ) );
720 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::valueOf( aRect.GetWidth() ) );
721 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::valueOf( aRect.GetHeight() ) );
722 : :
723 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrPatternUnits, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "userSpaceOnUse") ) );
724 : :
725 : : {
726 [ # # ]: 0 : SvXMLElementExport aElemPattern( mrExport, XML_NAMESPACE_NONE, aXMLElemPattern, sal_True, sal_True );
727 : :
728 : : // The origin of a pattern is positioned at (aRect.Left(), aRect.Top()).
729 : : // So we need to adjust the pattern coordinate.
730 : 0 : ::rtl::OUString aTransform;
731 [ # # ]: 0 : aTransform += B2UCONST( "translate" );
732 [ # # ]: 0 : aTransform += B2UCONST( "(" );
733 : 0 : aTransform += OUString::valueOf( -aRect.Left() );
734 [ # # ]: 0 : aTransform += B2UCONST( "," );
735 : 0 : aTransform += OUString::valueOf( -aRect.Top() );
736 [ # # ]: 0 : aTransform += B2UCONST( ")" );
737 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform );
738 : :
739 : : {
740 [ # # ]: 0 : SvXMLElementExport aElemG2( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True );
741 : :
742 [ # # ]: 0 : GDIMetaFile aTmpMtf;
743 [ # # ]: 0 : if( pHatch )
744 [ # # ]: 0 : mpVDev->AddHatchActions( rPolyPoly, *pHatch, aTmpMtf );
745 [ # # ]: 0 : else if ( pGradient )
746 [ # # ][ # # ]: 0 : mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), *pGradient, aTmpMtf );
747 [ # # ][ # # ]: 0 : ImplWriteActions( aTmpMtf, nWriteFlags, NULL );
[ # # ]
748 [ # # ]: 0 : }
749 [ # # ]: 0 : }
750 : : }
751 : :
752 : 0 : ::rtl::OUString aPatternStyle;
753 [ # # ]: 0 : aPatternStyle += B2UCONST( "fill:url(#" );
754 : 0 : aPatternStyle += aPatternId;
755 [ # # ]: 0 : aPatternStyle += B2UCONST( ")" );
756 : :
757 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aPatternStyle );
758 [ # # ][ # # ]: 0 : ImplWritePolyPolygon( rPolyPoly, sal_False );
759 : : }
760 : 0 : }
761 : :
762 : : // -----------------------------------------------------------------------------
763 : :
764 : 0 : void SVGActionWriter::ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient,
765 : : sal_uInt32 nWriteFlags, sal_Bool bApplyMapping )
766 : : {
767 [ # # ]: 0 : PolyPolygon aPolyPoly;
768 : :
769 [ # # ]: 0 : if( bApplyMapping )
770 [ # # ]: 0 : ImplMap( rPolyPoly, aPolyPoly );
771 : : else
772 [ # # ]: 0 : aPolyPoly = rPolyPoly;
773 : :
774 [ # # # # ]: 0 : if ( rGradient.GetStyle() == GradientStyle_LINEAR ||
[ # # ]
775 : 0 : rGradient.GetStyle() == GradientStyle_AXIAL )
776 : : {
777 [ # # ]: 0 : ImplWriteGradientLinear( aPolyPoly, rGradient );
778 : : }
779 : : else
780 : : {
781 [ # # ]: 0 : ImplWritePattern( aPolyPoly, NULL, &rGradient, nWriteFlags );
782 [ # # ]: 0 : }
783 : 0 : }
784 : :
785 : : // -----------------------------------------------------------------------------
786 : :
787 : 0 : void SVGActionWriter::ImplWriteGradientLinear( const PolyPolygon& rPolyPoly,
788 : : const Gradient& rGradient )
789 : : {
790 [ # # ]: 0 : if( rPolyPoly.Count() )
791 : : {
792 [ # # ]: 0 : SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True );
793 : :
794 : 0 : ::rtl::OUString aGradientId;
795 [ # # ]: 0 : aGradientId += B2UCONST( "gradient" );
796 : 0 : aGradientId += OUString::valueOf( mnCurGradientId++ );
797 : :
798 : : {
799 [ # # ]: 0 : SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True );
800 : :
801 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aGradientId );
802 : : {
803 [ # # ][ # # ]: 0 : Rectangle aTmpRect, aRect;
804 : 0 : Point aTmpCenter, aCenter;
805 : :
806 [ # # ][ # # ]: 0 : rGradient.GetBoundRect( rPolyPoly.GetBoundRect(), aTmpRect, aTmpCenter );
807 [ # # ]: 0 : ImplMap( aTmpRect, aRect );
808 [ # # ]: 0 : ImplMap( aTmpCenter, aCenter );
809 : 0 : const sal_uInt16 nAngle = rGradient.GetAngle() % 3600;
810 : :
811 [ # # ]: 0 : Polygon aPoly( 2 );
812 : : // Setting x value of a gradient vector to rotation center to
813 : : // place a gradient vector in a target polygon.
814 : : // This would help editing it in SVG editors like inkscape.
815 [ # # ][ # # ]: 0 : aPoly[ 0 ].X() = aPoly[ 1 ].X() = aCenter.X();
816 [ # # ]: 0 : aPoly[ 0 ].Y() = aRect.Top();
817 [ # # ]: 0 : aPoly[ 1 ].Y() = aRect.Bottom();
818 [ # # ]: 0 : aPoly.Rotate( aCenter, nAngle );
819 : :
820 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, OUString::valueOf( aPoly[ 0 ].X() ) );
821 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, OUString::valueOf( aPoly[ 0 ].Y() ) );
822 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, OUString::valueOf( aPoly[ 1 ].X() ) );
823 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, OUString::valueOf( aPoly[ 1 ].Y() ) );
824 : :
825 : : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits,
826 [ # # ][ # # ]: 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "userSpaceOnUse" ) ) );
[ # # ]
827 : : }
828 : :
829 : : {
830 [ # # ]: 0 : SvXMLElementExport aElemLinearGradient( mrExport, XML_NAMESPACE_NONE, aXMLElemLinearGradient, sal_True, sal_True );
831 : :
832 : 0 : const Color aStartColor = ImplGetColorWithIntensity( rGradient.GetStartColor(), rGradient.GetStartIntensity() );
833 : 0 : const Color aEndColor = ImplGetColorWithIntensity( rGradient.GetEndColor(), rGradient.GetEndIntensity() );
834 : 0 : double fBorderOffset = rGradient.GetBorder() / 100.0;
835 : 0 : const sal_uInt16 nSteps = rGradient.GetSteps();
836 [ # # ]: 0 : if( rGradient.GetStyle() == GradientStyle_LINEAR )
837 : : {
838 : : // Emulate non-smooth gradient
839 [ # # ][ # # ]: 0 : if( 0 < nSteps && nSteps < 100 )
840 : : {
841 : 0 : double fOffsetStep = ( 1.0 - fBorderOffset ) / (double)nSteps;
842 [ # # ]: 0 : for( sal_uInt16 i = 0; i < nSteps; i++ ) {
843 : 0 : Color aColor = ImplGetGradientColor( aStartColor, aEndColor, i / (double) nSteps );
844 [ # # ]: 0 : ImplWriteGradientStop( aColor, fBorderOffset + ( i + 1 ) * fOffsetStep );
845 : 0 : aColor = ImplGetGradientColor( aStartColor, aEndColor, ( i + 1 ) / (double) nSteps );
846 [ # # ]: 0 : ImplWriteGradientStop( aColor, fBorderOffset + ( i + 1 ) * fOffsetStep );
847 : 0 : }
848 : : }
849 : : else
850 : : {
851 [ # # ]: 0 : ImplWriteGradientStop( aStartColor, fBorderOffset );
852 [ # # ]: 0 : ImplWriteGradientStop( aEndColor, 1.0 );
853 : : }
854 : : }
855 : : else
856 : : {
857 : 0 : fBorderOffset /= 2;
858 : : // Emulate non-smooth gradient
859 [ # # ][ # # ]: 0 : if( 0 < nSteps && nSteps < 100 )
860 : : {
861 : 0 : double fOffsetStep = ( 0.5 - fBorderOffset ) / (double)nSteps;
862 : : // Upper half
863 [ # # ]: 0 : for( sal_uInt16 i = 0; i < nSteps; i++ )
864 : : {
865 : 0 : Color aColor = ImplGetGradientColor( aEndColor, aStartColor, i / (double) nSteps );
866 [ # # ]: 0 : ImplWriteGradientStop( aColor, fBorderOffset + i * fOffsetStep );
867 : 0 : aColor = ImplGetGradientColor( aEndColor, aStartColor, (i + 1 ) / (double) nSteps );
868 [ # # ]: 0 : ImplWriteGradientStop( aColor, fBorderOffset + i * fOffsetStep );
869 : : }
870 : : // Lower half
871 [ # # ]: 0 : for( sal_uInt16 i = 0; i < nSteps; i++ )
872 : : {
873 : 0 : Color aColor = ImplGetGradientColor( aStartColor, aEndColor, i / (double) nSteps );
874 [ # # ]: 0 : ImplWriteGradientStop( aColor, 0.5 + (i + 1) * fOffsetStep );
875 : 0 : aColor = ImplGetGradientColor( aStartColor, aEndColor, (i + 1 ) / (double) nSteps );
876 [ # # ]: 0 : ImplWriteGradientStop( aColor, 0.5 + (i + 1) * fOffsetStep );
877 : 0 : }
878 : : }
879 : : else
880 : : {
881 [ # # ]: 0 : ImplWriteGradientStop( aEndColor, fBorderOffset );
882 [ # # ]: 0 : ImplWriteGradientStop( aStartColor, 0.5 );
883 [ # # ]: 0 : ImplWriteGradientStop( aEndColor, 1.0 - fBorderOffset );
884 : : }
885 [ # # ]: 0 : }
886 [ # # ]: 0 : }
887 : : }
888 : :
889 : 0 : ::rtl::OUString aGradientStyle;
890 [ # # ]: 0 : aGradientStyle += B2UCONST( "fill:" );
891 [ # # ]: 0 : aGradientStyle += B2UCONST( "url(#" );
892 : 0 : aGradientStyle += aGradientId;
893 [ # # ]: 0 : aGradientStyle += B2UCONST( ")" );
894 : :
895 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aGradientStyle );
896 [ # # ][ # # ]: 0 : ImplWritePolyPolygon( rPolyPoly, sal_False );
897 : : }
898 : 0 : }
899 : :
900 : 0 : void SVGActionWriter::ImplWriteGradientStop( const Color& rColor, double fOffset )
901 : : {
902 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, rtl::OUString::valueOf( fOffset ) );
903 : :
904 : 0 : ::rtl::OUString aStyle, aColor;
905 [ # # ]: 0 : aStyle += B2UCONST( "stop-color:" );
906 [ # # ]: 0 : SVGAttributeWriter::ImplGetColorStr ( rColor, aColor );
907 : 0 : aStyle += aColor;
908 : :
909 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aStyle );
910 : : {
911 [ # # ][ # # ]: 0 : SvXMLElementExport aElemStartStop( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True );
912 : 0 : }
913 : 0 : }
914 : :
915 : 0 : Color SVGActionWriter::ImplGetColorWithIntensity( const Color& rColor,
916 : : sal_uInt16 nIntensity )
917 : : {
918 : 0 : sal_uInt8 nNewRed = (sal_uInt8)( (long)rColor.GetRed() * nIntensity / 100L );
919 : 0 : sal_uInt8 nNewGreen = (sal_uInt8)( (long)rColor.GetGreen() * nIntensity / 100L );
920 : 0 : sal_uInt8 nNewBlue = (sal_uInt8)( (long)rColor.GetBlue() * nIntensity / 100L );
921 : 0 : return Color( nNewRed, nNewGreen, nNewBlue);
922 : : }
923 : :
924 : 0 : Color SVGActionWriter::ImplGetGradientColor( const Color& rStartColor,
925 : : const Color& rEndColor,
926 : : double fOffset )
927 : : {
928 : 0 : long nRedStep = rEndColor.GetRed() - rStartColor.GetRed();
929 : 0 : long nNewRed = rStartColor.GetRed() + (long)( nRedStep * fOffset );
930 [ # # ]: 0 : nNewRed = ( nNewRed < 0 ) ? 0 : ( nNewRed > 0xFF) ? 0xFF : nNewRed;
931 : :
932 : 0 : long nGreenStep = rEndColor.GetGreen() - rStartColor.GetGreen();
933 : 0 : long nNewGreen = rStartColor.GetGreen() + (long)( nGreenStep * fOffset );
934 [ # # ]: 0 : nNewGreen = ( nNewGreen < 0 ) ? 0 : ( nNewGreen > 0xFF) ? 0xFF : nNewGreen;
935 : :
936 : 0 : long nBlueStep = rEndColor.GetBlue() - rStartColor.GetBlue();
937 : 0 : long nNewBlue = rStartColor.GetBlue() + (long)( nBlueStep * fOffset );
938 [ # # ]: 0 : nNewBlue = ( nNewBlue < 0 ) ? 0 : ( nNewBlue > 0xFF) ? 0xFF : nNewBlue;
939 : :
940 : 0 : return Color( (sal_uInt8)nNewRed, (sal_uInt8)nNewGreen, (sal_uInt8)nNewBlue );
941 : : }
942 : :
943 : : // -----------------------------------------------------------------------------
944 : :
945 : 0 : void SVGActionWriter::ImplWriteMask( GDIMetaFile& rMtf,
946 : : const Point& rDestPt,
947 : : const Size& rDestSize,
948 : : const Gradient& rGradient,
949 : : sal_uInt32 nWriteFlags )
950 : : {
951 : 0 : Point aSrcPt( rMtf.GetPrefMapMode().GetOrigin() );
952 : 0 : const Size aSrcSize( rMtf.GetPrefSize() );
953 [ # # ]: 0 : const double fScaleX = aSrcSize.Width() ? (double) rDestSize.Width() / aSrcSize.Width() : 1.0;
954 [ # # ]: 0 : const double fScaleY = aSrcSize.Height() ? (double) rDestSize.Height() / aSrcSize.Height() : 1.0;
955 : : long nMoveX, nMoveY;
956 : :
957 [ # # ][ # # ]: 0 : if( fScaleX != 1.0 || fScaleY != 1.0 )
958 : : {
959 [ # # ]: 0 : rMtf.Scale( fScaleX, fScaleY );
960 : 0 : aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
961 : : }
962 : :
963 : 0 : nMoveX = rDestPt.X() - aSrcPt.X(), nMoveY = rDestPt.Y() - aSrcPt.Y();
964 : :
965 [ # # ][ # # ]: 0 : if( nMoveX || nMoveY )
966 [ # # ]: 0 : rMtf.Move( nMoveX, nMoveY );
967 : :
968 : 0 : ::rtl::OUString aMaskId;
969 [ # # ]: 0 : aMaskId += B2UCONST( "mask" );
970 : 0 : aMaskId += OUString::valueOf( mnCurMaskId++ );
971 : :
972 : : {
973 [ # # ]: 0 : SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True );
974 : :
975 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aMaskId );
976 : : {
977 [ # # ]: 0 : SvXMLElementExport aElemMask( mrExport, XML_NAMESPACE_NONE, aXMLElemMask, sal_True, sal_True );
978 : :
979 [ # # ][ # # ]: 0 : const PolyPolygon aPolyPolygon( PolyPolygon( Rectangle( rDestPt, rDestSize ) ) );
[ # # ][ # # ]
980 [ # # ]: 0 : Gradient aGradient( rGradient );
981 : :
982 : : // swap gradient stops to adopt SVG mask
983 : 0 : Color aTmpColor( aGradient.GetStartColor() );
984 : 0 : sal_uInt16 nTmpIntensity( aGradient.GetStartIntensity() );
985 [ # # ]: 0 : aGradient.SetStartColor( aGradient.GetEndColor() );
986 [ # # ]: 0 : aGradient.SetStartIntensity( aGradient.GetEndIntensity() ) ;
987 [ # # ]: 0 : aGradient.SetEndColor( aTmpColor );
988 [ # # ]: 0 : aGradient.SetEndIntensity( nTmpIntensity );
989 : :
990 [ # # ][ # # ]: 0 : ImplWriteGradientEx( aPolyPolygon, aGradient, nWriteFlags );
[ # # ][ # # ]
991 [ # # ]: 0 : }
992 : : }
993 : :
994 : 0 : ::rtl::OUString aMaskStyle;
995 [ # # ]: 0 : aMaskStyle += B2UCONST( "mask:url(#" );
996 : 0 : aMaskStyle += aMaskId;
997 [ # # ]: 0 : aMaskStyle += B2UCONST( ")" );
998 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aMaskStyle );
999 : :
1000 : : {
1001 [ # # ]: 0 : SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True );
1002 : :
1003 [ # # ]: 0 : mpVDev->Push();
1004 [ # # ]: 0 : ImplWriteActions( rMtf, nWriteFlags, NULL );
1005 [ # # ][ # # ]: 0 : mpVDev->Pop();
1006 : 0 : }
1007 : 0 : }
1008 : :
1009 : : // -----------------------------------------------------------------------------
1010 : :
1011 : 0 : void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
1012 : : const sal_Int32* pDXArray, long nWidth,
1013 : : sal_Bool bApplyMapping )
1014 : : {
1015 [ # # ]: 0 : const FontMetric aMetric( mpVDev->GetFontMetric() );
1016 : :
1017 [ # # ][ # # ]: 0 : bool bTextSpecial = aMetric.IsShadow() || aMetric.IsOutline() || (aMetric.GetRelief() != RELIEF_NONE);
[ # # ][ # # ]
[ # # ][ # # ]
1018 : :
1019 [ # # ]: 0 : if( !bTextSpecial )
1020 : : {
1021 [ # # ]: 0 : ImplWriteText( rPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1022 : : }
1023 : : else
1024 : : {
1025 [ # # ][ # # ]: 0 : if( aMetric.GetRelief() != RELIEF_NONE )
1026 : : {
1027 : 0 : Color aReliefColor( COL_LIGHTGRAY );
1028 : 0 : Color aTextColor( mpVDev->GetTextColor() );
1029 : :
1030 [ # # ]: 0 : if ( aTextColor.GetColor() == COL_BLACK )
1031 : 0 : aTextColor = Color( COL_WHITE );
1032 : :
1033 [ # # ]: 0 : if ( aTextColor.GetColor() == COL_WHITE )
1034 : 0 : aReliefColor = Color( COL_BLACK );
1035 : :
1036 : :
1037 : 0 : Point aPos( rPos );
1038 : 0 : Point aOffset( 6, 6 );
1039 : :
1040 [ # # ][ # # ]: 0 : if ( aMetric.GetRelief() == RELIEF_ENGRAVED )
1041 : : {
1042 : 0 : aPos -= aOffset;
1043 : : }
1044 : : else
1045 : : {
1046 : 0 : aPos += aOffset;
1047 : : }
1048 : :
1049 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, aReliefColor, bApplyMapping );
1050 [ # # ]: 0 : ImplWriteText( rPos, rText, pDXArray, nWidth, aTextColor, bApplyMapping );
1051 : : }
1052 : : else
1053 : : {
1054 [ # # ][ # # ]: 0 : if( aMetric.IsShadow() )
1055 : : {
1056 [ # # ]: 0 : long nOff = 1 + ((aMetric.GetLineHeight()-24)/24);
1057 [ # # ][ # # ]: 0 : if ( aMetric.IsOutline() )
1058 : 0 : nOff += 6;
1059 : :
1060 : 0 : Color aTextColor( mpVDev->GetTextColor() );
1061 : 0 : Color aShadowColor = Color( COL_BLACK );
1062 : :
1063 [ # # ][ # # ]: 0 : if ( (aTextColor.GetColor() == COL_BLACK) || (aTextColor.GetLuminance() < 8) )
[ # # ][ # # ]
1064 : 0 : aShadowColor = Color( COL_LIGHTGRAY );
1065 : :
1066 : 0 : Point aPos( rPos );
1067 : 0 : aPos += Point( nOff, nOff );
1068 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, aShadowColor, bApplyMapping );
1069 : :
1070 [ # # ][ # # ]: 0 : if( !aMetric.IsOutline() )
1071 : : {
1072 [ # # ]: 0 : ImplWriteText( rPos, rText, pDXArray, nWidth, aTextColor, bApplyMapping );
1073 : : }
1074 : : }
1075 : :
1076 [ # # ][ # # ]: 0 : if( aMetric.IsOutline() )
1077 : : {
1078 : 0 : Point aPos = rPos + Point( -6, -6 );
1079 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1080 : 0 : aPos = rPos + Point( +6, +6);
1081 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1082 : 0 : aPos = rPos + Point( -6, +0);
1083 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1084 : 0 : aPos = rPos + Point( -6, +6);
1085 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1086 : 0 : aPos = rPos + Point( +0, +6);
1087 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1088 : 0 : aPos = rPos + Point( +0, -6);
1089 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1090 : 0 : aPos = rPos + Point( +6, -1);
1091 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1092 : 0 : aPos = rPos + Point( +6, +0);
1093 [ # # ]: 0 : ImplWriteText( aPos, rText, pDXArray, nWidth, mpVDev->GetTextColor(), bApplyMapping );
1094 : :
1095 [ # # ]: 0 : ImplWriteText( rPos, rText, pDXArray, nWidth, Color( COL_WHITE ), bApplyMapping );
1096 : : }
1097 : : }
1098 [ # # ]: 0 : }
1099 : 0 : }
1100 : :
1101 : 0 : void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
1102 : : const sal_Int32* pDXArray, long nWidth,
1103 : : Color aTextColor, sal_Bool bApplyMapping )
1104 : : {
1105 : 0 : sal_Int32 nLen = rText.Len();
1106 : 0 : Size aNormSize;
1107 : 0 : Point aPos;
1108 : 0 : Point aBaseLinePos( rPos );
1109 [ # # ]: 0 : const FontMetric aMetric( mpVDev->GetFontMetric() );
1110 : 0 : const Font& rFont = mpVDev->GetFont();
1111 : :
1112 [ # # ][ # # ]: 0 : if( rFont.GetAlign() == ALIGN_TOP )
1113 [ # # ]: 0 : aBaseLinePos.Y() += aMetric.GetAscent();
1114 [ # # ][ # # ]: 0 : else if( rFont.GetAlign() == ALIGN_BOTTOM )
1115 [ # # ]: 0 : aBaseLinePos.Y() -= aMetric.GetDescent();
1116 : :
1117 [ # # ]: 0 : if( bApplyMapping )
1118 [ # # ]: 0 : ImplMap( rPos, aPos );
1119 : : else
1120 : 0 : aPos = rPos;
1121 : :
1122 [ # # ][ # # ]: 0 : boost::shared_array<sal_Int32> xTmpArray(new sal_Int32[nLen]);
1123 : : // get text sizes
1124 [ # # ]: 0 : if( pDXArray )
1125 : : {
1126 [ # # ]: 0 : aNormSize = Size( mpVDev->GetTextWidth( rText ), 0 );
1127 : 0 : memcpy(xTmpArray.get(), pDXArray, nLen * sizeof(sal_Int32));
1128 : : }
1129 : : else
1130 : : {
1131 [ # # ]: 0 : aNormSize = Size( mpVDev->GetTextArray( rText, xTmpArray.get() ), 0 );
1132 : : }
1133 : 0 : sal_Int32* pDX = xTmpArray.get();
1134 : :
1135 : : // if text is rotated, set transform matrix at new g element
1136 [ # # ][ # # ]: 0 : if( rFont.GetOrientation() )
1137 : : {
1138 : 0 : Point aRot( aPos );
1139 [ # # ]: 0 : String aTransform;
1140 : :
1141 [ # # ][ # # ]: 0 : aTransform = String( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "translate" ) ) );
[ # # ][ # # ]
1142 [ # # ]: 0 : aTransform += '(';
1143 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString::valueOf( aRot.X() ) );
[ # # ]
1144 [ # # ]: 0 : aTransform += ',';
1145 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString::valueOf( aRot.Y() ) );
[ # # ]
1146 [ # # ]: 0 : aTransform += ')';
1147 : :
1148 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " rotate" ) ) );
[ # # ][ # # ]
1149 [ # # ]: 0 : aTransform += '(';
1150 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString::valueOf( rFont.GetOrientation() * -0.1 ) );
[ # # ][ # # ]
1151 [ # # ]: 0 : aTransform += ')';
1152 : :
1153 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " translate" ) ) );
[ # # ][ # # ]
1154 [ # # ]: 0 : aTransform += '(';
1155 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString::valueOf( -aRot.X() ) );
[ # # ]
1156 [ # # ]: 0 : aTransform += ',';
1157 [ # # ][ # # ]: 0 : aTransform += String( ::rtl::OUString::valueOf( -aRot.Y() ) );
[ # # ]
1158 [ # # ]: 0 : aTransform += ')';
1159 : :
1160 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform );
[ # # ]
1161 : : }
1162 : :
1163 : :
1164 [ # # ]: 0 : mpContext->AddPaintAttr( COL_TRANSPARENT, aTextColor );
1165 : :
1166 : : // for each line of text there should be at least one group element
1167 [ # # ]: 0 : SvXMLElementExport aSVGGElem( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_False );
1168 : :
1169 : 0 : sal_Bool bIsPlaceholderField = sal_False;
1170 : :
1171 [ # # ]: 0 : if( mbIsPlacehlolderShape )
1172 : : {
1173 [ # # ]: 0 : OUString sTextContent = rText;
1174 : 0 : bIsPlaceholderField = sTextContent.match( sPlaceholderTag );
1175 : : // for a placeholder text field we export only one <text> svg element
1176 [ # # ]: 0 : if( bIsPlaceholderField )
1177 : : {
1178 : 0 : OUString sCleanTextContent;
1179 [ # # ][ # # ]: 0 : static const sal_Int32 nFrom = sPlaceholderTag.getLength();
1180 [ # # ]: 0 : if( sTextContent.getLength() > nFrom )
1181 : : {
1182 : 0 : sCleanTextContent = sTextContent.copy( nFrom );
1183 : : }
1184 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "PlaceholderText" ) );
1185 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) );
1186 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
1187 : : {
1188 [ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
1189 : : // At least for the single slide case we need really to export placeholder text
1190 [ # # ][ # # ]: 0 : mrExport.GetDocHandler()->characters( sCleanTextContent );
[ # # ]
1191 : 0 : }
1192 : 0 : }
1193 : : }
1194 : :
1195 [ # # ]: 0 : if( !bIsPlaceholderField )
1196 : : {
1197 [ # # ]: 0 : if( nLen > 1 )
1198 : : {
1199 [ # # ][ # # ]: 0 : aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rtl::OUString(rText.GetChar(nLen - 1)) );
[ # # ]
1200 : :
1201 [ # # ][ # # ]: 0 : if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) )
[ # # ][ # # ]
1202 : : {
1203 : : long i;
1204 : 0 : const double fFactor = (double) nWidth / aNormSize.Width();
1205 : :
1206 [ # # ]: 0 : for( i = 0; i < ( nLen - 1 ); i++ )
1207 : 0 : pDX[ i ] = FRound( pDX[ i ] * fFactor );
1208 : : }
1209 : : else
1210 : : {
1211 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( ::vcl::unohelper::CreateBreakIterator() );
1212 [ # # ][ # # ]: 0 : const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale();
1213 : 0 : sal_Int32 nCurPos = 0, nLastPos = 0, nX = aPos.X();
1214 : :
1215 : : // write single glyphs at absolute text positions
1216 [ # # ]: 0 : for( sal_Bool bCont = sal_True; bCont; )
1217 : : {
1218 : 0 : sal_Int32 nCount = 1;
1219 : :
1220 : 0 : nLastPos = nCurPos;
1221 [ # # ]: 0 : nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale,
1222 : : ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL,
1223 [ # # ][ # # ]: 0 : nCount, nCount );
1224 : :
1225 : 0 : nCount = nCurPos - nLastPos;
1226 [ # # ][ # # ]: 0 : bCont = ( nCurPos < rText.Len() ) && nCount;
1227 : :
1228 [ # # ]: 0 : if( nCount )
1229 : : {
1230 [ # # ][ # # ]: 0 : const ::rtl::OUString aGlyph( rText.Copy( nLastPos, nCount ) );
[ # # ]
1231 : :
1232 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) );
1233 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
1234 : :
1235 : : {
1236 [ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
1237 [ # # ][ # # ]: 0 : mrExport.GetDocHandler()->characters( aGlyph );
[ # # ]
1238 : : }
1239 : :
1240 [ # # ]: 0 : if( bCont )
1241 : 0 : nX = aPos.X() + pDX[ nCurPos - 1 ];
1242 : : }
1243 : 0 : }
1244 : : }
1245 : : }
1246 : : else
1247 : : {
1248 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) );
1249 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
1250 : :
1251 : : {
1252 [ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
1253 [ # # ][ # # ]: 0 : mrExport.GetDocHandler()->characters( rText );
[ # # ][ # # ]
1254 : : }
1255 : : }
1256 : : }
1257 : :
1258 : :
1259 [ # # ][ # # ]: 0 : if( !mrExport.IsUseNativeTextDecoration() )
1260 : : {
1261 [ # # ][ # # ]: 0 : if( rFont.GetStrikeout() != STRIKEOUT_NONE || rFont.GetUnderline() != UNDERLINE_NONE )
[ # # ][ # # ]
[ # # ]
1262 : : {
1263 [ # # ]: 0 : Polygon aPoly( 4 );
1264 [ # # ]: 0 : const long nLineHeight = Max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 );
1265 : :
1266 [ # # ][ # # ]: 0 : if( rFont.GetStrikeout() )
1267 : : {
1268 [ # # ]: 0 : const long nYLinePos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 );
1269 : :
1270 [ # # ][ # # ]: 0 : aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = nYLinePos - ( nLineHeight >> 1 );
1271 [ # # ][ # # ]: 0 : aPoly[ 1 ].X() = aBaseLinePos.X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y();
[ # # ]
1272 [ # # ][ # # ]: 0 : aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 0 ].Y() + nLineHeight - 1;
[ # # ][ # # ]
1273 [ # # ][ # # ]: 0 : aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y();
[ # # ][ # # ]
1274 : :
1275 [ # # ][ # # ]: 0 : ImplWritePolyPolygon( aPoly, sal_False );
[ # # ]
1276 : : }
1277 : :
1278 [ # # ][ # # ]: 0 : if( rFont.GetUnderline() )
1279 : : {
1280 : 0 : const long nYLinePos = aBaseLinePos.Y() + ( nLineHeight << 1 );
1281 : :
1282 [ # # ][ # # ]: 0 : aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = nYLinePos - ( nLineHeight >> 1 );
1283 [ # # ][ # # ]: 0 : aPoly[ 1 ].X() = aBaseLinePos.X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y();
[ # # ]
1284 [ # # ][ # # ]: 0 : aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 0 ].Y() + nLineHeight - 1;
[ # # ][ # # ]
1285 [ # # ][ # # ]: 0 : aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y();
[ # # ][ # # ]
1286 : :
1287 [ # # ][ # # ]: 0 : ImplWritePolyPolygon( aPoly, sal_False );
[ # # ]
1288 [ # # ]: 0 : }
1289 : : }
1290 [ # # ][ # # ]: 0 : }
[ # # ]
1291 : 0 : }
1292 : :
1293 : : // -----------------------------------------------------------------------------
1294 : :
1295 : 0 : void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx,
1296 : : const Point& rPt, const Size& rSz,
1297 : : const Point& rSrcPt, const Size& rSrcSz,
1298 : : sal_Bool bApplyMapping )
1299 : : {
1300 [ # # ]: 0 : if( !!rBmpEx )
1301 : : {
1302 [ # # ]: 0 : BitmapEx aBmpEx( rBmpEx );
1303 : 0 : Point aPoint = Point();
1304 [ # # ]: 0 : const Rectangle aBmpRect( aPoint, rBmpEx.GetSizePixel() );
1305 [ # # ]: 0 : const Rectangle aSrcRect( rSrcPt, rSrcSz );
1306 : :
1307 [ # # ][ # # ]: 0 : if( aSrcRect != aBmpRect )
1308 [ # # ]: 0 : aBmpEx.Crop( aSrcRect );
1309 : :
1310 [ # # ]: 0 : if( !!aBmpEx )
1311 : : {
1312 [ # # ]: 0 : SvMemoryStream aOStm( 65535, 65535 );
1313 : :
1314 [ # # ][ # # ]: 0 : if( GraphicConverter::Export( aOStm, rBmpEx, CVT_PNG ) == ERRCODE_NONE )
[ # # ][ # # ]
1315 : : {
1316 : 0 : Point aPt;
1317 : 0 : Size aSz;
1318 [ # # ][ # # ]: 0 : Sequence< sal_Int8 > aSeq( (sal_Int8*) aOStm.GetData(), aOStm.Tell() );
1319 : 0 : rtl::OUStringBuffer aBuffer;
1320 [ # # ]: 0 : aBuffer.appendAscii( "data:image/png;base64," );
1321 [ # # ]: 0 : ::sax::Converter::encodeBase64( aBuffer, aSeq );
1322 : :
1323 [ # # ]: 0 : if( bApplyMapping )
1324 : : {
1325 [ # # ]: 0 : ImplMap( rPt, aPt );
1326 [ # # ]: 0 : ImplMap( rSz, aSz );
1327 : : }
1328 : : else
1329 : : {
1330 : 0 : aPt = rPt;
1331 : 0 : aSz = rSz;
1332 : : }
1333 : :
1334 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::valueOf( aPt.X() ) );
1335 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::valueOf( aPt.Y() ) );
1336 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::valueOf( aSz.Width() ) );
1337 [ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::valueOf( aSz.Height() ) );
1338 [ # # ][ # # ]: 0 : mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, aBuffer.makeStringAndClear() );
1339 : : {
1340 [ # # ][ # # ]: 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemImage, sal_True, sal_True );
1341 [ # # ]: 0 : }
1342 [ # # ]: 0 : }
1343 [ # # ]: 0 : }
1344 : : }
1345 : 0 : }
1346 : :
1347 : : // -----------------------------------------------------------------------------
1348 : :
1349 : 0 : void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
1350 : : sal_uInt32 nWriteFlags,
1351 : : const ::rtl::OUString* pElementId )
1352 : : {
1353 [ # # ]: 0 : if( mnInnerMtfCount )
1354 : 0 : nWriteFlags |= SVGWRITER_NO_SHAPE_COMMENTS;
1355 : :
1356 : 0 : mbIsPlacehlolderShape = false;
1357 [ # # ][ # # ]: 0 : if( pElementId != NULL && ( *pElementId == sPlaceholderTag ) )
[ # # ]
1358 : : {
1359 : 0 : mbIsPlacehlolderShape = true;
1360 : : // since we utilize pElementId in an improper way we reset it to NULL before to go on
1361 : 0 : pElementId = NULL;
1362 : : }
1363 : :
1364 [ # # ]: 0 : for( sal_uLong nCurAction = 0, nCount = rMtf.GetActionSize(); nCurAction < nCount; nCurAction++ )
1365 : : {
1366 : 0 : const MetaAction* pAction = rMtf.GetAction( nCurAction );
1367 : 0 : const sal_uInt16 nType = pAction->GetType();
1368 : :
1369 [ # # # # : 0 : switch( nType )
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
1370 : : {
1371 : : case( META_PIXEL_ACTION ):
1372 : : {
1373 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1374 : : {
1375 : 0 : const MetaPixelAction* pA = (const MetaPixelAction*) pAction;
1376 : :
1377 : 0 : mpContext->AddPaintAttr( pA->GetColor(), pA->GetColor() );
1378 : 0 : ImplWriteLine( pA->GetPoint(), pA->GetPoint(), &pA->GetColor() );
1379 : : }
1380 : : }
1381 : 0 : break;
1382 : :
1383 : : case( META_POINT_ACTION ):
1384 : : {
1385 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1386 : : {
1387 : 0 : const MetaPointAction* pA = (const MetaPointAction*) pAction;
1388 : :
1389 : 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() );
1390 : 0 : ImplWriteLine( pA->GetPoint(), pA->GetPoint(), NULL );
1391 : : }
1392 : : }
1393 : 0 : break;
1394 : :
1395 : : case( META_LINE_ACTION ):
1396 : : {
1397 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1398 : : {
1399 : 0 : const MetaLineAction* pA = (const MetaLineAction*) pAction;
1400 : :
1401 : 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() );
1402 : 0 : ImplWriteLine( pA->GetStartPoint(), pA->GetEndPoint(), NULL );
1403 : : }
1404 : : }
1405 : 0 : break;
1406 : :
1407 : : case( META_RECT_ACTION ):
1408 : : {
1409 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1410 : : {
1411 : 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
1412 : 0 : ImplWriteRect( ( (const MetaRectAction*) pAction )->GetRect(), 0, 0 );
1413 : : }
1414 : : }
1415 : 0 : break;
1416 : :
1417 : : case( META_ROUNDRECT_ACTION ):
1418 : : {
1419 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1420 : : {
1421 : 0 : const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction;
1422 : :
1423 : 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
1424 : 0 : ImplWriteRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() );
1425 : : }
1426 : : }
1427 : 0 : break;
1428 : :
1429 : : case( META_ELLIPSE_ACTION ):
1430 : : {
1431 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1432 : : {
1433 : 0 : const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction;
1434 : 0 : const Rectangle& rRect = pA->GetRect();
1435 : :
1436 : 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
1437 [ # # ]: 0 : ImplWriteEllipse( rRect.Center(), rRect.GetWidth() >> 1, rRect.GetHeight() >> 1 );
1438 : : }
1439 : : }
1440 : 0 : break;
1441 : :
1442 : : case( META_ARC_ACTION ):
1443 : : case( META_PIE_ACTION ):
1444 : : case( META_CHORD_ACTION ):
1445 : : case( META_POLYGON_ACTION ):
1446 : : {
1447 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1448 : : {
1449 [ # # ]: 0 : Polygon aPoly;
1450 : :
1451 [ # # # # : 0 : switch( nType )
# ]
1452 : : {
1453 : : case( META_ARC_ACTION ):
1454 : : {
1455 : 0 : const MetaArcAction* pA = (const MetaArcAction*) pAction;
1456 [ # # ][ # # ]: 0 : aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC );
[ # # ]
1457 : : }
1458 : 0 : break;
1459 : :
1460 : : case( META_PIE_ACTION ):
1461 : : {
1462 : 0 : const MetaPieAction* pA = (const MetaPieAction*) pAction;
1463 [ # # ][ # # ]: 0 : aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE );
[ # # ]
1464 : : }
1465 : 0 : break;
1466 : :
1467 : : case( META_CHORD_ACTION ):
1468 : : {
1469 : 0 : const MetaChordAction* pA = (const MetaChordAction*) pAction;
1470 [ # # ][ # # ]: 0 : aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD );
[ # # ]
1471 : : }
1472 : 0 : break;
1473 : :
1474 : : case( META_POLYGON_ACTION ):
1475 [ # # ]: 0 : aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon();
1476 : 0 : break;
1477 : : }
1478 : :
1479 [ # # ][ # # ]: 0 : if( aPoly.GetSize() )
1480 : : {
1481 [ # # ]: 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
1482 [ # # ][ # # ]: 0 : ImplWritePolyPolygon( aPoly, sal_False );
[ # # ]
1483 [ # # ]: 0 : }
1484 : : }
1485 : : }
1486 : 0 : break;
1487 : :
1488 : : case( META_POLYLINE_ACTION ):
1489 : : {
1490 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1491 : : {
1492 : 0 : const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pAction;
1493 : 0 : const Polygon& rPoly = pA->GetPolygon();
1494 : :
1495 [ # # ]: 0 : if( rPoly.GetSize() )
1496 : : {
1497 [ # # ]: 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), Color( COL_TRANSPARENT ) );
1498 [ # # ]: 0 : ImplWritePolyPolygon( rPoly, sal_True );
1499 : : }
1500 : : }
1501 : : }
1502 : 0 : break;
1503 : :
1504 : : case( META_POLYPOLYGON_ACTION ):
1505 : : {
1506 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1507 : : {
1508 : 0 : const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pAction;
1509 : 0 : const PolyPolygon& rPolyPoly = pA->GetPolyPolygon();
1510 : :
1511 [ # # ]: 0 : if( rPolyPoly.Count() )
1512 : : {
1513 : 0 : mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
1514 : 0 : ImplWritePolyPolygon( rPolyPoly, sal_False );
1515 : : }
1516 : : }
1517 : : }
1518 : 0 : break;
1519 : :
1520 : : case( META_GRADIENT_ACTION ):
1521 : : {
1522 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1523 : : {
1524 : 0 : const MetaGradientAction* pA = (const MetaGradientAction*) pAction;
1525 [ # # ]: 0 : const Polygon aRectPoly( pA->GetRect() );
1526 [ # # ]: 0 : const PolyPolygon aRectPolyPoly( aRectPoly );
1527 : :
1528 [ # # ][ # # ]: 0 : ImplWriteGradientEx( aRectPolyPoly, pA->GetGradient(), nWriteFlags );
[ # # ]
1529 : : }
1530 : : }
1531 : 0 : break;
1532 : :
1533 : : case( META_GRADIENTEX_ACTION ):
1534 : : {
1535 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1536 : : {
1537 : 0 : const MetaGradientExAction* pA = (const MetaGradientExAction*) pAction;
1538 : 0 : ImplWriteGradientEx( pA->GetPolyPolygon(), pA->GetGradient(), nWriteFlags );
1539 : : }
1540 : : }
1541 : 0 : break;
1542 : :
1543 : : case META_HATCH_ACTION:
1544 : : {
1545 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1546 : : {
1547 : 0 : const MetaHatchAction* pA = (const MetaHatchAction*) pAction;
1548 : 0 : ImplWritePattern( pA->GetPolyPolygon(), &pA->GetHatch(), NULL, nWriteFlags );
1549 : : }
1550 : : }
1551 : 0 : break;
1552 : :
1553 : : case( META_TRANSPARENT_ACTION ):
1554 : : {
1555 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1556 : : {
1557 : 0 : const MetaTransparentAction* pA = (const MetaTransparentAction*) pAction;
1558 : 0 : const PolyPolygon& rPolyPoly = pA->GetPolyPolygon();
1559 : :
1560 [ # # ]: 0 : if( rPolyPoly.Count() )
1561 : : {
1562 : 0 : Color aNewLineColor( mpVDev->GetLineColor() ), aNewFillColor( mpVDev->GetFillColor() );
1563 : :
1564 [ # # ]: 0 : aNewLineColor.SetTransparency( sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) );
1565 [ # # ]: 0 : aNewFillColor.SetTransparency( sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) );
1566 : :
1567 [ # # ]: 0 : mpContext->AddPaintAttr( aNewLineColor, aNewFillColor );
1568 [ # # ]: 0 : ImplWritePolyPolygon( rPolyPoly, sal_False );
1569 : : }
1570 : : }
1571 : : }
1572 : 0 : break;
1573 : :
1574 : : case( META_FLOATTRANSPARENT_ACTION ):
1575 : : {
1576 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1577 : : {
1578 : 0 : const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction;
1579 [ # # ]: 0 : GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
1580 : 0 : ImplWriteMask( aTmpMtf, pA->GetPoint(), pA->GetSize(),
1581 [ # # ][ # # ]: 0 : pA->GetGradient(), nWriteFlags );
1582 : : }
1583 : : }
1584 : 0 : break;
1585 : :
1586 : : case( META_EPS_ACTION ):
1587 : : {
1588 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1589 : : {
1590 : 0 : const MetaEPSAction* pA = (const MetaEPSAction*) pAction;
1591 [ # # ]: 0 : const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() );
1592 : 0 : sal_Bool bFound = sal_False;
1593 : :
1594 [ # # ][ # # ]: 0 : for( sal_uInt32 k = 0, nCount2 = aGDIMetaFile.GetActionSize(); ( k < nCount2 ) && !bFound; ++k )
[ # # ][ # # ]
1595 : : {
1596 [ # # ]: 0 : const MetaAction* pSubstAct = aGDIMetaFile.GetAction( k );
1597 : :
1598 [ # # ]: 0 : if( pSubstAct->GetType() == META_BMPSCALE_ACTION )
1599 : : {
1600 : 0 : bFound = sal_True;
1601 : 0 : const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*) pSubstAct;
1602 : 0 : ImplWriteBmp( pBmpScaleAction->GetBitmap(),
1603 : 0 : pA->GetPoint(), pA->GetSize(),
1604 [ # # ][ # # ]: 0 : Point(), pBmpScaleAction->GetBitmap().GetSizePixel() );
[ # # ][ # # ]
1605 : : }
1606 [ # # ]: 0 : }
1607 : : }
1608 : : }
1609 : 0 : break;
1610 : :
1611 : : case( META_COMMENT_ACTION ):
1612 : : {
1613 : 0 : const MetaCommentAction* pA = (const MetaCommentAction*) pAction;
1614 [ # # ]: 0 : String aSkipComment;
1615 : :
1616 [ # # ][ # # ]: 0 : if( ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")) ) &&
[ # # ]
1617 : : ( nWriteFlags & SVGWRITER_WRITE_FILL ) )
1618 : : {
1619 : 0 : const MetaGradientExAction* pGradAction = NULL;
1620 : 0 : sal_Bool bDone = sal_False;
1621 : :
1622 [ # # ][ # # ]: 0 : while( !bDone && ( ++nCurAction < nCount ) )
[ # # ]
1623 : : {
1624 [ # # ]: 0 : pAction = rMtf.GetAction( nCurAction );
1625 : :
1626 [ # # ]: 0 : if( pAction->GetType() == META_GRADIENTEX_ACTION )
1627 : 0 : pGradAction = (const MetaGradientExAction*) pAction;
1628 [ # # # # ]: 0 : else if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
[ # # ]
1629 : 0 : ( ( (const MetaCommentAction*) pAction )->GetComment().
1630 : 0 : equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) ) )
1631 : : {
1632 : 0 : bDone = sal_True;
1633 : : }
1634 : : }
1635 : :
1636 [ # # ]: 0 : if( pGradAction )
1637 [ # # ]: 0 : ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), nWriteFlags );
1638 : : }
1639 [ # # ][ # # ]: 0 : else if( ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) ) &&
[ # # # # ]
[ # # ]
1640 : 0 : ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) &&
1641 : 0 : pA->GetDataSize() )
1642 : : {
1643 : : // write open shape in every case
1644 [ # # ]: 0 : if( mapCurShape.get() )
1645 : : {
1646 [ # # ]: 0 : ImplWriteShape( *mapCurShape );
1647 : 0 : mapCurShape.reset();
1648 : : }
1649 : :
1650 [ # # ]: 0 : SvMemoryStream aMemStm( (void*) pA->GetData(), pA->GetDataSize(), STREAM_READ );
1651 [ # # ]: 0 : SvtGraphicFill aFill;
1652 : :
1653 [ # # ]: 0 : aMemStm >> aFill;
1654 : :
1655 [ # # ]: 0 : sal_Bool bGradient = SvtGraphicFill::fillGradient == aFill.getFillType() &&
1656 [ # # ]: 0 : ( SvtGraphicFill::gradientLinear == aFill.getGradientType() ||
1657 [ # # ][ # # ]: 0 : SvtGraphicFill::gradientRadial == aFill.getGradientType() );
[ # # ][ # # ]
1658 [ # # ][ # # ]: 0 : sal_Bool bSkip = ( SvtGraphicFill::fillSolid == aFill.getFillType() || bGradient );
[ # # ]
1659 : :
1660 [ # # ]: 0 : if( bSkip )
1661 : : {
1662 [ # # ]: 0 : PolyPolygon aShapePolyPoly;
1663 : :
1664 [ # # ]: 0 : aFill.getPath( aShapePolyPoly );
1665 : :
1666 [ # # ][ # # ]: 0 : if( aShapePolyPoly.Count() )
1667 : : {
1668 [ # # ][ # # ]: 0 : mapCurShape.reset( new SVGShapeDescriptor );
1669 : :
1670 [ # # ]: 0 : if( pElementId )
1671 : 0 : mapCurShape->maId = *pElementId;
1672 : :
1673 [ # # ]: 0 : mapCurShape->maShapePolyPoly = aShapePolyPoly;
1674 [ # # ]: 0 : mapCurShape->maShapeFillColor = aFill.getFillColor();
1675 [ # # ][ # # ]: 0 : mapCurShape->maShapeFillColor.SetTransparency( (sal_uInt8) FRound( 255.0 * aFill.getTransparency() ) );
1676 : :
1677 [ # # ]: 0 : if( bGradient )
1678 : : {
1679 : : // step through following actions until the first Gradient/GradientEx action is found
1680 [ # # ][ # # ]: 0 : while( !mapCurShape->mapShapeGradient.get() && bSkip && ( ++nCurAction < nCount ) )
[ # # ][ # # ]
1681 : : {
1682 [ # # ]: 0 : pAction = rMtf.GetAction( nCurAction );
1683 : :
1684 [ # # # # ]: 0 : if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
[ # # ]
1685 : 0 : ( ( (const MetaCommentAction*) pAction )->GetComment().
1686 : 0 : equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) )
1687 : : {
1688 : 0 : bSkip = sal_False;
1689 : : }
1690 [ # # ]: 0 : else if( pAction->GetType() == META_GRADIENTEX_ACTION )
1691 : : {
1692 : 0 : mapCurShape->mapShapeGradient.reset( new Gradient(
1693 [ # # ][ # # ]: 0 : static_cast< const MetaGradientExAction* >( pAction )->GetGradient() ) );
1694 : : }
1695 [ # # ]: 0 : else if( pAction->GetType() == META_GRADIENT_ACTION )
1696 : : {
1697 : 0 : mapCurShape->mapShapeGradient.reset( new Gradient(
1698 [ # # ][ # # ]: 0 : static_cast< const MetaGradientAction* >( pAction )->GetGradient() ) );
1699 : : }
1700 : : }
1701 : : }
1702 : : }
1703 : : else
1704 [ # # ]: 0 : bSkip = sal_False;
1705 : : }
1706 : :
1707 : : // skip rest of comment
1708 [ # # ][ # # ]: 0 : while( bSkip && ( ++nCurAction < nCount ) )
[ # # ]
1709 : : {
1710 [ # # ]: 0 : pAction = rMtf.GetAction( nCurAction );
1711 : :
1712 [ # # # # ]: 0 : if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
[ # # ]
1713 : 0 : ( ( (const MetaCommentAction*) pAction )->GetComment().
1714 : 0 : equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_END")) ) )
1715 : : {
1716 : 0 : bSkip = sal_False;
1717 : : }
1718 [ # # ][ # # ]: 0 : }
1719 : : }
1720 [ # # ][ # # ]: 0 : else if( ( pA->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_BEGIN")) ) &&
[ # # # # ]
[ # # ]
1721 : 0 : ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) &&
1722 : 0 : pA->GetDataSize() )
1723 : : {
1724 [ # # ]: 0 : SvMemoryStream aMemStm( (void*) pA->GetData(), pA->GetDataSize(), STREAM_READ );
1725 [ # # ]: 0 : SvtGraphicStroke aStroke;
1726 [ # # ][ # # ]: 0 : PolyPolygon aStartArrow, aEndArrow;
1727 : :
1728 [ # # ]: 0 : aMemStm >> aStroke;
1729 [ # # ]: 0 : aStroke.getStartArrow( aStartArrow );
1730 [ # # ]: 0 : aStroke.getEndArrow( aEndArrow );
1731 : :
1732 : : // Currently no support for strokes with start/end arrow(s)
1733 [ # # ][ # # ]: 0 : sal_Bool bSkip = ( !aStartArrow.Count() && !aEndArrow.Count() );
[ # # ][ # # ]
1734 : :
1735 [ # # ]: 0 : if( bSkip )
1736 : : {
1737 [ # # ]: 0 : if( !mapCurShape.get() )
1738 : : {
1739 [ # # ]: 0 : Polygon aPoly;
1740 : :
1741 [ # # ][ # # ]: 0 : mapCurShape.reset( new SVGShapeDescriptor );
1742 : :
1743 [ # # ]: 0 : if( pElementId )
1744 : 0 : mapCurShape->maId = *pElementId;
1745 : :
1746 [ # # ]: 0 : aStroke.getPath( aPoly );
1747 [ # # ][ # # ]: 0 : mapCurShape->maShapePolyPoly = aPoly;
[ # # ][ # # ]
1748 : : }
1749 : :
1750 : 0 : mapCurShape->maShapeLineColor = mpVDev->GetLineColor();
1751 [ # # ][ # # ]: 0 : mapCurShape->maShapeLineColor.SetTransparency( (sal_uInt8) FRound( aStroke.getTransparency() * 255.0 ) );
1752 [ # # ]: 0 : mapCurShape->mnStrokeWidth = FRound( aStroke.getStrokeWidth() );
1753 [ # # ]: 0 : aStroke.getDashArray( mapCurShape->maDashArray );
1754 : : }
1755 : :
1756 : : // write open shape in every case
1757 [ # # ]: 0 : if( mapCurShape.get() )
1758 : : {
1759 [ # # ]: 0 : ImplWriteShape( *mapCurShape );
1760 : 0 : mapCurShape.reset();
1761 : : }
1762 : :
1763 : : // skip rest of comment
1764 [ # # ][ # # ]: 0 : while( bSkip && ( ++nCurAction < nCount ) )
[ # # ]
1765 : : {
1766 [ # # ]: 0 : pAction = rMtf.GetAction( nCurAction );
1767 : :
1768 [ # # # # ]: 0 : if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
[ # # ]
1769 : 0 : ( ( (const MetaCommentAction*) pAction )->GetComment().
1770 : 0 : equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XPATHSTROKE_SEQ_END")) ) )
1771 : : {
1772 : 0 : bSkip = sal_False;
1773 : : }
1774 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1775 [ # # ]: 0 : }
1776 : : }
1777 : 0 : break;
1778 : :
1779 : : case( META_BMP_ACTION ):
1780 : : {
1781 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1782 : : {
1783 : 0 : const MetaBmpAction* pA = (const MetaBmpAction*) pAction;
1784 : :
1785 : 0 : ImplWriteBmp( pA->GetBitmap(),
1786 [ # # ]: 0 : pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ),
1787 [ # # # # ]: 0 : Point(), pA->GetBitmap().GetSizePixel() );
[ # # ][ # # ]
1788 : : }
1789 : : }
1790 : 0 : break;
1791 : :
1792 : : case( META_BMPSCALE_ACTION ):
1793 : : {
1794 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1795 : : {
1796 : 0 : const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction;
1797 : :
1798 : 0 : ImplWriteBmp( pA->GetBitmap(),
1799 : 0 : pA->GetPoint(), pA->GetSize(),
1800 [ # # ][ # # ]: 0 : Point(), pA->GetBitmap().GetSizePixel() );
[ # # ]
1801 : : }
1802 : : }
1803 : 0 : break;
1804 : :
1805 : : case( META_BMPSCALEPART_ACTION ):
1806 : : {
1807 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1808 : : {
1809 : 0 : const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction;
1810 : :
1811 : 0 : ImplWriteBmp( pA->GetBitmap(),
1812 : 0 : pA->GetDestPoint(), pA->GetDestSize(),
1813 [ # # ]: 0 : pA->GetSrcPoint(), pA->GetSrcSize() );
1814 : : }
1815 : : }
1816 : 0 : break;
1817 : :
1818 : : case( META_BMPEX_ACTION ):
1819 : : {
1820 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1821 : : {
1822 : 0 : const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction;
1823 : :
1824 : 0 : ImplWriteBmp( pA->GetBitmapEx(),
1825 : 0 : pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ),
1826 [ # # # # ]: 0 : Point(), pA->GetBitmapEx().GetSizePixel() );
1827 : : }
1828 : : }
1829 : 0 : break;
1830 : :
1831 : : case( META_BMPEXSCALE_ACTION ):
1832 : : {
1833 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1834 : : {
1835 : 0 : const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction;
1836 : :
1837 : 0 : ImplWriteBmp( pA->GetBitmapEx(),
1838 : 0 : pA->GetPoint(), pA->GetSize(),
1839 [ # # ]: 0 : Point(), pA->GetBitmapEx().GetSizePixel() );
1840 : : }
1841 : : }
1842 : 0 : break;
1843 : :
1844 : : case( META_BMPEXSCALEPART_ACTION ):
1845 : : {
1846 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1847 : : {
1848 : 0 : const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction;
1849 : :
1850 : 0 : ImplWriteBmp( pA->GetBitmapEx(),
1851 : 0 : pA->GetDestPoint(), pA->GetDestSize(),
1852 : 0 : pA->GetSrcPoint(), pA->GetSrcSize() );
1853 : : }
1854 : : }
1855 : 0 : break;
1856 : :
1857 : : case( META_TEXT_ACTION ):
1858 : : {
1859 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_TEXT )
1860 : : {
1861 : 0 : const MetaTextAction* pA = (const MetaTextAction*) pAction;
1862 [ # # ][ # # ]: 0 : const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
[ # # ]
1863 : :
1864 [ # # ]: 0 : if( aText.Len() )
1865 : : {
1866 [ # # ]: 0 : Font aFont( mpVDev->GetFont() );
1867 : 0 : Size aSz;
1868 : :
1869 [ # # ][ # # ]: 0 : ImplMap( Size( 0, aFont.GetHeight() ), aSz );
1870 : :
1871 [ # # ]: 0 : aFont.SetHeight( aSz.Height() );
1872 : : // lead to a browser error since it duplicates the stroke and
1873 : : // the fill attributes on the first glyph of each line when
1874 : : // the text font is the same
1875 : : //mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() );
1876 [ # # ]: 0 : mpContext->SetFontAttr( aFont );
1877 [ # # ][ # # ]: 0 : ImplWriteText( pA->GetPoint(), aText, NULL, 0 );
1878 [ # # ]: 0 : }
1879 : : }
1880 : : }
1881 : 0 : break;
1882 : :
1883 : : case( META_TEXTRECT_ACTION ):
1884 : : {
1885 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_TEXT )
1886 : : {
1887 : 0 : const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction;
1888 : :
1889 [ # # ]: 0 : if (!pA->GetText().isEmpty())
1890 : : {
1891 [ # # ]: 0 : Font aFont( mpVDev->GetFont() );
1892 : 0 : Size aSz;
1893 : :
1894 [ # # ][ # # ]: 0 : ImplMap( Size( 0, aFont.GetHeight() ), aSz );
1895 : :
1896 [ # # ]: 0 : aFont.SetHeight( aSz.Height() );
1897 : : //mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() );
1898 [ # # ]: 0 : mpContext->SetFontAttr( aFont );
1899 [ # # ][ # # ]: 0 : ImplWriteText( pA->GetRect().TopLeft(), pA->GetText(), NULL, 0 );
[ # # ][ # # ]
1900 : : }
1901 : : }
1902 : : }
1903 : 0 : break;
1904 : :
1905 : : case( META_TEXTARRAY_ACTION ):
1906 : : {
1907 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_TEXT )
1908 : : {
1909 : 0 : const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction;
1910 [ # # ][ # # ]: 0 : const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
[ # # ]
1911 : :
1912 [ # # ]: 0 : if( aText.Len() )
1913 : : {
1914 [ # # ]: 0 : Font aFont( mpVDev->GetFont() );
1915 : 0 : Size aSz;
1916 : :
1917 [ # # ][ # # ]: 0 : ImplMap( Size( 0, aFont.GetHeight() ), aSz );
1918 : :
1919 [ # # ]: 0 : aFont.SetHeight( aSz.Height() );
1920 : : //mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() );
1921 [ # # ]: 0 : mpContext->SetFontAttr( aFont );
1922 [ # # ][ # # ]: 0 : ImplWriteText( pA->GetPoint(), aText, pA->GetDXArray(), 0 );
1923 [ # # ]: 0 : }
1924 : : }
1925 : : }
1926 : 0 : break;
1927 : :
1928 : : case( META_STRETCHTEXT_ACTION ):
1929 : : {
1930 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_TEXT )
1931 : : {
1932 : 0 : const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction;
1933 [ # # ][ # # ]: 0 : const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
[ # # ]
1934 : :
1935 [ # # ]: 0 : if( aText.Len() )
1936 : : {
1937 [ # # ]: 0 : Font aFont( mpVDev->GetFont() );
1938 : 0 : Size aSz;
1939 : :
1940 [ # # ][ # # ]: 0 : ImplMap( Size( 0, aFont.GetHeight() ), aSz );
1941 : :
1942 [ # # ]: 0 : aFont.SetHeight( aSz.Height() );
1943 : : //mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() );
1944 [ # # ]: 0 : mpContext->SetFontAttr( aFont );
1945 [ # # ][ # # ]: 0 : ImplWriteText( pA->GetPoint(), aText, NULL, pA->GetWidth() );
1946 [ # # ]: 0 : }
1947 : : }
1948 : : }
1949 : 0 : break;
1950 : :
1951 : : case( META_RENDERGRAPHIC_ACTION ):
1952 : : {
1953 [ # # ]: 0 : if( nWriteFlags & SVGWRITER_WRITE_FILL )
1954 : : {
1955 : : // TODO KA: try to embed the native data in case the RenderGraphic
1956 : : // contains valid SVG data (MimeType "image/svg+xml")
1957 : : // => incorporate 'use' or 'image' element (KA 01/2011)
1958 : 0 : const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pAction;
1959 [ # # ]: 0 : const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() );
1960 : 0 : const Point aPointPixel;
1961 [ # # ]: 0 : const Size aSizePixel( mpVDev->LogicToPixel( pA->GetSize() ) );
1962 [ # # ][ # # ]: 0 : const BitmapEx aBmpEx( aRasterizer.Rasterize( aSizePixel ) );
1963 : :
1964 [ # # ][ # # ]: 0 : ImplWriteBmp( aBmpEx, pA->GetPoint(), pA->GetSize(), aPointPixel, aBmpEx.GetSizePixel() );
[ # # ]
1965 : : }
1966 : : }
1967 : 0 : break;
1968 : :
1969 : : case( META_CLIPREGION_ACTION ):
1970 : : case( META_ISECTRECTCLIPREGION_ACTION ):
1971 : : case( META_ISECTREGIONCLIPREGION_ACTION ):
1972 : : case( META_MOVECLIPREGION_ACTION ):
1973 : : {
1974 : 0 : ( (MetaAction*) pAction )->Execute( mpVDev );
1975 : 0 : mbClipAttrChanged = sal_True;
1976 : : }
1977 : 0 : break;
1978 : :
1979 : : case( META_REFPOINT_ACTION ):
1980 : : case( META_MAPMODE_ACTION ):
1981 : : case( META_LINECOLOR_ACTION ):
1982 : : case( META_FILLCOLOR_ACTION ):
1983 : : case( META_TEXTLINECOLOR_ACTION ):
1984 : : case( META_TEXTFILLCOLOR_ACTION ):
1985 : : case( META_TEXTCOLOR_ACTION ):
1986 : : case( META_TEXTALIGN_ACTION ):
1987 : : case( META_FONT_ACTION ):
1988 : : case( META_PUSH_ACTION ):
1989 : : case( META_POP_ACTION ):
1990 : : case( META_LAYOUTMODE_ACTION ):
1991 : : {
1992 : 0 : ( (MetaAction*) pAction )->Execute( mpVDev );
1993 : : }
1994 : 0 : break;
1995 : :
1996 : : case( META_RASTEROP_ACTION ):
1997 : : case( META_MASK_ACTION ):
1998 : : case( META_MASKSCALE_ACTION ):
1999 : : case( META_MASKSCALEPART_ACTION ):
2000 : : case( META_WALLPAPER_ACTION ):
2001 : : case( META_TEXTLINE_ACTION ):
2002 : : {
2003 : : // !!! >>> we don't want to support these actions
2004 : : }
2005 : 0 : break;
2006 : :
2007 : : default:
2008 : : OSL_FAIL( "SVGActionWriter::ImplWriteActions: unsupported MetaAction #" );
2009 : 0 : break;
2010 : : }
2011 : : }
2012 : 0 : }
2013 : :
2014 : : // -----------------------------------------------------------------------------
2015 : :
2016 : 0 : void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm,
2017 : : const Size& rSize100thmm,
2018 : : const GDIMetaFile& rMtf,
2019 : : sal_uInt32 nWriteFlags,
2020 : : const ::rtl::OUString* pElementId )
2021 : : {
2022 [ # # ]: 0 : MapMode aMapMode( rMtf.GetPrefMapMode() );
2023 : 0 : Size aPrefSize( rMtf.GetPrefSize() );
2024 [ # # ]: 0 : Fraction aFractionX( aMapMode.GetScaleX() );
2025 [ # # ]: 0 : Fraction aFractionY( aMapMode.GetScaleY() );
2026 : :
2027 [ # # ]: 0 : mpVDev->Push();
2028 : :
2029 [ # # ][ # # ]: 0 : Size aSize( OutputDevice::LogicToLogic( rSize100thmm, MAP_100TH_MM, aMapMode ) );
[ # # ]
2030 [ # # ][ # # ]: 0 : aMapMode.SetScaleX( aFractionX *= Fraction( aSize.Width(), aPrefSize.Width() ) );
[ # # ]
2031 [ # # ][ # # ]: 0 : aMapMode.SetScaleY( aFractionY *= Fraction( aSize.Height(), aPrefSize.Height() ) );
[ # # ]
2032 : :
2033 [ # # ][ # # ]: 0 : Point aOffset( OutputDevice::LogicToLogic( rPos100thmm, MAP_100TH_MM, aMapMode ) );
[ # # ]
2034 [ # # ]: 0 : aMapMode.SetOrigin( aOffset += aMapMode.GetOrigin() );
2035 : :
2036 [ # # ]: 0 : mpVDev->SetMapMode( aMapMode );
2037 [ # # ]: 0 : ImplAcquireContext();
2038 : :
2039 : 0 : mapCurShape.reset();
2040 : :
2041 [ # # ]: 0 : ImplWriteActions( rMtf, nWriteFlags, pElementId );
2042 : :
2043 : : // draw open shape that doesn't have a border
2044 [ # # ]: 0 : if( mapCurShape.get() )
2045 : : {
2046 [ # # ]: 0 : ImplWriteShape( *mapCurShape );
2047 : 0 : mapCurShape.reset();
2048 : : }
2049 : :
2050 [ # # ]: 0 : ImplReleaseContext();
2051 [ # # ][ # # ]: 0 : mpVDev->Pop();
2052 [ + - ][ + - ]: 18 : }
2053 : :
2054 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|