text/qtextodfwriter.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <qglobal.h> -
43 -
44#ifndef QT_NO_TEXTODFWRITER -
45 -
46#include "qtextodfwriter_p.h" -
47 -
48#include <QImageWriter> -
49#include <QTextListFormat> -
50#include <QTextList> -
51#include <QBuffer> -
52#include <QUrl> -
53 -
54#include "qtextdocument_p.h" -
55#include "qtexttable.h" -
56#include "qtextcursor.h" -
57#include "qtextimagehandler_p.h" -
58#include "qzipwriter_p.h" -
59 -
60#include <QDebug> -
61 -
62QT_BEGIN_NAMESPACE -
63 -
64/// Convert pixels to postscript point units -
65static QString pixelToPoint(qreal pixels) -
66{ -
67 // we hardcode 96 DPI, we do the same in the ODF importer to have a perfect roundtrip. -
68 return QString::number(pixels * 72 / 96) + QString::fromLatin1("pt");
never executed: return QString::number(pixels * 72 / 96) + QString::fromLatin1("pt");
0
69} -
70 -
71// strategies -
72class QOutputStrategy { -
73public: -
74 QOutputStrategy() : contentStream(0), counter(1) { }
executed: }
Execution Count:3
3
75 virtual ~QOutputStrategy() {} -
76 virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) = 0; -
77 -
78 QString createUniqueImageName() -
79 { -
80 return QString::fromLatin1("Pictures/Picture%1").arg(counter++);
never executed: return QString::fromLatin1("Pictures/Picture%1").arg(counter++);
0
81 } -
82 -
83 QIODevice *contentStream; -
84 int counter; -
85}; -
86 -
87class QXmlStreamStrategy : public QOutputStrategy { -
88public: -
89 QXmlStreamStrategy(QIODevice *device) -
90 { -
91 contentStream = device;
never executed (the execution status of this line is deduced): contentStream = device;
-
92 }
never executed: }
0
93 -
94 virtual ~QXmlStreamStrategy() -
95 { -
96 if (contentStream)
never evaluated: contentStream
0
97 contentStream->close();
never executed: contentStream->close();
0
98 }
never executed: }
0
99 virtual void addFile(const QString &, const QString &, const QByteArray &) -
100 { -
101 // we ignore this... -
102 } -
103}; -
104 -
105class QZipStreamStrategy : public QOutputStrategy { -
106public: -
107 QZipStreamStrategy(QIODevice *device) -
108 : zip(device), -
109 manifestWriter(&manifest) -
110 { -
111 QByteArray mime("application/vnd.oasis.opendocument.text");
executed (the execution status of this line is deduced): QByteArray mime("application/vnd.oasis.opendocument.text");
-
112 zip.setCompressionPolicy(QZipWriter::NeverCompress);
executed (the execution status of this line is deduced): zip.setCompressionPolicy(QZipWriter::NeverCompress);
-
113 zip.addFile(QString::fromLatin1("mimetype"), mime); // for mime-magick
executed (the execution status of this line is deduced): zip.addFile(QString::fromLatin1("mimetype"), mime);
-
114 zip.setCompressionPolicy(QZipWriter::AutoCompress);
executed (the execution status of this line is deduced): zip.setCompressionPolicy(QZipWriter::AutoCompress);
-
115 contentStream = &content;
executed (the execution status of this line is deduced): contentStream = &content;
-
116 content.open(QIODevice::WriteOnly);
executed (the execution status of this line is deduced): content.open(QIODevice::WriteOnly);
-
117 manifest.open(QIODevice::WriteOnly);
executed (the execution status of this line is deduced): manifest.open(QIODevice::WriteOnly);
-
118 -
119 manifestNS = QString::fromLatin1("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
executed (the execution status of this line is deduced): manifestNS = QString::fromLatin1("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
-
120 // prettyfy -
121 manifestWriter.setAutoFormatting(true);
executed (the execution status of this line is deduced): manifestWriter.setAutoFormatting(true);
-
122 manifestWriter.setAutoFormattingIndent(1);
executed (the execution status of this line is deduced): manifestWriter.setAutoFormattingIndent(1);
-
123 -
124 manifestWriter.writeNamespace(manifestNS, QString::fromLatin1("manifest"));
executed (the execution status of this line is deduced): manifestWriter.writeNamespace(manifestNS, QString::fromLatin1("manifest"));
-
125 manifestWriter.writeStartDocument();
executed (the execution status of this line is deduced): manifestWriter.writeStartDocument();
-
126 manifestWriter.writeStartElement(manifestNS, QString::fromLatin1("manifest"));
executed (the execution status of this line is deduced): manifestWriter.writeStartElement(manifestNS, QString::fromLatin1("manifest"));
-
127 manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
executed (the execution status of this line is deduced): manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
-
128 addFile(QString::fromLatin1("/"), QString::fromLatin1("application/vnd.oasis.opendocument.text"));
executed (the execution status of this line is deduced): addFile(QString::fromLatin1("/"), QString::fromLatin1("application/vnd.oasis.opendocument.text"));
-
129 addFile(QString::fromLatin1("content.xml"), QString::fromLatin1("text/xml"));
executed (the execution status of this line is deduced): addFile(QString::fromLatin1("content.xml"), QString::fromLatin1("text/xml"));
-
130 }
executed: }
Execution Count:3
3
131 -
132 ~QZipStreamStrategy() -
133 { -
134 manifestWriter.writeEndDocument();
executed (the execution status of this line is deduced): manifestWriter.writeEndDocument();
-
135 manifest.close();
executed (the execution status of this line is deduced): manifest.close();
-
136 zip.addFile(QString::fromLatin1("META-INF/manifest.xml"), &manifest);
executed (the execution status of this line is deduced): zip.addFile(QString::fromLatin1("META-INF/manifest.xml"), &manifest);
-
137 content.close();
executed (the execution status of this line is deduced): content.close();
-
138 zip.addFile(QString::fromLatin1("content.xml"), &content);
executed (the execution status of this line is deduced): zip.addFile(QString::fromLatin1("content.xml"), &content);
-
139 zip.close();
executed (the execution status of this line is deduced): zip.close();
-
140 }
executed: }
Execution Count:3
3
141 -
142 virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) -
143 { -
144 zip.addFile(fileName, bytes);
never executed (the execution status of this line is deduced): zip.addFile(fileName, bytes);
-
145 addFile(fileName, mimeType);
never executed (the execution status of this line is deduced): addFile(fileName, mimeType);
-
146 }
never executed: }
0
147 -
148private: -
149 void addFile(const QString &fileName, const QString &mimeType) -
150 { -
151 manifestWriter.writeEmptyElement(manifestNS, QString::fromLatin1("file-entry"));
executed (the execution status of this line is deduced): manifestWriter.writeEmptyElement(manifestNS, QString::fromLatin1("file-entry"));
-
152 manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("media-type"), mimeType);
executed (the execution status of this line is deduced): manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("media-type"), mimeType);
-
153 manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("full-path"), fileName);
executed (the execution status of this line is deduced): manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("full-path"), fileName);
-
154 }
executed: }
Execution Count:6
6
155 -
156 QBuffer content; -
157 QBuffer manifest; -
158 QZipWriter zip; -
159 QXmlStreamWriter manifestWriter; -
160 QString manifestNS; -
161}; -
162 -
163static QString bulletChar(QTextListFormat::Style style) -
164{ -
165 switch(style) { -
166 case QTextListFormat::ListDisc: -
167 return QChar(0x25cf); // bullet character
never executed: return QChar(0x25cf);
0
168 case QTextListFormat::ListCircle: -
169 return QChar(0x25cb); // white circle
never executed: return QChar(0x25cb);
0
170 case QTextListFormat::ListSquare: -
171 return QChar(0x25a1); // white square
never executed: return QChar(0x25a1);
0
172 case QTextListFormat::ListDecimal: -
173 return QString::fromLatin1("1");
never executed: return QString::fromLatin1("1");
0
174 case QTextListFormat::ListLowerAlpha: -
175 return QString::fromLatin1("a");
never executed: return QString::fromLatin1("a");
0
176 case QTextListFormat::ListUpperAlpha: -
177 return QString::fromLatin1("A");
never executed: return QString::fromLatin1("A");
0
178 case QTextListFormat::ListLowerRoman: -
179 return QString::fromLatin1("i");
never executed: return QString::fromLatin1("i");
0
180 case QTextListFormat::ListUpperRoman: -
181 return QString::fromLatin1("I");
never executed: return QString::fromLatin1("I");
0
182 default: -
183 case QTextListFormat::ListStyleUndefined: -
184 return QString();
never executed: return QString();
0
185 } -
186}
never executed: }
0
187 -
188void QTextOdfWriter::writeFrame(QXmlStreamWriter &writer, const QTextFrame *frame) -
189{ -
190 Q_ASSERT(frame);
executed (the execution status of this line is deduced): qt_noop();
-
191 const QTextTable *table = qobject_cast<const QTextTable*> (frame);
executed (the execution status of this line is deduced): const QTextTable *table = qobject_cast<const QTextTable*> (frame);
-
192 -
193 if (table) { // Start a table.
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
194 writer.writeStartElement(tableNS, QString::fromLatin1("table"));
never executed (the execution status of this line is deduced): writer.writeStartElement(tableNS, QString::fromLatin1("table"));
-
195 writer.writeEmptyElement(tableNS, QString::fromLatin1("table-column"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(tableNS, QString::fromLatin1("table-column"));
-
196 writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-repeated"), QString::number(table->columns()));
never executed (the execution status of this line is deduced): writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-repeated"), QString::number(table->columns()));
-
197 } else if (frame->document() && frame->document()->rootFrame() != frame) { // start a section
never executed: }
partially evaluated: frame->document()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: frame->document()->rootFrame() != frame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
198 writer.writeStartElement(textNS, QString::fromLatin1("section"));
never executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("section"));
-
199 }
never executed: }
0
200 -
201 QTextFrame::iterator iterator = frame->begin();
executed (the execution status of this line is deduced): QTextFrame::iterator iterator = frame->begin();
-
202 QTextFrame *child = 0;
executed (the execution status of this line is deduced): QTextFrame *child = 0;
-
203 -
204 int tableRow = -1;
executed (the execution status of this line is deduced): int tableRow = -1;
-
205 while (! iterator.atEnd()) {
evaluated: ! iterator.atEnd()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
206 if (iterator.currentFrame() && child != iterator.currentFrame())
partially evaluated: iterator.currentFrame()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: child != iterator.currentFrame()
0-3
207 writeFrame(writer, iterator.currentFrame());
never executed: writeFrame(writer, iterator.currentFrame());
0
208 else { // no frame, its a block -
209 QTextBlock block = iterator.currentBlock();
executed (the execution status of this line is deduced): QTextBlock block = iterator.currentBlock();
-
210 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
211 QTextTableCell cell = table->cellAt(block.position());
never executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(block.position());
-
212 if (tableRow < cell.row()) {
never evaluated: tableRow < cell.row()
0
213 if (tableRow >= 0)
never evaluated: tableRow >= 0
0
214 writer.writeEndElement(); // close table row
never executed: writer.writeEndElement();
0
215 tableRow = cell.row();
never executed (the execution status of this line is deduced): tableRow = cell.row();
-
216 writer.writeStartElement(tableNS, QString::fromLatin1("table-row"));
never executed (the execution status of this line is deduced): writer.writeStartElement(tableNS, QString::fromLatin1("table-row"));
-
217 }
never executed: }
0
218 writer.writeStartElement(tableNS, QString::fromLatin1("table-cell"));
never executed (the execution status of this line is deduced): writer.writeStartElement(tableNS, QString::fromLatin1("table-cell"));
-
219 if (cell.columnSpan() > 1)
never evaluated: cell.columnSpan() > 1
0
220 writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-spanned"), QString::number(cell.columnSpan()));
never executed: writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-spanned"), QString::number(cell.columnSpan()));
0
221 if (cell.rowSpan() > 1)
never evaluated: cell.rowSpan() > 1
0
222 writer.writeAttribute(tableNS, QString::fromLatin1("number-rows-spanned"), QString::number(cell.rowSpan()));
never executed: writer.writeAttribute(tableNS, QString::fromLatin1("number-rows-spanned"), QString::number(cell.rowSpan()));
0
223 if (cell.format().isTableCellFormat()) {
never evaluated: cell.format().isTableCellFormat()
0
224 writer.writeAttribute(tableNS, QString::fromLatin1("style-name"), QString::fromLatin1("T%1").arg(cell.tableCellFormatIndex()));
never executed (the execution status of this line is deduced): writer.writeAttribute(tableNS, QString::fromLatin1("style-name"), QString::fromLatin1("T%1").arg(cell.tableCellFormatIndex()));
-
225 }
never executed: }
0
226 }
never executed: }
0
227 writeBlock(writer, block);
executed (the execution status of this line is deduced): writeBlock(writer, block);
-
228 if (table)
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
229 writer.writeEndElement(); // table-cell
never executed: writer.writeEndElement();
0
230 }
executed: }
Execution Count:3
3
231 child = iterator.currentFrame();
executed (the execution status of this line is deduced): child = iterator.currentFrame();
-
232 ++iterator;
executed (the execution status of this line is deduced): ++iterator;
-
233 }
executed: }
Execution Count:3
3
234 if (tableRow >= 0)
partially evaluated: tableRow >= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
235 writer.writeEndElement(); // close table-row
never executed: writer.writeEndElement();
0
236 -
237 if (table || (frame->document() && frame->document()->rootFrame() != frame))
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: frame->document()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: frame->document()->rootFrame() != frame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
238 writer.writeEndElement(); // close table or section element
never executed: writer.writeEndElement();
0
239}
executed: }
Execution Count:3
3
240 -
241void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &block) -
242{ -
243 if (block.textList()) { // its a list-item
partially evaluated: block.textList()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
244 const int listLevel = block.textList()->format().indent();
never executed (the execution status of this line is deduced): const int listLevel = block.textList()->format().indent();
-
245 if (m_listStack.isEmpty() || m_listStack.top() != block.textList()) {
never evaluated: m_listStack.isEmpty()
never evaluated: m_listStack.top() != block.textList()
0
246 // not the same list we were in. -
247 while (m_listStack.count() >= listLevel && !m_listStack.isEmpty() && m_listStack.top() != block.textList() ) { // we need to close tags
never evaluated: m_listStack.count() >= listLevel
never evaluated: !m_listStack.isEmpty()
never evaluated: m_listStack.top() != block.textList()
0
248 m_listStack.pop();
never executed (the execution status of this line is deduced): m_listStack.pop();
-
249 writer.writeEndElement(); // list
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
250 if (m_listStack.count())
never evaluated: m_listStack.count()
0
251 writer.writeEndElement(); // list-item
never executed: writer.writeEndElement();
0
252 }
never executed: }
0
253 while (m_listStack.count() < listLevel) {
never evaluated: m_listStack.count() < listLevel
0
254 if (m_listStack.count())
never evaluated: m_listStack.count()
0
255 writer.writeStartElement(textNS, QString::fromLatin1("list-item"));
never executed: writer.writeStartElement(textNS, QString::fromLatin1("list-item"));
0
256 writer.writeStartElement(textNS, QString::fromLatin1("list"));
never executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("list"));
-
257 if (m_listStack.count() == listLevel - 1) {
never evaluated: m_listStack.count() == listLevel - 1
0
258 m_listStack.push(block.textList());
never executed (the execution status of this line is deduced): m_listStack.push(block.textList());
-
259 writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("L%1")
never executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("L%1")
-
260 .arg(block.textList()->formatIndex()));
never executed (the execution status of this line is deduced): .arg(block.textList()->formatIndex()));
-
261 }
never executed: }
0
262 else { -
263 m_listStack.push(0);
never executed (the execution status of this line is deduced): m_listStack.push(0);
-
264 }
never executed: }
0
265 } -
266 }
never executed: }
0
267 writer.writeStartElement(textNS, QString::fromLatin1("list-item"));
never executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("list-item"));
-
268 }
never executed: }
0
269 else { -
270 while (! m_listStack.isEmpty()) {
partially evaluated: ! m_listStack.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
271 m_listStack.pop();
never executed (the execution status of this line is deduced): m_listStack.pop();
-
272 writer.writeEndElement(); // list
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
273 if (m_listStack.count())
never evaluated: m_listStack.count()
0
274 writer.writeEndElement(); // list-item
never executed: writer.writeEndElement();
0
275 }
never executed: }
0
276 }
executed: }
Execution Count:3
3
277 -
278 if (block.length() == 1) { // only a linefeed
partially evaluated: block.length() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
279 writer.writeEmptyElement(textNS, QString::fromLatin1("p"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(textNS, QString::fromLatin1("p"));
-
280 writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
never executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
-
281 .arg(block.blockFormatIndex()));
never executed (the execution status of this line is deduced): .arg(block.blockFormatIndex()));
-
282 if (block.textList())
never evaluated: block.textList()
0
283 writer.writeEndElement(); // numbered-paragraph
never executed: writer.writeEndElement();
0
284 return;
never executed: return;
0
285 } -
286 writer.writeStartElement(textNS, QString::fromLatin1("p"));
executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("p"));
-
287 writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
-
288 .arg(block.blockFormatIndex()));
executed (the execution status of this line is deduced): .arg(block.blockFormatIndex()));
-
289 for (QTextBlock::Iterator frag= block.begin(); !frag.atEnd(); frag++) {
evaluated: !frag.atEnd()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
290 writer.writeCharacters(QString()); // Trick to make sure that the span gets no linefeed in front of it.
executed (the execution status of this line is deduced): writer.writeCharacters(QString());
-
291 writer.writeStartElement(textNS, QString::fromLatin1("span"));
executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("span"));
-
292 -
293 QString fragmentText = frag.fragment().text();
executed (the execution status of this line is deduced): QString fragmentText = frag.fragment().text();
-
294 if (fragmentText.length() == 1 && fragmentText[0] == 0xFFFC) { // its an inline character.
partially evaluated: fragmentText.length() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: fragmentText[0] == 0xFFFC
0-3
295 writeInlineCharacter(writer, frag.fragment());
never executed (the execution status of this line is deduced): writeInlineCharacter(writer, frag.fragment());
-
296 writer.writeEndElement(); // span
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
297 continue;
never executed: continue;
0
298 } -
299 -
300 writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("c%1")
executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("c%1")
-
301 .arg(frag.fragment().charFormatIndex()));
executed (the execution status of this line is deduced): .arg(frag.fragment().charFormatIndex()));
-
302 bool escapeNextSpace = true;
executed (the execution status of this line is deduced): bool escapeNextSpace = true;
-
303 int precedingSpaces = 0;
executed (the execution status of this line is deduced): int precedingSpaces = 0;
-
304 int exportedIndex = 0;
executed (the execution status of this line is deduced): int exportedIndex = 0;
-
305 for (int i=0; i <= fragmentText.count(); ++i) {
evaluated: i <= fragmentText.count()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:3
3-20
306 QChar character = fragmentText[i];
executed (the execution status of this line is deduced): QChar character = fragmentText[i];
-
307 bool isSpace = character.unicode() == ' ';
executed (the execution status of this line is deduced): bool isSpace = character.unicode() == ' ';
-
308 -
309 // find more than one space. -> <text:s text:c="2" /> -
310 if (!isSpace && escapeNextSpace && precedingSpaces > 1) {
evaluated: !isSpace
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1
partially evaluated: escapeNextSpace
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
partially evaluated: precedingSpaces > 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
311 const bool startParag = exportedIndex == 0 && i == precedingSpaces;
never evaluated: exportedIndex == 0
never evaluated: i == precedingSpaces
0
312 if (!startParag)
never evaluated: !startParag
0
313 writer.writeCharacters(fragmentText.mid(exportedIndex, i - precedingSpaces + 1 - exportedIndex));
never executed: writer.writeCharacters(fragmentText.mid(exportedIndex, i - precedingSpaces + 1 - exportedIndex));
0
314 writer.writeEmptyElement(textNS, QString::fromLatin1("s"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(textNS, QString::fromLatin1("s"));
-
315 const int count = precedingSpaces - (startParag?0:1);
never evaluated: startParag
0
316 if (count > 1)
never evaluated: count > 1
0
317 writer.writeAttribute(textNS, QString::fromLatin1("c"), QString::number(count));
never executed: writer.writeAttribute(textNS, QString::fromLatin1("c"), QString::number(count));
0
318 precedingSpaces = 0;
never executed (the execution status of this line is deduced): precedingSpaces = 0;
-
319 exportedIndex = i;
never executed (the execution status of this line is deduced): exportedIndex = i;
-
320 }
never executed: }
0
321 -
322 if (i < fragmentText.count()) {
evaluated: i < fragmentText.count()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:3
3-17
323 if (character.unicode() == 0x2028) { // soft-return
partially evaluated: character.unicode() == 0x2028
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
324 //if (exportedIndex < i) -
325 writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
never executed (the execution status of this line is deduced): writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
-
326 writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
-
327 exportedIndex = i+1;
never executed (the execution status of this line is deduced): exportedIndex = i+1;
-
328 continue;
never executed: continue;
0
329 } else if (character.unicode() == '\t') { // Tab
partially evaluated: character.unicode() == '\t'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
330 //if (exportedIndex < i) -
331 writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
never executed (the execution status of this line is deduced): writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
-
332 writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
-
333 exportedIndex = i+1;
never executed (the execution status of this line is deduced): exportedIndex = i+1;
-
334 precedingSpaces = 0;
never executed (the execution status of this line is deduced): precedingSpaces = 0;
-
335 } else if (isSpace) {
never executed: }
evaluated: isSpace
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:16
0-16
336 ++precedingSpaces;
executed (the execution status of this line is deduced): ++precedingSpaces;
-
337 escapeNextSpace = true;
executed (the execution status of this line is deduced): escapeNextSpace = true;
-
338 } else if (!isSpace) {
executed: }
Execution Count:1
partially evaluated: !isSpace
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
339 precedingSpaces = 0;
executed (the execution status of this line is deduced): precedingSpaces = 0;
-
340 }
executed: }
Execution Count:16
16
341 } -
342 }
executed: }
Execution Count:20
20
343 -
344 writer.writeCharacters(fragmentText.mid(exportedIndex));
executed (the execution status of this line is deduced): writer.writeCharacters(fragmentText.mid(exportedIndex));
-
345 writer.writeEndElement(); // span
executed (the execution status of this line is deduced): writer.writeEndElement();
-
346 }
executed: }
Execution Count:3
3
347 writer.writeCharacters(QString()); // Trick to make sure that the span gets no linefeed behind it.
executed (the execution status of this line is deduced): writer.writeCharacters(QString());
-
348 writer.writeEndElement(); // p
executed (the execution status of this line is deduced): writer.writeEndElement();
-
349 if (block.textList())
partially evaluated: block.textList()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
350 writer.writeEndElement(); // list-item
never executed: writer.writeEndElement();
0
351}
executed: }
Execution Count:3
3
352 -
353void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const -
354{ -
355 writer.writeStartElement(drawNS, QString::fromLatin1("frame"));
never executed (the execution status of this line is deduced): writer.writeStartElement(drawNS, QString::fromLatin1("frame"));
-
356 if (m_strategy == 0) {
never evaluated: m_strategy == 0
0
357 // don't do anything. -
358 }
never executed: }
0
359 else if (fragment.charFormat().isImageFormat()) {
never evaluated: fragment.charFormat().isImageFormat()
0
360 QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
never executed (the execution status of this line is deduced): QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
-
361 writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name());
never executed (the execution status of this line is deduced): writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name());
-
362 -
363 // vvv Copy pasted mostly from Qt ================= -
364 QImage image;
never executed (the execution status of this line is deduced): QImage image;
-
365 QString name = imageFormat.name();
never executed (the execution status of this line is deduced): QString name = imageFormat.name();
-
366 if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
never evaluated: name.startsWith(QLatin1String(":/"))
0
367 name.prepend(QLatin1String("qrc"));
never executed: name.prepend(QLatin1String("qrc"));
0
368 QUrl url = QUrl(name);
never executed (the execution status of this line is deduced): QUrl url = QUrl(name);
-
369 const QVariant data = m_document->resource(QTextDocument::ImageResource, url);
never executed (the execution status of this line is deduced): const QVariant data = m_document->resource(QTextDocument::ImageResource, url);
-
370 if (data.type() == QVariant::Image) {
never evaluated: data.type() == QVariant::Image
0
371 image = qvariant_cast<QImage>(data);
never executed (the execution status of this line is deduced): image = qvariant_cast<QImage>(data);
-
372 } else if (data.type() == QVariant::ByteArray) {
never executed: }
never evaluated: data.type() == QVariant::ByteArray
0
373 image.loadFromData(data.toByteArray());
never executed (the execution status of this line is deduced): image.loadFromData(data.toByteArray());
-
374 }
never executed: }
0
375 -
376 if (image.isNull()) {
never evaluated: image.isNull()
0
377 QString context;
never executed (the execution status of this line is deduced): QString context;
-
378 if (image.isNull()) { // try direct loading
never evaluated: image.isNull()
0
379 name = imageFormat.name(); // remove qrc:/ prefix again
never executed (the execution status of this line is deduced): name = imageFormat.name();
-
380 image.load(name);
never executed (the execution status of this line is deduced): image.load(name);
-
381 }
never executed: }
0
382 }
never executed: }
0
383 -
384 // ^^^ Copy pasted mostly from Qt ================= -
385 if (! image.isNull()) {
never evaluated: ! image.isNull()
0
386 QBuffer imageBytes;
never executed (the execution status of this line is deduced): QBuffer imageBytes;
-
387 QImageWriter imageWriter(&imageBytes, "png");
never executed (the execution status of this line is deduced): QImageWriter imageWriter(&imageBytes, "png");
-
388 imageWriter.write(image);
never executed (the execution status of this line is deduced): imageWriter.write(image);
-
389 QString filename = m_strategy->createUniqueImageName();
never executed (the execution status of this line is deduced): QString filename = m_strategy->createUniqueImageName();
-
390 m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data());
never executed (the execution status of this line is deduced): m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data());
-
391 -
392 // get the width/height from the format. -
393 qreal width = (imageFormat.hasProperty(QTextFormat::ImageWidth)) ? imageFormat.width() : image.width();
never evaluated: (imageFormat.hasProperty(QTextFormat::ImageWidth))
0
394 writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width));
never executed (the execution status of this line is deduced): writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width));
-
395 qreal height = (imageFormat.hasProperty(QTextFormat::ImageHeight)) ? imageFormat.height() : image.height();
never evaluated: (imageFormat.hasProperty(QTextFormat::ImageHeight))
0
396 writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height));
never executed (the execution status of this line is deduced): writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height));
-
397 -
398 writer.writeStartElement(drawNS, QString::fromLatin1("image"));
never executed (the execution status of this line is deduced): writer.writeStartElement(drawNS, QString::fromLatin1("image"));
-
399 writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename);
never executed (the execution status of this line is deduced): writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename);
-
400 writer.writeEndElement(); // image
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
401 }
never executed: }
0
402 }
never executed: }
0
403 -
404 writer.writeEndElement(); // frame
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
405}
never executed: }
0
406 -
407void QTextOdfWriter::writeFormats(QXmlStreamWriter &writer, QSet<int> formats) const -
408{ -
409 writer.writeStartElement(officeNS, QString::fromLatin1("automatic-styles"));
executed (the execution status of this line is deduced): writer.writeStartElement(officeNS, QString::fromLatin1("automatic-styles"));
-
410 QVector<QTextFormat> allStyles = m_document->allFormats();
executed (the execution status of this line is deduced): QVector<QTextFormat> allStyles = m_document->allFormats();
-
411 QSetIterator<int> formatId(formats);
executed (the execution status of this line is deduced): QSetIterator<int> formatId(formats);
-
412 while(formatId.hasNext()) {
evaluated: formatId.hasNext()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
413 int formatIndex = formatId.next();
executed (the execution status of this line is deduced): int formatIndex = formatId.next();
-
414 QTextFormat textFormat = allStyles.at(formatIndex);
executed (the execution status of this line is deduced): QTextFormat textFormat = allStyles.at(formatIndex);
-
415 switch (textFormat.type()) { -
416 case QTextFormat::CharFormat: -
417 if (textFormat.isTableCellFormat())
partially evaluated: textFormat.isTableCellFormat()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
418 writeTableCellFormat(writer, textFormat.toTableCellFormat(), formatIndex);
never executed: writeTableCellFormat(writer, textFormat.toTableCellFormat(), formatIndex);
0
419 else -
420 writeCharacterFormat(writer, textFormat.toCharFormat(), formatIndex);
executed: writeCharacterFormat(writer, textFormat.toCharFormat(), formatIndex);
Execution Count:3
3
421 break;
executed: break;
Execution Count:3
3
422 case QTextFormat::BlockFormat: -
423 writeBlockFormat(writer, textFormat.toBlockFormat(), formatIndex);
executed (the execution status of this line is deduced): writeBlockFormat(writer, textFormat.toBlockFormat(), formatIndex);
-
424 break;
executed: break;
Execution Count:3
3
425 case QTextFormat::ListFormat: -
426 writeListFormat(writer, textFormat.toListFormat(), formatIndex);
never executed (the execution status of this line is deduced): writeListFormat(writer, textFormat.toListFormat(), formatIndex);
-
427 break;
never executed: break;
0
428 case QTextFormat::FrameFormat: -
429 writeFrameFormat(writer, textFormat.toFrameFormat(), formatIndex);
never executed (the execution status of this line is deduced): writeFrameFormat(writer, textFormat.toFrameFormat(), formatIndex);
-
430 break;
never executed: break;
0
431 case QTextFormat::TableFormat: -
432 ;break;
never executed: break;
0
433 } -
434 }
executed: }
Execution Count:6
6
435 -
436 writer.writeEndElement(); // automatic-styles
executed (the execution status of this line is deduced): writer.writeEndElement();
-
437}
executed: }
Execution Count:3
3
438 -
439void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat format, int formatIndex) const -
440{ -
441 writer.writeStartElement(styleNS, QString::fromLatin1("style"));
executed (the execution status of this line is deduced): writer.writeStartElement(styleNS, QString::fromLatin1("style"));
-
442 writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("p%1").arg(formatIndex));
executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("p%1").arg(formatIndex));
-
443 writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("paragraph"));
executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("paragraph"));
-
444 writer.writeStartElement(styleNS, QString::fromLatin1("paragraph-properties"));
executed (the execution status of this line is deduced): writer.writeStartElement(styleNS, QString::fromLatin1("paragraph-properties"));
-
445 -
446 if (format.hasProperty(QTextFormat::BlockAlignment)) {
partially evaluated: format.hasProperty(QTextFormat::BlockAlignment)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
447 const Qt::Alignment alignment = format.alignment() & Qt::AlignHorizontal_Mask;
never executed (the execution status of this line is deduced): const Qt::Alignment alignment = format.alignment() & Qt::AlignHorizontal_Mask;
-
448 QString value;
never executed (the execution status of this line is deduced): QString value;
-
449 if (alignment == Qt::AlignLeading)
never evaluated: alignment == Qt::AlignLeading
0
450 value = QString::fromLatin1("start");
never executed: value = QString::fromLatin1("start");
0
451 else if (alignment == Qt::AlignTrailing)
never evaluated: alignment == Qt::AlignTrailing
0
452 value = QString::fromLatin1("end");
never executed: value = QString::fromLatin1("end");
0
453 else if (alignment == (Qt::AlignLeft | Qt::AlignAbsolute))
never evaluated: alignment == (Qt::AlignLeft | Qt::AlignAbsolute)
0
454 value = QString::fromLatin1("left");
never executed: value = QString::fromLatin1("left");
0
455 else if (alignment == (Qt::AlignRight | Qt::AlignAbsolute))
never evaluated: alignment == (Qt::AlignRight | Qt::AlignAbsolute)
0
456 value = QString::fromLatin1("right");
never executed: value = QString::fromLatin1("right");
0
457 else if (alignment == Qt::AlignHCenter)
never evaluated: alignment == Qt::AlignHCenter
0
458 value = QString::fromLatin1("center");
never executed: value = QString::fromLatin1("center");
0
459 else if (alignment == Qt::AlignJustify)
never evaluated: alignment == Qt::AlignJustify
0
460 value = QString::fromLatin1("justify");
never executed: value = QString::fromLatin1("justify");
0
461 else -
462 qWarning() << "QTextOdfWriter: unsupported paragraph alignment; " << format.alignment();
never executed: QMessageLogger("text/qtextodfwriter.cpp", 462, __PRETTY_FUNCTION__).warning() << "QTextOdfWriter: unsupported paragraph alignment; " << format.alignment();
0
463 if (! value.isNull())
never evaluated: ! value.isNull()
0
464 writer.writeAttribute(foNS, QString::fromLatin1("text-align"), value);
never executed: writer.writeAttribute(foNS, QString::fromLatin1("text-align"), value);
0
465 }
never executed: }
0
466 -
467 if (format.hasProperty(QTextFormat::BlockTopMargin))
partially evaluated: format.hasProperty(QTextFormat::BlockTopMargin)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
468 writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
0
469 if (format.hasProperty(QTextFormat::BlockBottomMargin))
partially evaluated: format.hasProperty(QTextFormat::BlockBottomMargin)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
470 writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
0
471 if (format.hasProperty(QTextFormat::BlockLeftMargin) || format.hasProperty(QTextFormat::BlockIndent))
partially evaluated: format.hasProperty(QTextFormat::BlockLeftMargin)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: format.hasProperty(QTextFormat::BlockIndent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
472 writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.),
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin() + format.indent())));
0
473 format.leftMargin() + format.indent())));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin() + format.indent())));
0
474 if (format.hasProperty(QTextFormat::BlockRightMargin))
partially evaluated: format.hasProperty(QTextFormat::BlockRightMargin)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
475 writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
0
476 if (format.hasProperty(QTextFormat::TextIndent))
partially evaluated: format.hasProperty(QTextFormat::TextIndent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
477 writer.writeAttribute(foNS, QString::fromLatin1("text-indent"), pixelToPoint(format.textIndent()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("text-indent"), pixelToPoint(format.textIndent()));
0
478 if (format.hasProperty(QTextFormat::PageBreakPolicy)) {
partially evaluated: format.hasProperty(QTextFormat::PageBreakPolicy)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
479 if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysBefore)
never evaluated: format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysBefore
0
480 writer.writeAttribute(foNS, QString::fromLatin1("break-before"), QString::fromLatin1("page"));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("break-before"), QString::fromLatin1("page"));
0
481 if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter)
never evaluated: format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter
0
482 writer.writeAttribute(foNS, QString::fromLatin1("break-after"), QString::fromLatin1("page"));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("break-after"), QString::fromLatin1("page"));
0
483 }
never executed: }
0
484 if (format.hasProperty(QTextFormat::BackgroundBrush)) {
partially evaluated: format.hasProperty(QTextFormat::BackgroundBrush)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
485 QBrush brush = format.background();
never executed (the execution status of this line is deduced): QBrush brush = format.background();
-
486 writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
never executed (the execution status of this line is deduced): writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
-
487 }
never executed: }
0
488 if (format.hasProperty(QTextFormat::BlockNonBreakableLines))
partially evaluated: format.hasProperty(QTextFormat::BlockNonBreakableLines)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
489 writer.writeAttribute(foNS, QString::fromLatin1("keep-together"),
never executed: writer.writeAttribute(foNS, QString::fromLatin1("keep-together"), format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false"));
0
490 format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false"));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("keep-together"), format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false"));
0
491 if (format.hasProperty(QTextFormat::TabPositions)) {
partially evaluated: format.hasProperty(QTextFormat::TabPositions)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
492 QList<QTextOption::Tab> tabs = format.tabPositions();
never executed (the execution status of this line is deduced): QList<QTextOption::Tab> tabs = format.tabPositions();
-
493 writer.writeStartElement(styleNS, QString::fromLatin1("tab-stops"));
never executed (the execution status of this line is deduced): writer.writeStartElement(styleNS, QString::fromLatin1("tab-stops"));
-
494 QList<QTextOption::Tab>::Iterator iterator = tabs.begin();
never executed (the execution status of this line is deduced): QList<QTextOption::Tab>::Iterator iterator = tabs.begin();
-
495 while(iterator != tabs.end()) {
never evaluated: iterator != tabs.end()
0
496 writer.writeEmptyElement(styleNS, QString::fromLatin1("tab-stop"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(styleNS, QString::fromLatin1("tab-stop"));
-
497 writer.writeAttribute(styleNS, QString::fromLatin1("position"), pixelToPoint(iterator->position) );
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("position"), pixelToPoint(iterator->position) );
-
498 QString type;
never executed (the execution status of this line is deduced): QString type;
-
499 switch(iterator->type) { -
500 case QTextOption::DelimiterTab: type = QString::fromLatin1("char"); break;
never executed: break;
0
501 case QTextOption::LeftTab: type = QString::fromLatin1("left"); break;
never executed: break;
0
502 case QTextOption::RightTab: type = QString::fromLatin1("right"); break;
never executed: break;
0
503 case QTextOption::CenterTab: type = QString::fromLatin1("center"); break;
never executed: break;
0
504 } -
505 writer.writeAttribute(styleNS, QString::fromLatin1("type"), type);
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("type"), type);
-
506 if (iterator->delimiter != 0)
never evaluated: iterator->delimiter != 0
0
507 writer.writeAttribute(styleNS, QString::fromLatin1("char"), iterator->delimiter);
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("char"), iterator->delimiter);
0
508 ++iterator;
never executed (the execution status of this line is deduced): ++iterator;
-
509 }
never executed: }
0
510 -
511 writer.writeEndElement(); // tab-stops
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
512 }
never executed: }
0
513 -
514 writer.writeEndElement(); // paragraph-properties
executed (the execution status of this line is deduced): writer.writeEndElement();
-
515 writer.writeEndElement(); // style
executed (the execution status of this line is deduced): writer.writeEndElement();
-
516}
executed: }
Execution Count:3
3
517 -
518void QTextOdfWriter::writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFormat format, int formatIndex) const -
519{ -
520 writer.writeStartElement(styleNS, QString::fromLatin1("style"));
executed (the execution status of this line is deduced): writer.writeStartElement(styleNS, QString::fromLatin1("style"));
-
521 writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("c%1").arg(formatIndex));
executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("c%1").arg(formatIndex));
-
522 writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("text"));
executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("text"));
-
523 writer.writeEmptyElement(styleNS, QString::fromLatin1("text-properties"));
executed (the execution status of this line is deduced): writer.writeEmptyElement(styleNS, QString::fromLatin1("text-properties"));
-
524 if (format.fontItalic())
partially evaluated: format.fontItalic()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
525 writer.writeAttribute(foNS, QString::fromLatin1("font-style"), QString::fromLatin1("italic"));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("font-style"), QString::fromLatin1("italic"));
0
526 if (format.hasProperty(QTextFormat::FontWeight) && format.fontWeight() != QFont::Normal) {
partially evaluated: format.hasProperty(QTextFormat::FontWeight)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: format.fontWeight() != QFont::Normal
0-3
527 QString value;
never executed (the execution status of this line is deduced): QString value;
-
528 if (format.fontWeight() == QFont::Bold)
never evaluated: format.fontWeight() == QFont::Bold
0
529 value = QString::fromLatin1("bold");
never executed: value = QString::fromLatin1("bold");
0
530 else -
531 value = QString::number(format.fontWeight() * 10);
never executed: value = QString::number(format.fontWeight() * 10);
0
532 writer.writeAttribute(foNS, QString::fromLatin1("font-weight"), value);
never executed (the execution status of this line is deduced): writer.writeAttribute(foNS, QString::fromLatin1("font-weight"), value);
-
533 }
never executed: }
0
534 if (format.hasProperty(QTextFormat::FontFamily))
partially evaluated: format.hasProperty(QTextFormat::FontFamily)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
535 writer.writeAttribute(foNS, QString::fromLatin1("font-family"), format.fontFamily());
never executed: writer.writeAttribute(foNS, QString::fromLatin1("font-family"), format.fontFamily());
0
536 else -
537 writer.writeAttribute(foNS, QString::fromLatin1("font-family"), QString::fromLatin1("Sans")); // Qt default
executed: writer.writeAttribute(foNS, QString::fromLatin1("font-family"), QString::fromLatin1("Sans"));
Execution Count:3
3
538 if (format.hasProperty(QTextFormat::FontPointSize))
partially evaluated: format.hasProperty(QTextFormat::FontPointSize)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
539 writer.writeAttribute(foNS, QString::fromLatin1("font-size"), QString::fromLatin1("%1pt").arg(format.fontPointSize()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("font-size"), QString::fromLatin1("%1pt").arg(format.fontPointSize()));
0
540 if (format.hasProperty(QTextFormat::FontCapitalization)) {
partially evaluated: format.hasProperty(QTextFormat::FontCapitalization)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
541 switch(format.fontCapitalization()) { -
542 case QFont::MixedCase: -
543 writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("none")); break;
never executed: break;
0
544 case QFont::AllUppercase: -
545 writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("uppercase")); break;
never executed: break;
0
546 case QFont::AllLowercase: -
547 writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("lowercase")); break;
never executed: break;
0
548 case QFont::Capitalize: -
549 writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("capitalize")); break;
never executed: break;
0
550 case QFont::SmallCaps: -
551 writer.writeAttribute(foNS, QString::fromLatin1("font-variant"), QString::fromLatin1("small-caps")); break;
never executed: break;
0
552 } -
553 }
never executed: }
0
554 if (format.hasProperty(QTextFormat::FontLetterSpacing))
partially evaluated: format.hasProperty(QTextFormat::FontLetterSpacing)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
555 writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()));
0
556 if (format.hasProperty(QTextFormat::FontWordSpacing) && format.fontWordSpacing() != 0)
partially evaluated: format.hasProperty(QTextFormat::FontWordSpacing)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: format.fontWordSpacing() != 0
0-3
557 writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing()));
0
558 if (format.hasProperty(QTextFormat::FontUnderline))
partially evaluated: format.hasProperty(QTextFormat::FontUnderline)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
559 writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"),
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"), format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
0
560 format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"), format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
0
561 if (format.hasProperty(QTextFormat::FontOverline)) {
partially evaluated: format.hasProperty(QTextFormat::FontOverline)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
562 // bool fontOverline () const TODO -
563 }
never executed: }
0
564 if (format.hasProperty(QTextFormat::FontStrikeOut))
partially evaluated: format.hasProperty(QTextFormat::FontStrikeOut)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
565 writer.writeAttribute(styleNS,QString::fromLatin1( "text-line-through-type"),
never executed: writer.writeAttribute(styleNS,QString::fromLatin1( "text-line-through-type"), format.fontStrikeOut() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
0
566 format.fontStrikeOut() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
never executed: writer.writeAttribute(styleNS,QString::fromLatin1( "text-line-through-type"), format.fontStrikeOut() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
0
567 if (format.hasProperty(QTextFormat::TextUnderlineColor))
partially evaluated: format.hasProperty(QTextFormat::TextUnderlineColor)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
568 writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-color"), format.underlineColor().name());
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-color"), format.underlineColor().name());
0
569 if (format.hasProperty(QTextFormat::FontFixedPitch)) {
partially evaluated: format.hasProperty(QTextFormat::FontFixedPitch)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
570 // bool fontFixedPitch () const TODO -
571 }
never executed: }
0
572 if (format.hasProperty(QTextFormat::TextUnderlineStyle)) {
partially evaluated: format.hasProperty(QTextFormat::TextUnderlineStyle)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
573 QString value;
never executed (the execution status of this line is deduced): QString value;
-
574 switch (format.underlineStyle()) { -
575 case QTextCharFormat::NoUnderline: value = QString::fromLatin1("none"); break;
never executed: break;
0
576 case QTextCharFormat::SingleUnderline: value = QString::fromLatin1("solid"); break;
never executed: break;
0
577 case QTextCharFormat::DashUnderline: value = QString::fromLatin1("dash"); break;
never executed: break;
0
578 case QTextCharFormat::DotLine: value = QString::fromLatin1("dotted"); break;
never executed: break;
0
579 case QTextCharFormat::DashDotLine: value = QString::fromLatin1("dash-dot"); break;
never executed: break;
0
580 case QTextCharFormat::DashDotDotLine: value = QString::fromLatin1("dot-dot-dash"); break;
never executed: break;
0
581 case QTextCharFormat::WaveUnderline: value = QString::fromLatin1("wave"); break;
never executed: break;
0
582 case QTextCharFormat::SpellCheckUnderline: value = QString::fromLatin1("none"); break;
never executed: break;
0
583 } -
584 writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-style"), value);
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-style"), value);
-
585 }
never executed: }
0
586 if (format.hasProperty(QTextFormat::TextVerticalAlignment)) {
partially evaluated: format.hasProperty(QTextFormat::TextVerticalAlignment)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
587 QString value;
never executed (the execution status of this line is deduced): QString value;
-
588 switch (format.verticalAlignment()) { -
589 case QTextCharFormat::AlignMiddle: -
590 case QTextCharFormat::AlignNormal: value = QString::fromLatin1("0%"); break;
never executed: break;
0
591 case QTextCharFormat::AlignSuperScript: value = QString::fromLatin1("super"); break;
never executed: break;
0
592 case QTextCharFormat::AlignSubScript: value = QString::fromLatin1("sub"); break;
never executed: break;
0
593 case QTextCharFormat::AlignTop: value = QString::fromLatin1("100%"); break;
never executed: break;
0
594 case QTextCharFormat::AlignBottom : value = QString::fromLatin1("-100%"); break;
never executed: break;
0
595 case QTextCharFormat::AlignBaseline: break;
never executed: break;
0
596 } -
597 writer.writeAttribute(styleNS, QString::fromLatin1("text-position"), value);
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("text-position"), value);
-
598 }
never executed: }
0
599 if (format.hasProperty(QTextFormat::TextOutline))
partially evaluated: format.hasProperty(QTextFormat::TextOutline)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
600 writer.writeAttribute(styleNS, QString::fromLatin1("text-outline"), QString::fromLatin1("true"));
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("text-outline"), QString::fromLatin1("true"));
0
601 if (format.hasProperty(QTextFormat::TextToolTip)) {
partially evaluated: format.hasProperty(QTextFormat::TextToolTip)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
602 // QString toolTip () const TODO -
603 }
never executed: }
0
604 if (format.hasProperty(QTextFormat::IsAnchor)) {
partially evaluated: format.hasProperty(QTextFormat::IsAnchor)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
605 // bool isAnchor () const TODO -
606 }
never executed: }
0
607 if (format.hasProperty(QTextFormat::AnchorHref)) {
partially evaluated: format.hasProperty(QTextFormat::AnchorHref)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
608 // QString anchorHref () const TODO -
609 }
never executed: }
0
610 if (format.hasProperty(QTextFormat::AnchorName)) {
partially evaluated: format.hasProperty(QTextFormat::AnchorName)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
611 // QString anchorName () const TODO -
612 }
never executed: }
0
613 if (format.hasProperty(QTextFormat::ForegroundBrush)) {
partially evaluated: format.hasProperty(QTextFormat::ForegroundBrush)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
614 QBrush brush = format.foreground();
never executed (the execution status of this line is deduced): QBrush brush = format.foreground();
-
615 writer.writeAttribute(foNS, QString::fromLatin1("color"), brush.color().name());
never executed (the execution status of this line is deduced): writer.writeAttribute(foNS, QString::fromLatin1("color"), brush.color().name());
-
616 }
never executed: }
0
617 if (format.hasProperty(QTextFormat::BackgroundBrush)) {
partially evaluated: format.hasProperty(QTextFormat::BackgroundBrush)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
618 QBrush brush = format.background();
never executed (the execution status of this line is deduced): QBrush brush = format.background();
-
619 writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
never executed (the execution status of this line is deduced): writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
-
620 }
never executed: }
0
621 -
622 writer.writeEndElement(); // style
executed (the execution status of this line is deduced): writer.writeEndElement();
-
623}
executed: }
Execution Count:3
3
624 -
625void QTextOdfWriter::writeListFormat(QXmlStreamWriter &writer, QTextListFormat format, int formatIndex) const -
626{ -
627 writer.writeStartElement(textNS, QString::fromLatin1("list-style"));
never executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("list-style"));
-
628 writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("L%1").arg(formatIndex));
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("L%1").arg(formatIndex));
-
629 -
630 QTextListFormat::Style style = format.style();
never executed (the execution status of this line is deduced): QTextListFormat::Style style = format.style();
-
631 if (style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha
never evaluated: style == QTextListFormat::ListDecimal
never evaluated: style == QTextListFormat::ListLowerAlpha
0
632 || style == QTextListFormat::ListUpperAlpha
never evaluated: style == QTextListFormat::ListUpperAlpha
0
633 || style == QTextListFormat::ListLowerRoman
never evaluated: style == QTextListFormat::ListLowerRoman
0
634 || style == QTextListFormat::ListUpperRoman) {
never evaluated: style == QTextListFormat::ListUpperRoman
0
635 writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number"));
never executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number"));
-
636 writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
-
637 -
638 if (format.hasProperty(QTextFormat::ListNumberSuffix))
never evaluated: format.hasProperty(QTextFormat::ListNumberSuffix)
0
639 writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), format.numberSuffix());
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), format.numberSuffix());
0
640 else -
641 writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), QString::fromLatin1("."));
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), QString::fromLatin1("."));
0
642 -
643 if (format.hasProperty(QTextFormat::ListNumberPrefix))
never evaluated: format.hasProperty(QTextFormat::ListNumberPrefix)
0
644 writer.writeAttribute(styleNS, QString::fromLatin1("num-prefix"), format.numberPrefix());
never executed: writer.writeAttribute(styleNS, QString::fromLatin1("num-prefix"), format.numberPrefix());
0
645 -
646 } else {
never executed: }
0
647 writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-bullet"));
never executed (the execution status of this line is deduced): writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-bullet"));
-
648 writer.writeAttribute(textNS, QString::fromLatin1("bullet-char"), bulletChar(style));
never executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("bullet-char"), bulletChar(style));
-
649 }
never executed: }
0
650 -
651 writer.writeAttribute(textNS, QString::fromLatin1("level"), QString::number(format.indent()));
never executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("level"), QString::number(format.indent()));
-
652 writer.writeEmptyElement(styleNS, QString::fromLatin1("list-level-properties"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(styleNS, QString::fromLatin1("list-level-properties"));
-
653 writer.writeAttribute(foNS, QString::fromLatin1("text-align"), QString::fromLatin1("start"));
never executed (the execution status of this line is deduced): writer.writeAttribute(foNS, QString::fromLatin1("text-align"), QString::fromLatin1("start"));
-
654 QString spacing = QString::fromLatin1("%1mm").arg(format.indent() * 8);
never executed (the execution status of this line is deduced): QString spacing = QString::fromLatin1("%1mm").arg(format.indent() * 8);
-
655 writer.writeAttribute(textNS, QString::fromLatin1("space-before"), spacing);
never executed (the execution status of this line is deduced): writer.writeAttribute(textNS, QString::fromLatin1("space-before"), spacing);
-
656 //writer.writeAttribute(textNS, QString::fromLatin1("min-label-width"), spacing); -
657 -
658 writer.writeEndElement(); // list-level-style-*
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
659 writer.writeEndElement(); // list-style
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
660}
never executed: }
0
661 -
662void QTextOdfWriter::writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat format, int formatIndex) const -
663{ -
664 writer.writeStartElement(styleNS, QString::fromLatin1("style"));
never executed (the execution status of this line is deduced): writer.writeStartElement(styleNS, QString::fromLatin1("style"));
-
665 writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex));
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex));
-
666 writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section"));
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section"));
-
667 writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties"));
-
668 if (format.hasProperty(QTextFormat::FrameTopMargin))
never evaluated: format.hasProperty(QTextFormat::FrameTopMargin)
0
669 writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
0
670 if (format.hasProperty(QTextFormat::FrameBottomMargin))
never evaluated: format.hasProperty(QTextFormat::FrameBottomMargin)
0
671 writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
0
672 if (format.hasProperty(QTextFormat::FrameLeftMargin))
never evaluated: format.hasProperty(QTextFormat::FrameLeftMargin)
0
673 writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) );
0
674 if (format.hasProperty(QTextFormat::FrameRightMargin))
never evaluated: format.hasProperty(QTextFormat::FrameRightMargin)
0
675 writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
never executed: writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
0
676 -
677 writer.writeEndElement(); // style
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
678 -
679// TODO consider putting the following properties in a qt-namespace. -
680// Position position () const -
681// qreal border () const -
682// QBrush borderBrush () const -
683// BorderStyle borderStyle () const -
684// qreal padding () const -
685// QTextLength width () const -
686// QTextLength height () const -
687// PageBreakFlags pageBreakPolicy () const -
688}
never executed: }
0
689 -
690void QTextOdfWriter::writeTableCellFormat(QXmlStreamWriter &writer, QTextTableCellFormat format, int formatIndex) const -
691{ -
692 writer.writeStartElement(styleNS, QString::fromLatin1("style"));
never executed (the execution status of this line is deduced): writer.writeStartElement(styleNS, QString::fromLatin1("style"));
-
693 writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("T%1").arg(formatIndex));
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("T%1").arg(formatIndex));
-
694 writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("table"));
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("table"));
-
695 writer.writeEmptyElement(styleNS, QString::fromLatin1("table-properties"));
never executed (the execution status of this line is deduced): writer.writeEmptyElement(styleNS, QString::fromLatin1("table-properties"));
-
696 -
697 -
698 qreal padding = format.topPadding();
never executed (the execution status of this line is deduced): qreal padding = format.topPadding();
-
699 if (padding > 0 && padding == format.bottomPadding()
never evaluated: padding > 0
never evaluated: padding == format.bottomPadding()
0
700 && padding == format.leftPadding() && padding == format.rightPadding()) {
never evaluated: padding == format.leftPadding()
never evaluated: padding == format.rightPadding()
0
701 writer.writeAttribute(foNS, QString::fromLatin1("padding"), pixelToPoint(padding));
never executed (the execution status of this line is deduced): writer.writeAttribute(foNS, QString::fromLatin1("padding"), pixelToPoint(padding));
-
702 }
never executed: }
0
703 else { -
704 if (padding > 0)
never evaluated: padding > 0
0
705 writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(padding));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(padding));
0
706 if (format.bottomPadding() > 0)
never evaluated: format.bottomPadding() > 0
0
707 writer.writeAttribute(foNS, QString::fromLatin1("padding-bottom"), pixelToPoint(format.bottomPadding()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("padding-bottom"), pixelToPoint(format.bottomPadding()));
0
708 if (format.leftPadding() > 0)
never evaluated: format.leftPadding() > 0
0
709 writer.writeAttribute(foNS, QString::fromLatin1("padding-left"), pixelToPoint(format.leftPadding()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("padding-left"), pixelToPoint(format.leftPadding()));
0
710 if (format.rightPadding() > 0)
never evaluated: format.rightPadding() > 0
0
711 writer.writeAttribute(foNS, QString::fromLatin1("padding-right"), pixelToPoint(format.rightPadding()));
never executed: writer.writeAttribute(foNS, QString::fromLatin1("padding-right"), pixelToPoint(format.rightPadding()));
0
712 }
never executed: }
0
713 -
714 if (format.hasProperty(QTextFormat::TextVerticalAlignment)) {
never evaluated: format.hasProperty(QTextFormat::TextVerticalAlignment)
0
715 QString pos;
never executed (the execution status of this line is deduced): QString pos;
-
716 switch (format.verticalAlignment()) { -
717 case QTextCharFormat::AlignMiddle: -
718 pos = QString::fromLatin1("middle"); break;
never executed: break;
0
719 case QTextCharFormat::AlignTop: -
720 pos = QString::fromLatin1("top"); break;
never executed: break;
0
721 case QTextCharFormat::AlignBottom: -
722 pos = QString::fromLatin1("bottom"); break;
never executed: break;
0
723 default: -
724 pos = QString::fromLatin1("automatic"); break;
never executed: break;
0
725 } -
726 writer.writeAttribute(styleNS, QString::fromLatin1("vertical-align"), pos);
never executed (the execution status of this line is deduced): writer.writeAttribute(styleNS, QString::fromLatin1("vertical-align"), pos);
-
727 }
never executed: }
0
728 -
729 // TODO -
730 // ODF just search for style-table-cell-properties-attlist) -
731 // QTextFormat::BackgroundImageUrl -
732 // format.background -
733 // QTextFormat::FrameBorder -
734 -
735 writer.writeEndElement(); // style
never executed (the execution status of this line is deduced): writer.writeEndElement();
-
736}
never executed: }
0
737 -
738/////////////////////// -
739 -
740QTextOdfWriter::QTextOdfWriter(const QTextDocument &document, QIODevice *device) -
741 : officeNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:office:1.0")), -
742 textNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:text:1.0")), -
743 styleNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:style:1.0")), -
744 foNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")), -
745 tableNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:table:1.0")), -
746 drawNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0")), -
747 xlinkNS (QLatin1String("http://www.w3.org/1999/xlink")), -
748 svgNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")), -
749 m_document(&document), -
750 m_device(device), -
751 m_strategy(0), -
752 m_codec(0), -
753 m_createArchive(true) -
754{ -
755}
executed: }
Execution Count:3
3
756 -
757bool QTextOdfWriter::writeAll() -
758{ -
759 if (m_createArchive)
partially evaluated: m_createArchive
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
760 m_strategy = new QZipStreamStrategy(m_device);
executed: m_strategy = new QZipStreamStrategy(m_device);
Execution Count:3
3
761 else -
762 m_strategy = new QXmlStreamStrategy(m_device);
never executed: m_strategy = new QXmlStreamStrategy(m_device);
0
763 -
764 if (!m_device->isWritable() && ! m_device->open(QIODevice::WriteOnly)) {
partially evaluated: !m_device->isWritable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: ! m_device->open(QIODevice::WriteOnly)
0-3
765 qWarning() << "QTextOdfWriter::writeAll: the device can not be opened for writing";
never executed (the execution status of this line is deduced): QMessageLogger("text/qtextodfwriter.cpp", 765, __PRETTY_FUNCTION__).warning() << "QTextOdfWriter::writeAll: the device can not be opened for writing";
-
766 return false;
never executed: return false;
0
767 } -
768 QXmlStreamWriter writer(m_strategy->contentStream);
executed (the execution status of this line is deduced): QXmlStreamWriter writer(m_strategy->contentStream);
-
769#ifndef QT_NO_TEXTCODEC -
770 if (m_codec)
partially evaluated: m_codec
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
771 writer.setCodec(m_codec);
executed: writer.setCodec(m_codec);
Execution Count:3
3
772#endif -
773 // prettyfy -
774 writer.setAutoFormatting(true);
executed (the execution status of this line is deduced): writer.setAutoFormatting(true);
-
775 writer.setAutoFormattingIndent(2);
executed (the execution status of this line is deduced): writer.setAutoFormattingIndent(2);
-
776 -
777 writer.writeNamespace(officeNS, QString::fromLatin1("office"));
executed (the execution status of this line is deduced): writer.writeNamespace(officeNS, QString::fromLatin1("office"));
-
778 writer.writeNamespace(textNS, QString::fromLatin1("text"));
executed (the execution status of this line is deduced): writer.writeNamespace(textNS, QString::fromLatin1("text"));
-
779 writer.writeNamespace(styleNS, QString::fromLatin1("style"));
executed (the execution status of this line is deduced): writer.writeNamespace(styleNS, QString::fromLatin1("style"));
-
780 writer.writeNamespace(foNS, QString::fromLatin1("fo"));
executed (the execution status of this line is deduced): writer.writeNamespace(foNS, QString::fromLatin1("fo"));
-
781 writer.writeNamespace(tableNS, QString::fromLatin1("table"));
executed (the execution status of this line is deduced): writer.writeNamespace(tableNS, QString::fromLatin1("table"));
-
782 writer.writeNamespace(drawNS, QString::fromLatin1("draw"));
executed (the execution status of this line is deduced): writer.writeNamespace(drawNS, QString::fromLatin1("draw"));
-
783 writer.writeNamespace(xlinkNS, QString::fromLatin1("xlink"));
executed (the execution status of this line is deduced): writer.writeNamespace(xlinkNS, QString::fromLatin1("xlink"));
-
784 writer.writeNamespace(svgNS, QString::fromLatin1("svg"));
executed (the execution status of this line is deduced): writer.writeNamespace(svgNS, QString::fromLatin1("svg"));
-
785 writer.writeStartDocument();
executed (the execution status of this line is deduced): writer.writeStartDocument();
-
786 writer.writeStartElement(officeNS, QString::fromLatin1("document-content"));
executed (the execution status of this line is deduced): writer.writeStartElement(officeNS, QString::fromLatin1("document-content"));
-
787 writer.writeAttribute(officeNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
executed (the execution status of this line is deduced): writer.writeAttribute(officeNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
-
788 -
789 // add fragments. (for character formats) -
790 QTextDocumentPrivate::FragmentIterator fragIt = m_document->docHandle()->begin();
executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator fragIt = m_document->docHandle()->begin();
-
791 QSet<int> formats;
executed (the execution status of this line is deduced): QSet<int> formats;
-
792 while (fragIt != m_document->docHandle()->end()) {
evaluated: fragIt != m_document->docHandle()->end()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
793 const QTextFragmentData * const frag = fragIt.value();
executed (the execution status of this line is deduced): const QTextFragmentData * const frag = fragIt.value();
-
794 formats << frag->format;
executed (the execution status of this line is deduced): formats << frag->format;
-
795 ++fragIt;
executed (the execution status of this line is deduced): ++fragIt;
-
796 }
executed: }
Execution Count:6
6
797 -
798 // add blocks (for blockFormats) -
799 QTextDocumentPrivate::BlockMap &blocks = m_document->docHandle()->blockMap();
executed (the execution status of this line is deduced): QTextDocumentPrivate::BlockMap &blocks = m_document->docHandle()->blockMap();
-
800 QTextDocumentPrivate::BlockMap::Iterator blockIt = blocks.begin();
executed (the execution status of this line is deduced): QTextDocumentPrivate::BlockMap::Iterator blockIt = blocks.begin();
-
801 while (blockIt != blocks.end()) {
evaluated: blockIt != blocks.end()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
802 const QTextBlockData * const block = blockIt.value();
executed (the execution status of this line is deduced): const QTextBlockData * const block = blockIt.value();
-
803 formats << block->format;
executed (the execution status of this line is deduced): formats << block->format;
-
804 ++blockIt;
executed (the execution status of this line is deduced): ++blockIt;
-
805 }
executed: }
Execution Count:3
3
806 -
807 // add objects for lists, frames and tables -
808 QVector<QTextFormat> allFormats = m_document->allFormats();
executed (the execution status of this line is deduced): QVector<QTextFormat> allFormats = m_document->allFormats();
-
809 QList<int> copy = formats.toList();
executed (the execution status of this line is deduced): QList<int> copy = formats.toList();
-
810 for (QList<int>::Iterator iter = copy.begin(); iter != copy.end(); ++iter) {
evaluated: iter != copy.end()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
811 QTextObject *object = m_document->objectForFormat(allFormats[*iter]);
executed (the execution status of this line is deduced): QTextObject *object = m_document->objectForFormat(allFormats[*iter]);
-
812 if (object)
partially evaluated: object
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
813 formats << object->formatIndex();
never executed: formats << object->formatIndex();
0
814 }
executed: }
Execution Count:6
6
815 -
816 writeFormats(writer, formats);
executed (the execution status of this line is deduced): writeFormats(writer, formats);
-
817 -
818 writer.writeStartElement(officeNS, QString::fromLatin1("body"));
executed (the execution status of this line is deduced): writer.writeStartElement(officeNS, QString::fromLatin1("body"));
-
819 writer.writeStartElement(officeNS, QString::fromLatin1("text"));
executed (the execution status of this line is deduced): writer.writeStartElement(officeNS, QString::fromLatin1("text"));
-
820 QTextFrame *rootFrame = m_document->rootFrame();
executed (the execution status of this line is deduced): QTextFrame *rootFrame = m_document->rootFrame();
-
821 writeFrame(writer, rootFrame);
executed (the execution status of this line is deduced): writeFrame(writer, rootFrame);
-
822 writer.writeEndElement(); // text
executed (the execution status of this line is deduced): writer.writeEndElement();
-
823 writer.writeEndElement(); // body
executed (the execution status of this line is deduced): writer.writeEndElement();
-
824 writer.writeEndElement(); // document-content
executed (the execution status of this line is deduced): writer.writeEndElement();
-
825 writer.writeEndDocument();
executed (the execution status of this line is deduced): writer.writeEndDocument();
-
826 delete m_strategy;
executed (the execution status of this line is deduced): delete m_strategy;
-
827 m_strategy = 0;
executed (the execution status of this line is deduced): m_strategy = 0;
-
828 -
829 return true;
executed: return true;
Execution Count:3
3
830} -
831 -
832QT_END_NAMESPACE -
833 -
834#endif // QT_NO_TEXTODFWRITER -
835 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial