1
/* This file is part of the KDE project
2
Copyright (C) 2002, Dirk Sch�nberger <dirk.schoenberger@sz-online.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
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 <qptrstack.h>
44
typedef QPair<QString,QString> Parameter;
45
typedef QPtrList<Parameter> Parameters;
46
typedef QPtrList<PathElement> PathElements;
48
typedef enum { POT_Filled = 1, POT_Stroked = 2, POT_FilledStroked = 3, POT_Clip = 4, POT_Ignore = 8, POT_Leave = -1, POT_Other = 0 } PathOutputType;
49
typedef enum { PTT_Output = 1, PTT_Combine = 2 } PathTransferType;
51
// typedef struct { int llx, lly, urx, ury; } BoundingBox;
53
class KarbonAIParserBase;
54
class KarbonGStateHandler;
55
class KarbonStructureHandler;
56
class KarbonPathHandler;
57
class KarbonDocumentHandler;
59
class 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);
71
class 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);
90
class 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 ();
104
class 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);
125
class 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 (QIODevice& fin, QDomDocument &doc);
137
VPath *m_curKarbonPath;
138
VDocument *m_document;
140
VPath *m_combination;
141
QPtrStack<VGroup> m_groupStack;
144
PathOutputType m_pot;
145
PathTransferType m_ptt;
147
// BoundingBox m_bbox;
151
/** AIColor m_strokeColor;
157
double m_miterLimit; */
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
QString 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);