Subversion Repositories Scribus

Rev

Rev 1973 | Rev 2031 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1972 craig 1
#ifndef PDFOPTIONS_H
2
#define PDFOPTIONS_H
3
 
4
/**
5
 * @file pdfoptions.h
6
 * @author Franz Schmidt
7
 * @author Craig Ringer
8
 * @brief Defines class PDFOptions, used for loading/saving/passing around PDF options
9
 */
10
 
11
#include "qstring.h"
12
#include "qmap.h"
13
#include "qvaluelist.h"
2030 craig 14
#include "qdom.h"
1972 craig 15
 
16
struct LPIData;
17
struct PDFPresentationData;
18
 
19
/**
20
 * @brief PDF Options struture. Capable of saving and loading to/from file and verifying its self.
21
 */
22
class PDFOptions
23
{
24
public:
25
        // Note: A default constructor, copy constructor, and
26
        // assignment operator must be defined so that this class
27
        // can be used as a value.
28
        // The automatically generated ones are quite sufficient.
29
        //PDFOptions();
30
        //PDFOptions(const PDFOptions& other);
31
        //PDFOptions& operator=(const PDFOptions& other);
32
        //~PDFOptions() {};
33
 
34
        enum VerifyResults
35
        {
36
                Verify_NoError = 0,
37
                Verify_OptionConflict,
38
                Verify_OptionOutOfRange,
39
                Verify_OtherError
40
        };
41
 
1973 craig 42
        enum PDFVersion
43
        {
44
                PDFVersion_13 = 13,
45
                PDFVersion_14 = 14,
46
                PDFVersion_15 = 15,
47
                PDFVersion_X3 = 12,
48
        };
49
 
1972 craig 50
        /**
51
         * @author Craig Ringer
52
         * @brief Sanity check the options defined.
53
         *
54
         * Unimplemented, always returns Verify_OtherError
55
         *
56
         * Checks the PDF option structure for conflicts between mututally
57
         * exclusive options, ensures all options are within sane ranges,
58
         * and that there are no nonsensical options values set. If nothing
59
         * is wrong, returns Verify_NoError, otherwise returns error code from
60
         * PDFOptions::VerifyResults. If problemDescription is not NULL,
61
         * it will contain a human-readable description of the error on return.
62
         *
63
         * @warning DO NOT *EVER* TEST THE VALUE OF problemDescription. Rely on the
64
         *                      return code instead. problemDescription is subject to
65
         *                      translation and its contents may change without notice.
66
         *
67
         * @param problemDescription Error description
68
         * @return Verify_NoError for sane options, otherwise error code.
69
         */
70
        PDFOptions::VerifyResults verify(QString* problemDescription);
2030 craig 71
        PDFOptions::VerifyResults verify();
1972 craig 72
 
73
        bool Thumbnails;
74
        bool Articles;
75
        bool useLayers;
76
        bool Compress;
77
        int CompressMethod;
78
        int Quality;
79
        bool RecalcPic;
80
        bool Bookmarks;
81
        int PicRes;
1973 craig 82
        PDFVersion Version;
1972 craig 83
        int Resolution;
84
        int Binding;
85
        QValueList<QString> EmbedList;
86
        QValueList<QString> SubsetList;
87
        bool MirrorH;
88
        bool MirrorV;
89
        int RotateDeg;
90
        bool PresentMode;
91
        QValueList<PDFPresentationData> PresentVals;
92
        QString Datei;
93
        bool isGrayscale;
94
        bool UseRGB;
95
        bool UseProfiles;
96
        bool UseProfiles2;
97
        bool UseLPI;
98
        QMap<QString,LPIData> LPISettings;
99
        QString SolidProf;
100
        int SComp;
101
        QString ImageProf;
102
        bool EmbeddedI;
103
        int Intent2;
104
        QString PrintProf;
105
        QString Info;
106
        int Intent;
107
        double BleedTop;
108
        double BleedLeft;
109
        double BleedRight;
110
        double BleedBottom;
111
        bool Encrypt;
112
        QString PassOwner;
113
        QString PassUser;
114
        int Permissions;
115
};
116
 
2030 craig 117
/*
118
 * @brief Helper class for reading/writing PDFOptions
119
 * @author Craig Ringer
120
 *
121
 * PDFOptionsIO reads and writes PDFOptions to various
122
 * formats. Currently only a custom XML format is
123
 * supported, but support for reading/writing Adobe's
124
 * .joboptions (for example) might be added in future.
125
 *
126
 * Usage:
127
 *    // Writing:
128
 *    // where `opts' is an existing PDFOptions instance
129
 *    PDFOptionsIO io(opts);
130
 *    if (!io.writeTo("/path/to/file"))
131
 *       // handle error. Not like this:
132
 *       qDebug("Darn, it didn't work.");
133
 *
134
 *    // Reading:
135
 *    PDFOptions opts;
136
 *    PDFOptionsIO io(opts);
137
 *    if (!io.readFrom("/path/to/file"))
138
 *       // handle error. Not like this:
139
 *       qDebug("incomprehensible gibberish");
140
 */
141
class PDFOptionsIO
142
{
143
public:
144
        /**
145
         * @brief simple ctor
146
         */
147
        PDFOptionsIO(PDFOptions& opts);
148
 
149
        /**
150
         * @brief Save the PDF settings to a file or other stream
151
         *
152
         * @warning unimplemented, always fails.
153
         *
154
         * @param outStream QTextStream to write output to.
155
         * @return True for success.
156
         */
157
        bool writeTo(QTextStream& outStream);
158
        bool writeTo(QString outFileName);
159
        bool writeTo(FILE* outFilePtr);
160
 
161
        /**
162
         * @brief Load the PDF settings from a file or other data stream, overwriting
163
         *        any current settings
164
         *
165
         * @warning unimplemented, always fails
166
         *
167
         * @warning on failure, struct contents are undefined.
168
         *
169
         * @param inStream QTextStream to settings data from.
170
         * @return True for success.
171
         */
172
        bool readFrom(QTextStream& inStream);
173
        bool readFrom(QString inFileName);
174
        bool readFrom(FILE* inFilePtr);
175
 
176
protected:
177
        // Populate the current DOM tree with the settings from the
178
        // current PDFOptions instance.
179
        bool buildSettings();
180
 
181
        // Helper functions. Add elements under the root element
182
        // with a single attribute "value=" set to the passed value.
183
        void addElem(QString name, bool value);
184
        void addElem(QString name, QString value);
185
        void addElem(QString name, int value);
186
        void addElem(QString name, double value);
187
 
188
        // The QDomDocument used by the class for all its XML work
189
        QDomDocument doc;
190
        // The root element
191
        QDomElement root;
192
        // The PDFOptions instance we're operating on
193
        PDFOptions* opts;
194
 
195
        // Version, of the form Mmpr: Major, minor, patch, revision
196
        // eg 1300 - 1.3.0r0
197
        static const int formatVersion;
198
};
199
 
1972 craig 200
#endif