26#include <tqvaluestack.h>
27#include <tqvaluevector.h>
28#include <tqvaluelist.h>
34const void arraytoa ( const TQValueVector<AIElement> &data);
35const void elementtoa ( const AIElement &data);
36const void stacktoa ( const TQValueStack<AIElement> &data);
37const void stacktoa2 ( const TQValueStack<TQValueVector<AIElement> >&data);
39class GStateHandlerBase;
40class StructureHandlerBase;
42class MiscGStateHandlerBase;
43class DocumentHandlerBase;
44class ModuleHandlerBase;
45class EmbeddedHandlerBase;
54typedef enum { PET_MoveTo, PET_LineTo, PET_CurveTo, PET_CurveToOmitC1, PET_CurveToOmitC2 } PathElementType;
55typedef enum { PT_Smooth, PT_Corner } PointType;
56typedef enum { TO_FillStroke, TO_Fill, TO_Append, TO_Ignore, TO_Stroke } TextOperation;
57typedef enum { FM_NonZero=0, FM_EvenOdd=1 } FillMode;
58typedef enum { FS_Roman, FS_Kanji } FontScript;
60typedef enum { DS_Array, DS_Block, DS_Other } DataSink;
61typedef enum { ST_Setup, ST_Prolog, ST_ProcSet, ST_Encoding, ST_Pattern, ST_Document, ST_BrushPattern, ST_Gradient, ST_Palette, ST_Resource } SectionType;
63typedef enum { TA_HLeft, TA_HCenter, TA_HRight, TA_VTop, TA_VCenter, TA_VBottom } TextAlign;
66#define PC_Magenta 0x0002
67#define PC_Yellow 0x0004
68#define PC_Black 0x0008
72 AIO_SetFillColorCMYK, AIO_SetStrokeColorCMYK,
73 AIO_SetFillColorGray, AIO_SetStrokeColorGray,
74 AIO_SetFillColorCustom, AIO_SetStrokeColorCustom,
75 AIO_SetFillPattern, AIO_SetStrokePattern,
76 AIO_SetFillOverprinting, AIO_SetStrokeOverprinting,
77 AIO_SetFlatness, AIO_SetLineCap, AIO_SetLineJoin,
78 AIO_SetLineWidth, AIO_SetMiterLimit, AIO_SetDash,
79 AIO_BeginGroupClip, AIO_EndGroupClip,
85 AIO_CurveToOmitC1Smooth,
86 AIO_CurveToOmitC1Corner,
87 AIO_CurveToOmitC2Smooth,
88 AIO_CurveToOmitC2Corner,
90 AIO_PathIgnoreNoReset, AIO_PathIgnoreNoResetClose,
92 AIO_PathIgnoreReset, AIO_PathIgnoreResetClose,
93 AIO_PathFillNonZero, AIO_PathFillNonZeroClose,
94 AIO_PathStroke, AIO_PathStrokeClose,
95 AIO_PathFillNoReset, AIO_PathFillNoResetClose,
98 AIO_PatternDefinition,
101 AIO_TextBlockFillStroke,
109 AIO_GsaveIncludeDocument,
118 AIO_BeginGroupNoClip, AIO_EndGroupNoClip,
119 AIO_BeginCombination, AIO_EndCombination,
145 CO_BeginSetup, CO_EndSetup,
146 CO_BeginProlog, CO_EndProlog,
147 CO_BeginProcSet, CO_EndProcSet,
148 CO_BeginEncoding, CO_EndEncoding,
149 CO_BeginPattern, CO_EndPattern,
151 CO_BeginDocument, CO_EndDocument,
166 CO_DocumentSuppliedProcSets,
167 CO_DocumentProcessColors,
168 CO_DocumentCustomColors,
181 CO_BeginBrushPattern, CO_EndBrushPattern,
182 CO_BeginGradient, CO_EndGradient,
183 CO_BeginPalette, CO_EndPalette,
186 CO_BeginResource, CO_EndResource,
189 CO_DocumentNeededResources,
195 CM_DocumentFonts = 1,
196 CM_DocumentFiles = 2,
197 CM_DocumentCustomColors = 3,
198 CM_CMYKCustomColor = 4,
199 CM_DocumentNeededResources = 5,
206} PatternDefinitionOperation;
209#define PatternTileFilledDefiniton "_"
210#define TextSizeUnknown -1
217 PathElementType petype;
223 float x1, y1, x2, y2, x3, y3;
229class AIParserBase : protected AILexer {
237 TQValueStack<AIElement> m_stack;
238 TQValueStack<TQValueVector<AIElement> > m_arrayStack;
239 TQValueStack<TQValueVector<AIElement> > m_blockStack;
241 TQValueList<TQString> m_modules;
242 ContinuationMode m_continuationMode;
244 const double getDoubleValue( void);
245 const int getIntValue( void);
246 const bool getBoolValue( void);
247 const TQString getStringValue( void);
248 const TQString& getReferenceValue( void);
249 const TQString getOperatorValue( void);
266 void _handlePSExec();
268 void _handlePSString();
269 void _handlePSBind();
270 void _handlePSUserdict();
271 void _handlePSDict();
273 void _handlePSBegin();
276 void _handleDocumentFonts( const char *data);
277 void _handleDocumentFiles( const char *data);
278 void _handleDocumentCustomColors( const char *data);
279 void _handleCMYKCustomColor( const char *data);
280 void _handleDocumentProcessColors( const char *data);
281 void _handleDocumentNeededResources( const char *data);
282 void _handleIncludeResource( const char *data);
288 void _handleCreationDate ( const char *data);
290 AIOperation getAIOperation ( const char *operand);
291 PSOperation getPSOperation ( const char *operand);
292 CommentOperation getCommentOperation ( const char *command);
294 bool handlePS ( const char *operand);
296 const char *getValue ( const char *input);
297 bool getRectangle ( const char* input, int &llx, int &lly, int &urx, int &ury);
298 bool getPoint ( const char* input, int &x, int &y);
300 void gotComment ( const char *value);
301 void gotIntValue ( int value);
302 void gotDoubleValue ( double value);
303 void gotStringValue ( const char *value);
304 void gotToken ( const char *value);
305 void gotReference ( const char *value);
306 void gotBlockStart ();
308 void gotArrayStart ();
310 void gotByte (uchar value);
311 void gotByteArray ( const TQByteArray &data);
313 GStateHandlerBase *m_gstateHandler;
314 StructureHandlerBase *m_structureHandler;
315 PathHandlerBase *m_pathHandler;
316 MiscGStateHandlerBase *m_miscGStateHandler;
317 DocumentHandlerBase *m_documentHandler;
318 ModuleHandlerBase *m_moduleHandler;
319 EmbeddedHandlerBase *m_embeddedHandler;
320 TextHandlerBase *m_textHandler;
326 void cleanupArrays();
331 bool parse (TQIODevice& fin);
334const void aiotoa (AIOperation &data);
335const void sttoa (SectionType &data, bool begin);
337class GStateHandlerBase
340 GStateHandlerBase() {}
341 virtual ~GStateHandlerBase() {}
343 virtual void gotFillColor ( AIColor &) {}
344 virtual void gotStrokeColor ( AIColor &) {}
345 virtual void gotFillPattern ( const char *pname, double px, double py, double sx, double sy, double angle, double rf, double r, double k, double ka, const TQValueVector<AIElement>& transformData);
346 virtual void gotStrokePattern ( const char *pname, double px, double py, double sx, double sy, double angle, double rf, double r, double k, double ka, const TQValueVector<AIElement>& transformData);
347 virtual void gotFlatness ( double) {}
348 virtual void gotLineWidth ( double) {}
349 virtual void gotLineCaps ( int) {}
350 virtual void gotLineJoin ( int) {}
351 virtual void gotMiterLimit ( double) {}
352 virtual void gotWindingOrder ( int) {}
353 virtual void gotDash ( const TQValueVector<AIElement>& , double ) {}
356class StructureHandlerBase {
358 StructureHandlerBase() {}
359 virtual ~StructureHandlerBase() {}
361 virtual void gotBeginGroup ( bool ) {}
362 virtual void gotEndGroup ( bool ) {}
363 virtual void gotBeginCombination () {}
364 virtual void gotEndCombination () {}
367class PathHandlerBase {
370 virtual ~PathHandlerBase() {}
372 virtual void gotPathElement (PathElement &) {}
373 virtual void gotFillPath ( bool , bool ) {}
374 virtual void gotStrokePath ( bool ) {}
375 virtual void gotIgnorePath ( bool , bool ) {}
376 virtual void gotClipPath ( bool ) {}
377 virtual void gotFillMode (FillMode) {}
380class MiscGStateHandlerBase {
382 MiscGStateHandlerBase() {}
383 virtual ~MiscGStateHandlerBase() {}
385 virtual void gotLockNextObject ( bool ) {}
386 virtual void gotFillOverprinting ( bool ) {}
387 virtual void gotStrokeOverprinting ( bool ) {}
390class DocumentHandlerBase {
392 DocumentHandlerBase() {}
393 virtual ~DocumentHandlerBase() {}
395 virtual void gotBoundingBox ( int , int , int , int ) {}
396 virtual void gotTemplateBox ( int , int , int , int ) {}
397 virtual void gotMargin ( int , int , int , int ) {}
398 virtual void gotPrinterRect ( int , int , int , int ) {}
399 virtual void gotPrinterName ( const char *) {}
400 virtual void gotPageOrigin ( int , int ) {}
401 virtual void gotTemplate ( const char *) {}
402 virtual void gotTitle ( const char *) {}
403 virtual void gotCreator ( const char *) {}
404 virtual void gotPatternDefinition ( const char *, const TQValueVector<AIElement>& , double , double , double , double ) {}
405 virtual void gotCreationDate ( const char *, const char *) {}
406 virtual void gotProcessColors ( int ) {}
409class ModuleHandlerBase {
411 ModuleHandlerBase() {}
412 virtual ~ModuleHandlerBase() {}
414 virtual void gotBeginSection (SectionType, const char *) {}
415 virtual void gotEndSection (SectionType, const char *) {}
418class EmbeddedHandlerBase {
420 EmbeddedHandlerBase() {}
421 virtual ~EmbeddedHandlerBase() {}
423 virtual void gotGsaveIncludeDocument ( const TQValueVector<AIElement>& , int , int , int , int , const char*) {}
424 virtual void gotGrestore () {}
427class TextHandlerBase {
430 virtual ~TextHandlerBase() {}
432 virtual void gotFontEncoding ( const TQValueVector<AIElement>& encodingData, const char*oldFontName, const char*newFontName);
433 virtual void gotFontDefinition ( const char*fontName, double size, double leading, double kerning, TextAlign align);
434 virtual void gotTextBlockBegin ( const TQValueVector<AIElement>& transData, TextOperation mode);
435 virtual void gotTextOutput ( const char*text, int length=-1);
436 virtual void gotTextBlockEnd ();
|