18 #include <QAbstractTextDocumentLayout>
25 , m_builder(m_textDocument.contentDocumentData(), QTextCursor(&m_textDocument.contentDocument()), report)
34 painter.translate(0, -pageNumber * m_textDocument.contentDocument().pageSize().height());
40 QAbstractTextDocumentLayout::PaintContext ctx;
41 ctx.clip = painter.clipRegion().boundingRect();
42 ctx.palette.setColor(QPalette::Text, Qt::black);
43 m_textDocument.contentDocument().documentLayout()->draw(&painter, ctx);
51 return m_textDocument.contentDocument().pageCount();
57 m_textDocument.setPageSize(size);
64 return m_textDocument.asHtml();
69 m_textDocument.layoutWithTextWidth(docWidth);
70 qreal docHeight = m_textDocument.contentDocument().size().height();
74 QTextCursor c(&m_textDocument.contentDocument());
76 QTextBlock block = m_textDocument.contentDocument().firstBlock();
79 QTextBlockFormat format = block.blockFormat();
80 if (format.pageBreakPolicy() != QTextBlockFormat::PageBreak_Auto)
81 format.setPageBreakPolicy(QTextBlockFormat::PageBreak_Auto);
82 c.setPosition(block.position());
83 c.setBlockFormat(format);
85 }
while (block.isValid());
88 setPageContentSize(QSizeF(docWidth, docHeight));
89 qDebug() <<
"m_textDocument.layoutDocument().setPageSize" << docWidth <<
"x" << docHeight << numberOfPages() <<
"pages";
90 qreal newDocHeight = m_textDocument.contentDocument().size().height();
91 if (newDocHeight > docHeight) {
95 qDebug() <<
"newDocHeight=" << newDocHeight <<
"expected" << docHeight;
96 setPageContentSize(QSizeF(docWidth, newDocHeight));
97 newDocHeight = m_textDocument.contentDocument().size().height();
98 qDebug() <<
"final newDocHeight=" << newDocHeight << numberOfPages() <<
"pages";
102 Q_ASSERT(numberOfPages() == 1);
108 m_textDocument.contentDocumentData().saveResourcesToFiles();
113 m_textDocument.contentDocument().setDefaultFont(font);
114 m_builder.setDefaultFont(font);
119 return m_textDocument.defaultFont();
124 m_textDocument.updateTextValue(
id, newValue);
131 return m_textDocument.contentDocument().idealWidth() + 1;
136 Q_UNUSED(numPagesHorizontally);
137 Q_UNUSED(numPagesVertically);
138 qWarning(
"scaleTo is only implemented in Spreadsheet mode currently");
145 qWarning(
"fixed row height is only implemented in Spreadsheet mode");
162 qWarning(
"font scaling is only implemented in Spreadsheet mode currently");
172 const QPointF posInPage = pos + QPointF(0, pageNumber * m_textDocument.contentDocument().pageSize().height());
173 return m_textDocument.contentDocument().documentLayout()->anchorAt(posInPage);