diff options
author | jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870> | 2012-07-03 21:45:33 +0000 |
---|---|---|
committer | jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870> | 2012-07-03 21:45:33 +0000 |
commit | 276f258e5dfbe286db4cc4b48c6bc82d6b96a0d0 (patch) | |
tree | 582d8596e632f1f178fe05589beb6909153ddc01 | |
parent | a54210afd8b14ce32a77fce552aa6201d0173f8e (diff) | |
download | scribus-276f258e5dfbe286db4cc4b48c6bc82d6b96a0d0.tar.gz scribus-276f258e5dfbe286db4cc4b48c6bc82d6b96a0d0.tar.xz scribus-276f258e5dfbe286db4cc4b48c6bc82d6b96a0d0.zip |
#9110: Non-breakable spaces export as underscores
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17673 11d20701-8431-0410-a711-e3c959e3b870
-rw-r--r-- | scribus/storyeditor.cpp | 2 | ||||
-rw-r--r-- | scribus/text/storytext.cpp | 22 | ||||
-rw-r--r-- | scribus/text/storytext.h | 8 |
3 files changed, 31 insertions, 1 deletions
diff --git a/scribus/storyeditor.cpp b/scribus/storyeditor.cpp index ce9398e..76cb972 100644 --- a/scribus/storyeditor.cpp +++ b/scribus/storyeditor.cpp @@ -3289,7 +3289,7 @@ void StoryEditor::SaveTextFile() 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; } diff --git a/scribus/text/storytext.cpp b/scribus/text/storytext.cpp index 76285a9..062015a 100644 --- a/scribus/text/storytext.cpp +++ b/scribus/text/storytext.cpp @@ -637,6 +637,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 { return text(d->cursorPosition); diff --git a/scribus/text/storytext.h b/scribus/text/storytext.h index 420c3c7..b77779b 100644 --- a/scribus/text/storytext.h +++ b/scribus/text/storytext.h @@ -137,7 +137,15 @@ class SCRIBUS_API StoryText : public QObject, public SaxIO 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 |