Qt 4.8
qtextodfwriter.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 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 
63 
65 static 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");
69 }
70 
71 // strategies
73 public:
75  virtual ~QOutputStrategy() {}
76  virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) = 0;
77 
79  {
80  return QString::fromLatin1("Pictures/Picture%1").arg(counter++);
81  }
82 
84  int counter;
85 };
86 
88 public:
90  {
91  contentStream = device;
92  }
93 
95  {
96  if (contentStream)
98  }
99  virtual void addFile(const QString &, const QString &, const QByteArray &)
100  {
101  // we ignore this...
102  }
103 };
104 
106 public:
108  : zip(device),
109  manifestWriter(&manifest)
110  {
111  QByteArray mime("application/vnd.oasis.opendocument.text");
112  zip.setCompressionPolicy(QZipWriter::NeverCompress);
113  zip.addFile(QString::fromLatin1("mimetype"), mime); // for mime-magick
114  zip.setCompressionPolicy(QZipWriter::AutoCompress);
115  contentStream = &content;
116  content.open(QIODevice::WriteOnly);
117  manifest.open(QIODevice::WriteOnly);
118 
119  manifestNS = QString::fromLatin1("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
120  // prettyfy
121  manifestWriter.setAutoFormatting(true);
122  manifestWriter.setAutoFormattingIndent(1);
123 
124  manifestWriter.writeNamespace(manifestNS, QString::fromLatin1("manifest"));
125  manifestWriter.writeStartDocument();
126  manifestWriter.writeStartElement(manifestNS, QString::fromLatin1("manifest"));
127  manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
128  addFile(QString::fromLatin1("/"), QString::fromLatin1("application/vnd.oasis.opendocument.text"));
129  addFile(QString::fromLatin1("content.xml"), QString::fromLatin1("text/xml"));
130  }
131 
133  {
134  manifestWriter.writeEndDocument();
135  manifest.close();
136  zip.addFile(QString::fromLatin1("META-INF/manifest.xml"), &manifest);
137  content.close();
138  zip.addFile(QString::fromLatin1("content.xml"), &content);
139  zip.close();
140  }
141 
142  virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes)
143  {
144  zip.addFile(fileName, bytes);
145  addFile(fileName, mimeType);
146  }
147 
148 private:
149  void addFile(const QString &fileName, const QString &mimeType)
150  {
151  manifestWriter.writeEmptyElement(manifestNS, QString::fromLatin1("file-entry"));
152  manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("media-type"), mimeType);
153  manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("full-path"), fileName);
154  }
155 
161 };
162 
164 {
165  switch(style) {
167  return QChar(0x25cf); // bullet character
169  return QChar(0x25cb); // white circle
171  return QChar(0x25a1); // white square
173  return QString::fromLatin1("1");
175  return QString::fromLatin1("a");
177  return QString::fromLatin1("A");
179  return QString::fromLatin1("i");
181  return QString::fromLatin1("I");
182  default:
184  return QString();
185  }
186 }
187 
189 {
190  Q_ASSERT(frame);
191  const QTextTable *table = qobject_cast<const QTextTable*> (frame);
192 
193  if (table) { // Start a table.
194  writer.writeStartElement(tableNS, QString::fromLatin1("table"));
195  writer.writeEmptyElement(tableNS, QString::fromLatin1("table-column"));
196  writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-repeated"), QString::number(table->columns()));
197  } else if (frame->document() && frame->document()->rootFrame() != frame) { // start a section
198  writer.writeStartElement(textNS, QString::fromLatin1("section"));
199  }
200 
201  QTextFrame::iterator iterator = frame->begin();
202  QTextFrame *child = 0;
203 
204  int tableRow = -1;
205  while (! iterator.atEnd()) {
206  if (iterator.currentFrame() && child != iterator.currentFrame())
207  writeFrame(writer, iterator.currentFrame());
208  else { // no frame, its a block
209  QTextBlock block = iterator.currentBlock();
210  if (table) {
211  QTextTableCell cell = table->cellAt(block.position());
212  if (tableRow < cell.row()) {
213  if (tableRow >= 0)
214  writer.writeEndElement(); // close table row
215  tableRow = cell.row();
216  writer.writeStartElement(tableNS, QString::fromLatin1("table-row"));
217  }
218  writer.writeStartElement(tableNS, QString::fromLatin1("table-cell"));
219  if (cell.columnSpan() > 1)
220  writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-spanned"), QString::number(cell.columnSpan()));
221  if (cell.rowSpan() > 1)
222  writer.writeAttribute(tableNS, QString::fromLatin1("number-rows-spanned"), QString::number(cell.rowSpan()));
223  if (cell.format().isTableCellFormat()) {
224  writer.writeAttribute(tableNS, QString::fromLatin1("style-name"), QString::fromLatin1("T%1").arg(cell.tableCellFormatIndex()));
225  }
226  }
227  writeBlock(writer, block);
228  if (table)
229  writer.writeEndElement(); // table-cell
230  }
231  child = iterator.currentFrame();
232  ++iterator;
233  }
234  if (tableRow >= 0)
235  writer.writeEndElement(); // close table-row
236 
237  if (table || (frame->document() && frame->document()->rootFrame() != frame))
238  writer.writeEndElement(); // close table or section element
239 }
240 
242 {
243  if (block.textList()) { // its a list-item
244  const int listLevel = block.textList()->format().indent();
245  if (m_listStack.isEmpty() || m_listStack.top() != block.textList()) {
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
248  m_listStack.pop();
249  writer.writeEndElement(); // list
250  if (m_listStack.count())
251  writer.writeEndElement(); // list-item
252  }
253  while (m_listStack.count() < listLevel) {
254  if (m_listStack.count())
255  writer.writeStartElement(textNS, QString::fromLatin1("list-item"));
256  writer.writeStartElement(textNS, QString::fromLatin1("list"));
257  if (m_listStack.count() == listLevel - 1) {
258  m_listStack.push(block.textList());
259  writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("L%1")
260  .arg(block.textList()->formatIndex()));
261  }
262  else {
263  m_listStack.push(0);
264  }
265  }
266  }
267  writer.writeStartElement(textNS, QString::fromLatin1("list-item"));
268  }
269  else {
270  while (! m_listStack.isEmpty()) {
271  m_listStack.pop();
272  writer.writeEndElement(); // list
273  if (m_listStack.count())
274  writer.writeEndElement(); // list-item
275  }
276  }
277 
278  if (block.length() == 1) { // only a linefeed
279  writer.writeEmptyElement(textNS, QString::fromLatin1("p"));
280  writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
281  .arg(block.blockFormatIndex()));
282  if (block.textList())
283  writer.writeEndElement(); // numbered-paragraph
284  return;
285  }
286  writer.writeStartElement(textNS, QString::fromLatin1("p"));
287  writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
288  .arg(block.blockFormatIndex()));
289  for (QTextBlock::Iterator frag= block.begin(); !frag.atEnd(); frag++) {
290  writer.writeCharacters(QString()); // Trick to make sure that the span gets no linefeed in front of it.
291  writer.writeStartElement(textNS, QString::fromLatin1("span"));
292 
293  QString fragmentText = frag.fragment().text();
294  if (fragmentText.length() == 1 && fragmentText[0] == 0xFFFC) { // its an inline character.
295  writeInlineCharacter(writer, frag.fragment());
296  writer.writeEndElement(); // span
297  continue;
298  }
299 
300  writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("c%1")
301  .arg(frag.fragment().charFormatIndex()));
302  bool escapeNextSpace = true;
303  int precedingSpaces = 0;
304  int exportedIndex = 0;
305  for (int i=0; i <= fragmentText.count(); ++i) {
306  bool isSpace = false;
307  QChar character = fragmentText[i];
308  isSpace = character.unicode() == ' ';
309 
310  // find more than one space. -> <text:s text:c="2" />
311  if (!isSpace && escapeNextSpace && precedingSpaces > 1) {
312  const bool startParag = exportedIndex == 0 && i == precedingSpaces;
313  if (!startParag)
314  writer.writeCharacters(fragmentText.mid(exportedIndex, i - precedingSpaces + 1 - exportedIndex));
315  writer.writeEmptyElement(textNS, QString::fromLatin1("s"));
316  const int count = precedingSpaces - (startParag?0:1);
317  if (count > 1)
318  writer.writeAttribute(textNS, QString::fromLatin1("c"), QString::number(count));
319  precedingSpaces = 0;
320  exportedIndex = i;
321  }
322 
323  if (i < fragmentText.count()) {
324  if (character.unicode() == 0x2028) { // soft-return
325  //if (exportedIndex < i)
326  writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
327  writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
328  exportedIndex = i+1;
329  continue;
330  } else if (character.unicode() == '\t') { // Tab
331  //if (exportedIndex < i)
332  writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
333  writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
334  exportedIndex = i+1;
335  precedingSpaces = 0;
336  } else if (isSpace) {
337  ++precedingSpaces;
338  escapeNextSpace = true;
339  } else if (!isSpace) {
340  precedingSpaces = 0;
341  }
342  }
343  }
344 
345  writer.writeCharacters(fragmentText.mid(exportedIndex));
346  writer.writeEndElement(); // span
347  }
348  writer.writeCharacters(QString()); // Trick to make sure that the span gets no linefeed behind it.
349  writer.writeEndElement(); // p
350  if (block.textList())
351  writer.writeEndElement(); // list-item
352 }
353 
355 {
356  writer.writeStartElement(drawNS, QString::fromLatin1("frame"));
357  if (m_strategy == 0) {
358  // don't do anything.
359  }
360  else if (fragment.charFormat().isImageFormat()) {
361  QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
362  writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name());
363 
364  // vvv Copy pasted mostly from Qt =================
365  QImage image;
366  QString name = imageFormat.name();
367  if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
368  name.prepend(QLatin1String("qrc"));
369  QUrl url = QUrl::fromEncoded(name.toUtf8());
370  const QVariant data = m_document->resource(QTextDocument::ImageResource, url);
371  if (data.type() == QVariant::Image) {
372  image = qvariant_cast<QImage>(data);
373  } else if (data.type() == QVariant::ByteArray) {
374  image.loadFromData(data.toByteArray());
375  }
376 
377  if (image.isNull()) {
378  QString context;
380  image = QTextImageHandler::externalLoader(name, context);
381 
382  if (image.isNull()) { // try direct loading
383  name = imageFormat.name(); // remove qrc:/ prefix again
384  image.load(name);
385  }
386  }
387 
388  // ^^^ Copy pasted mostly from Qt =================
389  if (! image.isNull()) {
390  QBuffer imageBytes;
391  QImageWriter imageWriter(&imageBytes, "png");
392  imageWriter.write(image);
393  QString filename = m_strategy->createUniqueImageName();
394  m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data());
395 
396  // get the width/height from the format.
397  qreal width = (imageFormat.hasProperty(QTextFormat::ImageWidth)) ? imageFormat.width() : image.width();
398  writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width));
399  qreal height = (imageFormat.hasProperty(QTextFormat::ImageHeight)) ? imageFormat.height() : image.height();
400  writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height));
401 
402  writer.writeStartElement(drawNS, QString::fromLatin1("image"));
403  writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename);
404  writer.writeEndElement(); // image
405  }
406  }
407 
408  writer.writeEndElement(); // frame
409 }
410 
412 {
413  writer.writeStartElement(officeNS, QString::fromLatin1("automatic-styles"));
414  QVector<QTextFormat> allStyles = m_document->allFormats();
415  QSetIterator<int> formatId(formats);
416  while(formatId.hasNext()) {
417  int formatIndex = formatId.next();
418  QTextFormat textFormat = allStyles.at(formatIndex);
419  switch (textFormat.type()) {
421  if (textFormat.isTableCellFormat())
422  writeTableCellFormat(writer, textFormat.toTableCellFormat(), formatIndex);
423  else
424  writeCharacterFormat(writer, textFormat.toCharFormat(), formatIndex);
425  break;
427  writeBlockFormat(writer, textFormat.toBlockFormat(), formatIndex);
428  break;
430  writeListFormat(writer, textFormat.toListFormat(), formatIndex);
431  break;
433  writeFrameFormat(writer, textFormat.toFrameFormat(), formatIndex);
434  break;
436  ;break;
437  }
438  }
439 
440  writer.writeEndElement(); // automatic-styles
441 }
442 
444 {
445  writer.writeStartElement(styleNS, QString::fromLatin1("style"));
446  writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("p%1").arg(formatIndex));
447  writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("paragraph"));
448  writer.writeStartElement(styleNS, QString::fromLatin1("paragraph-properties"));
449 
451  const Qt::Alignment alignment = format.alignment() & Qt::AlignHorizontal_Mask;
452  QString value;
453  if (alignment == Qt::AlignLeading)
454  value = QString::fromLatin1("start");
455  else if (alignment == Qt::AlignTrailing)
456  value = QString::fromLatin1("end");
457  else if (alignment == (Qt::AlignLeft | Qt::AlignAbsolute))
458  value = QString::fromLatin1("left");
459  else if (alignment == (Qt::AlignRight | Qt::AlignAbsolute))
460  value = QString::fromLatin1("right");
461  else if (alignment == Qt::AlignHCenter)
462  value = QString::fromLatin1("center");
463  else if (alignment == Qt::AlignJustify)
464  value = QString::fromLatin1("justify");
465  else
466  qWarning() << "QTextOdfWriter: unsupported paragraph alignment; " << format.alignment();
467  if (! value.isNull())
468  writer.writeAttribute(foNS, QString::fromLatin1("text-align"), value);
469  }
470 
472  writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
474  writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
476  writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.),
477  format.leftMargin() + format.indent())));
479  writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
481  writer.writeAttribute(foNS, QString::fromLatin1("text-indent"), pixelToPoint(format.textIndent()));
484  writer.writeAttribute(foNS, QString::fromLatin1("break-before"), QString::fromLatin1("page"));
486  writer.writeAttribute(foNS, QString::fromLatin1("break-after"), QString::fromLatin1("page"));
487  }
489  QBrush brush = format.background();
490  writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
491  }
493  writer.writeAttribute(foNS, QString::fromLatin1("keep-together"),
494  format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false"));
496  QList<QTextOption::Tab> tabs = format.tabPositions();
497  writer.writeStartElement(styleNS, QString::fromLatin1("tab-stops"));
498  QList<QTextOption::Tab>::Iterator iterator = tabs.begin();
499  while(iterator != tabs.end()) {
500  writer.writeEmptyElement(styleNS, QString::fromLatin1("tab-stop"));
501  writer.writeAttribute(styleNS, QString::fromLatin1("position"), pixelToPoint(iterator->position) );
502  QString type;
503  switch(iterator->type) {
504  case QTextOption::DelimiterTab: type = QString::fromLatin1("char"); break;
505  case QTextOption::LeftTab: type = QString::fromLatin1("left"); break;
506  case QTextOption::RightTab: type = QString::fromLatin1("right"); break;
507  case QTextOption::CenterTab: type = QString::fromLatin1("center"); break;
508  }
509  writer.writeAttribute(styleNS, QString::fromLatin1("type"), type);
510  if (iterator->delimiter != 0)
511  writer.writeAttribute(styleNS, QString::fromLatin1("char"), iterator->delimiter);
512  ++iterator;
513  }
514 
515  writer.writeEndElement(); // tab-stops
516  }
517 
518  writer.writeEndElement(); // paragraph-properties
519  writer.writeEndElement(); // style
520 }
521 
523 {
524  writer.writeStartElement(styleNS, QString::fromLatin1("style"));
525  writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("c%1").arg(formatIndex));
526  writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("text"));
527  writer.writeEmptyElement(styleNS, QString::fromLatin1("text-properties"));
528  if (format.fontItalic())
529  writer.writeAttribute(foNS, QString::fromLatin1("font-style"), QString::fromLatin1("italic"));
530  if (format.hasProperty(QTextFormat::FontWeight) && format.fontWeight() != QFont::Normal) {
531  QString value;
532  if (format.fontWeight() == QFont::Bold)
533  value = QString::fromLatin1("bold");
534  else
535  value = QString::number(format.fontWeight() * 10);
536  writer.writeAttribute(foNS, QString::fromLatin1("font-weight"), value);
537  }
539  writer.writeAttribute(foNS, QString::fromLatin1("font-family"), format.fontFamily());
540  else
541  writer.writeAttribute(foNS, QString::fromLatin1("font-family"), QString::fromLatin1("Sans")); // Qt default
543  writer.writeAttribute(foNS, QString::fromLatin1("font-size"), QString::fromLatin1("%1pt").arg(format.fontPointSize()));
545  switch(format.fontCapitalization()) {
546  case QFont::MixedCase:
547  writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("none")); break;
548  case QFont::AllUppercase:
549  writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("uppercase")); break;
550  case QFont::AllLowercase:
551  writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("lowercase")); break;
552  case QFont::Capitalize:
553  writer.writeAttribute(foNS, QString::fromLatin1("text-transform"), QString::fromLatin1("capitalize")); break;
554  case QFont::SmallCaps:
555  writer.writeAttribute(foNS, QString::fromLatin1("font-variant"), QString::fromLatin1("small-caps")); break;
556  }
557  }
559  writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()));
560  if (format.hasProperty(QTextFormat::FontWordSpacing) && format.fontWordSpacing() != 0)
561  writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing()));
563  writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"),
564  format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
566  // bool fontOverline () const TODO
567  }
569  writer.writeAttribute(styleNS,QString::fromLatin1( "text-line-through-type"),
570  format.fontStrikeOut() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
572  writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-color"), format.underlineColor().name());
574  // bool fontFixedPitch () const TODO
575  }
577  QString value;
578  switch (format.underlineStyle()) {
579  case QTextCharFormat::NoUnderline: value = QString::fromLatin1("none"); break;
580  case QTextCharFormat::SingleUnderline: value = QString::fromLatin1("solid"); break;
581  case QTextCharFormat::DashUnderline: value = QString::fromLatin1("dash"); break;
582  case QTextCharFormat::DotLine: value = QString::fromLatin1("dotted"); break;
583  case QTextCharFormat::DashDotLine: value = QString::fromLatin1("dash-dot"); break;
584  case QTextCharFormat::DashDotDotLine: value = QString::fromLatin1("dot-dot-dash"); break;
585  case QTextCharFormat::WaveUnderline: value = QString::fromLatin1("wave"); break;
586  case QTextCharFormat::SpellCheckUnderline: value = QString::fromLatin1("none"); break;
587  }
588  writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-style"), value);
589  }
591  QString value;
592  switch (format.verticalAlignment()) {
595  case QTextCharFormat::AlignNormal: value = QString::fromLatin1("0%"); break;
596  case QTextCharFormat::AlignSuperScript: value = QString::fromLatin1("super"); break;
597  case QTextCharFormat::AlignSubScript: value = QString::fromLatin1("sub"); break;
598  case QTextCharFormat::AlignTop: value = QString::fromLatin1("100%"); break;
599  case QTextCharFormat::AlignBottom : value = QString::fromLatin1("-100%"); break;
600  }
601  writer.writeAttribute(styleNS, QString::fromLatin1("text-position"), value);
602  }
604  writer.writeAttribute(styleNS, QString::fromLatin1("text-outline"), QString::fromLatin1("true"));
606  // QString toolTip () const TODO
607  }
608  if (format.hasProperty(QTextFormat::IsAnchor)) {
609  // bool isAnchor () const TODO
610  }
611  if (format.hasProperty(QTextFormat::AnchorHref)) {
612  // QString anchorHref () const TODO
613  }
614  if (format.hasProperty(QTextFormat::AnchorName)) {
615  // QString anchorName () const TODO
616  }
618  QBrush brush = format.foreground();
619  writer.writeAttribute(foNS, QString::fromLatin1("color"), brush.color().name());
620  }
622  QBrush brush = format.background();
623  writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
624  }
625 
626  writer.writeEndElement(); // style
627 }
628 
630 {
631  writer.writeStartElement(textNS, QString::fromLatin1("list-style"));
632  writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("L%1").arg(formatIndex));
633 
634  QTextListFormat::Style style = format.style();
638  || style == QTextListFormat::ListUpperRoman) {
639  writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number"));
640  writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
641 
643  writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), format.numberSuffix());
644  else
645  writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), QString::fromLatin1("."));
646 
648  writer.writeAttribute(styleNS, QString::fromLatin1("num-prefix"), format.numberPrefix());
649 
650  } else {
651  writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-bullet"));
652  writer.writeAttribute(textNS, QString::fromLatin1("bullet-char"), bulletChar(style));
653  }
654 
655  writer.writeAttribute(textNS, QString::fromLatin1("level"), QString::number(format.indent()));
656  writer.writeEmptyElement(styleNS, QString::fromLatin1("list-level-properties"));
657  writer.writeAttribute(foNS, QString::fromLatin1("text-align"), QString::fromLatin1("start"));
658  QString spacing = QString::fromLatin1("%1mm").arg(format.indent() * 8);
659  writer.writeAttribute(textNS, QString::fromLatin1("space-before"), spacing);
660  //writer.writeAttribute(textNS, QString::fromLatin1("min-label-width"), spacing);
661 
662  writer.writeEndElement(); // list-level-style-*
663  writer.writeEndElement(); // list-style
664 }
665 
667 {
668  writer.writeStartElement(styleNS, QString::fromLatin1("style"));
669  writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex));
670  writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section"));
671  writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties"));
673  writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
675  writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
677  writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) );
679  writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
680 
681  writer.writeEndElement(); // style
682 
683 // TODO consider putting the following properties in a qt-namespace.
684 // Position position () const
685 // qreal border () const
686 // QBrush borderBrush () const
687 // BorderStyle borderStyle () const
688 // qreal padding () const
689 // QTextLength width () const
690 // QTextLength height () const
691 // PageBreakFlags pageBreakPolicy () const
692 }
693 
695 {
696  writer.writeStartElement(styleNS, QString::fromLatin1("style"));
697  writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("T%1").arg(formatIndex));
698  writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("table"));
699  writer.writeEmptyElement(styleNS, QString::fromLatin1("table-properties"));
700 
701 
702  qreal padding = format.topPadding();
703  if (padding > 0 && padding == format.bottomPadding()
704  && padding == format.leftPadding() && padding == format.rightPadding()) {
705  writer.writeAttribute(foNS, QString::fromLatin1("padding"), pixelToPoint(padding));
706  }
707  else {
708  if (padding > 0)
709  writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(padding));
710  if (format.bottomPadding() > 0)
711  writer.writeAttribute(foNS, QString::fromLatin1("padding-bottom"), pixelToPoint(format.bottomPadding()));
712  if (format.leftPadding() > 0)
713  writer.writeAttribute(foNS, QString::fromLatin1("padding-left"), pixelToPoint(format.leftPadding()));
714  if (format.rightPadding() > 0)
715  writer.writeAttribute(foNS, QString::fromLatin1("padding-right"), pixelToPoint(format.rightPadding()));
716  }
717 
719  QString pos;
720  switch (format.verticalAlignment()) {
722  pos = QString::fromLatin1("middle"); break;
724  pos = QString::fromLatin1("top"); break;
726  pos = QString::fromLatin1("bottom"); break;
727  default:
728  pos = QString::fromLatin1("automatic"); break;
729  }
730  writer.writeAttribute(styleNS, QString::fromLatin1("vertical-align"), pos);
731  }
732 
733  // TODO
734  // ODF just search for style-table-cell-properties-attlist)
735  // QTextFormat::BackgroundImageUrl
736  // format.background
737  // QTextFormat::FrameBorder
738 
739  writer.writeEndElement(); // style
740 }
741 
743 
745  : officeNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:office:1.0")),
746  textNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:text:1.0")),
747  styleNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:style:1.0")),
748  foNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")),
749  tableNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:table:1.0")),
750  drawNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0")),
751  xlinkNS (QLatin1String("http://www.w3.org/1999/xlink")),
752  svgNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")),
753  m_document(&document),
754  m_device(device),
755  m_strategy(0),
756  m_codec(0),
757  m_createArchive(true)
758 {
759 }
760 
762 {
763  if (m_createArchive)
765  else
767 
769  qWarning() << "QTextOdfWriter::writeAll: the device can not be opened for writing";
770  return false;
771  }
773 #ifndef QT_NO_TEXTCODEC
774  if (m_codec)
775  writer.setCodec(m_codec);
776 #endif
777  // prettyfy
778  writer.setAutoFormatting(true);
779  writer.setAutoFormattingIndent(2);
780 
781  writer.writeNamespace(officeNS, QString::fromLatin1("office"));
782  writer.writeNamespace(textNS, QString::fromLatin1("text"));
783  writer.writeNamespace(styleNS, QString::fromLatin1("style"));
784  writer.writeNamespace(foNS, QString::fromLatin1("fo"));
785  writer.writeNamespace(tableNS, QString::fromLatin1("table"));
786  writer.writeNamespace(drawNS, QString::fromLatin1("draw"));
787  writer.writeNamespace(xlinkNS, QString::fromLatin1("xlink"));
788  writer.writeNamespace(svgNS, QString::fromLatin1("svg"));
789  writer.writeStartDocument();
790  writer.writeStartElement(officeNS, QString::fromLatin1("document-content"));
792 
793  // add fragments. (for character formats)
795  QSet<int> formats;
796  while (fragIt != m_document->docHandle()->end()) {
797  const QTextFragmentData * const frag = fragIt.value();
798  formats << frag->format;
799  ++fragIt;
800  }
801 
802  // add blocks (for blockFormats)
805  while (blockIt != blocks.end()) {
806  const QTextBlockData * const block = blockIt.value();
807  formats << block->format;
808  ++blockIt;
809  }
810 
811  // add objects for lists, frames and tables
813  QList<int> copy = formats.toList();
814  for (QList<int>::Iterator iter = copy.begin(); iter != copy.end(); ++iter) {
815  QTextObject *object = m_document->objectForFormat(allFormats[*iter]);
816  if (object)
817  formats << object->formatIndex();
818  }
819 
820  writeFormats(writer, formats);
821 
824  QTextFrame *rootFrame = m_document->rootFrame();
825  writeFrame(writer, rootFrame);
826  writer.writeEndElement(); // text
827  writer.writeEndElement(); // body
828  writer.writeEndElement(); // document-content
829  writer.writeEndDocument();
830  delete m_strategy;
831  m_strategy = 0;
832 
833  return true;
834 }
835 
837 
838 #endif // QT_NO_TEXTODFWRITER
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
T qobject_cast(QObject *object)
Definition: qobject.h:375
int columns() const
Returns the number of columns in the table.
void writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFormat format, int formatIndex) const
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
qreal rightPadding() const
Gets the right padding of the table cell.
Definition: qtextformat.h:959
QIODevice * m_device
const QString xlinkNS
int type
Definition: qmetatype.cpp:239
int formatIndex() const
Returns the index of the object&#39;s format in the document&#39;s internal list of formats.
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
double qreal
Definition: qglobal.h:1193
The QTextListFormat class provides formatting information for lists in a QTextDocument.
Definition: qtextformat.h:642
int blockFormatIndex() const
Returns an index into the document&#39;s internal list of block formats for the text block&#39;s format...
QIODevice * contentStream
const QString svgNS
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
FragmentIterator end() const
QTextList * textList() const
If the block represents a list item, returns the list that the item belongs to; otherwise returns 0...
const QByteArray & data() const
Returns the data contained in the buffer.
Definition: qbuffer.cpp:301
bool isWritable() const
Returns true if data can be written to the device; otherwise returns false.
Definition: qiodevice.cpp:558
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
Definition: qiodevice.cpp:590
bool fontStrikeOut() const
Returns true if the text format&#39;s font is struck out (has a horizontal line drawn through it); otherw...
Definition: qtextformat.h:443
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
The QTextFrame class represents a frame in a QTextDocument.
Definition: qtextobject.h:122
QColor underlineColor() const
Returns the color used to underline the characters with this format.
Definition: qtextformat.h:448
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
Iterator begin()
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
QTextTableCellFormat toTableCellFormat() const
Returns this format as a table cell format.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool atEnd() const
Returns true if the current item is the last item in the text block.
Definition: qtextobject.h:264
PageBreakFlags pageBreakPolicy() const
Returns the currently set page break policy for the paragraph.
Definition: qtextformat.h:608
QTextFrame * currentFrame() const
Returns the current frame pointed to by the iterator, or 0 if the iterator currently points to a bloc...
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString & prepend(QChar c)
Definition: qstring.h:261
const QString officeNS
static QString pixelToPoint(qreal pixels)
Convert pixels to postscript point units.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
const char * mime
const QTextDocument * m_document
QTextDocument * document() const
Returns the document this object belongs to.
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
void writeEndDocument()
Closes all remaining open start elements and writes a newline.
void writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat format, int formatIndex) const
static Q_GUI_EXPORT ExternalImageLoaderFunction externalLoader
qreal leftMargin() const
Returns the width of the frame&#39;s left margin in pixels.
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
void writeTableCellFormat(QXmlStreamWriter &writer, QTextTableCellFormat format, int formatIndex) const
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
qreal height() const
Returns the height of the rectangle occupied by the image.
Definition: qtextformat.h:710
static QString bulletChar(QTextListFormat::Style style)
qreal topMargin() const
Returns the paragraph&#39;s top margin.
Definition: qtextformat.h:566
int indent() const
Returns the paragraph&#39;s indent.
Definition: qtextformat.h:590
qreal rightMargin() const
Returns the paragraph&#39;s right margin.
Definition: qtextformat.h:581
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Qt::Alignment alignment() const
Returns the paragraph&#39;s alignment.
Definition: qtextformat.h:561
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool load(QIODevice *device, const char *format)
This function reads a QImage from the given device.
Definition: qimage.cpp:5251
FragmentMap::ConstIterator FragmentIterator
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes)=0
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
QTextFrame * rootFrame() const
Returns the document&#39;s root frame.
QTextCodec * m_codec
int position() const
Returns the index of the block&#39;s first character within the document.
QTextFrameFormat toFrameFormat() const
Returns this format as a frame format.
void addFile(const QString &fileName, const QString &mimeType)
QZipStreamStrategy(QIODevice *device)
void writeBlock(QXmlStreamWriter &writer, const QTextBlock &block)
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
int type() const
Returns the type of this format.
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
void setCodec(QTextCodec *codec)
Sets the codec for this stream to codec.
QTextCharFormat charFormat() const
Returns the text fragment&#39;s character format.
The QTextImageFormat class provides formatting information for images in a QTextDocument.
Definition: qtextformat.h:694
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Style style() const
Returns the list format&#39;s style.
Definition: qtextformat.h:662
UnderlineStyle underlineStyle() const
Returns the style of underlining the text.
Definition: qtextformat.h:481
void writeAttribute(const QString &qualifiedName, const QString &value)
Writes an attribute with qualifiedName and value.
qreal topMargin() const
Returns the width of the frame&#39;s top margin in pixels.
virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes)
QTextCharFormat format() const
Returns the cell&#39;s character format.
Definition: qtexttable.cpp:153
qreal bottomMargin() const
Returns the width of the frame&#39;s bottom margin in pixels.
virtual void addFile(const QString &, const QString &, const QByteArray &)
QString numberSuffix() const
Returns the list format&#39;s number suffix.
Definition: qtextformat.h:674
QList< T > toList() const
Definition: qset.h:296
Style
This enum describes the symbols used to decorate list items:
Definition: qtextformat.h:649
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
The QImageWriter class provides a format independent interface for writing images to files or other d...
Definition: qimagewriter.h:59
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.
Iterator end()
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
const char * name
void writeNamespace(const QString &namespaceUri, const QString &prefix=QString())
Writes a namespace declaration for namespaceUri with prefix.
const QString foNS
QList< QTextOption::Tab > tabPositions() const
Returns a list of tab positions defined for the text block.
void writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat format, int formatIndex) const
const QString textNS
int fontWeight() const
Returns the text format&#39;s font weight.
Definition: qtextformat.h:413
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
static const char * data(const QByteArray &arr)
QTextBlockFormat toBlockFormat() const
Returns this format as a block format.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QTextListFormat toListFormat() const
Returns this format as a list format.
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
virtual ~QOutputStrategy()
int length() const
Returns the length of the block in characters.
QBrush background() const
Returns the brush used to paint the document&#39;s background.
Definition: qtextformat.h:345
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
const BlockMap & blockMap() const
void writeListFormat(QXmlStreamWriter &writer, QTextListFormat format, int formatIndex) const
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
Definition: qtextobject.h:297
void writeCharacters(const QString &text)
Writes text.
qreal textIndent() const
Returns the paragraph&#39;s text indent.
Definition: qtextformat.h:586
const QString tableNS
int count() const
Definition: qstring.h:103
The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock...
Definition: qtextobject.h:251
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The iterator class provides an iterator for reading the contents of a QTextFrame. ...
Definition: qtextobject.h:144
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QVector< QTextFormat > allFormats() const
Returns a vector of text formats for all the formats used in the document.
virtual ~QXmlStreamStrategy()
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
Definition: qtextformat.h:486
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QTextImageFormat toImageFormat() const
Returns this format as an image format.
const QString drawNS
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
bool nonBreakableLines() const
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
Definition: qtextformat.h:603
QString numberPrefix() const
Returns the list format&#39;s number prefix.
Definition: qtextformat.h:670
void writeFormats(QXmlStreamWriter &writer, QSet< int > formatIds) const
void writeStartDocument()
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setAutoFormattingIndent(int spacesOrTabs)
void writeEndElement()
Closes the previous start element.
void writeFrame(QXmlStreamWriter &writer, const QTextFrame *frame)
FragmentIterator begin() const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
qreal bottomMargin() const
Returns the paragraph&#39;s bottom margin.
Definition: qtextformat.h:571
qreal fontWordSpacing() const
Returns the current word spacing value.
Definition: qtextformat.h:429
qreal rightMargin() const
Returns the width of the frame&#39;s right margin in pixels.
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
Definition: qtextformat.h:727
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
Definition: qtextformat.h:352
QXmlStreamStrategy(QIODevice *device)
void writeEmptyElement(const QString &qualifiedName)
Writes an empty element with qualified name qualifiedName.
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
Definition: qiodevice.cpp:570
The QTextTableCellFormat class provides formatting information for table cells in a QTextDocument...
Definition: qtextformat.h:898
QOutputStrategy * m_strategy
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
int tableCellFormatIndex() const
Returns the index of the tableCell&#39;s format in the document&#39;s internal list of formats.
Definition: qtexttable.cpp:173
QTextCharFormat toCharFormat() const
Returns this format as a character format.
void setAutoFormatting(bool)
const QString styleNS
bool atEnd() const
Returns true if the current item is the last item in the text frame.
Definition: qtextobject.h:165
void writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const
qreal fontPointSize() const
Returns the font size used to display text in this format.
Definition: qtextformat.h:408
qreal topPadding() const
Gets the top padding of the table cell.
Definition: qtextformat.h:929
bool isImageFormat() const
Returns true if this text format is an image format; otherwise returns false.
Definition: qtextformat.h:322
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228
bool isTableCellFormat() const
Returns true if this text format is a TableCellFormat; otherwise returns false.
Definition: qtextformat.h:324
static QUrl fromEncoded(const QByteArray &url)
Parses input and returns the corresponding QUrl.
Definition: qurl.cpp:5964
the QZipWriter class provides a way to create a new zip archive.
Definition: qzipwriter_p.h:64
qreal fontLetterSpacing() const
Returns the current letter spacing percentage.
Definition: qtextformat.h:425
The QTextObject class is a base class for different kinds of objects that can group parts of a QTextD...
Definition: qtextobject.h:64
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
qreal leftPadding() const
Gets the left padding of the table cell.
Definition: qtextformat.h:949
bool fontItalic() const
Returns true if the text format&#39;s font is italic; otherwise returns false.
Definition: qtextformat.h:417
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
QString fontFamily() const
Returns the text format&#39;s font family.
Definition: qtextformat.h:403
qreal bottomPadding() const
Gets the bottom padding of the table cell.
Definition: qtextformat.h:939
QTextBlock currentBlock() const
Returns the current block the iterator points to.
static QString fileName(const QString &fileUrl)
int indent() const
Returns the list format&#39;s indentation.
Definition: qtextformat.h:666
qreal leftMargin() const
Returns the paragraph&#39;s left margin.
Definition: qtextformat.h:576
QString name() const
Returns the name of the color in the format "#RRGGBB"; i.e.
Definition: qcolor.cpp:529
QFont::Capitalization fontCapitalization() const
Returns the current capitalization type of the font.
Definition: qtextformat.h:421
QTextOdfWriter(const QTextDocument &document, QIODevice *device)
QString name() const
Returns the name of the image.
Definition: qtextformat.h:702
bool fontUnderline() const
Returns true if the text format&#39;s font is underlined; otherwise returns false.
void writeStartElement(const QString &qualifiedName)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool loadFromData(const uchar *buf, int len, const char *format=0)
Loads an image from the first len bytes of the given binary data.
Definition: qimage.cpp:5275
iterator begin() const
Returns an iterator pointing to the first document element inside the frame.
qreal width() const
Returns the width of the rectangle occupied by the image.
Definition: qtextformat.h:706
QXmlStreamWriter manifestWriter
QString createUniqueImageName()
QTextListFormat format() const
Returns the list&#39;s format.
Definition: qtextlist.h:80