Scribus
Open source desktop publishing at your fingertips
scribus134format.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 #ifndef SCRIBUS134FORMAT_H
8 #define SCRIBUS134FORMAT_H
9 
10 #include "pluginapi.h"
11 #include "loadsaveplugin.h"
12 #include "scfonts.h"
13 #include "scribusstructs.h"
14 #include "styles/styleset.h"
15 
16 #include <QHash>
17 #include <QList>
18 #include <QMap>
19 #include <QProgressBar>
20 #include <QString>
21 
22 class QIODevice;
23 
24 class ColorList;
25 class multiLine;
26 class ScLayer;
27 class ScribusDoc;
28 //struct ScribusDoc::BookMa;
30 class ScXmlStreamReader;
31 class ScXmlStreamWriter;
32 
33 class PLUGIN_API Scribus134Format : public LoadSavePlugin
34 {
35  Q_OBJECT
36 
37  public:
38  // Standard plugin implementation
40  virtual ~Scribus134Format();
41  virtual const QString fullTrName() const;
42  virtual const AboutData* getAboutData() const;
43  virtual void deleteAboutData(const AboutData* about) const;
44  virtual void languageChange();
45  //Not the same as readSLA. This one only reads max 4k of the file for speed.
46  virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
47 
48  virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
49  virtual bool saveFile(const QString & fileName, const FileFormat & fmt) { return false; };
51 
52  // Special features - .sla page extraction support
53  virtual bool loadPage(const QString & fileName, int pageNumber, bool Mpage, QString renamedPageName=QString::null);
54  virtual bool readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles);
55  virtual bool readCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles);
56  virtual bool readLineStyles(const QString& fileName, QHash<QString, multiLine> *Sty);
57  virtual bool readColors(const QString& fileName, ColorList & colors);
58  virtual bool readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames);
59  virtual void getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces);
60 
61  private:
62 
63  enum ItemSelection {
64  ItemSelectionMaster = 0,
65  ItemSelectionPage = 1,
66  ItemSelectionFrame = 2,
67  ItemSelectionPattern= 3,
68  };
69 
70  class ItemInfo
71  {
72  public:
73  ItemInfo(void) { groupLastItem = nextItem = ownLink = ownNr = 0; item = NULL; isGroupFlag = false; };
74  PageItem* item;
75  int groupLastItem;
76  int nextItem;
77  int ownLink;
78  int ownNr;
79  bool isGroupFlag;
80  };
81 
82  void registerFormats();
83 
84  QIODevice* slaReader(const QString & fileName);
85 
86  void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet<ParagraphStyle> *docParagraphStyles, ScribusDoc* doc, bool fl);
87 
88  void readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
89  void readCMSSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
90  void readDocumentInfo(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
91  void readGuideSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
92  void readToolSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
93  void readTypographicSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
94 
95  bool readArrows(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
96  bool readBookMark(ScribusDoc::BookMa& bookmark, int& elem, ScXmlStreamAttributes& attrs);
97  bool readCheckProfile(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
98  bool readColor(ColorList& colors, ScXmlStreamAttributes& attrs);
99  void readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
100  void readNamedCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
101  bool readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader);
102  bool readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader);
103  bool readItemText(PageItem* item, ScXmlStreamAttributes& attrs, LastStyles* last);
104  bool readLatexInfo(PageItem_LatexFrame* item, ScXmlStreamReader& reader);
105  void readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs);
106  bool readMultiline(multiLine& ml, ScXmlStreamReader& reader);
107  bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage);
108  bool readPage(ScribusDoc* doc, ScXmlStreamReader& reader);
109  bool readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader);
110  bool readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader);
111  void readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle);
112  bool readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, const QString& baseDir);
113  bool readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
114  bool readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
115  bool readSections(ScribusDoc* doc, ScXmlStreamReader& reader);
116  bool readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader);
117 
118  PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, int pagenr = -2 /* currentPage*/);
119 
120  QMap<QString, QString> parStyleMap;
121  QMap<uint, QString> legacyStyleMap;
122  uint legacyStyleCount;
123 
124  QMap<int, int> groupRemap;
125  QMap<int, int> itemRemap;
126  QMap<int, int> itemNext;
127  QMap<int, int> itemRemapM;
128  QMap<int, int> itemNextM;
129  QList<PageItem*> FrameItems;
130  QList<PDFPresentationData> EffVal;
131 
132  int itemCount;
133  int itemCountM;
134  QFile aFile;
135 };
136 
137 extern "C" PLUGIN_API int scribus134format_getPluginAPIVersion();
138 extern "C" PLUGIN_API ScPlugin* scribus134format_getPlugin();
139 extern "C" PLUGIN_API void scribus134format_freePlugin(ScPlugin* plugin);
140 
141 #endif
Definition: charstyle.h:78
Definition: loadsaveplugin.h:190
virtual const QString fullTrName() const =0
Plug-in's human-readable, translated name.
Displays all kinds of content generated by external programs. Named LatexFrame because it initally on...
Definition: pageitem_latexframe.h:43
virtual void addToMainWindowMenu(ScribusMainWindow *)
Allow plugins to add to a main menu.
Definition: scribus134format.h:50
Abstract super class for all Scribus plug-ins.
Definition: scplugin.h:90
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
virtual void languageChange()=0
Update all user-visible text to reflect current UI language.
Definition: paragraphstyle.h:27
Definition: sccolor.h:155
Definition: scxmlstreamreader.h:36
the Document Class
Definition: scribusdoc.h:90
Definition: scribus134format.h:33
Definition: scxmlstreamreader.h:15
ScPlugin provides an interface to ask plugins for information about themselves.
Definition: scplugin.h:103
Definition: sclayer.h:17
Definition: scxmlstreamwriter.h:15
Superclass for all file import/export/load/save plugins.
Definition: loadsaveplugin.h:33
virtual const AboutData * getAboutData() const =0
Return descriptive information about the plug-in.
Definition: pageitem.h:92
Definition: scribusdoc.h:1322
Definition: scribusstructs.h:250
Definition: scribusstructs.h:338