summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorThomas Zander <thomas.zander@trolltech.com>2009-06-11 11:12:30 (GMT)
committerThomas Zander <thomas.zander@trolltech.com>2009-06-11 12:15:37 (GMT)
commitdc802d17d998b62546de0a9725535202d7cbf9e4 (patch)
tree430834243566dda2f3c0e7233259079fe3508f1e /src/gui/text
parent5f31403e74c4eaf89a213ce3514fe380d221298b (diff)
downloadQt-dc802d17d998b62546de0a9725535202d7cbf9e4.zip
Qt-dc802d17d998b62546de0a9725535202d7cbf9e4.tar.gz
Qt-dc802d17d998b62546de0a9725535202d7cbf9e4.tar.bz2
Makes the ODF writer use one text:tab tag for each tab, per ODF spec.
We used tab-ref to place multiple tabs compressed into one tag just like text:s does, but thats not what the spec says. We now don't sum up tabs anymore but just simply write out one "<text:tab/>" tag per tab. Task: 249110
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextodfwriter.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 75e89d2..bc8ac5b 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -295,28 +295,13 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("c%1")
.arg(frag.fragment().charFormatIndex()));
bool escapeNextSpace = true;
- int precedingSpaces = 0, precedingTabs = 0;
+ int precedingSpaces = 0;
int exportedIndex = 0;
for (int i=0; i <= fragmentText.count(); ++i) {
- bool isTab = false, isSpace = false;
- if (i < fragmentText.count()) {
+ bool isSpace = false;
QChar character = fragmentText[i];
- isTab = character.unicode() == '\t';
isSpace = character.unicode() == ' ';
- if (character.unicode() == 0x2028) { // soft-return
- writer.writeCharacters(fragmentText.mid(exportedIndex, i));
- writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
- exportedIndex = i+1;
- continue;
- }
- if (isSpace) {
- ++precedingSpaces;
- escapeNextSpace = true;
- }
- else if (isTab) {
- precedingTabs++;
- }
- }
+
// find more than one space. -> <text:s text:c="2" />
if (!isSpace && escapeNextSpace && precedingSpaces > 1) {
const bool startParag = exportedIndex == 0 && i == precedingSpaces;
@@ -329,17 +314,27 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
precedingSpaces = 0;
exportedIndex = i;
}
- // find tabs. -> <text:tab text:tab-ref="3" /> or <text:tab/>
- if (!isTab && precedingTabs) {
- writer.writeCharacters(fragmentText.mid(exportedIndex, i - precedingTabs - exportedIndex));
- writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
- if (precedingTabs > 1)
- writer.writeAttribute(textNS, QString::fromLatin1("tab-ref"), QString::number(precedingTabs));
- precedingTabs = 0;
- exportedIndex = i;
+
+ if (i < fragmentText.count()) {
+ if (character.unicode() == 0x2028) { // soft-return
+ //if (exportedIndex < i)
+ writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
+ writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
+ exportedIndex = i+1;
+ continue;
+ } else if (character.unicode() == '\t') { // Tab
+ //if (exportedIndex < i)
+ writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
+ writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
+ exportedIndex = i+1;
+ precedingSpaces = 0;
+ } else if (isSpace) {
+ ++precedingSpaces;
+ escapeNextSpace = true;
+ } else if (!isSpace) {
+ precedingSpaces = 0;
+ }
}
- if (!isSpace && !isTab)
- precedingSpaces = 0;
}
writer.writeCharacters(fragmentText.mid(exportedIndex));