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 IMPORTIDMLIMPL_H 8 #define IMPORTIDMLIMPL_H 9 10 #include "pageitem.h" 11 #include "sccolor.h" 12 #include "fpointarray.h" 13 #include "docpreference.h" 14 15 #include <QObject> 16 #include <QList> 17 #include <QTransform> 18 #include <QMultiMap> 19 #include <QtGlobal> 20 #include <QObject> 21 #include <QString> 22 #include <QRect> 23 #include <QStack> 24 #include <QDomNode> 25 #include <QDomElement> 26 #include <QPointF> 27 28 class QString; 29 class ScribusDoc; 30 class MultiProgressDialog; 31 class Selection; 32 class TransactionSettings; 33 class ScLayer; 34 35 enum Capitalization 36 { 37 AllCaps, 38 SmallCaps, 39 Normal 40 }; 41 enum Justification 42 { 43 LeftAlign, 44 CenterAlign, 45 RightAlign, 46 FullyJustified 47 }; 48 enum Position 49 { 50 NormalP, 51 SuperScript, 52 SubScript 53 }; 54 struct CommonTextProps 55 { 56 // CommonTextProperties represented as Attributes 57 QString AppliedCStyle; 58 QString AppliedLanguage; 59 QString AppliedPStyle; 60 double AutoLeading; 61 double BaselineShift; 62 Capitalization Capital; 63 double DesiredGlyphScale; 64 double DesiredWordSpace; 65 double DropCapChars; //Not supported in Scribus 66 double DropCapLines; 67 QString FillColor; 68 QString FillTint; 69 double FirstLineIndent; 70 QString FontStyle; 71 double GradFillAngle; 72 double GradFillLength; 73 double GradStrokeAngle; 74 double GradStrokeLength; 75 double HorizontalScale; 76 Justification justify; 77 double KerningValue; 78 double LeftIndent; 79 double MaxGlyphScaling; 80 double MaxWordSpacing; 81 double MinGlyphScaling; 82 double MinWordSpacing; 83 double PointSize; 84 Position position; 85 double RightIndent; 86 double SpaceAfter; 87 double SpaceBefore; 88 double StrikeThruWeight; 89 double StrikeThruOffset; 90 bool StrikeThru; 91 QString StrokeColor; 92 double StrokeTint; 93 double Tracking; 94 bool Underline; 95 double UnderlineOffset; 96 double UnderlineWeight; 97 //CommonTextProperties represented as elements 98 QString AppliedFont; 99 /* Handle Tablists later */ 100 }; 101 102 struct CStyleRange 103 { 104 CommonTextProps properties; 105 QString Content; 106 }; 107 108 /*! 109 \brief Stuct PStyleRange will hold the values of all those attributes/elements which can occur in the ParagraphStyleRange in a Story. Since it can contain any number of CharacterStyleRange elements as its children, we use a list to store all of them. 110 \param properties contain all the common text properties, of which if anyone is skipped, we use the default value for it from the docpreference object. 111 \param cstyleRange contain all the CharacterStyleRange elements in the ParagraphStyleRange 112 */ 113 struct PStyleRange 114 { 115 CommonTextProps properties; 116 QList<CStyleRange> cstyleRange; 117 }; 118 119 class Story 120 { 121 public: 122 QList<PStyleRange> pstyleRange; 123 CommonTextProps properties; 124 }; 125 126 struct PathPoint 127 { 128 QPointF Anchor; 129 QPointF Left; 130 QPoint Right; 131 }; 132 133 class ImportIdmlImpl : public QObject 134 { 135 Q_OBJECT 136 public: 137 ImportIdmlImpl(); ~ImportIdmlImpl()138 ~ImportIdmlImpl() {}; 139 bool run(const QString & target, ScribusDoc* doc=0); 140 141 QString desmapPath, fontPath, stylePath, graphicPath, preferPath, mspreadPath; 142 private: 143 bool processDesignMap(); 144 bool processFont(); 145 bool processStyles(); 146 bool importPStyles(QDomNode&); importCStyles(QDomNode &)147 bool importCStyles(QDomNode&) { return false; }; 148 bool processSpreads(); 149 bool processStory(); 150 bool readStoryObjects(QDomNode); 151 void readComTextProps(QDomNode, CommonTextProps&); 152 void readSpread(QDomNode); 153 void readMSpread(QDomNode); 154 void docAttributes(QDomElement&); 155 void handleLanguage(QDomElement&); 156 void handleLayer(ScLayer&,QDomElement&); 157 void handleSection(ScribusDoc*, QDomElement&); 158 void handleCRFormat(QDomElement&); 159 void handleBookmarks(QDomElement&); 160 161 /** PageItem Functions */ 162 void handleGroup(QDomNode); 163 void readGradiant(QDomNode); 164 void addTextFrame(ScribusDoc*,QDomNode); 165 void addPage(ScribusDoc*, QDomNode); 166 void addMasterPage(ScribusDoc*,QDomNode); addRectangle(ScribusDoc *,QDomNode)167 void addRectangle(ScribusDoc*,QDomNode) {}; 168 void addOval(ScribusDoc*,QDomNode); addPolygon(ScribusDoc *,QDomNode)169 void addPolygon(ScribusDoc*,QDomNode) {}; addGraphicLine(ScribusDoc *,QDomNode)170 void addGraphicLine(ScribusDoc*,QDomNode) {}; 171 double findWidth(double,double,double,double); 172 double findHeight(double,double,double,double); applyTransform(QString)173 QTransform applyTransform(QString) { return QTransform(); } 174 PathPoint readPathPoint(QDomElement); 175 176 void getMSpreadSrc(QDomElement&); 177 void getSpreadSrc(QDomElement&); 178 void getStorySrc(QDomElement&); 179 void getBStorySrc(QDomElement&); 180 void readParagraphStyle(ScribusDoc *doc, QDomNode node, ParagraphStyle& newStyle, SCFonts &fonts); 181 void readCharacterStyle(ScribusDoc *doc, QDomNode node, CharStyle& newStyle); 182 void fixLegacyParStyle(ParagraphStyle& pstyle); fixLegacyCStyle(CharStyle & cstyle)183 void fixLegacyCStyle(CharStyle& cstyle) {}; 184 CStyleRange readCStyleRange(QDomNode node); 185 186 QDomElement loadXmlFile(QString &filename); 187 QDomDocument doc; 188 QDomNode node; 189 QDomElement root; 190 QDomElement element; 191 QMap<QString,int> layerMap; 192 QMap<QString,Story> storyMap; 193 QList<QString> storyList; 194 QList<QString> storyPath; 195 QList<QString> Spreads; 196 QList<QString> spreadPath; 197 QList<QString> MasterSpreads; 198 QList<QString> MSpreadPath; 199 QList<PageItem*> Elements; 200 int layerID; 201 int pageNumber; 202 int currentLayer; 203 int importerFlags; 204 int currentPageNr; 205 bool interactive; 206 bool cancel; 207 bool firstLayer; 208 double baseX, baseY; 209 double docWidth; 210 double docHeight; 211 QString baseFile; 212 QString activeLayer; 213 DocPreferences preference; 214 FPointArray coords; 215 MultiProgressDialog *progressDialog; 216 ScribusDoc* m_Doc; 217 SCFonts* m_AvailableFonts; 218 Selection *tmpSel; 219 ParagraphStyle vg; 220 CharStyle cs; 221 PageItem *currItem; 222 }; 223 224 #endif 225