Iterate the utf8 correctly + handle tabs too

Change-Id: Ie6a4750ebd04e3b1ed8ad0985e141b6ff2e65e98
This commit is contained in:
Fridrich Štrba
2012-08-23 14:13:49 +02:00
parent 8a274f73a2
commit 7afb1fffef

View File

@@ -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();
}
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)