Scribus
Open source desktop publishing at your fingertips
xtgscanner.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  * Copyright (C) 2009 by Jain Basil Aliyas *
9  * mail@jainbasil.net *
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  * This program is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19  * GNU General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU General Public License *
22  * along with this program; if not, write to the *
23  * Free Software Foundation, Inc., *
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25  ***************************************************************************/
26 
27 #ifndef XTGSCANNER_H
28 #define XTGSCANNER_H
29 
30 #include "scconfig.h"
31 #include "textwriter.h"
32 #include "styles/charstyle.h"
33 
34 #include "fontselectdialog.h"
35 
36 #include <QHash>
40 enum scannerMode
41 {
42  textMode,
43  tagMode,
44  nameMode,
45  stringMode
46 };
47 
48 
54 {
55 private:
59  scannerMode Mode;
60  scannerMode prevMode;
64  TextWriter* writer;
65  bool importTextOnly;
66  bool usePrefix;
67  QString docname;
68  bool readProperties;
72  bool newlineFlag;
73  bool xflag;
74  bool isBold;
75  bool isItalic;
79  QString input_Buffer;
80  int top;
81 
82  ScFace curFontUsed;
83  ScribusDoc* doc;
87  CharStyle currentCharStyle;
88  ParagraphStyle currentParagraphStyle;
89 
91  CharStyle defCharStyle;
92  ParagraphStyle defParagraphStyle;
93  int featureIndex;
94 
96  QStringList ccsFeatures;
97 
99  QStringList dcsFeatures;
100 
102  QStringList unSupported;
103  QStringList definedStyles;
104  QStringList definedCStyles;
108  QString textToAppend;
109  QString token;
110  QString sfcName; // Name of Style/Fontset/Color to be defined, hence named sfcName
111 
112  QHash<QString,void (XtgScanner::*)(void)> tagModeHash;
113  QHash<QString,void (XtgScanner::*)(void)> textModeHash;
114  QHash<QString,void (XtgScanner::*)(void)> nameModeHash;
115  QHash<int,QString> languages;
116  QHash<int,QString> encodings;
117 
124  int define;
125 
126 public:
127  XtgScanner(QString documentName, TextWriter *wr, QString& buffer, bool textOnly, bool prefix);
128  ~XtgScanner();
129 
133  void initBasicHash();
134  void initTagMode();
135  void initTextMode();
136  void initNameMode();
137  void initLanguages();
141  void xtgParse();
145  QChar lookAhead();
146 
150  QChar nextSymbol();
151 
155  scannerMode currentState();
156  scannerMode previousState();
160  void enterState(scannerMode Mode);
161 
165  QString getToken();
169  QString sliceString();
174  void applyFeature(const QString &feature);
178  void flushText();
182  bool styleStatus(QStringList &name,QString &sfcname);
186  void showWarning(QString &name);
187 
189  void setPlain();
190  void setBold();
191  void setItalics();
192  void setShadow();
193  void setOutline();
194  void setUnderline();
195  void setWordUnder();
196  void setStrikethrough();
197  void setDoubleStrike();
198  void setAllCaps();
199  void setSmallCaps();
200  void setSuperscript();
201  void setSubscript();
202  void setSuperior();
203  void setFont();
204  void setFontSize();
205  void setColor();
206  void setShade();
207  void setHorizontalScale();
208  void setKern();
209  void setTrack();
210  void setBaseLineShift();
211  void setVerticalScale();
212  void setLigatures();
213  void csetOpacity();
214  void setOpenType();
215  void setCharAlignment();
216  void setVertStories();
217  void setEmphasisMarks();
218  void setAsncjk();
219  void setLanguages();
220  void setXPresOwn();
221  void setAlignLeft();
222  void setAlignCenter();
223  void setAlignRight();
224  void setAlignJustify();
225  void setAlignFJustify();
226  void setTabStops();
227  void setPAttributes();
228  void setHyphenation();
229  void setPRuleAbove();
230  void setPRuleBelow();
231  void setDropCap();
232  void setKeepNextPar();
233  void setKeepTogether();
234  void setHangingCSet();
235  void setGlyph();
236  void setTranscodeSeq();
237  void setUnencodedGlyph();
238  void xFlag();
239  void definePStyles();
240  void defineCStyle();
241  void applyCStyle1();
242  void applyCStyle2();
243  void applyCStyle3();
244  void applyCStyle4();
245  void applyCStyle5();
246  void applyCStyle6();
247  void setTypeStyle();
248  void appendSpChar1();
249  void appendSpChar2();
250  void appendSpChar3();
254  void defNewLine();
255  void defHardReturn();
256  void defFontSet();
257  void defColor();
258  void defEquals();
259  void defClose();
260  void defOpen();
261  void defAtRate();
262  void defColon();
263 
264 
265 protected:
266  void (XtgScanner::*funPointer)(void);
267 };
268 
269 #endif
QString sliceString()
Function to Slice the string so as to remove the inch character etc.
Definition: xtgscanner.cpp:1046
Definition: charstyle.h:78
scannerMode currentState()
This function will return the current state of Scanner.
Definition: xtgscanner.cpp:1244
Definition: textwriter.h:46
void enterState(scannerMode Mode)
This function will switch the state of Scanner into textMode or tagMode or styleMode.
Definition: xtgscanner.cpp:1040
void defNewLine()
Definition: xtgscanner.cpp:855
void showWarning(QString &name)
Function which will show a message box if a Style "name" is not defined in the document.
Definition: xtgscanner.cpp:1292
void flushText()
Function which will empty the textToAppend variable by writing into text frame.
Definition: xtgscanner.cpp:1269
void definePStyles()
Definition: xtgscanner.cpp:961
void initLanguages()
Definition: xtgscanner.cpp:63
QString getToken()
This function will return a token which is to be evaluated in parser. Each token will be available in...
Definition: xtgscanner.cpp:1067
Definition: paragraphstyle.h:27
QChar nextSymbol()
A function which returns the next symbol in the input stream as character. This function will increme...
Definition: xtgscanner.cpp:1261
void setFont()
Definition: xtgscanner.cpp:317
the Document Class
Definition: scribusdoc.h:90
void xtgParse()
parse function which will parse the inputBuffer and append it into the PageItem
Definition: xtgscanner.cpp:1326
void initTagMode()
Definition: xtgscanner.cpp:103
QChar lookAhead()
This function will return the character in Buffer to which top is now pointing to.
Definition: xtgscanner.cpp:1253
Base Class ScFace : This is a total rewrite of the old Foi class.
Definition: scface.h:73
void setPlain()
Definition: xtgscanner.cpp:196
Binary buffer.
Definition: pdbim.h:93
void defClose()
Definition: xtgscanner.cpp:889
void initBasicHash()
initialise all hash functions with tokens and corresponding function pointers
bool styleStatus(QStringList &name, QString &sfcname)
Function which returns the status of Style whether defined or not.
Definition: xtgscanner.cpp:1279
void initNameMode()
Definition: xtgscanner.cpp:183
void initTextMode()
Definition: xtgscanner.cpp:173
Class for scanning and parsing an XPress Tags Document.
Definition: xtgscanner.h:53