Subversion Repositories Scribus

Rev

Rev 23705 | Rev 23764 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13746 jghali 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
*/
22370 jghali 7
#ifndef SCRIBUS150FORMAT_H
8
#define SCRIBUS150FORMAT_H
13746 jghali 9
 
10
#include "pluginapi.h"
11
#include "loadsaveplugin.h"
17826 craig 12
#include "notesstyles.h"
13746 jghali 13
#include "scfonts.h"
14
#include "scribusstructs.h"
15
#include "styles/styleset.h"
16162 fschmid 16
#include "selection.h"
13746 jghali 17
 
17982 jghali 18
#include <QList>
13746 jghali 19
#include <QMap>
17982 jghali 20
#include <QProgressBar>
13746 jghali 21
#include <QString>
22
 
17982 jghali 23
class QIODevice;
24
 
13746 jghali 25
class  ColorList;
26
class  multiLine;
23675 jghali 27
class  PageItem_NoteFrame;
13746 jghali 28
class  ScLayer;
29
class  ScribusDoc;
14272 subik 30
//struct ScribusDoc::BookMa;
13746 jghali 31
class  ScXmlStreamAttributes;
32
class  ScXmlStreamReader;
33
class  ScXmlStreamWriter;
18840 jghali 34
class  StoryText;
23675 jghali 35
class  TextNote;
13746 jghali 36
 
37
class PLUGIN_API Scribus150Format : public LoadSavePlugin
38
{
39
        Q_OBJECT
40
 
41
        public:
42
                // Standard plugin implementation
43
                Scribus150Format();
44
                virtual ~Scribus150Format();
23705 craig 45
                QString fullTrName() const override;
46
                const AboutData* getAboutData() const override;
47
                void deleteAboutData(const AboutData* about) const override;
48
                void languageChange() override;
13746 jghali 49
                //Not the same as readSLA. This one only reads max 4k of the file for speed.
23705 craig 50
                bool fileSupported(QIODevice* file, const QString & fileName=QString()) const override;
13746 jghali 51
 
23705 craig 52
                bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0) override;
53
                bool saveFile(const QString & fileName, const FileFormat & fmt) override;
54
                bool savePalette(const QString & fileName) override;
55
                QString saveElements(double xp, double yp, double wp, double hp, Selection* selection, QByteArray &prevData) override;
56
                bool loadPalette(const QString & fileName) override;
57
                bool loadElements(const QString & data, const QString& fileDir, int toLayer, double Xp_in, double Yp_in, bool loc) override;
58
                void addToMainWindowMenu(ScribusMainWindow *) override {};
13746 jghali 59
 
60
                // Special features - .sla page extraction support
23705 craig 61
                bool loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName=QString()) override;
62
                bool readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles) override;
63
                bool readCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles) override;
64
                bool readLineStyles(const QString& fileName, QHash<QString, multiLine> *Sty) override;
65
                bool readColors(const QString& fileName, ColorList & colors) override;
66
                bool readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames) override;
67
                void getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces) override;
13746 jghali 68
 
69
        private:
70
 
71
                enum ItemSelection {
72
                        ItemSelectionMaster = 0,
73
                        ItemSelectionPage   = 1,
74
                        ItemSelectionFrame  = 2,
75
                        ItemSelectionPattern= 3,
16105 fschmid 76
                        ItemSelectionGroup  = 4,
16926 fschmid 77
                        ItemSelectionElements = 5
13746 jghali 78
                };
79
 
80
                class ItemInfo
81
                {
82
                public:
23757 craig 83
                        ItemInfo(void);
84
                        PageItem* item {nullptr};
85
                        int groupLastItem {0};
86
                        int nextItem {0};
87
                        int ownLink {0};
88
                        int ownWeld {0};
89
                        int ownNr {0};
90
                        int itemID {0};
91
                        bool isGroupFlag {false};
92
                        bool isWeldFlag {false};
13746 jghali 93
                };
94
 
23616 jghali 95
                class ReadObjectParams
96
                {
97
                public:
98
                        ReadObjectParams() {}
99
 
100
                        PageItem::ItemKind itemKind { PageItem::StandardItem };
101
                        bool    loadingPage { false };
102
                        QString baseDir;
103
                        QString renamedMasterPage;
104
                };
105
 
13746 jghali 106
                void registerFormats();
107
 
17982 jghali 108
                QIODevice* slaReader(const QString & fileName);
