r14472 by fschmid - Added Jain Basil Aliyas XTG importer.
scribus-commit
scribus-commit at lists.scribus.net
Tue Jan 5 19:50:31 CET 2010
Revision: 14472
Author: fschmid
Date: 2010-01-05T05:54:39.650288Z
Commit message: Added Jain Basil Aliyas XTG importer.
Changeset:
A /trunk/Scribus/scribus/plugins/gettext/xtgim/fontselectdialog.h
A /trunk/Scribus/scribus/plugins/gettext/xtgim/CMakeLists.txt
A /trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
A /trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.h
A /trunk/Scribus/scribus/plugins/gettext/xtgim
M /trunk/Scribus/scribus/CMakeLists.txt
A /trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.h
M /trunk/Scribus/scribus/gtgettext.cpp
A /trunk/Scribus/scribus/plugins/gettext/xtgim/xtgdialog.cpp
M /trunk/Scribus/scribus/plugins/gettext/CMakeLists.txt
A /trunk/Scribus/scribus/textwriter.cpp
A /trunk/Scribus/scribus/plugins/gettext/xtgim/fontselectdialog.cpp
A /trunk/Scribus/scribus/plugins/gettext/xtgim/xtgdialog.h
A /trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.cpp
A /trunk/Scribus/scribus/textwriter.h
Diffs:
Index: scribus/textwriter.cpp
===================================================================
--- scribus/textwriter.cpp (revision 0)
+++ scribus/textwriter.cpp (revision 14472)
@@ -0,0 +1,140 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Andreas Vox *
+ * avox at scribus.info *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "textwriter.h"
+#include "pageitem.h"
+#include "scribusdoc.h"
+#include "text/storytext.h"
+
+TextWriter::TextWriter(ScribusDoc *doc)
+{
+ document = doc;
+}
+
+void TextWriter::open(PageItem *textframe)
+{
+ frame = textframe;
+ charStyleMap.clear();
+ parStyleMap.clear();
+ fontMap.clear();
+ colorMap.clear();
+
+ styledUptoPos = frame->itemText.length();
+
+ currentCharStyle.erase();
+ currentParStyle.erase();
+}
+
+void TextWriter::appendText(const QString &text)
+{
+ frame->itemText.insertChars(frame->itemText.length(), text);
+}
+
+void TextWriter::setStyles()
+{
+ StoryText& story(frame->itemText);
+
+ if (story.length() > styledUptoPos)
+ {
+ story.setCharStyle(styledUptoPos, story.length() - styledUptoPos, currentCharStyle);
+ for (int i = styledUptoPos; i < story.length()-1; ++i)
+ if (story.text(i) == SpecialChars::PARSEP)
+ story.setStyle(i+1, currentParStyle);
+ styledUptoPos = story.length();
+ }
+}
+
+void TextWriter::close()
+{
+ setStyles();
+ document->redefineCharStyles(charStyles, false);
+ document->redefineStyles(parStyles, false);
+}
+
+void TextWriter::setCharStyle(const CharStyle &cstyle)
+{
+ if (currentCharStyle != cstyle)
+ setStyles();
+ currentCharStyle = cstyle;
+}
+
+void TextWriter::setCharStyle(const QString &name)
+{
+ CharStyle cstyle;
+ cstyle.setParent(name);
+ setCharStyle(cstyle);
+}
+
+void TextWriter::setStyle(const ParagraphStyle &pstyle)
+{
+ if (currentParStyle != pstyle)
+ setStyles();
+ currentParStyle = pstyle;
+}
+
+void TextWriter::setStyle(const QString &name)
+{
+ ParagraphStyle pstyle;
+ pstyle.setParent(name);
+ setStyle(pstyle);
+}
+
+void TextWriter::defineCharStyle(const QString name, const CharStyle &cstyle)
+{
+ CharStyle* newStyle = charStyles.create(cstyle);
+ newStyle->setName(name);
+}
+
+void TextWriter::defineStyle(const QString& name, const ParagraphStyle& pstyle)
+{
+ ParagraphStyle* newStyle = parStyles.create(pstyle);
+ newStyle->setName(name);
+}
+
+void TextWriter::defineFont(const QString &name, const QString& family, const QString& variant, bool bold, bool italic)
+{
+ document->AddFont(name);
+}
+
+void TextWriter::defineColor(const QString &name, const ScColor& color)
+{
+ document->PageColors.insert(name, color);
+}
+
+CharStyle TextWriter::getCurrentCharStyle()
+{
+ return currentCharStyle;
+}
+
+ParagraphStyle TextWriter::getCurrentStyle()
+{
+ return currentParStyle;
+}
+
+ScribusDoc* TextWriter::currentDoc()
+{
+ return document;
+}
\ No newline at end of file
Index: scribus/textwriter.h
===================================================================
--- scribus/textwriter.h (revision 0)
+++ scribus/textwriter.h (revision 14472)
@@ -0,0 +1,127 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Andreas Vox *
+ * avox at scribus.info *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef TEXTWRITER_H
+#define TEXTWRITER_H
+
+#include <QString>
+#include <QMap>
+#include "scconfig.h"
+#include "scribusapi.h"
+
+#include "styles/charstyle.h"
+#include "styles/paragraphstyle.h"
+#include "styles/styleset.h"
+
+class ScribusDoc;
+class PageItem;
+class ScColor;
+
+/**
+ * Helper class for importing text
+ */
+class SCRIBUS_API TextWriter
+{
+public:
+ TextWriter(ScribusDoc* doc);
+ /**
+ Sets the target for following set* and append operations.
+ Only one pageitem of a linked chain may be opened at the same time,
+ it's responsibility of the programmer to ensure that
+ */
+ void open(PageItem* textframe);
+ /**
+ Writes all pending information to the target. This method returns
+ the document into a consistent state. Failing to call it may cause
+ data loss or corruption.
+ */
+ void close();
+ /**
+ Return the current character style
+ */
+ CharStyle getCurrentCharStyle();
+ /**
+ Return the current character style
+ */
+ ParagraphStyle getCurrentStyle();
+ /**
+ Sets the character style for following append operations
+ */
+ void setCharStyle(const CharStyle& cstyle);
+ void setCharStyle(const QString& name);
+ /**
+ Sets the paragraph style for following append operations, ie. the
+ style to be used when the next paragraph separator (\n) is appended.
+ The current paragraph style will not be changed
+ */
+ void setStyle(const ParagraphStyle& pstyle);
+ void setStyle(const QString& name);
+ /**
+ Appends text using current character style and paragraph style
+ */
+ void appendText(const QString& text);
+
+ /**
+ Introduces a new named character style into the document
+ */
+ void defineCharStyle(const QString name, const CharStyle& cstyle);
+ /**
+ Introduces a new named paragraph style into the document
+ */
+ void defineStyle(const QString& name, const ParagraphStyle& pstyle);
+ /**
+ Introduces a new named font into the document.
+ If the document already uses a font 'name', use that. Otherwise find a match
+ using 'family', 'variant', 'bold' and 'italic'
+ */
+ void defineFont(const QString& name, const QString& family, const QString& variant, bool bold=false, bool italic=false);
+ /**
+ Introduces a new named color into the document
+ */
+ void defineColor(const QString& name, const ScColor& color);
+ ScribusDoc* currentDoc();
+
+private:
+ ScribusDoc* document;
+ PageItem* frame;
+
+ CharStyle currentCharStyle;
+ ParagraphStyle currentParStyle;
+
+ int styledUptoPos;
+ void setStyles();
+
+ StyleSet<CharStyle> charStyles;
+ StyleSet<ParagraphStyle> parStyles;
+
+ // for resolving name conflicts:
+ QMap<QString, QString> parStyleMap;
+ QMap<QString, QString> charStyleMap;
+ QMap<QString, QString> fontMap;
+ QMap<QString, QString> colorMap;
+};
+
+#endif
\ No newline at end of file
Index: scribus/plugins/gettext/xtgim/xtgscanner.h
===================================================================
--- scribus/plugins/gettext/xtgim/xtgscanner.h (revision 0)
+++ scribus/plugins/gettext/xtgim/xtgscanner.h (revision 14472)
@@ -0,0 +1,271 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * mail at jainbasil.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef XTGSCANNER_H
+#define XTGSCANNER_H
+
+#include "scconfig.h"
+#include "textwriter.h"
+#include "styles/charstyle.h"
+#include "scribus.h"
+#include "fontselectdialog.h"
+
+#include <QHash>
+/**
+Enum datatype for determining the Scanner mode
+*/
+enum scannerMode
+{
+ textMode,
+ tagMode,
+ nameMode,
+ stringMode
+};
+
+
+/**
+\brief Class for scanning and parsing an XPress Tags Document
+*/
+
+class SCRIBUS_API XtgScanner
+{
+private:
+ /**
+ \variable Variables based on which scanner works in different modes
+ */
+ scannerMode Mode;
+ scannerMode prevMode;
+ /**
+ \variable Variables of the importer
+ */
+ TextWriter* writer;
+ bool importTextOnly;
+ bool usePrefix;
+ QString docname;
+ bool readProperties;
+ /**
+ \variable Flag variables used in the scanner
+ */
+ bool newlineFlag;
+ bool xflag;
+ bool isBold;
+ bool isItalic;
+ /**
+ \variable Input Buffer to which properly encoded file is loaded
+ */
+ QString input_Buffer;
+ int top;
+
+ ScFace curFontUsed;
+ ScribusDoc* doc;
+ /**
+ \variable current Character and paragraph styles
+ */
+ CharStyle currentCharStyle;
+ ParagraphStyle currentParagraphStyle;
+
+ /** character and paragraph styles for defining a new style into the document */
+ CharStyle defCharStyle;
+ ParagraphStyle defParagraphStyle;
+ int featureIndex;
+
+ /** A QStringList to store the features of current character Style and current paragraph Style */
+ QStringList ccsFeatures;
+
+ /** A QStringList to store the features of defined character Style and defined paragraph Style */
+ QStringList dcsFeatures;
+
+ /**
+ To store unsupported attributes
+ */
+ QStringList unSupported;
+ QStringList definedStyles;
+ QStringList definedCStyles;
+ /**
+ \brief textToAppend will be the QString used by the function TextWriter::append(QString& )
+ */
+ QString textToAppend;
+ QString token;
+ QString sfcName; // Name of Style/Fontset/Color to be defined, hence named sfcName
+
+ QHash<QString,void (XtgScanner::*)(void)> tagModeHash;
+ QHash<QString,void (XtgScanner::*)(void)> textModeHash;
+ QHash<QString,void (XtgScanner::*)(void)> nameModeHash;
+ QHash<int,QString> languages;
+ QHash<int,QString> encodings;
+
+ /** define variable will take the following values :
+ \brief
+ 0 Not a definition
+ 1 Character Stylesheet Definition
+ 2 Paragraph Stylesheet Definition
+ */
+ int define;
+
+public:
+ XtgScanner(QString documentName,TextWriter *wr,QString& buffer, bool textOnly, bool prefix);
+ ~XtgScanner();
+
+ /**
+ \brief initialise all hash functions with tokens and corresponding function pointers
+ */
+ void initBasicHash();
+ void initTagMode();
+ void initTextMode();
+ void initNameMode();
+ void initLanguages();
+ /**
+ \brief parse function which will parse the inputBuffer and append it into the PageItem
+ */
+ void xtgParse();
+ /**
+ \brief This function will return the character in Buffer to which top is now pointing to
+ */
+ QChar lookAhead();
+
+ /**
+ \brief A function which returns the next symbol in the input stream as character. This function will increment the top by 1
+ */
+ QChar nextSymbol();
+
+ /**
+ \brief This function will return the current state of Scanner.
+ */
+ scannerMode currentState();
+ scannerMode previousState();
+ /**
+ \brief This function will switch the state of Scanner into textMode or tagMode or styleMode.
+ */
+ void enterState(scannerMode Mode);
+
+ /**
+ \brief This function will return a token which is to be evaluated in parser. Each token will be available in the class member token as a QString.
+ */
+ QString getToken();
+ /**
+ \brief Function to Slice the string so as to remove the inch character etc
+ */
+ QString sliceString();
+ /**
+ \name applyFeature
+ \brief Function to applyFeature to a character Style
+ */
+ void applyFeature(const QString &feature);
+ /**
+ \brief Function which will empty the textToAppend variable by writing into text frame
+ */
+ void flushText();
+ /**
+ \brief Function which returns the status of Style whether defined or not
+ */
+ bool styleStatus(QStringList &name,QString &sfcname);
+ /**
+ \brief Function which will show a message box if a Style "name" is not defined in the document
+ */
+ void showWarning(QString &name);
+
+ /** Set Functions for setting the styles */
+ void setPlain();
+ void setBold();
+ void setItalics();
+ void setShadow();
+ void setOutline();
+ void setUnderline();
+ void setWordUnder();
+ void setStrikethrough();
+ void setDoubleStrike();
+ void setAllCaps();
+ void setSmallCaps();
+ void setSuperscript();
+ void setSubscript();
+ void setSuperior();
+ void setFont();
+ void setFontSize();
+ void setColor();
+ void setShade();
+ void setHorizontalScale();
+ void setKern();
+ void setTrack();
+ void setBaseLineShift();
+ void setVerticalScale();
+ void setLigatures();
+ void csetOpacity();
+ void setOpenType();
+ void setCharAlignment();
+ void setVertStories();
+ void setEmphasisMarks();
+ void setAsncjk();
+ void setLanguages();
+ void setXPresOwn();
+ void setAlignLeft();
+ void setAlignCenter();
+ void setAlignRight();
+ void setAlignJustify();
+ void setAlignFJustify();
+ void setTabStops();
+ void setPAttributes();
+ void setHyphenation();
+ void setPRuleAbove();
+ void setPRuleBelow();
+ void setDropCap();
+ void setKeepNextPar();
+ void setKeepTogether();
+ void setHangingCSet();
+ void setGlyph();
+ void setTranscodeSeq();
+ void setUnencodedGlyph();
+ void xFlag();
+ void definePStyles();
+ void defineCStyle();
+ void applyCStyle1();
+ void applyCStyle2();
+ void applyCStyle3();
+ void applyCStyle4();
+ void applyCStyle5();
+ void applyCStyle6();
+ void setTypeStyle();
+ void appendSpChar1();
+ void appendSpChar2();
+ void appendSpChar3();
+ /**
+ Functions used in textMode Hash
+ */
+ void defNewLine();
+ void defHardReturn();
+ void defFontSet();
+ void defColor();
+ void defEquals();
+ void defClose();
+ void defOpen();
+ void defAtRate();
+ void defColon();
+
+
+protected:
+ void (XtgScanner::*funPointer)(void);
+};
+
+#endif
Property changes on: scribus/plugins/gettext/xtgim/xtgscanner.h
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/xtgdialog.cpp
===================================================================
--- scribus/plugins/gettext/xtgim/xtgdialog.cpp (revision 0)
+++ scribus/plugins/gettext/xtgim/xtgdialog.cpp (revision 14472)
@@ -0,0 +1,98 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * jainbasil at gmail.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "xtgdialog.h"
+
+#include <QToolTip>
+#include <QBoxLayout>
+#include <QVBoxLayout>
+#include <QPixmap>
+#include <QHBoxLayout>
+#include <QCheckBox>
+#include <QPushButton>
+
+#include "scribusapi.h"
+#include <QToolTip>
+#include "util_icon.h"
+
+XtgDialog::XtgDialog(bool prefix) : QDialog(0)
+{
+ setModal(true);
+ setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
+ setWindowTitle( tr("Quark XPress Tags Importer Options"));
+
+ QBoxLayout* layout = new QVBoxLayout(this);
+ layout->setMargin(0);
+ layout->setSpacing(0);
+
+ QBoxLayout* playout = new QHBoxLayout;
+ playout->setMargin(5);
+ playout->setSpacing(5);
+ prefixCheck = new QCheckBox( tr("Use document name as a prefix for Styles"), this);
+ prefixCheck->setChecked(prefix);
+ prefixCheck->setToolTip( "<qt>" + tr("Prepend the document name to the Style name in Scribus.") +"</qt>");
+ playout->addWidget(prefixCheck);
+ layout->addLayout(playout);
+
+ QBoxLayout* dlayout = new QHBoxLayout;
+ dlayout->setMargin(5);
+ dlayout->setSpacing(5);
+ doNotAskCheck = new QCheckBox( tr("Do not ask again"), this);
+ doNotAskCheck->setChecked(false);
+ doNotAskCheck->setToolTip( "<qt>" + tr("Make these settings the default and do not prompt again when importing an XPress Tags document.") +"</qt>");
+ //dlayout->addStretch(10);
+ dlayout->addWidget(doNotAskCheck);
+ layout->addLayout(dlayout);
+
+ QBoxLayout* blayout = new QHBoxLayout;
+ blayout->setMargin(5);
+ blayout->setSpacing(5);
+ blayout->addStretch(10);
+ okButton = new QPushButton( tr("OK"), this);
+ blayout->addWidget(okButton);
+ cancelButton = new QPushButton( tr("Cancel"), this);
+ blayout->addWidget(cancelButton);
+ layout->addLayout(blayout);
+
+ connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
+
+bool XtgDialog::usePrefix()
+{
+ return prefixCheck->isChecked();
+}
+
+bool XtgDialog::askAgain()
+{
+ return !(doNotAskCheck->isChecked());
+}
+
+XtgDialog::~XtgDialog()
+{
+
+}
+
Property changes on: scribus/plugins/gettext/xtgim/xtgdialog.cpp
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/fontselectdialog.cpp
===================================================================
--- scribus/plugins/gettext/xtgim/fontselectdialog.cpp (revision 0)
+++ scribus/plugins/gettext/xtgim/fontselectdialog.cpp (revision 14472)
@@ -0,0 +1,90 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * mail at jainbasil.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "fontselectdialog.h"
+#include "util_icon.h"
+#include <QDebug>
+
+FontSelect::FontSelect(QStringList list):QDialog(0)
+{
+ setModal(true);
+ setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
+ setWindowTitle( tr("Select Alternate Font"));
+
+ resize(370, 83);
+ layoutWidget = new QWidget(this);
+ layoutWidget->setGeometry(QRect(10, 10, 350, 63));
+ verticalLayout_2 = new QVBoxLayout(layoutWidget);
+ verticalLayout_2->setContentsMargins(0, 0, 0, 0);
+ horizontalLayout_2 = new QHBoxLayout();
+ label = new QLabel(layoutWidget);
+ label->setText( tr("Font") );
+ label->setMinimumSize(QSize(61, 0));
+
+ horizontalLayout_2->addWidget(label);
+
+ fontList = new QComboBox(layoutWidget);
+ fontList->setMinimumSize(QSize(281, 0));
+ fontList->addItems(list);
+
+ horizontalLayout_2->addWidget(fontList);
+
+
+ verticalLayout_2->addLayout(horizontalLayout_2);
+
+ horizontalLayout_3 = new QHBoxLayout();
+ horizontalSpacer = new QSpacerItem(128, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+ horizontalLayout_3->addItem(horizontalSpacer);
+
+ okButton = new QPushButton("OK",layoutWidget);
+ okButton->setEnabled(true);
+ okButton->setMinimumSize(QSize(105, 0));
+
+ horizontalLayout_3->addWidget(okButton);
+
+ verticalLayout_2->addLayout(horizontalLayout_3);
+ label->setBuddy(fontList);
+ font = fontList->currentText();
+
+ connect(fontList, SIGNAL(activated(int)), this, SLOT(selectFont()));
+ connect(okButton,SIGNAL(clicked()),this,SLOT(accept()));
+}
+
+void FontSelect::selectFont()
+{
+ font = fontList->currentText();
+}
+
+QString FontSelect::setFont()
+{
+ return font;
+}
+
+void FontSelect::resetFont()
+{
+ font = "";
+}
\ No newline at end of file
Property changes on: scribus/plugins/gettext/xtgim/fontselectdialog.cpp
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/xtgdialog.h
===================================================================
--- scribus/plugins/gettext/xtgim/xtgdialog.h (revision 0)
+++ scribus/plugins/gettext/xtgim/xtgdialog.h (revision 14472)
@@ -0,0 +1,53 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * jainbasil at gmail.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#ifndef XTGDIALOG_H
+#define XTGDIALOG_H
+
+#include "scconfig.h"
+
+#include <QDialog>
+class QCheckBox;
+class QPushButton;
+
+class XtgDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ XtgDialog(bool prefix);
+ ~XtgDialog();
+ bool usePrefix();
+ bool askAgain();
+private:
+ QCheckBox* prefixCheck;
+ QCheckBox* doNotAskCheck;
+ QPushButton* okButton;
+ QPushButton* cancelButton;
+};
+
+#endif /* XTGDIALOG_H */
\ No newline at end of file
Property changes on: scribus/plugins/gettext/xtgim/xtgdialog.h
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/xtgim.cpp
===================================================================
--- scribus/plugins/gettext/xtgim/xtgim.cpp (revision 0)
+++ scribus/plugins/gettext/xtgim/xtgim.cpp (revision 14472)
@@ -0,0 +1,123 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * mail at jainbasil.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "xtgim.h"
+#include "xtgscanner.h"
+#include "xtgdialog.h"
+
+#include "prefsmanager.h"
+#include "util.h"
+#include <prefsfile.h>
+#include <prefscontext.h>
+#include <prefstable.h>
+#include <QFile>
+#include <QFileInfo>
+#include <QTextCodec>
+#include "styles/paragraphstyle.h"
+#include "styles/charstyle.h"
+#include "scribus/scribus.h"
+
+
+QString FileFormatName()
+{
+ return QObject::tr("Quark XPress Tags Document");
+}
+
+QStringList FileExtensions()
+{
+ return QStringList("xtg");
+}
+
+void GetText2(QString filename, QString encoding, bool textOnly, PageItem *textItem)
+{
+ XtgIm* xtgim = new XtgIm(filename, encoding, textItem, textOnly);
+ delete xtgim;
+}
+
+/********************************Class XtgIm***********************************/
+
+XtgIm::XtgIm(QString fileName, QString enc, PageItem *textItem, bool textOnly)
+{
+ PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("XtgIm");
+ bool prefix = prefs->getBool("prefix", true);
+ bool ask = prefs->getBool("askAgain", true);
+ encoding = enc;
+ qDebug()<<"Encoding = "<<encoding;
+ in_Buffer = "";
+ TextWriter *writer = new TextWriter(textItem->doc());
+ writer->open(textItem);
+ if (!textOnly)
+ {
+ if (ask)
+ {
+ XtgDialog* xtgdia = new XtgDialog(prefix);
+ if (xtgdia->exec()) {
+ prefix = xtgdia->usePrefix();
+ prefs->set("prefix", xtgdia->usePrefix());
+ prefs->set("askAgain", xtgdia->askAgain());
+ delete xtgdia;
+ }
+ else {
+ delete xtgdia;
+ return;
+ }
+ }
+ }
+ filename = fileName;
+ /**
+ This will load the xtg file into a QByte Array which will be used for
+ furthur parsing
+ */
+ loadFiletoArray();
+ in_Buffer = toUnicode(buffer);
+ QString docname = filename.right(filename.length() - filename.lastIndexOf("/") - 1);
+ docname = docname.left(docname.lastIndexOf("."));
+ XtgScanner *scanner = new XtgScanner(docname,writer,in_Buffer,textOnly,prefix);
+ scanner->xtgParse();
+ writer->close();
+}
+
+/** \brief Load the file into a buffer of type QByteArray */
+
+void XtgIm::loadFiletoArray()
+{
+ loadRawBytes(filename, buffer);
+}
+
+QString XtgIm::toUnicode(const QByteArray& rawText)
+{
+ QTextCodec *codec;
+ if (encoding.isEmpty())
+ codec = QTextCodec::codecForLocale();
+ else
+ codec = QTextCodec::codecForName(encoding.toLocal8Bit());
+ QString unistr = codec->toUnicode(rawText);
+ return unistr;
+}
+
+XtgIm::~XtgIm()
+{
+}
Property changes on: scribus/plugins/gettext/xtgim/xtgim.cpp
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/fontselectdialog.h
===================================================================
--- scribus/plugins/gettext/xtgim/fontselectdialog.h (revision 0)
+++ scribus/plugins/gettext/xtgim/fontselectdialog.h (revision 14472)
@@ -0,0 +1,72 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * mail at jainbasil.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef FONTSELECTDIALOG_H
+#define FONTSELECTDIALOG_H
+
+#include "scribusapi.h"
+#include <QString>
+#include <QStringList>
+#include <QDialog>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QWidget>
+#include <QLabel>
+#include <QPushButton>
+#include <QSpacerItem>
+#include <QComboBox>
+
+class QPushButton;
+class QComboBox;
+class QLabel;
+class QWidget;
+
+
+class SCRIBUS_API FontSelect:public QDialog
+{
+Q_OBJECT
+
+ public:
+ FontSelect(QStringList list);
+ ~FontSelect(){};
+ QString setFont();
+
+ private slots:
+ void selectFont();
+ void resetFont();
+ private:
+ QLabel *label;
+ QComboBox *fontList;
+ QPushButton *okButton;
+ QString font;
+ QWidget *layoutWidget;
+ QVBoxLayout *verticalLayout_2;
+ QHBoxLayout *horizontalLayout_2;
+ QSpacerItem *horizontalSpacer;
+ QHBoxLayout *horizontalLayout_3;
+};
+
+#endif
Property changes on: scribus/plugins/gettext/xtgim/fontselectdialog.h
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/CMakeLists.txt
===================================================================
--- scribus/plugins/gettext/xtgim/CMakeLists.txt (revision 0)
+++ scribus/plugins/gettext/xtgim/CMakeLists.txt (revision 14472)
@@ -0,0 +1,32 @@
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}
+${CMAKE_SOURCE_DIR}/scribus
+)
+
+SET(XTG_IM_PLUGIN_MOC_CLASSES
+xtgdialog.h
+fontselectdialog.h
+)
+
+SET(XTG_IM_PLUGIN_SOURCES
+xtgdialog.cpp
+xtgim.cpp
+xtgscanner.cpp
+fontselectdialog.cpp
+)
+
+SET(SCRIBUS_XTG_IM_PLUGIN "xtgimplugin")
+
+QT4_WRAP_CPP(XTG_IM_PLUGIN_MOC_SOURCES ${XTG_IM_PLUGIN_MOC_CLASSES})
+
+ADD_LIBRARY(${SCRIBUS_XTG_IM_PLUGIN} MODULE ${XTG_IM_PLUGIN_SOURCES} ${XTG_IM_PLUGIN_MOC_SOURCES})
+
+TARGET_LINK_LIBRARIES(${SCRIBUS_XTG_IM_PLUGIN} ${PLUGIN_LIBRARIES})
+
+INSTALL(TARGETS ${SCRIBUS_XTG_IM_PLUGIN}
+ LIBRARY
+ DESTINATION ${PLUGINDIR}gettext
+ PERMISSIONS ${PLUGIN_PERMISSIONS}
+)
+
+# SET_TARGET_PROPERTIES(${SCRIBUS_FONTPREVIEW_PLUGIN} PROPERTIES VERSION "0.0.0")
Property changes on: scribus/plugins/gettext/xtgim/CMakeLists.txt
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/xtgscanner.cpp
===================================================================
--- scribus/plugins/gettext/xtgim/xtgscanner.cpp (revision 0)
+++ scribus/plugins/gettext/xtgim/xtgscanner.cpp (revision 14472)
@@ -0,0 +1,1374 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+/***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * mail at jainbasil.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "xtgscanner.h"
+#include "text/specialchars.h"
+#include "fonts/scface.h"
+#include <QString>
+#include <QList>
+#include <QDebug>
+#include <QMessageBox>
+
+class ScribusDoc;
+
+XtgScanner::XtgScanner ( QString documentName,TextWriter *wr,QString& buffer, bool textOnly, bool prefix)
+{
+ writer = wr;
+ docname = documentName;
+ importTextOnly = textOnly;
+ usePrefix = prefix;
+ input_Buffer = buffer;
+ doc = writer->currentDoc();
+ initTagMode();
+ initTextMode();
+ initNameMode();
+ initLanguages();
+ top=0;
+ prevMode = textMode;
+ textToAppend = "";
+ define = 0;
+ isBold=false;
+ isItalic=false;
+}
+
+/** Initialise a QHash which maps the values of n## to corresponding language strings
+*/
+
+void XtgScanner::initLanguages()
+{
+ /* For more info, look at langmgr.cpp */
+ languages.insert(72,"Bulgarian");
+ languages.insert(73,"Catalan");
+ languages.insert(52,"Chinese");
+ languages.insert(53,"Chinese");
+ languages.insert(68,"Croatian");
+ languages.insert(56,"Czech");
+ languages.insert(9,"Danish");
+ languages.insert(5,"Dutch");
+ languages.insert(2,"English");
+ languages.insert(0,"English");
+ languages.insert(17,"Finnish");
+ languages.insert(1,"French");
+ languages.insert(3,"German");
+ languages.insert(70,"German");
+ languages.insert(19,"German");
+ languages.insert(20,"Greek");
+ languages.insert(43,"Hungarian");
+ languages.insert(21,"Icelandic");
+ languages.insert(4,"Italian");
+ languages.insert(14,"Japanese");
+ languages.insert(41,"Lithuanian");
+ languages.insert(12,"Norwegian (Bokmål)");
+ languages.insert(80,"Norwegian (Bokmål)");
+ languages.insert(42,"Polish");
+ languages.insert(71,"Portuguese (BR)");
+ languages.insert(10,"Portuguese");
+ languages.insert(39,"Romanian");
+ languages.insert(57,"Slovak");
+ languages.insert(66,"Slovenian");
+ languages.insert(8,"Spanish");
+ languages.insert(7,"Swedish");
+ languages.insert(62,"Ukranian");
+
+}
+
+/** Initialise the tagModeHash with the tokens returned in tagMode and its corresponding function pointers */
+
+void XtgScanner::initTagMode()
+{
+ tagModeHash.insert("P",&XtgScanner::setPlain);
+ tagModeHash.insert("B",&XtgScanner::setBold);
+ tagModeHash.insert("I",&XtgScanner::setItalics);
+ tagModeHash.insert("O",&XtgScanner::setOutline);
+ tagModeHash.insert("S",&XtgScanner::setShadow);
+ tagModeHash.insert("U",&XtgScanner::setUnderline);
+ tagModeHash.insert("W",&XtgScanner::setWordUnder);
+ tagModeHash.insert("/",&XtgScanner::setStrikethrough);
+ tagModeHash.insert("R",&XtgScanner::setDoubleStrike);
+ tagModeHash.insert("K",&XtgScanner::setAllCaps);
+ tagModeHash.insert("H",&XtgScanner::setSmallCaps);
+ tagModeHash.insert("+",&XtgScanner::setSuperscript);
+ tagModeHash.insert("-",&XtgScanner::setSubscript);
+ tagModeHash.insert("V",&XtgScanner::setSuperior);
+ tagModeHash.insert("f",&XtgScanner::setFont);
+ tagModeHash.insert("z",&XtgScanner::setFontSize);
+ tagModeHash.insert("c",&XtgScanner::setColor);
+ tagModeHash.insert("s",&XtgScanner::setShade);
+ tagModeHash.insert("h",&XtgScanner::setHorizontalScale);
+ tagModeHash.insert("k",&XtgScanner::setKern);
+ tagModeHash.insert("t",&XtgScanner::setTrack);
+ tagModeHash.insert("b",&XtgScanner::setBaseLineShift);
+ tagModeHash.insert("y",&XtgScanner::setVerticalScale);
+ tagModeHash.insert("G",&XtgScanner::setLigatures);
+ tagModeHash.insert("p",&XtgScanner::csetOpacity);
+ tagModeHash.insert("o",&XtgScanner::setOpenType);
+ tagModeHash.insert("*A",&XtgScanner::setCharAlignment);
+ tagModeHash.insert("L",&XtgScanner::setVertStories);
+ tagModeHash.insert("M",&XtgScanner::setEmphasisMarks);
+ tagModeHash.insert("Y",&XtgScanner::setAsncjk);//Apply sending to non-CJK characters.
+ tagModeHash.insert("n",&XtgScanner::setLanguages);
+ tagModeHash.insert("A(",&XtgScanner::setXPresOwn); //Apply features like Rubi text, group characters & hyperlink
+ tagModeHash.insert("*L",&XtgScanner::setAlignLeft);
+ tagModeHash.insert("*C",&XtgScanner::setAlignCenter);
+ tagModeHash.insert("*R",&XtgScanner::setAlignRight);
+ tagModeHash.insert("*J",&XtgScanner::setAlignJustify);
+ tagModeHash.insert("*F",&XtgScanner::setAlignFJustify);
+ tagModeHash.insert("*t",&XtgScanner::setTabStops);
+ tagModeHash.insert("*p",&XtgScanner::setPAttributes);
+ tagModeHash.insert("*h",&XtgScanner::setHyphenation);
+ tagModeHash.insert("*ra",&XtgScanner::setPRuleAbove);
+ tagModeHash.insert("*rb",&XtgScanner::setPRuleBelow);
+ tagModeHash.insert("*d",&XtgScanner::setDropCap);
+ tagModeHash.insert("*kn",&XtgScanner::setKeepNextPar);
+ tagModeHash.insert("*kt",&XtgScanner::setKeepTogether);
+ tagModeHash.insert("*s",&XtgScanner::setHangingCSet);
+ tagModeHash.insert("DoO",&XtgScanner::setGlyph);
+ tagModeHash.insert("EX",&XtgScanner::setTranscodeSeq);
+ tagModeHash.insert("DO",&XtgScanner::setUnencodedGlyph);
+
+ tagModeHash.insert("@>",&XtgScanner::applyCStyle1);
+ tagModeHash.insert("@$",&XtgScanner::applyCStyle2);
+ tagModeHash.insert("@$p",&XtgScanner::applyCStyle3);
+ tagModeHash.insert("$$",&XtgScanner::applyCStyle4);
+ tagModeHash.insert("a$",&XtgScanner::applyCStyle5);
+ tagModeHash.insert("a$$",&XtgScanner::applyCStyle6);
+
+ tagModeHash.insert("$",&XtgScanner::setTypeStyle);
+
+ tagModeHash.insert("\\@",&XtgScanner::appendSpChar1);
+ tagModeHash.insert("x",&XtgScanner::xFlag);
+ tagModeHash.insert("\\>",&XtgScanner::appendSpChar2);
+ tagModeHash.insert("\\",&XtgScanner::appendSpChar3);
+ tagModeHash.insert(">",&XtgScanner::defClose);
+}
+
+/** Initialise the textModeHash with tokens returned in textMode and its corresponding function pointers */
+
+void XtgScanner::initTextMode()
+{
+ textModeHash.insert("\n",&XtgScanner::defNewLine);
+ textModeHash.insert("<",&XtgScanner::defOpen);
+ textModeHash.insert("@",&XtgScanner::defAtRate);
+ textModeHash.insert("\r",&XtgScanner::defHardReturn);
+}
+
+/** Initialise the nameModeHash with tokens returned in nameMode and its corresponding function pointers */
+
+void XtgScanner::initNameMode()
+{
+ nameModeHash.insert("[F]",&XtgScanner::defFontSet);
+ nameModeHash.insert("[C]",&XtgScanner::defColor);
+ nameModeHash.insert("[Sp",&XtgScanner::definePStyles);
+ nameModeHash.insert("[St",&XtgScanner::defineCStyle);
+ nameModeHash.insert("=",&XtgScanner::defEquals);
+ nameModeHash.insert(":",&XtgScanner::defColon);
+}
+
+/** Function for each tokens in tagMode. Each token is hashed with corresponding function pointers
+*/
+
+void XtgScanner::setPlain()
+{
+}
+
+
+void XtgScanner::setBold()
+{
+ /* We need to toggle the bold status, hence we set the font as Regular if it is Bold and Italic if it is Bold Italic. If the case is not to toggle the font, we just set it to Bold or Bold Italic */
+ if(curFontUsed.isNone()==true)
+ {
+ isBold=true;
+ }
+ else
+ {
+ QHash<QString,QString> font;
+ font.insert("Regular","Bold");
+ font.insert("Italic","Bold Italic");
+ font.insert("Bold","Regular");
+ font.insert("Bold Italic","Italic");
+ QString fontStyle = curFontUsed.style();
+ fontStyle = font.value(fontStyle);
+ curFontUsed = (*(doc->AllFonts)).value( curFontUsed.family() +" "+ fontStyle );
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setFont(curFontUsed);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define==1)
+ defCharStyle.setFont(curFontUsed);
+ if(define==2)
+ defParagraphStyle.charStyle().setFont(curFontUsed);
+ }
+}
+
+void XtgScanner::setItalics()
+{
+ /* Hash is formed as in the case of setBold() */
+ if( curFontUsed.isNone()==true )
+ isItalic = true;
+ else
+ {
+ QHash<QString,QString> font;
+ font.insert("Regular","Italic");
+ font.insert("Bold","Bold Italic");
+ font.insert("Italic","Regular");
+ font.insert("Bold Italic","Bold");
+ QString fontStyle = curFontUsed.style();
+ fontStyle = font.value(fontStyle);
+ curFontUsed = (*(doc->AllFonts)).value( curFontUsed.family() +" "+ fontStyle );
+
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setFont(curFontUsed);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define==1)
+ defCharStyle.setFont(curFontUsed);
+ if(define==2)
+ defParagraphStyle.charStyle().setFont(curFontUsed);
+ }
+}
+
+void XtgScanner::setShadow()
+{
+ applyFeature(CharStyle::SHADOWED);
+}
+
+void XtgScanner::setOutline()
+{
+ applyFeature(CharStyle::OUTLINE);
+}
+
+void XtgScanner::setUnderline()
+{
+ applyFeature(CharStyle::UNDERLINE);
+}
+
+void XtgScanner::setWordUnder()
+{
+ unSupported.append(token);
+}
+
+void XtgScanner::setStrikethrough()
+{
+ applyFeature(CharStyle::STRIKETHROUGH);
+}
+
+void XtgScanner::setDoubleStrike()
+{
+ unSupported.append(token);
+}
+
+void XtgScanner::setAllCaps()
+{
+ applyFeature(CharStyle::ALLCAPS);
+}
+
+void XtgScanner::setSmallCaps()
+{
+ applyFeature(CharStyle::SMALLCAPS);
+}
+
+void XtgScanner::setSuperscript()
+{
+ applyFeature(CharStyle::SUPERSCRIPT);
+}
+
+void XtgScanner::setSubscript()
+{
+ applyFeature(CharStyle::SUBSCRIPT);
+}
+
+void XtgScanner::setSuperior()
+{
+ unSupported.append(token);
+}
+
+void XtgScanner::setFont()
+{
+ /** define/apply font */
+ flushText();
+ token = getToken();
+ curFontUsed = (*(doc->AllFonts)).value(token);
+ if(curFontUsed.isNone())
+ {
+ QList<QString> List = ((*(doc->AllFonts)).keys());
+ QStringList filter = static_cast<QStringList>(List).filter(token);
+ if( !filter.empty() )
+ List = filter;
+ FontSelect *f = new FontSelect(static_cast<QStringList>(List));
+ if( f->exec() )
+ {
+ token = f->setFont();
+ delete f;
+ }
+ else
+ delete f;
+ }
+ curFontUsed = (*(doc->AllFonts)).value(token);
+ /* Now we check whether isBold=true and isItalic=true. If yes, we will set those */
+ if( isBold && !(curFontUsed.style()).contains("Bold") )
+ {
+ setBold();
+ isBold=false;
+ }
+ if( isItalic && !(curFontUsed.style()).contains("Italic") )
+ {
+ setItalics();
+ isItalic=false;
+ }
+ if( define==0 )
+ {
+ flushText();
+ currentCharStyle.setFont(curFontUsed);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if( define==1 )
+ defCharStyle.setFont(curFontUsed);
+ if( define==2 )
+ defParagraphStyle.charStyle().setFont( curFontUsed );
+}
+
+void XtgScanner::setFontSize()
+{
+ token = getToken();
+ if( define== 0 )
+ {
+ flushText();
+ currentCharStyle.setFontSize( token.toDouble() * 10 );
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if( define == 1 )
+ defCharStyle.setFontSize( token.toDouble() * 10 );
+ if( define == 2 )
+ defParagraphStyle.charStyle().setFontSize( token.toDouble() * 10 );
+}
+
+void XtgScanner::setColor()
+{
+ token = getToken();
+
+ QHash<QString,QString> color;
+ color.insert("cC","Cyan");
+ color.insert("cM","Magenta");
+ color.insert("cY","Yellow");
+ color.insert("cK","Black");
+
+ if( token == "C" || token == "M" || token == "Y" || token == "K" )
+ {
+ token = "c" + token;
+ token = color.value(token);
+ }
+ if( define==0 )
+ {
+ flushText();
+ currentCharStyle.setFillColor(token);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if( define == 1 )
+ defCharStyle.setFillColor(token);
+ if( define == 2 )
+ defParagraphStyle.charStyle().setFillColor(token);
+}
+
+void XtgScanner::setShade()
+{
+ token = getToken();
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setFillShade(token.toDouble() * 10);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define == 1)
+ defCharStyle.setFillShade(token.toDouble() * 10);
+ if(define == 2)
+ defParagraphStyle.charStyle().setFillShade(token.toDouble() * 10);
+
+}
+
+void XtgScanner::setHorizontalScale()
+{
+ token = getToken();
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setScaleH(token.toDouble() * 10);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define == 1)
+ defCharStyle.setScaleH(token.toDouble() * 10);
+ if(define == 2)
+ defParagraphStyle.charStyle().setScaleH(token.toDouble() * 10);
+}
+
+void XtgScanner::setKern()
+{
+ token = getToken();
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setWordTracking(token.toDouble() * 10);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define == 1)
+ defCharStyle.setWordTracking(token.toDouble() * 10);
+ if(define == 2)
+ defParagraphStyle.charStyle().setWordTracking(token.toDouble() * 10);
+}
+
+void XtgScanner::setTrack()
+{
+ token = getToken();
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setTracking(token.toDouble() * 10);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define==1)
+ defCharStyle.setTracking(token.toDouble() * 10);
+ if(define == 2)
+ defParagraphStyle.charStyle().setTracking(token.toDouble() * 10);
+}
+
+void XtgScanner::setBaseLineShift()
+{
+ token = getToken();
+ unSupported.append("b"+token);
+}
+
+void XtgScanner::setVerticalScale()
+{
+ token = getToken();
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setScaleV(token.toDouble() * 10);
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define==1)
+ defCharStyle.setScaleV(token.toDouble() * 10);
+ if(define == 2)
+ defParagraphStyle.charStyle().setScaleV(token.toDouble() * 10);
+}
+
+void XtgScanner::setLigatures()
+{
+ token = getToken();
+ unSupported.append("G"+token);
+}
+
+void XtgScanner::csetOpacity()
+{
+ token = getToken();
+ unSupported.append("p"+token);
+}
+
+void XtgScanner::setOpenType()
+{
+ /* OpenType can be like this : o("xxxx","yyyy","zzzz") */
+}
+
+void XtgScanner::setCharAlignment()
+{
+ token.append( nextSymbol() );
+ unSupported.append(token);
+}
+
+void XtgScanner::setVertStories()
+{
+ token.append( nextSymbol() );
+ unSupported.append(token);
+}
+
+void XtgScanner::setEmphasisMarks()
+{
+ token.append( nextSymbol() );
+ unSupported.append(token);
+}
+
+void XtgScanner::setAsncjk()
+{
+ //Apply sending to non-CJK characters.
+ token.append( nextSymbol() );
+ unSupported.append(token);
+}
+
+void XtgScanner::setLanguages()
+{
+ token = getToken();
+ if(define==0)
+ {
+ flushText();
+ currentCharStyle.setLanguage( languages.value( token.toInt() ) );
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define==1)
+ defCharStyle.setLanguage( languages.value( token.toInt() ) );
+ if(define == 2)
+ defParagraphStyle.charStyle().setLanguage( languages.value( token.toInt() ) );
+}
+
+void XtgScanner::setXPresOwn()
+{
+
+ unSupported.append(token+')');
+ //All these tags are unsupported in Scribus, so just ignoring them till we find close paranthesis
+ while( lookAhead() != ')' )
+ top=top+1;
+ top=top+1;//Ignore )
+}
+
+void XtgScanner::setAlignLeft()
+{
+ if(define == 0)
+ {
+ flushText();
+ currentParagraphStyle.setAlignment(ParagraphStyle::Leftaligned);
+ writer->setStyle(currentParagraphStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ if(define == 2)
+ defParagraphStyle.setAlignment(ParagraphStyle::Leftaligned);
+}
+
+void XtgScanner::setAlignCenter()
+{
+ if(define==0)
+ {
+ flushText();
+ currentParagraphStyle.setAlignment(ParagraphStyle::Centered);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+ if(define == 2)
+ defParagraphStyle.setAlignment(ParagraphStyle::Centered);
+}
+
+void XtgScanner::setAlignRight()
+{
+ if(define==0)
+ {
+ flushText();
+ currentParagraphStyle.setAlignment(ParagraphStyle::Rightaligned);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+ if(define == 2)
+ defParagraphStyle.setAlignment(ParagraphStyle::Rightaligned);
+}
+
+void XtgScanner::setAlignJustify()
+{
+ if(define==0)
+ {
+ flushText();
+ currentParagraphStyle.setAlignment(ParagraphStyle::Justified);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+ if(define == 2)
+ defParagraphStyle.setAlignment(ParagraphStyle::Justified);
+}
+
+void XtgScanner::setAlignFJustify()
+{
+ if(define==0)
+ {
+ flushText();
+ currentParagraphStyle.setAlignment(ParagraphStyle::Extended);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+ if(define == 2)
+ defParagraphStyle.setAlignment(ParagraphStyle::Extended);
+}
+
+void XtgScanner::setTabStops()
+{
+ //tag *t
+// token = getToken(); // Will contain the position
+
+}
+
+void XtgScanner::setPAttributes()
+{
+ double leftIndent,firstlineIndent,rightIndent,leading,gapBefore,gapAfter;
+ leftIndent = getToken().toDouble();
+ firstlineIndent = getToken().toDouble();
+ rightIndent = getToken().toDouble();
+ leading = getToken().toDouble();
+ gapBefore = getToken().toDouble();
+ gapAfter = getToken().toDouble();
+ top = top+1;
+ token="";
+ token.append( nextSymbol() );
+
+ if(token == "g")
+ {
+ /* We have to discard (P,S)) since it is not yet supported in Scribus
+ */
+ while( lookAhead() != ')' )
+ top=top+1;
+ }
+ if(define==0)
+ {
+ flushText();
+ currentParagraphStyle.setLeftMargin(leftIndent);
+ currentParagraphStyle.setRightMargin(rightIndent);
+ currentParagraphStyle.setFirstIndent(firstlineIndent);
+ currentParagraphStyle.setLineSpacing(leading);
+ currentParagraphStyle.setGapBefore(gapBefore);
+ currentParagraphStyle.setGapAfter(gapAfter);
+ if( token == "G" )
+ currentParagraphStyle.setUseBaselineGrid(true);
+ if( token == "g" )
+ currentParagraphStyle.setUseBaselineGrid(false);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+ if(define == 2)
+ {
+ defParagraphStyle.setLeftMargin(leftIndent);
+ defParagraphStyle.setRightMargin(rightIndent);
+ defParagraphStyle.setFirstIndent(firstlineIndent);
+ defParagraphStyle.setLineSpacing(leading);
+ defParagraphStyle.setGapBefore(gapBefore);
+ defParagraphStyle.setGapAfter(gapAfter);
+ if( token == "G" )
+ defParagraphStyle.setUseBaselineGrid(true);
+ if( token == "g" )
+ defParagraphStyle.setUseBaselineGrid(false);
+ }
+}
+
+void XtgScanner::setHyphenation()
+{
+ token=getToken();
+}
+
+void XtgScanner::setPRuleAbove()
+{
+ unSupported.append(token);
+ while( lookAhead() != '>' )
+ top = top+1;
+}
+
+void XtgScanner::setPRuleBelow()
+{
+ unSupported.append(token);
+ while( lookAhead() != '>' )
+ top = top+1;
+}
+
+void XtgScanner::setDropCap()
+{
+ int lineCount;
+ double charCount;
+ lineCount = getToken().toInt();
+ if(lineCount==0) //Specify No rule
+ {
+ if( define==0 )
+ {
+ flushText();
+ currentParagraphStyle.setHasDropCap(false);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+ if( define==2 )
+ {
+ defParagraphStyle.setHasDropCap(false);
+ }
+ }
+ else
+ {
+ charCount = getToken().toDouble();
+
+ if( define==0 )
+ {
+ flushText();
+ currentParagraphStyle.setDropCapLines(lineCount);
+ currentParagraphStyle.setDropCapOffset(charCount);
+ currentParagraphStyle.setHasDropCap(true);
+ writer->setStyle(currentParagraphStyle);
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ }
+
+ if( define==2 )
+ {
+ defParagraphStyle.setDropCapLines(lineCount);
+ defParagraphStyle.setDropCapOffset(charCount);
+ defParagraphStyle.setHasDropCap(true);
+ }
+ }
+}
+
+void XtgScanner::setKeepNextPar()
+{
+ token.append(nextSymbol());
+ unSupported.append(token);
+}
+
+void XtgScanner::setKeepTogether()
+{
+ if( lookAhead() == '(' )
+ {
+ while(lookAhead() != ')')
+ token.append( nextSymbol() );
+ }
+ else token.append(nextSymbol());
+ unSupported.append(token);
+}
+
+void XtgScanner::setHangingCSet()
+{
+ token.append( getToken() );
+ unSupported.append(token);
+}
+
+void XtgScanner::setGlyph()
+{
+}
+
+void XtgScanner::setTranscodeSeq()
+{
+}
+
+void XtgScanner::setUnencodedGlyph()
+{
+}
+
+void XtgScanner::appendSpChar1()
+{
+ textToAppend.append("@");
+}
+
+void XtgScanner::appendSpChar2()
+{
+ textToAppend.append("<");
+}
+
+void XtgScanner::appendSpChar3()
+{
+}
+
+void XtgScanner::xFlag()
+{
+ xflag = true;
+}
+
+void XtgScanner::applyCStyle1()
+{
+ //apply nostyle character sheet <@>
+ define = 0;
+ flushText();
+ writer->setCharStyle("Default Character Style");
+ currentCharStyle = writer->getCurrentCharStyle();
+}
+
+void XtgScanner::applyCStyle2()
+{
+ //apply normal character style sheet <@$>
+ define = 0;
+ flushText();
+ writer->setCharStyle("Default Character Style");
+ currentCharStyle = writer->getCurrentCharStyle();
+}
+
+void XtgScanner::applyCStyle3()
+{
+ //apply paragraph's character stylesheet <@$p>
+ define = 0;
+ flushText();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ writer->setCharStyle(currentCharStyle);
+ currentCharStyle = writer->getCurrentCharStyle();
+}
+
+void XtgScanner::applyCStyle4()
+{
+
+}
+
+void XtgScanner::applyCStyle5()
+{
+ //tag = a$
+}
+
+void XtgScanner::applyCStyle6()
+{
+ //tag = a$$
+}
+
+void XtgScanner::setTypeStyle()
+{
+ //tag = $
+}
+
+/** Functions corresponding to tokens in textMode
+*/
+
+void XtgScanner::defNewLine()
+{
+ flushText();
+ if(lookAhead() == '@')
+ newlineFlag = true;
+ else
+ writer->appendText(SpecialChars::PARSEP);
+}
+
+void XtgScanner::defHardReturn()
+{
+ /* I saw a strange nature in XPress Tags that every hardreturn is followed by a soft return, hence fixing the
+ new line flag to true */
+ if( lookAhead() == '\n' )
+ newlineFlag = true;
+ else
+ writer->appendText(SpecialChars::PARSEP);
+}
+
+void XtgScanner::defOpen()
+{
+ // token <
+ enterState(tagMode);
+}
+
+void XtgScanner::defAtRate()
+{
+ enterState(nameMode);
+ sfcName = getToken();
+}
+
+/** Functions corresponding to tokens in nameMode
+*/
+
+void XtgScanner::defClose() //Token >
+{
+ if(usePrefix)
+ sfcName = docname+"-"+sfcName;
+ if(define == 1)
+ {
+ writer->defineCharStyle(sfcName,defCharStyle);
+ definedCStyles.append(sfcName);
+ defCharStyle.erase();
+ }
+ if(define == 2)
+ {
+ writer->defineStyle(sfcName,defParagraphStyle);
+ definedStyles.append(sfcName);
+ defParagraphStyle.erase();
+ }
+ if(define != 0)
+ {
+ define = 0;
+ dcsFeatures.clear();
+ }
+ enterState(textMode);
+}
+
+void XtgScanner::defEquals() //Token =
+{
+ //define a character stylesheet with the name in sfcName if the next character is not [
+ newlineFlag = false;
+ if( lookAhead() != '[' )
+ {
+ define = 1;
+ defCharStyle.setParent("");
+ enterState(textMode);
+ }
+ else
+ define = 2;
+}
+
+void XtgScanner::defColon()
+{
+ flushText();
+ if(sfcName.isEmpty())
+ qDebug()<<"Empty String";
+ if( sfcName == "@" )
+ sfcName = "Default Paragraph Style";
+ if( sfcName == "@$" )
+ sfcName = "Default Paragraph Style";
+ writer->setStyle(sfcName);
+ currentParagraphStyle = writer->getCurrentStyle();
+ writer->setCharStyle(currentParagraphStyle.charStyle());
+ currentCharStyle = writer->getCurrentCharStyle();
+ if( newlineFlag )
+ writer->appendText(SpecialChars::PARSEP);
+ newlineFlag = false;
+ enterState(textMode);
+ define = 0;
+}
+
+void XtgScanner::defFontSet()
+{
+ unSupported.append("[F]");
+ while( lookAhead() != '>' )
+ top = top+1;
+ top = top-1;
+}
+
+void XtgScanner::defColor()
+{
+ //Define the color using writer->defineColor()
+
+}
+
+void XtgScanner::definePStyles()
+{
+ QString s1,s2,s3;
+ enterState(stringMode);
+ define = 2;
+ top=top+1;//skip the inch
+ s1 = getToken();//will contain the string 1
+ top=top+2;//we have to skip comma and next inch character
+ s2 = getToken();
+ if( lookAhead() != ']' )
+ {
+ top = top+2;
+ s3 = getToken();
+ }
+ top++; // to ensure that ] is avoided
+
+ /** Type 1 definition of Paragraph Stylesheet. Refer Documentation for details
+ */
+ if( s1=="" && s2=="" && s3=="")
+ {
+ //define paragraph stylesheet with default character attributes
+ defParagraphStyle.setParent("");
+ defParagraphStyle.charStyle().setParent("Default Character Style");
+ }
+
+ /** Type 2 definition of Paragraph Stylesheet. Refer Documentation for details
+ */
+ else if( s1=="" && s2=="" && s3!="" )
+ {
+ //define paragraphstyle with character style whose name is in s3
+ defParagraphStyle.setParent("");
+ if(styleStatus(definedCStyles,s3))
+ defParagraphStyle.charStyle().setParent(s3);
+ else
+ {
+ showWarning(s3);
+ defParagraphStyle.charStyle().setParent("Default Character Style");
+ }
+ }
+
+ /** Type 3 definition of Paragraph Stylesheet. Refer Documentation for details
+ */
+ else if( s1!="" && s2!="" && s3!="" )
+ {
+ if( styleStatus(definedStyles,s1) )
+ defParagraphStyle.setParent(s1);
+ else
+ {
+ showWarning(s1);
+ defParagraphStyle.setParent("Default Paragraph Style");
+ }
+ /** s2 is the next paragraph style which is to be applied, but this cannot be done at moment in Scribus
+ */
+ currentParagraphStyle = writer->getCurrentStyle();
+ currentCharStyle = currentParagraphStyle.charStyle();
+ defParagraphStyle.charStyle().setParent(s3);
+ }
+ else
+ {
+ //generate error : parser error
+ }
+ enterState(textMode);
+}
+
+void XtgScanner::defineCStyle()
+{
+ //token [St
+ QString s4;
+ top = top+10;
+ s4 = getToken();
+ if( styleStatus(definedCStyles,s4) )
+ defCharStyle.setParent(s4);
+ else
+ {
+ showWarning(s4);
+ defCharStyle.setParent("Default Character Style");
+ }
+}
+
+void XtgScanner::enterState ( scannerMode mode )
+{
+ prevMode = Mode;
+ Mode = mode;
+}
+
+QString XtgScanner::sliceString()
+{
+ QString name;
+ if( Mode == stringMode )
+ {
+ while( lookAhead() != '\"' )
+ {
+ name.append( nextSymbol() );
+ }
+ top = top+1;
+ }
+ if( Mode == nameMode )
+ {
+ while( lookAhead() != '=' || lookAhead() != ':' )
+ {
+ name.append( nextSymbol() );
+ }
+ }
+ return name;
+}
+
+QString XtgScanner::getToken()
+{
+ QChar temp;
+ QString token;
+ temp = lookAhead();
+ if ( currentState() == textMode )
+ {
+ /**
+ This mode should return only '<' or '@' or newline. It also adds the text_to_be_appended to the QString textToAppend
+ */
+ if( temp =='<' || temp =='@' || temp == '\n' || temp == '\r')
+ token.append( nextSymbol() );
+ else if( temp == '\\' )
+ {
+ /**
+ An escape sequence is occurred, hence we will just append
+ the next character in buffer to the text. This will automatically
+ deal the occurrance of '\@' or '\:' or any other relevant escapes
+ */
+ top = top+1;
+ textToAppend.append( nextSymbol() );
+ }
+ else
+ textToAppend.append( nextSymbol() );
+ }
+
+ if ( currentState() == tagMode )
+ {
+ /**
+ This mode should return attributes B|I|U|O|....|*L|*C|... and an inch character "
+ */
+ if(temp == '@')
+ {
+ token.append( nextSymbol() ); // this will append @
+ if( lookAhead() == '$')
+ {
+ token.append( nextSymbol() ); //this will result in @$ if $ is found
+ if( lookAhead() == 'p' )
+ token.append( nextSymbol() ); //this will result in @$p if p is found
+ }
+ else // to get the name of character stylesheet applied as <@stylesheetname>
+ {
+ while( lookAhead() != '>' )
+ token.append( nextSymbol() );
+ token.append('>');
+ }
+ }
+ else if( temp == '*' )
+ {
+ token.append( nextSymbol() );
+ if( lookAhead() == 'r' || lookAhead() == 'k')
+ {
+ token.append( nextSymbol() );
+ token.append( nextSymbol() );
+ }
+ else
+ token.append( nextSymbol() );
+ }
+ else if( temp == '\\' )
+ {
+ /** append the * character and the nextSymbol to token so as to form a paragraph attribute and '\\' character to deal special characters that contain XPress Tags codes.
+ */
+ token.append( nextSymbol() );
+ token.append( nextSymbol() );
+ }
+ else if( temp == '\"')
+ {
+ /**If inch character is found, the scanner should enter the string mode and enter the corresponding string as the token
+ */
+ enterState(stringMode);
+ top = top+1;
+ token = getToken();
+ enterState( previousState() );
+ }
+ else if( temp.isDigit() )
+ {
+ while( lookAhead().isDigit() )
+ {
+ token.append( nextSymbol() );
+ if( lookAhead() == '.' )
+ token.append( nextSymbol() );
+ }
+ }
+ else if( temp == 'A')
+ {
+ token.append(nextSymbol());
+ }
+ else if( temp == 'a' )
+ {
+ token.append( nextSymbol() );
+ //look for $ or $$ so as to form the token a$ and a$$
+ token.append( getToken() );
+ }
+ else if( temp == '$' ) //look for tags like $,$$ etc
+ {
+ token.append( nextSymbol() );
+ //check for existence one more $
+ if( lookAhead() == '$' )
+ token.append( nextSymbol() );
+ }
+ else if( temp == '>' )
+ token.append( nextSymbol() );
+ else if( temp == '(' )
+ {
+ top = top+1;
+ token = getToken();
+ }
+ else if( temp == ',' )
+ {
+ top = top+1;
+ token=getToken();
+ }
+ else
+ token.append( nextSymbol() );
+ }
+
+ if ( currentState() == nameMode )
+ {
+ /**
+ This mode should return the name of stylesheet (or font set or color) or '=' or ':','[' etc. This mode works with the assumption that a character '@' have occurred prior to it.Hence inorder to obtain the tags like '@$:' or '@:' ,we will append @ symbol initially to the token.
+ */
+ if( (input_Buffer.at(top-1)=='@') && (temp == ':') ) // get the simplest token @
+ {
+ token.append('@');
+ }
+ else if( (input_Buffer.at(top-1)=='@') && (temp == '$') ) //get the token @$
+ {
+ token.append('@');
+ token.append( nextSymbol() );
+ }
+ else if( temp == '\"' )
+ {
+ enterState(stringMode);
+ top = top+1;
+ token = getToken();
+ enterState( previousState() );
+ }
+ else if( temp == ',' )
+ top = top+1;
+ else if( temp == '[' )
+ {
+ //return [F] or [C] or [Sp or [St
+ token.append( nextSymbol() );
+ if( lookAhead() == 'F' || lookAhead() == 'C' || lookAhead() == 'S')
+ {
+ token.append( nextSymbol() );
+ token.append( nextSymbol() ); //append ]
+ }
+ }
+ else if( lookAhead() == '=' )
+ token.append( nextSymbol() );
+ else if( lookAhead() == ':' )
+ token.append( nextSymbol() );
+ else if( lookAhead() == '<' )
+ {
+ token.append( nextSymbol() );
+ }
+ else
+ { // find the name and return it as a tag
+ while( 1 )
+ {
+ temp = lookAhead();
+ if( temp == ':' || temp == '=' )
+ break;
+ token.append( input_Buffer.at(top++) );
+ }
+ }
+ }
+
+ if ( currentState() == stringMode )
+ {
+ /* This mode should return those strings which are inside an inch character, while in tagMode. Hence this should set the mode to tagMode before returning the string value. This will call a function QString sliceString() which will return the required string and maintains the top correctly
+ */
+ token = sliceString();
+ }
+ return token;
+}
+scannerMode XtgScanner::currentState()
+{
+ return Mode;
+}
+scannerMode XtgScanner::previousState()
+{
+ return prevMode;
+}
+
+QChar XtgScanner::lookAhead()
+{
+ return input_Buffer.at ( top );
+}
+
+QChar XtgScanner::nextSymbol()
+{
+ return input_Buffer.at ( top++ );
+}
+
+void XtgScanner::flushText()
+{
+ /* Append any text if exist in textToAppend */
+ if(!textToAppend.isEmpty())
+ {
+ writer->appendText(textToAppend);
+ textToAppend="";
+ }
+}
+
+bool XtgScanner::styleStatus(QStringList &name,QString &sfcname)
+{
+ int i;
+ if( sfcname == "" )
+ return true;
+ for( i=0;i<name.size();i++)
+ {
+ if( name.at(i) == sfcname )
+ return true;
+ }
+ return false;
+}
+
+void XtgScanner::showWarning(QString &name)
+{
+ QMessageBox msgBox;
+ msgBox.setWindowTitle("Message");
+ QString message = "Style " + name + " is not defined, falling back to Scribus Default";
+ msgBox.setText(message);
+ msgBox.exec();
+}
+void XtgScanner::applyFeature(const QString &feature)
+{
+ if( define==0 )
+ {
+ flushText();
+ //checks whether the feature exist in feature list
+ if( (featureIndex=ccsFeatures.indexOf(feature,0)) == -1 )
+ ccsFeatures.append(feature);
+ else //feature exist in list, so remove it and update the style
+ ccsFeatures.removeAt( featureIndex );
+ currentCharStyle.setFeatures(ccsFeatures);
+ currentCharStyle.updateFeatures();
+ writer->setCharStyle(currentCharStyle);
+ }
+ if( define == 1)
+ {
+ dcsFeatures.append(feature);
+ defCharStyle.setFeatures(dcsFeatures);
+ }
+ if( define == 2)
+ {
+ dcsFeatures.append(feature);
+ defParagraphStyle.charStyle().setFeatures(dcsFeatures);
+ }
+}
+
+void XtgScanner::xtgParse()
+{
+ /* Enter the default mode as textMode */
+ enterState(textMode);
+ writer->setCharStyle("");
+ writer->setStyle("");
+ currentCharStyle = writer->getCurrentCharStyle();
+ currentParagraphStyle = writer->getCurrentStyle();
+ while( input_Buffer.at(top) != '\0' )
+ {
+ token = getToken();
+ QHash<QString,void (XtgScanner::*)(void)> *temp = NULL;
+ if( Mode == tagMode )
+ temp = &tagModeHash;
+ if( Mode == nameMode )
+ temp = &nameModeHash;
+ if( Mode == textMode )
+ temp = &textModeHash;
+ if( temp->contains(token) )
+ {
+ funPointer = temp->value(token);
+ (this->*funPointer)();
+ }
+
+ /**
+ Various character Style Applications <@stylesheetname>. We cannot hash this since stylesheetname
+ is not constant
+ */
+
+ else if( (currentState() == tagMode ) && token.startsWith('@') && token.endsWith('>') )
+ {
+ /*here we receive a token @stylesheetname>, hence we have to slice of token to
+ get the name of character stylesheet to be applied
+ */
+ define = 0;
+ sfcName = token.remove(0,1);
+ sfcName = sfcName.remove(sfcName.size()-1,1);
+ flushText();
+ if( styleStatus(definedCStyles,sfcName) )
+ writer->setCharStyle(sfcName);
+ else
+ {
+ showWarning(sfcName);
+ writer->setCharStyle("");
+ }
+ currentCharStyle = writer->getCurrentCharStyle();
+ }
+ }
+ writer->appendText(textToAppend);
+ qDebug()<<"Unsupported : "<<unSupported;
+}
+
+XtgScanner::~XtgScanner()
+{
+}
Property changes on: scribus/plugins/gettext/xtgim/xtgscanner.cpp
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/xtgim/xtgim.h
===================================================================
--- scribus/plugins/gettext/xtgim/xtgim.h (revision 0)
+++ scribus/plugins/gettext/xtgim/xtgim.h (revision 14472)
@@ -0,0 +1,61 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+ /***************************************************************************
+ * Copyright (C) 2009 by Jain Basil Aliyas *
+ * mail at jainbasil.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef XTGIM_H
+#define XTGIM_H
+
+#include "pluginapi.h"
+#include "pageitem.h"
+#include <QString>
+#include <QList>
+#include <QByteArray>
+#include <textwriter.h>
+#include "scribus/scribus.h"
+
+class ScribusMainWindow;
+
+
+extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, PageItem *textItem);
+extern "C" PLUGIN_API QString FileFormatName();
+extern "C" PLUGIN_API QStringList FileExtensions();
+
+class SCRIBUS_API XtgIm : public ScribusMainWindow
+{
+private:
+ QString encoding;
+ QString filename;
+ QString in_Buffer;
+ QByteArray buffer;
+ PageItem *textFrame;
+ TextWriter *writer;
+ void loadFiletoArray();
+ QString toUnicode(const QByteArray& rawText);
+ StyleManager *StyleMan;
+public:
+ XtgIm(QString fileName,QString enc,PageItem *textItem,bool textOnly);
+ ~XtgIm();
+};
+#endif /* XTGIM_H */
\ No newline at end of file
Property changes on: scribus/plugins/gettext/xtgim/xtgim.h
___________________________________________________________________
Added: svn:executable
+ *
Index: scribus/plugins/gettext/CMakeLists.txt
===================================================================
--- scribus/plugins/gettext/CMakeLists.txt (revision 14471)
+++ scribus/plugins/gettext/CMakeLists.txt (revision 14472)
@@ -11,3 +11,4 @@
ENDIF(HAVE_XML)
ADD_SUBDIRECTORY(textfilter)
ADD_SUBDIRECTORY(txtim)
+ADD_SUBDIRECTORY(xtgim)
Index: scribus/CMakeLists.txt
===================================================================
--- scribus/CMakeLists.txt (revision 14471)
+++ scribus/CMakeLists.txt (revision 14472)
@@ -751,6 +751,7 @@
ui/tabscrapbook.cpp
ui/tabtools.cpp
ui/tabtypography.cpp
+ textwriter.cpp
tocgenerator.cpp
ui/tocindexprefs.cpp
transaction.cpp
Index: scribus/gtgettext.cpp
===================================================================
--- scribus/gtgettext.cpp (revision 14471)
+++ scribus/gtgettext.cpp (revision 14472)
@@ -215,9 +215,12 @@
{
// Pointer for the loaded plugin.
void* gtplugin;
+ // Type definition for GetText pointer in the function in question.
+ typedef void (*gt2ptr)(QString filename, QString encoding, bool textOnly, PageItem *textframe);
// Type definition for GetText pointer in the function in question.
typedef void (*sdem)(QString filename, QString encoding, bool textOnly, gtWriter *writer);
// The point to the above.
+ gt2ptr fp_GetText2;
sdem fp_GetText;
// Initialize Path to the "DLL"
QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(idata.soFilePath);
@@ -229,23 +232,36 @@
qWarning("Failed to load plugin %s", pluginFilePath.toAscii().constData());
return;
} // if (!gtplugin)
- // Attempt to map the GetText method to to the pointer via the PluginManager. Store the result in fp_GetText.
- fp_GetText = (sdem) PluginManager::resolveSym(gtplugin, "GetText");
- // If fp_GetText is NULL, we could not find the symbol, report the error, unload the "DLL" and exit the method.
- if (!fp_GetText)
- {
- qWarning("Failed to get GetText() from %s", pluginFilePath.toAscii().constData());
- PluginManager::unloadDLL(gtplugin);
- return;
- } // if (!fp_GetText)
- // Create a new writer object in "append"'s mode ( true or false ) attached to the importItem
- gtWriter *w = new gtWriter(append, importItem);
- // Execute the importer's "GetText" method.
- (*fp_GetText)(filePath, encoding, textOnly, w);
- // Destroy the writer
- delete w;
- // Unload the plugin.
- PluginManager::unloadDLL(gtplugin);
+ fp_GetText2 = (gt2ptr) PluginManager::resolveSym(gtplugin,"GetText2");
+
+ if (fp_GetText2)
+ {
+ if (!append)
+ importItem->itemText.clear();
+ // Execute the importer's "GetText2" method.
+ (*fp_GetText2)(filePath, encoding, textOnly, importItem);
+ } // if (!fp_GetText2)
+ else
+ {
+ // Attempt to map the old GetText method to to the pointer via the PluginManager. Store the result in fp_GetText.
+ fp_GetText = (sdem) PluginManager::resolveSym(gtplugin,"GetText");
+ // If fp_GetText is NULL, we could not find the symbol,report the error, unload the "DLL" and exit the method.
+ if (fp_GetText)
+ {
+ // Create a new writer object in "append"'s mode (true or false ) attached to the importItem
+ gtWriter *w = new gtWriter(append, importItem);
+ // Execute the importer's "GetText" method.
+ (*fp_GetText)(filePath, encoding, textOnly, w);
+ // Destroy the writer
+ delete w;
+ } // if (!fp_GetText)
+ else
+ {
+ qWarning("Failed to get GetText() from %s",pluginFilePath.toAscii().constData());
+ }
+ }
+ // Unload the plugin.
+ PluginManager::unloadDLL(gtplugin);
} // void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath,
// const QString& encoding, bool textOnly, bool append, PageItem* importItem)
More information about the scribus-commit
mailing list