diff options
author | Brennan Vincent <brennanv@email.arizona.edu> | 2012-08-21 10:25:29 -0700 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-08-23 14:17:01 +0200 |
commit | 8a274f73a28ee9d358059bfe9ce4395e3e284031 (patch) | |
tree | d9c687b4348add47a5e097c81390632bb61ccdcc /writerperfect | |
parent | 2b5953a19e36a02040f2ff08bc87efe4785f80bd (diff) |
Move writerperfect newline-handling logic to OdgGenerator::insertText
Change-Id: I6d954ac1233f98a3744449555043e8f82a1d2083
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/source/filter/DocumentHandler.cxx | 31 | ||||
-rw-r--r-- | writerperfect/source/filter/OdgGenerator.cxx | 28 |
2 files changed, 30 insertions, 29 deletions
diff --git a/writerperfect/source/filter/DocumentHandler.cxx b/writerperfect/source/filter/DocumentHandler.cxx index e1f58b2dc45b..8336c077caf7 100644 --- a/writerperfect/source/filter/DocumentHandler.cxx +++ b/writerperfect/source/filter/DocumentHandler.cxx @@ -74,35 +74,12 @@ void DocumentHandler::endElement(const char *psName) void DocumentHandler::characters(const WPXString &sCharacters) { - int lastNewline = -1; - int length = sCharacters.len(); - for (int curr = 0; curr < length; ++curr) - { - if (sCharacters.cstr()[curr] == '\n') - { - if (curr > lastNewline + 1) - { - OUString sCharU16(sCharacters.cstr() + lastNewline + 1, curr - lastNewline - 1, RTL_TEXTENCODING_UTF8); -#ifdef DEBUG_XML - WPXString sEscapedCharacters(sCharacters, true); - printf("%s", sEscapedCharacters.cstr()); -#endif - mxHandler->characters(sCharU16); - } - startElement("text:line-break", WPXPropertyList()); - endElement("text:line-break"); - lastNewline = curr; - } - } - if (lastNewline + 1 < length) - { - OUString sCharU16(sCharacters.cstr() + lastNewline + 1, length - lastNewline - 1, RTL_TEXTENCODING_UTF8); + OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8); #ifdef DEBUG_XML - WPXString sEscapedCharacters(sCharacters, true); - printf("%s", sEscapedCharacters.cstr()); + WPXString sEscapedCharacters(sCharacters, true); + printf("%s", sEscapedCharacters.cstr()); #endif - mxHandler->characters(sCharU16); - } + mxHandler->characters(sCharU16); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/filter/OdgGenerator.cxx b/writerperfect/source/filter/OdgGenerator.cxx index f873343b5512..e8f365bda5eb 100644 --- a/writerperfect/source/filter/OdgGenerator.cxx +++ b/writerperfect/source/filter/OdgGenerator.cxx @@ -1750,8 +1750,32 @@ void OdgGenerator::endTextSpan() void OdgGenerator::insertText(const WPXString &text) { - DocumentElement *pText = new TextElement(text); - mpImpl->mBodyElements.push_back(pText); + int length = text.len(); + WPXString out; + for (int curr = 0; curr < length; ++curr) + { + char ch = text.cstr()[curr]; + if (ch == '\n') + { + if (out.len() != 0) + { + DocumentElement *pText = new TextElement(out); + mpImpl->mBodyElements.push_back(pText); + out.clear(); + } + mpImpl->mBodyElements.push_back(new TagOpenElement("text:line-break")); + mpImpl->mBodyElements.push_back(new TagCloseElement("text:line-break")); + } + else + { + out.append(ch); + } + } + if (out.len() != 0) + { + DocumentElement *pText = new TextElement(out); + mpImpl->mBodyElements.push_back(pText); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |