1 /*
2  *      qpdl.h                  (C) 2006-2007, Aurélien Croc (AP²C)
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; version 2 of the License.
7  *
8  *   This program is distributed in the hope that it will be useful,
9  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *   GNU General Public License for more details.
12  *
13  *   You should have received a copy of the GNU General Public License
14  *   along with this program; if not, write to the
15  *   Free Software Foundation, Inc.,
16  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  *   $Id$
19  */
20 #ifndef _QPDL_H_
21 #define _QPDL_H_
22 
23 #include <QtCore/qglobal.h>
24 #include "page.h"
25 
26 class QFile;
27 class QTextStream;
28 
29 class QPDLDocument
30 {
31     public:
32         enum Type {
33             SPL2,
34             SPLc,
35         };
36 
37         enum Color {
38             Cyan    = 1,
39             Magenta = 2,
40             Yellow  = 3,
41             Black   = 4,
42         };
43 
44     protected:
45         quint8                  _qpdl;
46         quint16                 _width;
47         quint32                 _pageNr;
48         quint8                  _duplex;
49         quint8                  _tumble;
50         quint16                 _height;
51         quint16                 _nrCopies;
52         quint8                  _paperType;
53         quint16                 _resolutionX;
54         quint16                 _resolutionY;
55         quint8                  _paperSource;
56         quint8                  _currentBandNr;
57         char                    _unknown[3];
58 
59         bool                    _quiet;
60         bool                    _decompression;
61         bool                    _dump;
62         Type                    _type;
63         Page                    _page;
64 
65     protected:
66         enum Result {
67             Error   = -1,
68             Ok      = 0,
69             End     = 1,
70         };
71 
72     protected:
73         bool                    _processBandAnalysis(quint8 color,
74                                     quint16 width, quint16 height,
75                                     quint8 compression, QByteArray& content,
76                                     QTextStream& out, QTextStream& err);
77         Result                  _readPageHeader(QFile& data, QTextStream& out,
78                                     QTextStream& err);
79         Result                  _readPageContent(QFile& data, QTextStream& out,
80                                     QTextStream& err);
81 
82     public:
83         QPDLDocument();
84 
85     public:
setQuiet(bool quiet)86         void                    setQuiet(bool quiet) {_quiet = quiet;}
setDecompressionState(bool state)87         void                    setDecompressionState(bool state)
88                                 {_decompression = state;}
setDump(bool state)89         void                    setDump(bool state) {_dump = state;}
setType(Type type)90         void                    setType(Type type) {_type = type;}
91 
decompressionState()92         bool                    decompressionState() const
93                                 {return _decompression;}
type()94         Type                    type() const {return _type;}
page()95         quint32                 page() const {return _pageNr;}
currentBandNr()96         quint32                 currentBandNr() const {return _currentBandNr;}
97 
98     public:
99         bool                    parse(QFile& data, QTextStream& out,
100                                     QTextStream& err);
101 };
102 
103 #endif /* _QPDL_H_ */
104 
105 /* vim: set expandtab tabstop=4 shiftwidth=4 smarttab tw=80 cin enc=utf8 : */
106 
107