13746 jghali 109
 
110
                void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet<ParagraphStyle> *docParagraphStyles, ScribusDoc* doc, bool fl);
111
 
112
                void readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
113
                void readCMSSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
114
                void readDocumentInfo(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
115
                void readGuideSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
116
                void readToolSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
117
                void readTypographicSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
118
 
119
                bool readArrows(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
120
                bool readBookMark(ScribusDoc::BookMa& bookmark, int& elem, ScXmlStreamAttributes& attrs);
121
                bool readCheckProfile(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
21984 craig 122
                void readColor(ColorList& colors, ScXmlStreamAttributes& attrs);
14150 fschmid 123
                bool readGradient(ScribusDoc *doc, VGradient &gra, ScXmlStreamReader& reader);
13746 jghali 124
                void readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
16448 jghali 125
                void readNamedCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
13746 jghali 126
                bool readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader);
127
                bool readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader);
18840 jghali 128
                bool readStoryText(ScribusDoc *doc, ScXmlStreamReader& reader, PageItem* item);
13786 jghali 129
                bool readItemText(PageItem* item, ScXmlStreamAttributes& attrs, LastStyles* last);
17316 fschmid 130
                bool readItemTableData(PageItem_Table* item, ScXmlStreamReader& reader, ScribusDoc *doc);
18840 jghali 131
                bool readItemTableCell(PageItem_Table* item, ScXmlStreamReader& reader, ScribusDoc *doc);
13746 jghali 132
                bool readLatexInfo(PageItem_LatexFrame* item, ScXmlStreamReader& reader);
133
                void readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs);
134
                bool readMultiline(multiLine& ml, ScXmlStreamReader& reader);
23616 jghali 135
                bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, const ReadObjectParams& loadParams, ItemInfo& info);
13746 jghali 136
                bool readPage(ScribusDoc* doc, ScXmlStreamReader& reader);
137
                bool readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader);
138
                bool readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader);
16531 jghali 139
                void readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle);
17318 fschmid 140
                void readTableStyle(ScribusDoc *doc, ScXmlStreamReader& reader, TableStyle& newStyle);
141
                void readCellStyle(ScribusDoc *doc, ScXmlStreamReader& reader, CellStyle& newStyle);
13746 jghali 142
                bool readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, const QString& baseDir);
143
                bool readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
144
                bool readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
145
                bool readSections(ScribusDoc* doc, ScXmlStreamReader& reader);
146
                bool readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader);
17826 craig 147
                bool readNotes(ScribusDoc* doc, ScXmlStreamReader& reader);
148
                bool readNotesStyles(ScribusDoc* doc, ScXmlStreamReader& reader);
149
                bool readNotesFrames(ScXmlStreamReader &reader);
150
                bool readMarks(ScribusDoc* doc, ScXmlStreamReader& reader);
13746 jghali 151
 
17826 craig 152
                //lists of items and marks with names only, which need update to pointers
153
                QMap<Mark*, int> markeredItemsMap;
154
                QMap<Mark*, QMap<QString, MarkType> > markeredMarksMap;
155
                QMap<QString, int> nsetRangeItemNamesMap;
156
                QMap<QString, TextNote*> notesMasterMarks;
157
                QMap<TextNote*, QString> notesNSets;
158
                struct NoteFrameData {
159
                        QString NSname;
160
                        int myID;
161
                        int itemID;
162
                        int index;
163
                        NumerationRange NSrange;
164
                };
165
                QList<NoteFrameData> notesFramesData;
18394 fschmid 166
                QList<PDFPresentationData> EffVal;
17826 craig 167
 
168
                void updateNames2Ptr(); //after document load items pointers should be updated in markeredItemList
169
 
23616 jghali 170
                PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, PageItem::ItemKind itemKind, int pageNr = -2 /* currentPage*/);
13746 jghali 171
 
172
                void writeCheckerProfiles(ScXmlStreamWriter& docu);
22783 jghali 173
                void writeLineStyles(ScXmlStreamWriter& docu);
13746 jghali 174
                void writeJavascripts(ScXmlStreamWriter& docu);
175
                void writeBookmarks(ScXmlStreamWriter& docu);
16162 fschmid 176
                void writeColors(ScXmlStreamWriter& docu, bool part = false);
177
                void writeGradients(ScXmlStreamWriter & docu, bool part = false);
13746 jghali 178
                void writeHyphenatorLists(ScXmlStreamWriter& docu);
