6#ifndef QT_NO_TEXTODFWRITER
10#include <QImageReader>
11#include <QImageWriter>
12#include <QTextListFormat>
23#include <QtCore/private/qzipwriter_p.h>
75 manifestWriter(&manifest)
87 manifestWriter.setAutoFormatting(
true);
88 manifestWriter.setAutoFormattingIndent(1);
91 manifestWriter.writeStartDocument();
100 manifestWriter.writeEndDocument();
125 QXmlStreamWriter manifestWriter;
133 static const char16_t chars[] = {
145 const auto idx =
map(style);
149 return {chars + idx, 1};
196 if (m_tableFormatsWithColWidthConstraints.
contains(
table->formatIndex())) {
197 for (
int colit = 0; colit <
table->columns(); ++colit) {
201 writer.writeEndElement();
208 }
else if (
frame->document() &&
frame->document()->rootFrame() !=
frame) {
216 while (! iterator.atEnd()) {
217 if (iterator.currentFrame() &&
child != iterator.currentFrame())
223 if (tableRow < cell.
row()) {
225 writer.writeEndElement();
226 tableRow = cell.
row();
248 writer.writeEndElement();
250 child = iterator.currentFrame();
254 writer.writeEndElement();
257 writer.writeEndElement();
266 while (m_listStack.
size() >= listLevel && !m_listStack.
isEmpty() && m_listStack.
top() != block.
textList() ) {
268 writer.writeEndElement();
269 if (m_listStack.
size())
270 writer.writeEndElement();
272 while (m_listStack.
size() < listLevel) {
273 if (m_listStack.
size())
276 if (m_listStack.
size() == listLevel - 1) {
282 m_listStack.
push(
nullptr);
289 while (! m_listStack.
isEmpty()) {
291 writer.writeEndElement();
292 if (m_listStack.
size())
293 writer.writeEndElement();
297 if (block.
length() == 1) {
302 writer.writeEndElement();
315 writer.writeCharacters(
QString());
318 QString fragmentText = frag.fragment().text();
319 if (fragmentText.
size() == 1 && fragmentText[0] == u
'\xFFFC') {
321 writer.writeEndElement();
326 .
arg(frag.fragment().charFormatIndex()));
327 bool escapeNextSpace =
true;
328 int precedingSpaces = 0;
329 int exportedIndex = 0;
330 for (
int i=0;
i <= fragmentText.
size(); ++
i) {
332 bool isSpace = character.
unicode() ==
' ';
335 if (!isSpace && escapeNextSpace && precedingSpaces > 1) {
336 const bool startParag = exportedIndex == 0 &&
i == precedingSpaces;
338 writer.writeCharacters(fragmentText.
mid(exportedIndex,
i - precedingSpaces + 1 - exportedIndex));
340 const int count = precedingSpaces - (startParag?0:1);
347 if (
i < fragmentText.
size()) {
348 if (character.
unicode() == 0x2028) {
350 writer.writeCharacters(fragmentText.
mid(exportedIndex,
i - exportedIndex));
357 }
else if (character.
unicode() ==
'\t') {
359 writer.writeCharacters(fragmentText.
mid(exportedIndex,
i - exportedIndex));
363 }
else if (isSpace) {
365 escapeNextSpace =
true;
366 }
else if (!isSpace) {
372 writer.writeCharacters(fragmentText.
mid(exportedIndex));
373 writer.writeEndElement();
374 writer.writeCharacters(
QString());
376 writer.writeEndElement();
378 writer.writeCharacters(
QString());
379 writer.writeEndElement();
381 writer.writeEndElement();
390 }
else if (
format ==
"jpg") {
392 }
else if (
format ==
"svg") {
410 if (m_strategy ==
nullptr) {
424 if (
name.startsWith(
":/"_L1))
445 if (!
image.isNull()) {
448 int imgQuality = imageFormat.
quality();
449 if (imgQuality >= 100 || imgQuality <= 0 ||
image.hasAlphaChannel()) {
469 if (!
data.isEmpty()) {
486 writer.writeEndElement();
489 writer.writeEndElement();
496 for (
int formatIndex :
formats) {
498 switch (textFormat.
type()) {
520 writer.writeEndElement();
531 const int blockLineHeightType =
format.lineHeightType();
534 switch (blockLineHeightType) {
576 qWarning() <<
"QTextOdfWriter: unsupported paragraph alignment; " <<
format.alignment();
577 if (!
value.isNull())
609 while(iterator != tabs.
end()) {
613 switch(iterator->type) {
620 if (!iterator->delimiter.isNull())
625 writer.writeEndElement();
628 writer.writeEndElement();
629 writer.writeEndElement();
655 switch(
format.fontCapitalization()) {
688 switch (
format.underlineStyle()) {
702 switch (
format.verticalAlignment()) {
736 writer.writeEndElement();
772 writer.writeEndElement();
773 writer.writeEndElement();
791 writer.writeEndElement();
813 if (m_tableFormatsWithBorders.
contains(formatIndex)) {
818 const char* align =
nullptr;
819 switch (
format.alignment()) {
835 if (
format.width().rawValue()) {
839 writer.writeEndElement();
841 if (
format.columnWidthConstraints().size()) {
843 m_tableFormatsWithColWidthConstraints.
insert(formatIndex);
844 for (
int colit = 0; colit <
format.columnWidthConstraints().
size(); ++colit) {
863 writer.writeEndElement();
872 if (m_cellFormatsInTablesWithBorders.
contains(formatIndex)) {
873 const QList<int> tableIdVector = m_cellFormatsInTablesWithBorders.
value(formatIndex);
874 for (
const auto &tableId : tableIdVector) {
875 const auto &tmpStyle = styles.
at(tableId);
876 if (tmpStyle.isTableFormat()) {
880 qDebug(
"QTextOdfWriter::writeTableCellFormat: ERROR writing table border format");
889 bool hasBorder,
int tableId,
908 if (padding > 0 && topPadding ==
format.bottomPadding()
909 && topPadding ==
format.leftPadding() && topPadding ==
format.rightPadding()) {
931 switch (
format.verticalAlignment()) {
948 writer.writeEndElement();
954 : officeNS (
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"_L1),
955 textNS (
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"_L1),
956 styleNS (
"urn:oasis:names:tc:opendocument:xmlns:style:1.0"_L1),
957 foNS (
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"_L1),
958 tableNS (
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"_L1),
959 drawNS (
"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"_L1),
960 xlinkNS (
"http://www.w3.org/1999/xlink"_L1),
961 svgNS (
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"_L1),
962 m_document(&document),
965 m_createArchive(true)
977 qWarning(
"QTextOdfWriter::writeAll: the device cannot be opened for writing");
982 writer.setAutoFormatting(
true);
983 writer.setAutoFormattingIndent(2);
993 writer.writeStartDocument();
1009 while (blockIt != blocks.
end()) {
1022 if (
auto *tableobject = qobject_cast<QTextTable *>(
object)) {
1023 if (tableobject->format().borderStyle()) {
1024 int tableID = tableobject->formatIndex();
1025 m_tableFormatsWithBorders.
insert(tableID);
1028 for (
int rowindex = 0; rowindex < tableobject->rows(); ++rowindex) {
1029 for (
int colindex = 0; colindex < tableobject->columns(); ++colindex) {
1030 const int cellFormatID = tableobject->cellAt(rowindex, colindex).tableCellFormatIndex();
1032 if (m_cellFormatsInTablesWithBorders.
contains(cellFormatID))
1033 tableIdsTmp = m_cellFormatsInTablesWithBorders.
value(cellFormatID);
1034 if (!tableIdsTmp.
contains(tableID))
1035 tableIdsTmp.
append(tableID);
1036 m_cellFormatsInTablesWithBorders.
insert(cellFormatID, tableIdsTmp);
1050 writer.writeEndElement();
1051 writer.writeEndElement();
1052 writer.writeEndElement();
1053 writer.writeEndDocument();
1055 m_strategy =
nullptr;
IOBluetoothDevice * device
const QColor & color() const
Returns the brush color.
\inmodule QtCore \reentrant
bool open(OpenMode openMode) override
\reimp
const QByteArray & data() const
Returns the data contained in the buffer.
void close() override
\reimp
QByteArray toLower() const &
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
QString name(NameFormat format=HexRgb) const
bool seek(qint64 offset) override
For random-access devices, this function sets the current position to pos, returning true on success,...
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
bool isWritable() const
Returns true if data can be written to the device; otherwise returns false.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
The QImageReader class provides a format independent interface for reading images from files or other...
QByteArray format() const
Returns the format QImageReader uses for reading images.
QSize size() const
Returns the size of the image, without actually reading the image contents.
QImage read()
Reads an image from the device.
The QImageWriter class provides a format independent interface for writing images to files or other d...
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
void setQuality(int quality)
Sets the quality setting of the image format to quality.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
virtual ~QOutputStrategy()
QIODevice * contentStream
QString createUniqueImageName()
virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes)=0
bool contains(const T &value) const
iterator insert(const T &value)
constexpr int width() const noexcept
Returns the width.
T & top()
Returns a reference to the stack's top item.
T pop()
Removes the top item from the stack and returns it.
void push(const T &t)
Adds element t to the top of the stack.
QString toString() const
Returns a deep copy of this string view's data as a QString.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & prepend(QChar c)
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
int length() const
Returns the length of the block in characters.
int position() const
Returns the index of the block's first character within the document.
QTextList * textList() const
If the block represents a list item, returns the list that the item belongs to; otherwise returns \nu...
int blockFormatIndex() const
Returns an index into the document's internal list of block formats for the text block's format.
static const QTextDocumentPrivate * get(const QTextDocument *document)
FragmentIterator begin() const
FragmentMap::ConstIterator FragmentIterator
\reentrant \inmodule QtGui
QList< QTextFormat > allFormats() const
Returns a list of text formats for all the formats used in the document.
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
QVariant resource(int type, const QUrl &name) const
Returns data of the specified type from the resource with the given name.
QTextFrame * rootFrame() const
Returns the document's root frame.
QTextCharFormat toCharFormat() const
Returns this format as a character format.
bool isTableCellFormat() const
QTextBlockFormat toBlockFormat() const
Returns this format as a block format.
bool isImageFormat() const
Returns true if this text format is an image format; otherwise returns false.
QTextTableFormat toTableFormat() const
Returns this format as a table format.
QTextImageFormat toImageFormat() const
Returns this format as an image format.
QTextTableCellFormat toTableCellFormat() const
QTextListFormat toListFormat() const
Returns this format as a list format.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false.
QTextFrameFormat toFrameFormat() const
Returns this format as a frame format.
int type() const
Returns the type of this format.
bool isTableFormat() const
Returns true if this text format is a TableFormat; otherwise returns false.
QTextCharFormat charFormat() const
Returns the text fragment's character format.
QBrush borderBrush() const
qreal border() const
Returns the width of the border in pixels.
BorderStyle borderStyle() const
qreal width() const
Returns the width of the rectangle occupied by the image.
qreal height() const
Returns the height of the rectangle occupied by the image.
QString name() const
Returns the name of the image.
Style
This enum describes the symbols used to decorate list items:
int indent() const
Returns the list format's indentation.
QTextListFormat format() const
Returns the list's format.
int formatIndex() const
Returns the index of the object's format in the document's internal list of formats.
void writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat format, int formatIndex) const
void writeFormats(QXmlStreamWriter &writer, const QSet< int > &formatIds) const
void writeFrame(QXmlStreamWriter &writer, const QTextFrame *frame)
void writeBlock(QXmlStreamWriter &writer, const QTextBlock &block)
QTextOdfWriter(const QTextDocument &document, QIODevice *device)
void writeTableFormat(QXmlStreamWriter &writer, QTextTableFormat format, int formatIndex) const
void tableCellStyleElement(QXmlStreamWriter &writer, const int &formatIndex, const QTextTableCellFormat &format, bool hasBorder, int tableId=0, const QTextTableFormat tableFormatTmp=QTextTableFormat()) const
void writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat format, int formatIndex) const
void writeTableCellFormat(QXmlStreamWriter &writer, QTextTableCellFormat format, int formatIndex, QList< QTextFormat > &styles) const
void writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const
void writeListFormat(QXmlStreamWriter &writer, QTextListFormat format, int formatIndex) const
void writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFormat format, int formatIndex) const
QTextCharFormat format() const
Returns the cell's character format.
int columnSpan() const
Returns the number of columns this cell spans.
int row() const
Returns the number of the row in the table that contains this cell.
int rowSpan() const
Returns the number of rows this cell spans.
int tableCellFormatIndex() const
qreal cellPadding() const
Returns the table's cell padding.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
virtual void addFile(const QString &, const QString &, const QByteArray &) override
QXmlStreamStrategy(QIODevice *device)
QZipStreamStrategy(QIODevice *device)
virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) override
the QZipWriter class provides a way to create a new zip archive.
void addFile(const QString &fileName, const QByteArray &data)
Add a file to the archive with data as the file contents.
void close()
Closes the zip file.
void setCompressionPolicy(CompressionPolicy policy)
Sets the policy for compressing newly added files to the new policy.
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
GLint GLsizei GLsizei GLenum format
GLenum GLenum GLsizei void * table
#define QStringLiteral(str)
static QString borderStyleName(QTextFrameFormat::BorderStyle style)
static QString pixelToPoint(qreal pixels)
Convert pixels to postscript point units.
static QString bulletChar(QTextListFormat::Style style)
static bool probeImageData(QIODevice *device, QImage *image, QString *mimeType, qreal *width, qreal *height)
static QStringView bullet_char(QTextListFormat::Style style)
QUrl url("example.com")
[constructor-url-reference]
application x qt windows mime
[2]
bool contains(const AT &t) const noexcept