update dev300-m58
[ooovba.git] / extensions / source / svg / svgaction.hxx
blob2f893c3fc414cc4d44c9c9386ff6122e4ef85a1d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svgaction.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVGACTION_HXX
32 #define _SVGACTION_HXX
34 #include "svgcom.hxx"
36 // --------------
37 // - FastString -
38 // --------------
40 class FastString
42 private:
44 NMSP_RTL::OUString maString;
45 sal_Unicode* mpBuffer;
46 sal_uInt32 mnBufLen;
47 sal_uInt32 mnCurLen;
48 sal_uInt32 mnBufInc;
49 sal_uInt32 mnPartPos;
51 public:
53 FastString( sal_uInt32 nInitLen = 2048, sal_uInt32 nIncrement = 2048 );
54 FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen );
55 ~FastString();
57 FastString& operator+=( const NMSP_RTL::OUString& rStr );
59 const NMSP_RTL::OUString& GetString() const;
60 sal_Bool GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString );
61 sal_Bool GetNextPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString );
63 sal_uInt32 GetLength() const { return mnCurLen; }
64 void Clear() { mnCurLen = 0, maString = NMSP_RTL::OUString(); }
67 // ----------------------
68 // - SVGAttributeWriter -
69 // ----------------------
71 class SVGActionWriter;
73 class SVGAttributeWriter
75 private:
77 Font maCurFont;
78 Color maCurLineColor;
79 Color maCurFillColor;
80 SVGActionWriter& mrParent;
81 SvXMLExport& mrExport;
82 SvXMLElementExport* mpElemFont;
83 SvXMLElementExport* mpElemPaint;
85 SVGAttributeWriter();
87 public:
89 SVGAttributeWriter( SVGActionWriter& rParent, SvXMLExport& rExport );
90 virtual ~SVGAttributeWriter();
92 NMSP_RTL::OUString GetFontStyle( const Font& rFont );
93 NMSP_RTL::OUString GetPaintStyle( const Color& rLineColor, const Color& rFillColor );
95 void SetFontAttr( const Font& rFont );
96 void SetPaintAttr( const Color& rLineColor, const Color& rFillColor );
99 // -------------------
100 // - SVGActionWriter -
101 // -------------------
103 class SVGAttributeWriter;
104 class SvXMLExport;
105 class GDIMetaFile;
107 class SVGActionWriter
109 friend class SVGAttributeWriter;
111 private:
113 Stack maContextStack;
114 SvXMLExport& mrExport;
115 const GDIMetaFile& mrMtf;
116 SVGAttributeWriter* mpContext;
117 VirtualDevice* mpVDev;
118 MapMode maTargetMapMode;
119 sal_Int32 mnCurClipId;
120 sal_Bool mbDestroyVDev;
121 sal_Bool mbPaintAttrChanged;
122 sal_Bool mbFontAttrChanged;
123 sal_Bool mbClipAttrChanged;
124 sal_Bool mbDoublePoints;
126 SVGAttributeWriter* ImplAcquireContext() { maContextStack.Push( mpContext = new SVGAttributeWriter( *this, mrExport ) ); return mpContext; }
127 void ImplReleaseContext() { delete (SVGAttributeWriter*) maContextStack.Pop(); mpContext = (SVGAttributeWriter*) maContextStack.Top(); }
129 long ImplMap( sal_Int32 nVal ) const;
130 Point ImplMap( const Point& rPt ) const;
131 Size ImplMap( const Size& rSz ) const;
132 inline Rectangle ImplMap( const Rectangle& rRect ) const { return Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) ); }
134 void ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor = NULL, const NMSP_RTL::OUString* pStyle = NULL );
135 void ImplWriteRect( const Rectangle& rRect, long nRadX = 0, long nRadY = 0, const NMSP_RTL::OUString* pStyle = NULL );
136 void ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, const NMSP_RTL::OUString* pStyle = NULL );
137 void ImplWritePolygon( const Polygon& rPoly, sal_Bool bLineOnly, const NMSP_RTL::OUString* pStyle = NULL );
138 void ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, const NMSP_RTL::OUString* pStyle = NULL );
139 void ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, const NMSP_RTL::OUString* pStyle = NULL );
140 void ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, const NMSP_RTL::OUString* pStyle = NULL );
141 void ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, const NMSP_RTL::OUString* pStyle = NULL );
143 void ImplCheckFontAttributes();
144 void ImplCheckPaintAttributes();
146 void ImplWriteActions( const GDIMetaFile& rMtf, const NMSP_RTL::OUString* pStyle = NULL );
148 sal_Int32 ImplGetNextClipId() { return mnCurClipId++; }
150 SVGActionWriter();
152 public:
154 static NMSP_RTL::OUString GetValueString( sal_Int32 nVal, sal_Bool bDoublePoints );
156 public:
158 SVGActionWriter( SvXMLExport& rExport, const GDIMetaFile& rMtf,
159 VirtualDevice* pParentVDev = NULL,
160 sal_Bool bWriteDoublePoints = sal_False );
161 virtual ~SVGActionWriter();
163 const VirtualDevice& GetVDev() const { return *mpVDev; }
164 BOOL HasDoublePoints() const { return mbDoublePoints; }
167 #endif