writerperfect/source/filter/DocumentHandler.cxx | 31 ++------------------- writerperfect/source/filter/OdgGenerator.cxx | 35 ++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 29 deletions(-)
New commits: commit 7afb1fffefb1806205ddcef3cba1d2a559e9b39e Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Thu Aug 23 14:13:49 2012 +0200 Iterate the utf8 correctly + handle tabs too Change-Id: Ie6a4750ebd04e3b1ed8ad0985e141b6ff2e65e98 diff --git a/writerperfect/source/filter/OdgGenerator.cxx b/writerperfect/source/filter/OdgGenerator.cxx index e8f365b..0d39862 100644 --- a/writerperfect/source/filter/OdgGenerator.cxx +++ b/writerperfect/source/filter/OdgGenerator.cxx @@ -1750,12 +1750,11 @@ void OdgGenerator::endTextSpan() void OdgGenerator::insertText(const WPXString &text) { - int length = text.len(); WPXString out; - for (int curr = 0; curr < length; ++curr) + WPXString::Iter i(text); + for (i.rewind(); i.next();) { - char ch = text.cstr()[curr]; - if (ch == '\n') + if ((*i()) == '\n' || (*i()) == '\t') { if (out.len() != 0) { @@ -1763,12 +1762,20 @@ void OdgGenerator::insertText(const WPXString &text) 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")); + if ((*i()) == '\n') + { + mpImpl->mBodyElements.push_back(new TagOpenElement("text:line-break")); + mpImpl->mBodyElements.push_back(new TagCloseElement("text:line-break")); + } + else if ((*i()) == '\t') + { + mpImpl->mBodyElements.push_back(new TagOpenElement("text:tab")); + mpImpl->mBodyElements.push_back(new TagCloseElement("text:tab")); + } } else { - out.append(ch); + out.append(i()); } } if (out.len() != 0) commit 8a274f73a28ee9d358059bfe9ce4395e3e284031 Author: Brennan Vincent <brenn...@email.arizona.edu> Date: Tue Aug 21 10:25:29 2012 -0700 Move writerperfect newline-handling logic to OdgGenerator::insertText Change-Id: I6d954ac1233f98a3744449555043e8f82a1d2083 diff --git a/writerperfect/source/filter/DocumentHandler.cxx b/writerperfect/source/filter/DocumentHandler.cxx index e1f58b2..8336c07 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 f873343..e8f365b 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: */
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits