r18843 by fschmid - Fixed Bug #11968: Crop/ignore empty lines during import of office and some DTP formats
scribus-commit
scribus-commit at lists.scribus.net
Tue Feb 25 21:35:22 UTC 2014
Author: fschmid
Date: Tue Feb 25 21:35:22 2014
New Revision: 18843
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18843
Log:
Fixed Bug #11968: Crop/ignore empty lines during import of office and some DTP formats
Modified:
trunk/Scribus/scribus/plugins/import/ai/importai.cpp
trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/import/pub/importpub.cpp
trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
trunk/Scribus/scribus/plugins/import/vsd/importvsd.cpp
trunk/Scribus/scribus/text/storytext.cpp
trunk/Scribus/scribus/text/storytext.h
Modified: trunk/Scribus/scribus/plugins/import/ai/importai.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/ai/importai.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/ai/importai.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/ai/importai.cpp Tue Feb 25 21:35:22 2014
@@ -2548,6 +2548,7 @@
ite = m_Doc->Items->at(z);
ite->setTextToFrameDist(0.0, 0.0, 0.0, 0.0);
ite->itemText.append(textData);
+ ite->itemText.trim();
double xpos = ite->xPos();
double ypos = ite->yPos();
ite->setWidthHeight(qMax(ite->width(), maxWidth), qMax(ite->height(), maxHeight));
Modified: trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/idml/importidml.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/idml/importidml.cpp Tue Feb 25 21:35:22 2014
@@ -2734,6 +2734,7 @@
}
}
}
+ item->itemText.trim();
}
}
return;
Modified: trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/odg/importodg.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/odg/importodg.cpp Tue Feb 25 21:35:22 2014
@@ -1348,7 +1348,7 @@
resovleStyle(pStyle, elem.attribute("text:style-name"));
for(QDomElement para = elem.firstChildElement(); !para.isNull(); para = para.nextSiblingElement())
{
- if (para.tagName() != "text:p")
+ if ((para.tagName() != "text:p") && (para.tagName() != "text:list"))
continue;
if (para.hasChildNodes())
{
@@ -1569,6 +1569,7 @@
posC = item->itemText.length();
}
}
+ item->itemText.trim();
}
void OdgPlug::parseTransform(const QString &transform, double *rotation, double *transX, double *transY)
Modified: trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp Tue Feb 25 21:35:22 2014
@@ -1136,6 +1136,7 @@
PageItem* OODPlug::finishNodeParsing(const QDomElement &elm, PageItem* item, OODrawStyle& oostyle)
{
item->setTextToFrameDist(0.0, 0.0, 0.0, 0.0);
+ item->itemText.trim();
// bool firstPa = false;
QString drawID = elm.attribute("draw:name");
item = parseTextP(elm, item);
Modified: trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pages/importpages.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pages/importpages.cpp Tue Feb 25 21:35:22 2014
@@ -1519,6 +1519,7 @@
if (itemText.length() > 0)
{
retObj->itemText.append(itemText);
+ retObj->itemText.trim();
}
finishItem(retObj, obState);
retObj = m_Doc->Items->takeAt(z);
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Tue Feb 25 21:35:22 2014
@@ -386,6 +386,7 @@
ite->annotation().setIcon(Annotation::Icon_Note);
ite->setItemName( CommonStrings::itemName_TextAnnotation + QString("%1").arg(m_doc->TotalItems));
ite->itemText.insertChars(UnicodeParsedString(annota->getContents()));
+ ite->itemText.trim();
return true;
}
@@ -739,6 +740,7 @@
{
ite->itemText.insertChars(UnicodeParsedString(btn->getContent()));
applyTextStyle(ite, fontName, CurrColorText, fontSize);
+ ite->itemText.trim();
if (btn->isMultiline())
ite->annotation().addToFlag(Annotation::Flag_Multiline);
if (btn->isPassword())
Modified: trunk/Scribus/scribus/plugins/import/pub/importpub.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/pub/importpub.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pub/importpub.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pub/importpub.cpp Tue Feb 25 21:35:22 2014
@@ -880,6 +880,8 @@
{
if (!doProcessing)
return;
+ if (actTextItem)
+ actTextItem->itemText.trim();
actTextItem = NULL;
lineSpSet = false;
lineSpIsPT = false;
Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp Tue Feb 25 21:35:22 2014
@@ -625,6 +625,7 @@
{
//QTransform mm = gc->matrix;
item->setLineWidth(item->lineWidth() * (coeff1 + coeff2) / 2.0);
+ item->itemText.trim();
}
break;
default:
Modified: trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/viva/importviva.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/viva/importviva.cpp Tue Feb 25 21:35:22 2014
@@ -1642,6 +1642,7 @@
item->setColumnGap(textColumnGap);
if (itemText.length() > 0)
item->itemText.append(itemText);
+ item->itemText.trim();
}
item->setLocked(locked);
item->setSizeLocked(resizeable);
Modified: trunk/Scribus/scribus/plugins/import/vsd/importvsd.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/plugins/import/vsd/importvsd.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/vsd/importvsd.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/vsd/importvsd.cpp Tue Feb 25 21:35:22 2014
@@ -793,6 +793,8 @@
{
if (!doProcessing)
return;
+ if (actTextItem)
+ actTextItem->itemText.trim();
actTextItem = NULL;
lineSpSet = false;
lineSpIsPT = false;
Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp (original)
+++ trunk/Scribus/scribus/text/storytext.cpp Tue Feb 25 21:35:22 2014
@@ -393,7 +393,7 @@
// demote this parsep so the assert code in replaceCharStyleContextInParagraph()
// doesnt choke:
it->ch = 0;
- d->replaceCharStyleContextInParagraph(pos, paragraphStyle(pos+1).charStyleContext());
+ d->replaceCharStyleContextInParagraph(pos, paragraphStyle(pos+1).charStyleContext());
}
void StoryText::removeChars(int pos, uint len)
@@ -441,6 +441,31 @@
m_selLast = -1;
}
invalidate(pos, length());
+}
+
+void StoryText::trim()
+{
+ if (length() < 2)
+ return;
+ int posCount = 0;
+ int pos = static_cast<int>(length()) - 1;
+ for ( int i = static_cast<int>(length()) - 1; i >= 0; --i )
+ {
+ ScText *it = d->at(i);
+ if ((it->ch != SpecialChars::PARSEP))
+ break;
+ else
+ {
+ pos--;
+ posCount++;
+ }
+ }
+ if (posCount > 0)
+ {
+ ParagraphStyle pst = paragraphStyle(pos);
+ removeChars(pos+1, posCount-1);
+ applyStyle(pos, pst);
+ }
}
void StoryText::insertChars(QString txt, bool applyNeighbourStyle) //, const CharStyle & charstyle)
Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18843&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h (original)
+++ trunk/Scribus/scribus/text/storytext.h Tue Feb 25 21:35:22 2014
@@ -120,6 +120,8 @@
void append(const StoryText& other) { insert(length(), other, false); }
// Remove len chars at specific position
void removeChars(int pos, uint len);
+ // Removes trailing empty paragraphs
+ void trim();
// Insert chars at current cursor position
void insertChars(QString txt, bool applyNeighbourStyle = false);
// Insert chars ar specific position
More information about the scribus-commit
mailing list