r21282 by fschmid -
scribus-commit
scribus-commit at lists.scribus.net
Thu May 5 09:59:58 UTC 2016
Author: fschmid
Date: Thu May 5 09:59:58 2016
New Revision: 21282
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21282
Log:
Fixed Bug #14010: ODT Importer Append completely overwrites text frame
Modified:
trunk/Scribus/scribus/gtgettext.cpp
trunk/Scribus/scribus/plugins/gettext/docxim/docxim.cpp
trunk/Scribus/scribus/plugins/gettext/docxim/docxim.h
trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp
trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.h
trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.cpp
trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.h
trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.cpp
trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.h
trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.h
Modified: trunk/Scribus/scribus/gtgettext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/gtgettext.cpp
==============================================================================
--- trunk/Scribus/scribus/gtgettext.cpp (original)
+++ trunk/Scribus/scribus/gtgettext.cpp Thu May 5 09:59:58 2016
@@ -223,7 +223,7 @@
// 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, bool prefix, PageItem *textframe);
+ typedef void (*gt2ptr)(QString filename, QString encoding, bool textOnly, bool prefix, bool append, 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.
@@ -246,7 +246,7 @@
if (!append)
importItem->itemText.clear();
// Execute the importer's "GetText2" method.
- (*fp_GetText2)(filePath, encoding, textOnly, prefix, importItem);
+ (*fp_GetText2)(filePath, encoding, textOnly, prefix, append, importItem);
} // if (!fp_GetText2)
else
{
Modified: trunk/Scribus/scribus/plugins/gettext/docxim/docxim.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/docxim/docxim.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/docxim/docxim.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/docxim/docxim.cpp Thu May 5 09:59:58 2016
@@ -34,17 +34,18 @@
return QStringList("docx");
}
-void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem)
-{
- DocXIm* docxim = new DocXIm(filename, textItem, textOnly, prefix);
+void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem)
+{
+ DocXIm* docxim = new DocXIm(filename, textItem, textOnly, prefix, append);
delete docxim;
}
-DocXIm::DocXIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix)
+DocXIm::DocXIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix, bool append)
{
m_Doc = textItem->doc();
m_item = textItem;
m_prefixName = prefix;
+ m_append = append;
themePart = "";
docPart = "";
stylePart = "";
@@ -274,6 +275,15 @@
{
qDebug() << "Error loading File" << errorMsg << "at Line" << errorLine << "Column" << errorColumn;
return;
+ }
+ if (!m_append)
+ {
+ QString pStyleD = CommonStrings::DefaultParagraphStyle;
+ ParagraphStyle newStyle;
+ newStyle.setDefaultStyle(false);
+ newStyle.setParent(pStyleD);
+ textItem->itemText.clear();
+ textItem->itemText.setDefaultStyle(newStyle);
}
textItem->itemText.setDefaultStyle(defaultParagraphStyle);
QDomElement docElem = designMapDom.documentElement();
@@ -598,6 +608,15 @@
qDebug() << "Error loading File" << errorMsg << "at Line" << errorLine << "Column" << errorColumn;
return;
}
+ if (!m_append)
+ {
+ QString pStyleD = CommonStrings::DefaultParagraphStyle;
+ ParagraphStyle newStyle;
+ newStyle.setDefaultStyle(false);
+ newStyle.setParent(pStyleD);
+ textItem->itemText.clear();
+ textItem->itemText.setDefaultStyle(newStyle);
+ }
currentParagraphStyle.setParent(CommonStrings::DefaultParagraphStyle);
currentParagraphStyle.charStyle().setParent(CommonStrings::DefaultCharacterStyle);
currentParagraphStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing);
Modified: trunk/Scribus/scribus/plugins/gettext/docxim/docxim.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/docxim/docxim.h
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/docxim/docxim.h (original)
+++ trunk/Scribus/scribus/plugins/gettext/docxim/docxim.h Thu May 5 09:59:58 2016
@@ -22,14 +22,14 @@
#include <QHash>
class ScZipHandler;
-extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem);
+extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem);
extern "C" PLUGIN_API QString FileFormatName();
extern "C" PLUGIN_API QStringList FileExtensions();
class DocXIm
{
public:
- DocXIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix);
+ DocXIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix, bool append);
~DocXIm();
private:
void parseContentTypes();
@@ -50,6 +50,7 @@
ScribusDoc* m_Doc;
PageItem* m_item;
bool m_prefixName;
+ bool m_append;
ParagraphStyle defaultParagraphStyle;
ParagraphStyle currentParagraphStyle;
QHash<QString, QString> map_ID_to_Name;
Modified: trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.cpp Thu May 5 09:59:58 2016
@@ -40,17 +40,18 @@
return ret;
}
-void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem)
-{
- ODTIm* docxim = new ODTIm(filename, textItem, textOnly, prefix);
+void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem)
+{
+ ODTIm* docxim = new ODTIm(filename, textItem, textOnly, prefix, append);
delete docxim;
}
-ODTIm::ODTIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix)
+ODTIm::ODTIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix, bool append)
{
m_Doc = textItem->doc();
m_item = textItem;
m_prefixName = prefix;
+ m_append = append;
QFileInfo fi = QFileInfo(fileName);
QString ext = fi.suffix().toLower();
if (ext == "fodt")
@@ -259,13 +260,16 @@
void ODTIm::parseRawText(QDomElement &elem, PageItem* item)
{
- int posC = 0;
QString pStyleD = CommonStrings::DefaultParagraphStyle;
ParagraphStyle newStyle;
newStyle.setDefaultStyle(false);
newStyle.setParent(pStyleD);
- item->itemText.clear();
- item->itemText.setDefaultStyle(newStyle);
+ if (!m_append)
+ {
+ item->itemText.clear();
+ item->itemText.setDefaultStyle(newStyle);
+ }
+ int posC = item->itemText.length();
for(QDomNode para = elem.firstChild(); !para.isNull(); para = para.nextSibling())
{
if ((para.nodeName() == "text:p") || (para.nodeName() == "text:h"))
@@ -788,7 +792,6 @@
void ODTIm::parseText(QDomElement &elem, PageItem* item, ObjStyleODT &tmpOStyle)
{
- int posC = 0;
QString pStyleD = CommonStrings::DefaultParagraphStyle;
ParagraphStyle newStyle;
newStyle.setDefaultStyle(false);
@@ -797,9 +800,13 @@
CharStyle nstyle = ttx.charStyle();
newStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing);
newStyle.setLineSpacing(nstyle.fontSize() / 10.0);
- item->itemText.clear();
- item->itemText.setDefaultStyle(newStyle);
- item->setFirstLineOffset(FLOPFontAscent);
+ if (!m_append)
+ {
+ item->itemText.clear();
+ item->itemText.setDefaultStyle(newStyle);
+ item->setFirstLineOffset(FLOPFontAscent);
+ }
+ int posC = item->itemText.length();
for(QDomNode para = elem.firstChild(); !para.isNull(); para = para.nextSibling())
{
if ((para.nodeName() == "text:p") || (para.nodeName() == "text:h"))
Modified: trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.h
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.h (original)
+++ trunk/Scribus/scribus/plugins/gettext/odt2im/importodt.h Thu May 5 09:59:58 2016
@@ -23,7 +23,7 @@
#include <QHash>
class ScZipHandler;
-extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem);
+extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem);
extern "C" PLUGIN_API QString FileFormatName();
extern "C" PLUGIN_API QStringList FileExtensions();
@@ -91,7 +91,7 @@
class ODTIm
{
public:
- ODTIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix);
+ ODTIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix, bool append);
~ODTIm();
private:
struct DrawStyle
@@ -155,6 +155,7 @@
ScribusDoc* m_Doc;
PageItem* m_item;
bool m_prefixName;
+ bool m_append;
QHash<QString, QString> map_ID_to_Name;
QHash<QString, QString> m_fontMap;
QHash<QString, DrawStyle> m_Styles;
Modified: trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.cpp Thu May 5 09:59:58 2016
@@ -30,7 +30,7 @@
return QStringList("rtf");
}
-void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem)
+void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem)
{
QFile f(filename);
if (f.open(QIODevice::ReadOnly))
@@ -41,6 +41,15 @@
buffer.open(QIODevice::ReadOnly);
RtfReader::SlaDocumentRtfOutput *output = new RtfReader::SlaDocumentRtfOutput(textItem, textItem->doc(), prefix);
RtfReader::Reader reader;
+ if (!append)
+ {
+ QString pStyleD = CommonStrings::DefaultParagraphStyle;
+ ParagraphStyle newStyle;
+ newStyle.setDefaultStyle(false);
+ newStyle.setParent(pStyleD);
+ textItem->itemText.clear();
+ textItem->itemText.setDefaultStyle(newStyle);
+ }
reader.parseFromDeviceTo(&buffer, output);
textItem->itemText.trim();
textItem->itemText.invalidateLayout();
Modified: trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.h
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.h (original)
+++ trunk/Scribus/scribus/plugins/gettext/rtfim/rtfim.h Thu May 5 09:59:58 2016
@@ -18,7 +18,7 @@
#include <QString>
-extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem);
+extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem);
extern "C" PLUGIN_API QString FileFormatName();
extern "C" PLUGIN_API QStringList FileExtensions();
Modified: trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.cpp Thu May 5 09:59:58 2016
@@ -37,17 +37,17 @@
return QStringList("xtg");
}
-void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem)
+void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem)
{
- XtgIm* xtgim = new XtgIm(filename, textItem, textOnly, prefix);
+ XtgIm* xtgim = new XtgIm(filename, textItem, textOnly, prefix, append);
delete xtgim;
}
/********************************Class XtgIm***********************************/
-XtgIm::XtgIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix)
+XtgIm::XtgIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix, bool append)
{
- XtgScanner *scanner = new XtgScanner(fileName, textItem, textOnly, prefix);
+ XtgScanner *scanner = new XtgScanner(fileName, textItem, textOnly, prefix, append);
scanner->xtgParse();
delete scanner;
}
Modified: trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.h
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.h (original)
+++ trunk/Scribus/scribus/plugins/gettext/xtgim/xtgim.h Thu May 5 09:59:58 2016
@@ -35,14 +35,14 @@
class StyleManager;
-extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, PageItem *textItem);
+extern "C" PLUGIN_API void GetText2(QString filename, QString encoding, bool textOnly, bool prefix, bool append, PageItem *textItem);
extern "C" PLUGIN_API QString FileFormatName();
extern "C" PLUGIN_API QStringList FileExtensions();
class XtgIm
{
public:
- XtgIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix);
+ XtgIm(QString fileName, PageItem *textItem, bool textOnly, bool prefix, bool append);
~XtgIm();
};
#endif /* XTGIM_H */
Modified: trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp Thu May 5 09:59:58 2016
@@ -39,10 +39,11 @@
#include "util.h"
-XtgScanner::XtgScanner(QString filename, PageItem *item, bool textOnly, bool prefix)
+XtgScanner::XtgScanner(QString filename, PageItem *item, bool textOnly, bool prefix, bool append)
{
m_item = item;
importTextOnly = textOnly;
+ m_append = append;
loadRawBytes(filename, input_Buffer);
top = 0;
if ((input_Buffer[0] == '\xFF') && (input_Buffer[1] == '\xFE'))
@@ -1502,6 +1503,15 @@
void XtgScanner::xtgParse()
{
/* Enter the default mode as textMode */
+ if (!m_append)
+ {
+ QString pStyleD = CommonStrings::DefaultParagraphStyle;
+ ParagraphStyle newStyle;
+ newStyle.setDefaultStyle(false);
+ newStyle.setParent(pStyleD);
+ m_item->itemText.clear();
+ m_item->itemText.setDefaultStyle(newStyle);
+ }
enterState(textMode);
currentParagraphStyle.setParent(CommonStrings::DefaultParagraphStyle);
currentParagraphStyle.charStyle().setParent(CommonStrings::DefaultCharacterStyle);
Modified: trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21282&path=/trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.h
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.h (original)
+++ trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.h Thu May 5 09:59:58 2016
@@ -64,6 +64,7 @@
PageItem* m_item;
bool importTextOnly;
bool m_prefixName;
+ bool m_append;
/**
\variable Flag variables used in the scanner
*/
@@ -111,7 +112,7 @@
bool m_isItalic;
public:
- XtgScanner(QString filename, PageItem* item, bool textOnly, bool prefix);
+ XtgScanner(QString filename, PageItem* item, bool textOnly, bool prefix, bool append);
~XtgScanner();
/**
More information about the scribus-commit
mailing list