Subversion Repositories Scribus

Rev

Rev 24307 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5653 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
#ifndef SCRIBUS134FORMAT_H
8
#define SCRIBUS134FORMAT_H
9
 
10
#include "pluginapi.h"
11
#include "loadsaveplugin.h"
12
#include "scfonts.h"
13
#include "scribusstructs.h"
5980 avox 14
#include "styles/styleset.h"
5653 cbradney 15
 
17400 fschmid 16
#include <QHash>
9803 fschmid 17
#include <QList>
17982 jghali 18
#include <QMap>
9953 cbradney 19
#include <QProgressBar>
17982 jghali 20
#include <QString>
5653 cbradney 21
 
17982 jghali 22
class QIODevice;
23
 
13710 jghali 24
class  ColorList;
25
class  multiLine;
26
class  ScLayer;
27
class  ScribusDoc;
14272 subik 28
//struct ScribusDoc::BookMa;
13710 jghali 29
class  ScXmlStreamAttributes;
30
class  ScXmlStreamReader;
31
class  ScXmlStreamWriter;
11804 jghali 32
 
5653 cbradney 33
class PLUGIN_API Scribus134Format : public LoadSavePlugin
34
{
35
        Q_OBJECT
36
 
37
        public:
38
                // Standard plugin implementation
39
                Scribus134Format();
40
                virtual ~Scribus134Format();
24307 jghali 41
 
23705 craig 42
                QString fullTrName() const override;
43
                const AboutData* getAboutData() const override;
44
                void deleteAboutData(const AboutData* about) const override;
45
                void languageChange() override;
5685 cbradney 46
                //Not the same as readSLA. This one only reads max 4k of the file for speed.
23705 craig 47
                bool fileSupported(QIODevice* file, const QString & fileName=QString()) const override;
5653 cbradney 48
 
23705 craig 49
                bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0) override;
50
                bool saveFile(const QString & fileName, const FileFormat & fmt) override { return false; };
51
                void addToMainWindowMenu(ScribusMainWindow *) override {};
5653 cbradney 52
 
53
                // Special features - .sla page extraction support
23705 craig 54
                bool loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName=QString()) override;
55
                bool readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles) override;
56
                bool readCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles) override;
57
                bool readLineStyles(const QString& fileName, QHash<QString, multiLine> *Sty) override;
58
                bool readColors(const QString& fileName, ColorList & colors) override;
59
                bool readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames) override;
60
                void getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces) override;
5653 cbradney 61
 
62
        private:
13710 jghali 63
 
10276 avox 64
                enum ItemSelection {
65
                        ItemSelectionMaster = 0,
66
                        ItemSelectionPage   = 1,
67
                        ItemSelectionFrame  = 2,
68
                        ItemSelectionPattern= 3,
69
                };
13710 jghali 70
 
71
                class ItemInfo
72
                {
73
                public:
22534 craig 74
                        ItemInfo(void) { groupLastItem = nextItem = ownLink = ownNr = 0; item = nullptr; isGroupFlag = false; };
13710 jghali 75
                        PageItem* item;
76
                        int groupLastItem;
77
                        int nextItem;
78
                        int ownLink;
16943 fschmid 79
                        int ownNr;
16113 fschmid 80
                        bool isGroupFlag;
13710 jghali 81
                };
82
 
5653 cbradney 83
                void registerFormats();
13710 jghali 84
 
17982 jghali 85
                QIODevice* slaReader(const QString & fileName);
11804 jghali 86
 
24307 jghali 87
                void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet<ParagraphStyle> *docParagraphStyles, ScribusDoc* doc, bool equiv);
88
                void getStyle(CharStyle& style, ScXmlStreamReader& reader, StyleSet<CharStyle> *docCharStyles, ScribusDoc* doc, bool equiv);
13710 jghali 89
 
90
                void readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
91
                void readCMSSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
92
                void readDocumentInfo(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
93
                void readGuideSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
94
                void readToolSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
95
                void readTypographicSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
96
 
97
                bool readArrows(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
13715 jghali 98
                bool readBookMark(ScribusDoc::BookMa& bookmark, int& elem, ScXmlStreamAttributes& attrs);
13710 jghali 99
                bool readCheckProfile(ScribusDoc* doc, ScXmlStreamAttributes& attrs);
100
                bool readColor(ColorList& colors, ScXmlStreamAttributes& attrs);
101
                void readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
16448 jghali 102
                void readNamedCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle);
13710 jghali 103
                bool readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader);
104
                bool readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader);
17689 jghali 105
                bool readItemText(PageItem* item, ScXmlStreamAttributes& attrs, LastStyles* last);
13710 jghali 106
                bool readLatexInfo(PageItem_LatexFrame* item, ScXmlStreamReader& reader);
107
                void readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs);
108
                bool readMultiline(multiLine& ml, ScXmlStreamReader& reader);
22608 craig 109
                bool readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage, const QString& renamedPageName = QString());
13710 jghali 110
                bool readPage(ScribusDoc* doc, ScXmlStreamReader& reader);
111
                bool readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader);
112
                bool readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader);
16531 jghali 113
                void readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle);
13710 jghali 114
                bool readPattern(ScribusDoc* doc, ScXmlStreamReader& reader, const QString& baseDir);
115
                bool readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
116
                bool readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
117
                bool readSections(ScribusDoc* doc, ScXmlStreamReader& reader);
118
                bool readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader);
119
 
20563 jghali 120
                PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, PageItem::ItemKind itemKind, int pagenr = -2 /* currentPage*/);
24307 jghali 121
 
122
                QMap<QString, QString> charStyleMap;
17335 jghali 123
                QMap<QString, QString> parStyleMap;
124
                QMap<uint, QString> legacyStyleMap;
125
                uint legacyStyleCount;
19104 jghali 126
 
13635 jghali 127
                QMap<int, int> groupRemap;
7994 avox 128
                QMap<int, int> itemRemap;
129
                QMap<int, int> itemNext;
130
                QMap<int, int> itemRemapM;
131
                QMap<int, int> itemNextM;
17407 fschmid 132
                QList<PageItem*> FrameItems;
25199 jghali 133
                QList<PDFPresentationData> pdfPresEffects;
13710 jghali 134
 
7994 avox 135
                int itemCount;
136
                int itemCountM;
18906 fschmid 137
                QFile aFile;
5653 cbradney 138
};
139
 
140
extern "C" PLUGIN_API int scribus134format_getPluginAPIVersion();
141
extern "C" PLUGIN_API ScPlugin* scribus134format_getPlugin();
142
extern "C" PLUGIN_API void scribus134format_freePlugin(ScPlugin* plugin);
143
 
144
#endif