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