r17673 by jghali - #9110: Non-breakable spaces export as underscores

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 3 21:45:33 UTC 2012


Author: jghali
Date: Tue Jul  3 21:45:33 2012
New Revision: 17673

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17673
Log:
#9110: Non-breakable spaces export as underscores

Modified:
    branches/Version14x/Scribus/scribus/storyeditor.cpp
    branches/Version14x/Scribus/scribus/text/storytext.cpp
    branches/Version14x/Scribus/scribus/text/storytext.h

Modified: branches/Version14x/Scribus/scribus/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17673&path=/branches/Version14x/Scribus/scribus/storyeditor.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.cpp (original)
+++ branches/Version14x/Scribus/scribus/storyeditor.cpp Tue Jul  3 21:45:33 2012
@@ -3289,7 +3289,7 @@
 	if (!fileName.isEmpty())
 	{
 		dirs->set("story_save", fileName.left(fileName.lastIndexOf("/")));
-		Serializer::writeWithEncoding(fileName, LoadEnc, Editor->toPlainText());
+		Serializer::writeWithEncoding(fileName, LoadEnc, Editor->StyledText.plainText());
 	}
 	blockUpdate = false;
 }

Modified: branches/Version14x/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17673&path=/branches/Version14x/Scribus/scribus/text/storytext.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/text/storytext.cpp (original)
+++ branches/Version14x/Scribus/scribus/text/storytext.cpp Tue Jul  3 21:45:33 2012
@@ -635,6 +635,28 @@
 int StoryText::length() const
 {
 	return d->len;
+}
+
+QString StoryText::plainText() const
+{
+	if (length() <= 0)
+		return QString();
+
+	QChar   ch;
+	QString result;
+
+	uint len = length();
+	result.reserve(len);
+
+	StoryText* that(const_cast<StoryText*>(this));
+	for (int i = 0; i < len; ++i) {
+		ch = that->d->at(i)->ch;
+		if (ch == SpecialChars::PARSEP)
+			ch = QLatin1Char('\n');
+		result += ch;
+	}
+
+	return result;
 }
 
 QChar StoryText::text() const

Modified: branches/Version14x/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17673&path=/branches/Version14x/Scribus/scribus/text/storytext.h
==============================================================================
--- branches/Version14x/Scribus/scribus/text/storytext.h (original)
+++ branches/Version14x/Scribus/scribus/text/storytext.h Tue Jul  3 21:45:33 2012
@@ -137,7 +137,15 @@
 
 	void hyphenateWord(int pos, uint len, char* hyphens);
 	
+	// Retrieve length of story text
  	int length() const;
+
+	// Get content at specific position as plain text
+	// Internal paragraph separator are converted to 
+	// unix new lines for better compatibility with
+	// text editors
+	QString plainText() const;
+
 	// Get char at current cursor position
 	QChar   text() const;
 	// Get char at specific position




More information about the scribus-commit mailing list