20#ifndef KARBONAIPARSERBASE_H
21#define KARBONAIPARSERBASE_H
23#include <aiparserbase.h>
31#include <core/vcomposite.h>
32#include <core/vdocument.h>
33#include <core/vlayer.h>
34#include <core/vgroup.h>
35#include <core/vfill.h>
36#include <core/vstroke.h>
39#include <tqptrstack.h>
44typedef TQPair<TQString,TQString> Parameter;
45typedef TQPtrList<Parameter> Parameters;
46typedef TQPtrList<PathElement> PathElements;
48typedef enum { POT_Filled = 1, POT_Stroked = 2, POT_FilledStroked = 3, POT_Clip = 4, POT_Ignore = 8, POT_Leave = -1, POT_Other = 0 } PathOutputType;
49typedef enum { PTT_Output = 1, PTT_Combine = 2 } PathTransferType;
53class KarbonAIParserBase;
54class KarbonGStateHandler;
55class KarbonStructureHandler;
56class KarbonPathHandler;
57class KarbonDocumentHandler;
59class KarbonDocumentHandler :
public DocumentHandlerBase
62 KarbonAIParserBase *delegate;
64 KarbonDocumentHandler (KarbonAIParserBase *delegate) : DocumentHandlerBase () { this->delegate = delegate; }
66 void gotBoundingBox (
int llx,
int lly,
int urx,
int ury);
67 void gotCreationDate (
const char *val1,
const char *val2);
68 void gotProcessColors (
int colors);
71class KarbonGStateHandler :
public GStateHandlerBase
74 KarbonAIParserBase *delegate;
76 KarbonGStateHandler (KarbonAIParserBase *delegate) : GStateHandlerBase() { this->delegate = delegate; }
78 void gotFillColor (AIColor &color);
79 void gotStrokeColor (AIColor &color);
81 void gotFlatness (
double val);
82 void gotLineWidth (
double val);
83 void gotLineCaps (
int val);
84 void gotLineJoin (
int val);
85 void gotMiterLimit (
double val);
86 void gotWindingOrder (
int val);
90class KarbonStructureHandler :
public StructureHandlerBase
93 KarbonAIParserBase *delegate;
95 KarbonStructureHandler (KarbonAIParserBase *delegate) : StructureHandlerBase() { this->delegate = delegate; }
97 void gotBeginGroup (
bool clipping);
98 void gotEndGroup (
bool clipping);
99 void gotBeginCombination ();
100 void gotEndCombination ();
104class KarbonPathHandler :
public PathHandlerBase
107 KarbonAIParserBase *delegate;
110 KarbonPathHandler (KarbonAIParserBase *delegate) : PathHandlerBase ()
113 this->delegate = delegate;
116 void gotPathElement (PathElement &element);
117 void gotFillPath (
bool closed,
bool reset);
118 void gotStrokePath (
bool closed);
119 void gotIgnorePath (
bool closed,
bool reset);
120 void gotClipPath (
bool closed);
121 void gotFillMode (FillMode fm);
125class KarbonAIParserBase :
public AIParserBase {
126 friend class KarbonDocumentHandler;
127 friend class KarbonGStateHandler;
128 friend class KarbonStructureHandler;
129 friend class KarbonPathHandler;
132 KarbonAIParserBase();
133 ~KarbonAIParserBase();
135 bool parse (TQIODevice& fin, TQDomDocument &doc);
137 VPath *m_curKarbonPath;
138 VDocument *m_document;
140 VPath *m_combination;
141 TQPtrStack<VGroup> m_groupStack;
144 PathOutputType m_pot;
145 PathTransferType m_ptt;
160 void doOutputCurrentPath2(PathOutputType type);
161 const VColor toKarbonColor (
const AIColor &color);
165 VStroke m_emptyStroke;
168 void setupHandlers();
169 void teardownHandlers();
171 void parsingStarted();
172 void parsingFinished();
174 TQString getParamList(Parameters& params);
176 void gotPathElement (PathElement &element);
177 void gotFillPath (
bool closed,
bool reset, FillMode fm = FM_NonZero);
178 void gotStrokePath (
bool closed);
179 void gotIgnorePath (
bool closed,
bool reset);
180 void gotClipPath (
bool closed);
182 void gotFillColor (AIColor &color);
183 void gotStrokeColor (AIColor &color);
184 void gotBoundingBox (
int llx,
int lly,
int urx,
int ury);
186 void gotFlatness (
double val);
187 void gotLineWidth (
double val);
188 void gotLineCaps (
int val);
189 void gotLineJoin (
int val);
190 void gotMiterLimit (
double val);
191 void gotWindingOrder (
int val);
192 void gotBeginGroup (
bool clipping);
193 void gotEndGroup (
bool clipping);
194 void gotBeginCombination ();
195 void gotEndCombination ();
197 virtual void gotStartTag (
const char *tagName, Parameters& params);
198 virtual void gotEndTag (
const char *tagName);
199 virtual void gotSimpleTag (
const char *tagName, Parameters& params);