Rev 13885 | Rev 13963 | 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" |
10124 | cbradney | 23 | |
10137 | jghali | 24 | bool SCRIBUS_API extensionIndicatesEPS(const QString &ext); |
25 | bool SCRIBUS_API extensionIndicatesEPSorPS(const QString &ext); |
||
10181 | cbradney | 26 | bool SCRIBUS_API extensionIndicatesJPEG(const QString &ext); |
27 | bool SCRIBUS_API extensionIndicatesPDF(const QString &ext); |
||
28 | bool SCRIBUS_API extensionIndicatesPSD(const QString &ext); |
||
29 | bool SCRIBUS_API extensionIndicatesPattern(const QString &ext); |
||
10137 | jghali | 30 | bool SCRIBUS_API extensionIndicatesTIFF(const QString &ext); |
10303 | cbradney | 31 | QString SCRIBUS_API getImageType(QString filename); |
10124 | cbradney | 32 | |
10181 | cbradney | 33 | class SCRIBUS_API FormatsManager |
34 | { |
||
35 | public: |
||
36 | |||
10271 | cbradney | 37 | enum ScImageFormatType |
10181 | cbradney | 38 | { |
13885 | fschmid | 39 | ALLIMAGES = 1|2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768, |
10317 | fschmid | 40 | IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512, // all Types suitable for Image Frames |
13957 | herm | 41 | VECTORIMAGES = 1|64|1024|2048|16384|32768|131072, // All pure vector image types |
42 | RASTORIMAGES = 2|4|8|32|512|65536, // All pure rastor image types |
||
10317 | fschmid | 43 | EPS = 1, // Encapsulated PostScript |
44 | GIF = 2, // GIF files |
||
45 | JPEG = 4, // JPEG |
||
46 | PAT = 8, // Pattern files |
||
47 | PDF = 16, // PDF Format |
||
48 | PNG = 32, // PNG files |
||
49 | PS = 64, // PostScript |
||
50 | PSD = 128, // Photoshop Format |
||
51 | TIFF = 256, // TIFF |
||
52 | XPM = 512, // XPM files |
||
53 | WMF = 1024, // WMF files |
||
13885 | fschmid | 54 | SVG = 2048, // SVG files |
10317 | fschmid | 55 | AI = 4096, // Adobe Illustrator files |
11615 | fschmid | 56 | XFIG = 8192, // Xfig files |
13957 | herm | 57 | CVG = 16384, // Calamus Cvg files |
58 | WPG = 32768, // Word Perfect WPG files |
||
59 | GMAGICK = 65536, // GraphicsMagick |
||
60 | UNICONV = 131072, // UniConvertor |
||
10181 | cbradney | 61 | }; |
10859 | cbradney | 62 | |
63 | /* |
||
64 | enum ScDocumentFormatType |
||
65 | { |
||
66 | ALLDOCUMENTS = 1|2, |
||
67 | TEXT = 2|4, |
||
68 | SPREADSHEETS = 2|4, |
||
69 | DTP = 0, |
||
70 | WEB = 0, |
||
71 | PRESENTATION = 0, |
||
72 | FORMULAS = 0, |
||
73 | SCRIBUSDOCS = 1, |
||
74 | TEXT = 2, |
||
75 | CSV = 4, |
||
76 | HTML = 8, |
||
77 | XML = 16, |
||
78 | CSV = 32, |
||
79 | CSV = 64, |
||
80 | CSV = 128, |
||
81 | CSV = 256, |
||
82 | CSV = 512, |
||
83 | = 1024, |
||
84 | OORG_WRITER = 2048, |
||
85 | MS_WORD = 4096, |
||
86 | ADOBE_INDESIGN = 8192, |
||
87 | ADOBE_PAGEMAKER = 16384, |
||
88 | QUARK_XPRESS = 32768, |
||
89 | }; |
||
90 | */ |
||
10181 | cbradney | 91 | FormatsManager(); |
92 | ~FormatsManager(); |
||
93 | |||
94 | /** |
||
95 | * @brief Returns a pointer to the FormatsManager instance |
||
96 | * @return A pointer to the FormatsManager instance |
||
97 | */ |
||
98 | static FormatsManager* instance(); |
||
99 | /** |
||
100 | * @brief Deletes the FormatsManager Instance |
||
101 | * Must be called when FormatsManager is no longer needed. |
||
102 | */ |
||
103 | static void deleteInstance(); |
||
104 | void imageFormatSupported(const QString&); |
||
10292 | cbradney | 105 | //! Returns the name of a format, eg "Encapsulated PostScript" |
106 | QString nameOfFormat(int type); |
||
10181 | cbradney | 107 | |
10292 | cbradney | 108 | //! Returns the mimetypes of a format, eg "application/postscript" |
109 | QStringList mimetypeOfFormat(int type); |
||
10181 | cbradney | 110 | |
10292 | cbradney | 111 | //! Returns in the form of "EPS (*.eps *.EPS *.epsf *.EPSF *.epsi *.EPSI)" |
112 | QString extensionsForFormat(int type); |
||
113 | |||
114 | //! Returns in the form of "*.eps *.epsf *.epsi" or "eps|epsf|epsi" |
||
115 | QString extensionListForFormat(int type, int listType); |
||
116 | |||
117 | //! 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 (*)" |
||
118 | QString fileDialogFormatList(int type); |
||
119 | |||
10181 | cbradney | 120 | protected: |
10292 | cbradney | 121 | QMap<int, QString> m_fmtNames; |
122 | QMap<int, QStringList> m_fmtMimeTypes; |
||
10181 | cbradney | 123 | QMap<int, QStringList> m_fmts; |
124 | QStringList m_fmtList; |
||
10292 | cbradney | 125 | |
10272 | cbradney | 126 | QList<QByteArray> m_qtSupportedImageFormats; |
10181 | cbradney | 127 | QList<QByteArray> m_supportedImageFormats; |
128 | void updateSupportedImageFormats(QList<QByteArray>& supportedImageFormats); |
||
10292 | cbradney | 129 | void fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly=false); |
10181 | cbradney | 130 | |
131 | private: |
||
132 | /** |
||
133 | * @brief The only instance of FormatsManager available. |
||
134 | * |
||
135 | * FormatsManager is singleton and the instance can be queried with the method |
||
136 | * instance(). |
||
137 | */ |
||
138 | static FormatsManager* _instance; |
||
139 | }; |
||
140 | |||
10124 | cbradney | 141 | #endif |