Rev 18164 | Rev 19757 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10124 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | |||
8 | //Added by Craig Bradney in July 2007 |
||
9 | //To be used for basic format detection and checking |
||
10 | //One central place for storing all our extensions we support, etc |
||
11 | |||
10212 | cbradney | 12 | #ifndef _UTIL_FORMATs_H |
13 | #define _UTIL_FORMATs_H |
||
10124 | cbradney | 14 | |
10181 | cbradney | 15 | #include <QByteArray> |
10303 | cbradney | 16 | #include <QFile> |
17 | #include <QFileInfo> |
||
10181 | cbradney | 18 | #include <QList> |
19 | #include <QMap> |
||
10124 | cbradney | 20 | #include <QString> |
10181 | cbradney | 21 | #include <QStringList> |
10137 | jghali | 22 | #include "scribusapi.h" |
13963 | fschmid | 23 | #include "scconfig.h" |
10124 | cbradney | 24 | |
10137 | jghali | 25 | bool SCRIBUS_API extensionIndicatesEPS(const QString &ext); |
26 | bool SCRIBUS_API extensionIndicatesEPSorPS(const QString &ext); |
||
10181 | cbradney | 27 | bool SCRIBUS_API extensionIndicatesJPEG(const QString &ext); |
28 | bool SCRIBUS_API extensionIndicatesPDF(const QString &ext); |
||
29 | bool SCRIBUS_API extensionIndicatesPSD(const QString &ext); |
||
30 | bool SCRIBUS_API extensionIndicatesPattern(const QString &ext); |
||
10137 | jghali | 31 | bool SCRIBUS_API extensionIndicatesTIFF(const QString &ext); |
10303 | cbradney | 32 | QString SCRIBUS_API getImageType(QString filename); |
10124 | cbradney | 33 | |
10181 | cbradney | 34 | class SCRIBUS_API FormatsManager |
35 | { |
||
36 | public: |
||
37 | |||
10271 | cbradney | 38 | enum ScImageFormatType |
10181 | cbradney | 39 | { |
18954 | fschmid | 40 | ALLIMAGES = 1|2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768|524288|1048576|2097152, |
13963 | fschmid | 41 | #ifdef GMAGICK_FOUND |
18954 | fschmid | 42 | IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|65536|1048576|2097152, // all Types suitable for Image Frames |
13963 | fschmid | 43 | #else |
18954 | fschmid | 44 | IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|262144|524288|1048576|2097152, // all Types suitable for Image Frames |
13963 | fschmid | 45 | #endif |
14535 | fschmid | 46 | VECTORIMAGES = 1|64|1024|2048|16384|32768|131072|262144, // All pure vector image types |
18954 | fschmid | 47 | RASTORIMAGES = 2|4|8|32|128|256|512|65536|524288|1048576|2097152, // All pure rastor image types |
10317 | fschmid | 48 | EPS = 1, // Encapsulated PostScript |
49 | GIF = 2, // GIF files |
||
50 | JPEG = 4, // JPEG |
||
51 | PAT = 8, // Pattern files |
||
52 | PDF = 16, // PDF Format |
||
53 | PNG = 32, // PNG files |
||
54 | PS = 64, // PostScript |
||
55 | PSD = 128, // Photoshop Format |
||
56 | TIFF = 256, // TIFF |
||
57 | XPM = 512, // XPM files |
||
58 | WMF = 1024, // WMF files |
||
13885 | fschmid | 59 | SVG = 2048, // SVG files |
10317 | fschmid | 60 | AI = 4096, // Adobe Illustrator files |
11615 | fschmid | 61 | XFIG = 8192, // Xfig files |
13957 | herm | 62 | CVG = 16384, // Calamus Cvg files |
63 | WPG = 32768, // Word Perfect WPG files |
||
13963 | fschmid | 64 | #ifdef GMAGICK_FOUND |
13957 | herm | 65 | GMAGICK = 65536, // GraphicsMagick |
13963 | fschmid | 66 | #endif |
13957 | herm | 67 | UNICONV = 131072, // UniConvertor |
14261 | fschmid | 68 | PCT = 262144, // Mac Pict |
15673 | craig | 69 | BMP = 524288, // BMP |
18954 | fschmid | 70 | PGF = 1048576, // PGF |
71 | ORA = 2097152 // ORA |
||
10181 | cbradney | 72 | }; |
10859 | cbradney | 73 | |
74 | /* |
||
75 | enum ScDocumentFormatType |
||
76 | { |
||
77 | ALLDOCUMENTS = 1|2, |
||
78 | TEXT = 2|4, |
||
79 | SPREADSHEETS = 2|4, |
||
80 | DTP = 0, |
||
81 | WEB = 0, |
||
82 | PRESENTATION = 0, |
||
83 | FORMULAS = 0, |
||
84 | SCRIBUSDOCS = 1, |
||
85 | TEXT = 2, |
||
86 | CSV = 4, |
||
87 | HTML = 8, |
||
88 | XML = 16, |
||
89 | CSV = 32, |
||
90 | CSV = 64, |
||
91 | CSV = 128, |
||
92 | CSV = 256, |
||
93 | CSV = 512, |
||
94 | = 1024, |
||
95 | OORG_WRITER = 2048, |
||
96 | MS_WORD = 4096, |
||
97 | ADOBE_INDESIGN = 8192, |
||
98 | ADOBE_PAGEMAKER = 16384, |
||
99 | QUARK_XPRESS = 32768, |
||
100 | }; |
||
101 | */ |
||
10181 | cbradney | 102 | FormatsManager(); |
103 | ~FormatsManager(); |
||
104 | |||
105 | /** |
||
106 | * @brief Returns a pointer to the FormatsManager instance |
||
107 | * @return A pointer to the FormatsManager instance |
||
108 | */ |
||
109 | static FormatsManager* instance(); |
||
110 | /** |
||
111 | * @brief Deletes the FormatsManager Instance |
||
112 | * Must be called when FormatsManager is no longer needed. |
||
113 | */ |
||
114 | static void deleteInstance(); |
||
115 | void imageFormatSupported(const QString&); |
||
10292 | cbradney | 116 | //! Returns the name of a format, eg "Encapsulated PostScript" |
117 | QString nameOfFormat(int type); |
||
10181 | cbradney | 118 | |
10292 | cbradney | 119 | //! Returns the mimetypes of a format, eg "application/postscript" |
120 | QStringList mimetypeOfFormat(int type); |
||
10181 | cbradney | 121 | |
10292 | cbradney | 122 | //! Returns in the form of "EPS (*.eps *.EPS *.epsf *.EPSF *.epsi *.EPSI)" |
123 | QString extensionsForFormat(int type); |
||
124 | |||
125 | //! Returns in the form of "*.eps *.epsf *.epsi" or "eps|epsf|epsi" |
||
126 | QString extensionListForFormat(int type, int listType); |
||
127 | |||
128 | //! Returns in the form of "All Supported Formats (*.eps *.EPS *.epsf *.EPSF *.epsi *.EPSI);;EPS (*.eps *.EPS);;EPSI (*.epsf *.EPSF);;EPSI (*.epsi *.EPSI);;All Files (*)" |
||
129 | QString fileDialogFormatList(int type); |
||
130 | |||
10181 | cbradney | 131 | protected: |
10292 | cbradney | 132 | QMap<int, QString> m_fmtNames; |
133 | QMap<int, QStringList> m_fmtMimeTypes; |
||
10181 | cbradney | 134 | QMap<int, QStringList> m_fmts; |
135 | QStringList m_fmtList; |
||
10292 | cbradney | 136 | |
10272 | cbradney | 137 | QList<QByteArray> m_qtSupportedImageFormats; |
10181 | cbradney | 138 | QList<QByteArray> m_supportedImageFormats; |
139 | void updateSupportedImageFormats(QList<QByteArray>& supportedImageFormats); |
||
10292 | cbradney | 140 | void fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly=false); |
10181 | cbradney | 141 | |
142 | private: |
||
143 | /** |
||
144 | * @brief The only instance of FormatsManager available. |
||
145 | * |
||
146 | * FormatsManager is singleton and the instance can be queried with the method |
||
147 | * instance(). |
||
148 | */ |
||
149 | static FormatsManager* _instance; |
||
150 | }; |
||
151 | |||
10124 | cbradney | 152 | #endif |