~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to filters/karbon/ai/karbonaiparserbase.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2002, Dirk Sch�nberger <dirk.schoenberger@sz-online.de>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#ifndef KARBONAIPARSERBASE_H
 
21
#define KARBONAIPARSERBASE_H
 
22
 
 
23
#include <aiparserbase.h>
 
24
#include <qptrlist.h>
 
25
#include <qstring.h>
 
26
#include <qpair.h>
 
27
 
 
28
#include "aicolor.h"
 
29
 
 
30
#include <koPoint.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>
 
37
#include <qdom.h>
 
38
 
 
39
#include <qptrstack.h>
 
40
 
 
41
/**
 
42
  *@author 
 
43
  */
 
44
typedef QPair<QString,QString> Parameter;
 
45
typedef QPtrList<Parameter> Parameters;
 
46
typedef QPtrList<PathElement> PathElements;
 
47
 
 
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;
 
50
 
 
51
// typedef struct { int llx, lly, urx, ury; } BoundingBox;
 
52
 
 
53
class KarbonAIParserBase;
 
54
class KarbonGStateHandler;
 
55
class KarbonStructureHandler;
 
56
class KarbonPathHandler;
 
57
class KarbonDocumentHandler;
 
58
 
 
59
class KarbonDocumentHandler : public DocumentHandlerBase
 
60
{
 
61
  private:
 
62
    KarbonAIParserBase *delegate;
 
63
  public:
 
64
    KarbonDocumentHandler (KarbonAIParserBase *delegate) : DocumentHandlerBase () { this->delegate = delegate; }
 
65
 
 
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);
 
69
};
 
70
 
 
71
class KarbonGStateHandler : public GStateHandlerBase
 
72
{
 
73
  private:
 
74
    KarbonAIParserBase *delegate;
 
75
  public:
 
76
    KarbonGStateHandler (KarbonAIParserBase *delegate) : GStateHandlerBase() { this->delegate = delegate; }
 
77
 
 
78
    void gotFillColor (AIColor &color);
 
79
    void gotStrokeColor (AIColor &color);
 
80
 
 
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);
 
87
 
 
88
};
 
89
 
 
90
class KarbonStructureHandler : public StructureHandlerBase
 
91
{
 
92
  private:
 
93
    KarbonAIParserBase *delegate;
 
94
  public:
 
95
    KarbonStructureHandler (KarbonAIParserBase *delegate) : StructureHandlerBase() { this->delegate = delegate; }
 
96
 
 
97
   void gotBeginGroup (bool clipping);
 
98
   void gotEndGroup (bool clipping);
 
99
   void gotBeginCombination ();
 
100
   void gotEndCombination ();
 
101
 
 
102
};
 
103
 
 
104
class KarbonPathHandler : public PathHandlerBase
 
105
{
 
106
  private:
 
107
    KarbonAIParserBase *delegate;
 
108
    FillMode m_fm;
 
109
  public:
 
110
    KarbonPathHandler (KarbonAIParserBase *delegate) : PathHandlerBase ()
 
111
    {
 
112
       m_fm = FM_EvenOdd;
 
113
       this->delegate = delegate;
 
114
    }
 
115
 
 
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);
 
122
 
 
123
};
 
124
 
 
125
class KarbonAIParserBase : public AIParserBase {
 
126
  friend class KarbonDocumentHandler;
 
127
  friend class KarbonGStateHandler;
 
128
  friend class KarbonStructureHandler;
 
129
  friend class KarbonPathHandler;
 
130
 
 
131
public: 
 
132
        KarbonAIParserBase();
 
133
        ~KarbonAIParserBase();
 
134
 
 
135
  bool parse (QIODevice& fin, QDomDocument &doc);
 
136
private:
 
137
  VPath *m_curKarbonPath;
 
138
  VDocument *m_document;
 
139
  VLayer *m_layer;
 
140
  VPath *m_combination;
 
141
  QPtrStack<VGroup> m_groupStack;
 
142
 
 
143
  FillMode m_fm;
 
144
  PathOutputType m_pot;
 
145
  PathTransferType m_ptt;
 
146
 
 
147
//  BoundingBox  m_bbox;
 
148
  KoRect m_bbox;
 
149
  VFill m_fill;
 
150
  VStroke m_stroke;
 
151
/**  AIColor m_strokeColor;
 
152
  AIColor m_fillColor;
 
153
  double m_lineWidth;
 
154
  double m_flatness;
 
155
  int m_lineCaps;
 
156
  int m_lineJoin;
 
157
  double m_miterLimit; */
 
158
  int m_windingOrder;
 
159
 
 
160
  void doOutputCurrentPath2(PathOutputType type);
 
161
  const VColor toKarbonColor (const AIColor &color);
 
162
  void ensureLayer ();
 
163
 
 
164
  VFill m_emptyFill;
 
165
  VStroke m_emptyStroke;
 
166
 
 
167
protected:
 
168
  void setupHandlers();
 
169
  void teardownHandlers();
 
170
 
 
171
  void parsingStarted();
 
172
  void parsingFinished();
 
173
 
 
174
  QString getParamList(Parameters& params);
 
175
 
 
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);
 
181
 
 
182
  void gotFillColor (AIColor &color);
 
183
  void gotStrokeColor (AIColor &color);
 
184
  void gotBoundingBox (int llx, int lly, int urx, int ury);
 
185
 
 
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 ();
 
196
 
 
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);
 
200
};
 
201
 
 
202
#endif