12 #include <QAbstractTextDocumentLayout>
19 , m_builder(m_textDocument.contentDocumentData(), QTextCursor(&m_textDocument.contentDocument()), report)
30 painter.translate(0, -pageNumber * m_textDocument.contentDocument().pageSize().height());
36 QAbstractTextDocumentLayout::PaintContext ctx;
37 ctx.clip = painter.clipRegion().boundingRect();
38 ctx.palette.setColor(QPalette::Text, Qt::black);
39 m_textDocument.contentDocument().documentLayout()->draw(&painter, ctx);
47 return m_textDocument.contentDocument().pageCount();
53 m_textDocument.setPageSize(size);
62 return m_textDocument.asHtml();
67 m_textDocument.layoutWithTextWidth(docWidth);
68 qreal docHeight = m_textDocument.contentDocument().size().height();
72 QTextCursor c(&m_textDocument.contentDocument());
74 QTextBlock block = m_textDocument.contentDocument().firstBlock();
77 QTextBlockFormat format = block.blockFormat();
78 if (format.pageBreakPolicy() != QTextBlockFormat::PageBreak_Auto)
79 format.setPageBreakPolicy(QTextBlockFormat::PageBreak_Auto);
80 c.setPosition(block.position());
81 c.setBlockFormat(format);
83 }
while (block.isValid());
86 setPageContentSize(QSizeF(docWidth, docHeight));
87 qDebug() <<
"m_textDocument.layoutDocument().setPageSize" << docWidth <<
"x" << docHeight << numberOfPages() <<
"pages";
88 qreal newDocHeight = m_textDocument.contentDocument().size().height();
89 if (newDocHeight > docHeight) {
93 qDebug() <<
"newDocHeight=" << newDocHeight <<
"expected" << docHeight;
94 setPageContentSize(QSizeF(docWidth, newDocHeight));
95 newDocHeight = m_textDocument.contentDocument().size().height();
96 qDebug() <<
"final newDocHeight=" << newDocHeight << numberOfPages() <<
"pages";
99 Q_ASSERT(numberOfPages() == 1);
105 m_textDocument.contentDocumentData().saveResourcesToFiles();
110 m_textDocument.contentDocument().setDefaultFont(font);
111 m_builder.setDefaultFont(font);
116 return m_textDocument.defaultFont();
121 m_textDocument.updateTextValue(
id, newValue);
128 return m_textDocument.contentDocument().idealWidth() + 1;
133 Q_UNUSED(numPagesHorizontally);
134 Q_UNUSED(numPagesVertically);
135 qWarning(
"scaleTo is only implemented in Spreadsheet mode currently");
142 qWarning(
"fixed row height is only implemented in Spreadsheet mode");
159 qWarning(
"font scaling is only implemented in Spreadsheet mode currently");
169 const QPointF posInPage = pos + QPointF(0, pageNumber * m_textDocument.contentDocument().pageSize().height());
170 return m_textDocument.contentDocument().documentLayout()->anchorAt(posInPage);
TextDocReportLayout(KDReports::Report *report)
int maximumNumberOfPagesForHorizontalScaling() const override
Reimplemented for internal purposes. .
void ensureLayouted() override
Reimplemented for internal purposes. .
void finishHtmlExport() override
Reimplemented for internal purposes. .
void setFixedRowHeight(qreal height) override
Reimplemented for internal purposes. .
void setPageContentSize(QSizeF size) override
Reimplemented for internal purposes. .
bool scaleTo(int numPagesHorizontally, int numPagesVertically) override
Reimplemented for internal purposes. .
qreal userRequestedFontScalingFactor() const override
Reimplemented for internal purposes. .
QFont defaultFont() const override
Reimplemented for internal purposes. .
void setLayoutDirty() override
Reimplemented for internal purposes. .
void setDefaultFont(const QFont &font) override
Reimplemented for internal purposes. .
qreal layoutAsOnePage(qreal width) override
Reimplemented for internal purposes. .
qreal idealWidth() override
Reimplemented for internal purposes. .
int numberOfPages() override
Reimplemented for internal purposes. .
QString anchorAt(int pageNumber, QPoint pos) override
Reimplemented for internal purposes. .
void setUserRequestedFontScalingFactor(qreal factor) override
Reimplemented for internal purposes. .
void updateTextValue(const QString &id, const QString &newValue) override
Reimplemented for internal purposes. .
void paintPageContent(int pageNumber, QPainter &painter) override
Reimplemented for internal purposes. .
int maximumNumberOfPagesForVerticalScaling() const override
Reimplemented for internal purposes. .
QString toHtml() const override
Reimplemented for internal purposes. .