1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _SVGACTION_HXX
29 #define _SVGACTION_HXX
41 NMSP_RTL::OUString maString
;
42 sal_Unicode
* mpBuffer
;
50 FastString( sal_uInt32 nInitLen
= 2048, sal_uInt32 nIncrement
= 2048 );
51 FastString( sal_Char
* pBufferForBase64Encoding
, sal_uInt32 nBufLen
);
54 FastString
& operator+=( const NMSP_RTL::OUString
& rStr
);
56 const NMSP_RTL::OUString
& GetString() const;
57 sal_Bool
GetFirstPartString( const sal_uInt32 nPartLen
, NMSP_RTL::OUString
& rPartString
);
58 sal_Bool
GetNextPartString( const sal_uInt32 nPartLen
, NMSP_RTL::OUString
& rPartString
);
60 sal_uInt32
GetLength() const { return mnCurLen
; }
61 void Clear() { mnCurLen
= 0, maString
= NMSP_RTL::OUString(); }
64 // ----------------------
65 // - SVGAttributeWriter -
66 // ----------------------
68 class SVGActionWriter
;
70 class SVGAttributeWriter
77 SVGActionWriter
& mrParent
;
78 SvXMLExport
& mrExport
;
79 SvXMLElementExport
* mpElemFont
;
80 SvXMLElementExport
* mpElemPaint
;
86 SVGAttributeWriter( SVGActionWriter
& rParent
, SvXMLExport
& rExport
);
87 virtual ~SVGAttributeWriter();
89 NMSP_RTL::OUString
GetFontStyle( const Font
& rFont
);
90 NMSP_RTL::OUString
GetPaintStyle( const Color
& rLineColor
, const Color
& rFillColor
);
92 void SetFontAttr( const Font
& rFont
);
93 void SetPaintAttr( const Color
& rLineColor
, const Color
& rFillColor
);
96 // -------------------
97 // - SVGActionWriter -
98 // -------------------
100 class SVGAttributeWriter
;
104 class SVGActionWriter
106 friend class SVGAttributeWriter
;
110 Stack maContextStack
;
111 SvXMLExport
& mrExport
;
112 const GDIMetaFile
& mrMtf
;
113 SVGAttributeWriter
* mpContext
;
114 VirtualDevice
* mpVDev
;
115 MapMode maTargetMapMode
;
116 sal_Int32 mnCurClipId
;
117 sal_Bool mbDestroyVDev
;
118 sal_Bool mbPaintAttrChanged
;
119 sal_Bool mbFontAttrChanged
;
120 sal_Bool mbClipAttrChanged
;
121 sal_Bool mbDoublePoints
;
123 SVGAttributeWriter
* ImplAcquireContext() { maContextStack
.Push( mpContext
= new SVGAttributeWriter( *this, mrExport
) ); return mpContext
; }
124 void ImplReleaseContext() { delete (SVGAttributeWriter
*) maContextStack
.Pop(); mpContext
= (SVGAttributeWriter
*) maContextStack
.Top(); }
126 long ImplMap( sal_Int32 nVal
) const;
127 Point
ImplMap( const Point
& rPt
) const;
128 Size
ImplMap( const Size
& rSz
) const;
129 inline Rectangle
ImplMap( const Rectangle
& rRect
) const { return Rectangle( ImplMap( rRect
.TopLeft() ), ImplMap( rRect
.GetSize() ) ); }
131 void ImplWriteLine( const Point
& rPt1
, const Point
& rPt2
, const Color
* pLineColor
= NULL
, const NMSP_RTL::OUString
* pStyle
= NULL
);
132 void ImplWriteRect( const Rectangle
& rRect
, long nRadX
= 0, long nRadY
= 0, const NMSP_RTL::OUString
* pStyle
= NULL
);
133 void ImplWriteEllipse( const Point
& rCenter
, long nRadX
, long nRadY
, const NMSP_RTL::OUString
* pStyle
= NULL
);
134 void ImplWritePolygon( const Polygon
& rPoly
, sal_Bool bLineOnly
, const NMSP_RTL::OUString
* pStyle
= NULL
);
135 void ImplWritePolyPolygon( const PolyPolygon
& rPolyPoly
, sal_Bool bLineOnly
, const NMSP_RTL::OUString
* pStyle
= NULL
);
136 void ImplWriteGradientEx( const PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
, const NMSP_RTL::OUString
* pStyle
= NULL
);
137 void ImplWriteText( const Point
& rPos
, const String
& rText
, const sal_Int32
* pDXArray
, long nWidth
, const NMSP_RTL::OUString
* pStyle
= NULL
);
138 void ImplWriteBmp( const BitmapEx
& rBmpEx
, const Point
& rPt
, const Size
& rSz
, const Point
& rSrcPt
, const Size
& rSrcSz
, const NMSP_RTL::OUString
* pStyle
= NULL
);
140 void ImplCheckFontAttributes();
141 void ImplCheckPaintAttributes();
143 void ImplWriteActions( const GDIMetaFile
& rMtf
, const NMSP_RTL::OUString
* pStyle
= NULL
);
145 sal_Int32
ImplGetNextClipId() { return mnCurClipId
++; }
151 static NMSP_RTL::OUString
GetValueString( sal_Int32 nVal
, sal_Bool bDoublePoints
);
155 SVGActionWriter( SvXMLExport
& rExport
, const GDIMetaFile
& rMtf
,
156 VirtualDevice
* pParentVDev
= NULL
,
157 sal_Bool bWriteDoublePoints
= sal_False
);
158 virtual ~SVGActionWriter();
160 const VirtualDevice
& GetVDev() const { return *mpVDev
; }
161 BOOL
HasDoublePoints() const { return mbDoublePoints
; }