179
                void writePStyles(ScXmlStreamWriter& docu);
180
                void writeCStyles(ScXmlStreamWriter& docu);
16859 craig 181
                void writeTableStyles(ScXmlStreamWriter& docu);
182
                void writeCellStyles(ScXmlStreamWriter& docu);
13746 jghali 183
                void putPStyle(ScXmlStreamWriter& docu, const ParagraphStyle & style, const QString &nodeName);
184
                void putCStyle(ScXmlStreamWriter& docu, const CharStyle & style);
185
                void putNamedCStyle(ScXmlStreamWriter& docu, const CharStyle & style);
16859 craig 186
                void putTableStyle(ScXmlStreamWriter& docu, const TableStyle & style);
187
                void putCellStyle(ScXmlStreamWriter& docu, const CellStyle & style);
18840 jghali 188
                void writeStoryText(ScribusDoc *doc, ScXmlStreamWriter&, PageItem* item);
13746 jghali 189
                void writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter&, PageItem* item);
190
                void writeLayers(ScXmlStreamWriter& docu);
191
                void writePrintOptions(ScXmlStreamWriter& docu);
192
                void writePdfOptions(ScXmlStreamWriter& docu);
193
                void writeDocItemAttributes(ScXmlStreamWriter& docu);
194
                void writeTOC(ScXmlStreamWriter& docu);
17826 craig 195
                void writeMarks(ScXmlStreamWriter & docu);
196
                void writeNotesStyles(ScXmlStreamWriter & docu);
23675 jghali 197
                void writeNotesStyles(ScXmlStreamWriter & docu, const QStringList& styleSelection);
17826 craig 198
                void writeNotesFrames(ScXmlStreamWriter & docu);
23675 jghali 199
                void writeNotesFrames(ScXmlStreamWriter & docu, const QList<PageItem_NoteFrame*>& nfList);
17826 craig 200
                void writeNotes(ScXmlStreamWriter & docu);
23675 jghali 201
                void writeNotes(ScXmlStreamWriter & docu, const QList<TextNote*>& noteList);
13746 jghali 202
                void writePageSets(ScXmlStreamWriter& docu);
203
                void writeSections(ScXmlStreamWriter& docu);
16162 fschmid 204
                void writePatterns(ScXmlStreamWriter& docu, const QString& baseDir, bool part = false, Selection* selection = 0);
13746 jghali 205
                void writeContent(ScXmlStreamWriter& docu, const QString& baseDir);
206
 
207
                void WritePages(ScribusDoc *doc, ScXmlStreamWriter& docu, QProgressBar *dia2, uint maxC, bool master);
208
                void WriteObjects(ScribusDoc *doc, ScXmlStreamWriter& docu, const QString& baseDir, QProgressBar *dia2, uint maxC, ItemSelection master, QList<PageItem*> *items = 0);
19900 jghali 209
                void SetItemProps(ScXmlStreamWriter& docu, PageItem* item, const QString& baseDir);
13746 jghali 210
 
17335 jghali 211
                QMap<QString, QString> parStyleMap;
212
 
13746 jghali 213
                QMap<int, int> itemRemap;
214
                QMap<int, int> itemNext;
215
                QMap<int, int> itemRemapF;
216
                QMap<int, int> itemNextF;
217
                QMap<int, int> itemRemapM;
218
                QMap<int, int> itemNextM;
23637 jghali 219
                QMap<int, PageItem*> LinkID;
17407 fschmid 220
                QList<PageItem*> FrameItems;
16926 fschmid 221
                QMap<PageItem*, QString> itemsWeld;  //item* and master name
13746 jghali 222
 
23757 craig 223
                QFile aFile;
15694 fschmid 224
                QString clipPath;
23757 craig 225
                bool isNewFormat {false};
226
                bool layerFound {false};
227
                double GrX {0.0};
228
                double GrY {0.0};
229
                double Xp {0.0};
230
                double Yp {0.0};
231
                int LayerToPaste {0};
232
                int itemCount {0};
233
                int itemCountM {0};
13746 jghali 234
};
235
 
236
extern "C" PLUGIN_API int scribus150format_getPluginAPIVersion();
237
extern "C" PLUGIN_API ScPlugin* scribus150format_getPlugin();
238
extern "C" PLUGIN_API void scribus150format_freePlugin(ScPlugin* plugin);
239
 
240
#endif