filters
karbonaiparserbase.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KARBONAIPARSERBASE_H
00021 #define KARBONAIPARSERBASE_H
00022
00023 #include <aiparserbase.h>
00024 #include <qptrlist.h>
00025 #include <qstring.h>
00026 #include <qpair.h>
00027
00028 #include "aicolor.h"
00029
00030 #include <KoPoint.h>
00031 #include <core/vcomposite.h>
00032 #include <core/vdocument.h>
00033 #include <core/vlayer.h>
00034 #include <core/vgroup.h>
00035 #include <core/vfill.h>
00036 #include <core/vstroke.h>
00037 #include <qdom.h>
00038
00039 #include <qptrstack.h>
00040
00044 typedef QPair<QString,QString> Parameter;
00045 typedef QPtrList<Parameter> Parameters;
00046 typedef QPtrList<PathElement> PathElements;
00047
00048 typedef enum { POT_Filled = 1, POT_Stroked = 2, POT_FilledStroked = 3, POT_Clip = 4, POT_Ignore = 8, POT_Leave = -1, POT_Other = 0 } PathOutputType;
00049 typedef enum { PTT_Output = 1, PTT_Combine = 2 } PathTransferType;
00050
00051
00052
00053 class KarbonAIParserBase;
00054 class KarbonGStateHandler;
00055 class KarbonStructureHandler;
00056 class KarbonPathHandler;
00057 class KarbonDocumentHandler;
00058
00059 class KarbonDocumentHandler : public DocumentHandlerBase
00060 {
00061 private:
00062 KarbonAIParserBase *delegate;
00063 public:
00064 KarbonDocumentHandler (KarbonAIParserBase *delegate) : DocumentHandlerBase () { this->delegate = delegate; }
00065
00066 void gotBoundingBox (int llx, int lly, int urx, int ury);
00067 void gotCreationDate (const char *val1,const char *val2);
00068 void gotProcessColors (int colors);
00069 };
00070
00071 class KarbonGStateHandler : public GStateHandlerBase
00072 {
00073 private:
00074 KarbonAIParserBase *delegate;
00075 public:
00076 KarbonGStateHandler (KarbonAIParserBase *delegate) : GStateHandlerBase() { this->delegate = delegate; }
00077
00078 void gotFillColor (AIColor &color);
00079 void gotStrokeColor (AIColor &color);
00080
00081 void gotFlatness (double val);
00082 void gotLineWidth (double val);
00083 void gotLineCaps (int val);
00084 void gotLineJoin (int val);
00085 void gotMiterLimit (double val);
00086 void gotWindingOrder (int val);
00087
00088 };
00089
00090 class KarbonStructureHandler : public StructureHandlerBase
00091 {
00092 private:
00093 KarbonAIParserBase *delegate;
00094 public:
00095 KarbonStructureHandler (KarbonAIParserBase *delegate) : StructureHandlerBase() { this->delegate = delegate; }
00096
00097 void gotBeginGroup (bool clipping);
00098 void gotEndGroup (bool clipping);
00099 void gotBeginCombination ();
00100 void gotEndCombination ();
00101
00102 };
00103
00104 class KarbonPathHandler : public PathHandlerBase
00105 {
00106 private:
00107 KarbonAIParserBase *delegate;
00108 FillMode m_fm;
00109 public:
00110 KarbonPathHandler (KarbonAIParserBase *delegate) : PathHandlerBase ()
00111 {
00112 m_fm = FM_EvenOdd;
00113 this->delegate = delegate;
00114 }
00115
00116 void gotPathElement (PathElement &element);
00117 void gotFillPath (bool closed, bool reset);
00118 void gotStrokePath (bool closed);
00119 void gotIgnorePath (bool closed, bool reset);
00120 void gotClipPath (bool closed);
00121 void gotFillMode (FillMode fm);
00122
00123 };
00124
00125 class KarbonAIParserBase : public AIParserBase {
00126 friend class KarbonDocumentHandler;
00127 friend class KarbonGStateHandler;
00128 friend class KarbonStructureHandler;
00129 friend class KarbonPathHandler;
00130
00131 public:
00132 KarbonAIParserBase();
00133 ~KarbonAIParserBase();
00134
00135 bool parse (QIODevice& fin, QDomDocument &doc);
00136 private:
00137 VPath *m_curKarbonPath;
00138 VDocument *m_document;
00139 VLayer *m_layer;
00140 VPath *m_combination;
00141 QPtrStack<VGroup> m_groupStack;
00142
00143 FillMode m_fm;
00144 PathOutputType m_pot;
00145 PathTransferType m_ptt;
00146
00147
00148 KoRect m_bbox;
00149 VFill m_fill;
00150 VStroke m_stroke;
00158 int m_windingOrder;
00159
00160 void doOutputCurrentPath2(PathOutputType type);
00161 const VColor toKarbonColor (const AIColor &color);
00162 void ensureLayer ();
00163
00164 VFill m_emptyFill;
00165 VStroke m_emptyStroke;
00166
00167 protected:
00168 void setupHandlers();
00169 void teardownHandlers();
00170
00171 void parsingStarted();
00172 void parsingFinished();
00173
00174 QString getParamList(Parameters& params);
00175
00176 void gotPathElement (PathElement &element);
00177 void gotFillPath (bool closed, bool reset, FillMode fm = FM_NonZero);
00178 void gotStrokePath (bool closed);
00179 void gotIgnorePath (bool closed, bool reset);
00180 void gotClipPath (bool closed);
00181
00182 void gotFillColor (AIColor &color);
00183 void gotStrokeColor (AIColor &color);
00184 void gotBoundingBox (int llx, int lly, int urx, int ury);
00185
00186 void gotFlatness (double val);
00187 void gotLineWidth (double val);
00188 void gotLineCaps (int val);
00189 void gotLineJoin (int val);
00190 void gotMiterLimit (double val);
00191 void gotWindingOrder (int val);
00192 void gotBeginGroup (bool clipping);
00193 void gotEndGroup (bool clipping);
00194 void gotBeginCombination ();
00195 void gotEndCombination ();
00196
00197 virtual void gotStartTag (const char *tagName, Parameters& params);
00198 virtual void gotEndTag (const char *tagName);
00199 virtual void gotSimpleTag (const char *tagName, Parameters& params);
00200 };
00201
00202 #endif
|