Kaydet (Commit) 8a274f73 authored tarafından Brennan Vincent's avatar Brennan Vincent Kaydeden (comit) Fridrich Štrba

Move writerperfect newline-handling logic to OdgGenerator::insertText

Change-Id: I6d954ac1233f98a3744449555043e8f82a1d2083
üst 2b5953a1
......@@ -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: */
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment