Scribus
Open source desktop publishing at your fingertips
util_formats.h
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 
12 #ifndef _UTIL_FORMATs_H
13 #define _UTIL_FORMATs_H
14 
15 #include <QByteArray>
16 #include <QFile>
17 #include <QFileInfo>
18 #include <QList>
19 #include <QMap>
20 #include <QString>
21 #include <QStringList>
22 #include "scribusapi.h"
23 #include "scconfig.h"
24 
25 bool SCRIBUS_API extensionIndicatesEPS(const QString &ext);
26 bool SCRIBUS_API extensionIndicatesEPSorPS(const QString &ext);
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);
31 bool SCRIBUS_API extensionIndicatesTIFF(const QString &ext);
32 QString SCRIBUS_API getImageType(QString filename);
33 
34 class SCRIBUS_API FormatsManager
35 {
36  public:
37 
38  enum ScImageFormatType
39  {
40  ALLIMAGES = 1|2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768|524288|1048576|2097152|4194304,
41 #ifdef GMAGICK_FOUND
42  IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|65536|1048576|2097152|4194304, // all Types suitable for Image Frames
43 #else
44  IMAGESIMGFRAME = 1|2|4|16|32|64|128|256|512|262144|524288|1048576|2097152|4194304, // all Types suitable for Image Frames
45 #endif
46  VECTORIMAGES = 1|64|1024|2048|16384|32768|131072|262144|4194304, // All pure vector image types
47  RASTORIMAGES = 2|4|8|32|128|256|512|65536|524288|1048576|2097152, // All pure rastor image types
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
59  SVG = 2048, // SVG files
60  AI = 4096, // Adobe Illustrator files
61  XFIG = 8192, // Xfig files
62  CVG = 16384, // Calamus Cvg files
63  WPG = 32768, // Word Perfect WPG files
64 #ifdef GMAGICK_FOUND
65  GMAGICK = 65536, // GraphicsMagick
66 #endif
67  UNICONV = 131072, // UniConvertor
68  PCT = 262144, // Mac Pict
69  BMP = 524288, // BMP
70  PGF = 1048576, // PGF
71  ORA = 2097152, // ORA
72  QT = 4194304 // Qt
73  };
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 */
103  FormatsManager();
104  ~FormatsManager();
105 
110  static FormatsManager* instance();
115  static void deleteInstance();
116  void imageFormatSupported(const QString&);
118  QString nameOfFormat(int type);
119 
121  QStringList mimetypeOfFormat(int type);
122 
124  QString extensionsForFormat(int type);
125 
127  QString extensionListForFormat(int type, int listType);
128 
130  QString fileDialogFormatList(int type);
131 
132  protected:
133  QMap<int, QString> m_fmtNames;
134  QMap<int, QStringList> m_fmtMimeTypes;
135  QMap<int, QStringList> m_fmts;
136  QStringList m_fmtList;
137 
138  QList<QByteArray> m_qtSupportedImageFormats;
139  QList<QByteArray> m_supportedImageFormats;
140  void updateSupportedImageFormats(QList<QByteArray>& supportedImageFormats);
141  void fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly=false);
142 
143  private:
150  static FormatsManager* _instance;
151 };
152 
153 #endif
Definition: util_formats.h:34