Rev 19757 | Rev 21427 | 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 | { |
19757 | fschmid | 40 | ALLIMAGES = 1|2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768|524288|1048576|2097152|4194304, |
13963 | fschmid | 41 | #ifdef GMAGICK_FOUND |
19757 | fschmid | 42 | IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|65536|1048576|2097152|4194304, // all Types suitable for Image Frames |
13963 | fschmid | 43 | #else |
19757 | fschmid | 44 | IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|262144|524288|1048576|2097152|4194304, // all Types suitable for Image Frames |
13963 | fschmid | 45 | #endif |
19757 | fschmid | 46 | VECTORIMAGES = 1|64|1024|2048|16384|32768|131072|262144|4194304, // 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 |
19757 | fschmid | 71 | ORA = 2097152, // ORA |
72 | QT = 4194304 // Qt |
||
10181 | cbradney | 73 | }; |
10859 | cbradney | 74 | |
75 | /* |
||
76 | enum ScDocumentFormatType |
||
77 | { |
||
78 | ALLDOCUMENTS = 1|2, |
||
79 | TEXT = 2|4, |
||
80 | SPREADSHEETS = 2|4, |
||
81 | DTP = 0, |
||
82 | WEB = 0, |
||
83 | PRESENTATION = 0, |
||
84 | FORMULAS = 0, |
||
85 | SCRIBUSDOCS = 1, |
||
86 | TEXT = 2, |
||
87 | CSV = 4, |
||
88 | HTML = 8, |
||
89 | XML = 16, |
||
90 | CSV = 32, |
||
91 | CSV = 64, |
||
92 | CSV = 128, |
||
93 | CSV = 256, |
||
94 | CSV = 512, |
||
95 | = 1024, |
||
96 | OORG_WRITER = 2048, |
||
97 | MS_WORD = 4096, |
||
98 | ADOBE_INDESIGN = 8192, |
||
99 | ADOBE_PAGEMAKER = 16384, |
||
100 | QUARK_XPRESS = 32768, |
||
101 | }; |
||
102 | */ |
||
10181 | cbradney | 103 | FormatsManager(); |
104 | ~FormatsManager(); |
||
105 | |||
106 | /** |
||
107 | * @brief Returns a pointer to the FormatsManager instance |
||
108 | * @return A pointer to the FormatsManager instance |
||
109 | */ |
||
110 | static FormatsManager* instance(); |
||
111 | /** |
||
112 | * @brief Deletes the FormatsManager Instance |
||
113 | * Must be called when FormatsManager is no longer needed. |
||
114 | */ |
||
115 | static void deleteInstance(); |
||
116 | void imageFormatSupported(const QString&); |
||
10292 | cbradney | 117 | //! Returns the name of a format, eg "Encapsulated PostScript" |
118 | QString nameOfFormat(int type); |
||
10181 | cbradney | 119 | |
10292 | cbradney | 120 | //! Returns the mimetypes of a format, eg "application/postscript" |
121 | QStringList mimetypeOfFormat(int type); |
||
10181 | cbradney | 122 | |
10292 | cbradney | 123 | //! Returns in the form of "EPS (*.eps *.EPS *.epsf *.EPSF *.epsi *.EPSI)" |
124 | QString extensionsForFormat(int type); |
||
125 | |||
126 | //! Returns in the form of "*.eps *.epsf *.epsi" or "eps|epsf|epsi" |
||
127 | QString extensionListForFormat(int type, int listType); |
||
128 | |||
129 | //! 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 (*)" |
||
130 | QString fileDialogFormatList(int type); |
||
131 | |||
10181 | cbradney | 132 | protected: |
10292 | cbradney | 133 | QMap<int, QString> m_fmtNames; |
134 | QMap<int, QStringList> m_fmtMimeTypes; |
||
10181 | cbradney | 135 | QMap<int, QStringList> m_fmts; |
136 | QStringList m_fmtList; |
||
10292 | cbradney | 137 | |
10272 | cbradney | 138 | QList<QByteArray> m_qtSupportedImageFormats; |
10181 | cbradney | 139 | QList<QByteArray> m_supportedImageFormats; |
140 | void updateSupportedImageFormats(QList<QByteArray>& supportedImageFormats); |
||
10292 | cbradney | 141 | void fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly=false); |
10181 | cbradney | 142 | |
143 | private: |
||
144 | /** |
||
145 | * @brief The only instance of FormatsManager available. |
||
146 | * |
||
147 | * FormatsManager is singleton and the instance can be queried with the method |
||
148 | * instance(). |
||
149 | */ |
||
20691 | craig | 150 | static FormatsManager* m_instance; |
10181 | cbradney | 151 | }; |
152 | |||
10124 | cbradney | 153 | #endif |