Git commit 7538442f82e5ef212e1bc4c6d9c75016c7362c37 by Thorsten Zachmann. Committed on 07/05/2011 at 08:30. Pushed by zachmann into branch 'master'.
Make sure page is there when resize is called @Casper and Sebastian: Is that ok to do it like that. CCMAIL: calligra-devel@kde.org M +1 -0 libs/kotext/KoTextDocument.cpp M +3 -1 libs/kotext/KoTextDocument.h M +3 -0 libs/kotext/KoTextPage.h M +5 -1 libs/textlayout/KoTextDocumentLayout.cpp M +8 -2 plugins/variables/PageVariable.cpp http://commits.kde.org/calligra/7538442f82e5ef212e1bc4c6d9c75016c7362c37 diff --git a/libs/kotext/KoTextDocument.cpp b/libs/kotext/KoTextDocument.cpp index 3c3d5f4..0f319a1 100644 --- a/libs/kotext/KoTextDocument.cpp +++ b/libs/kotext/KoTextDocument.cpp @@ -54,6 +54,7 @@ const QUrl KoTextDocument::FootNotesFrameURL = QUrl("kotext://footnotesframe"); const QUrl KoTextDocument::RelativeTabsURL = QUrl("kotext://relativetabs"); const QUrl KoTextDocument::HeadingListURL = QUrl("kotext://headingList"); const QUrl KoTextDocument::SelectionsURL = QUrl("kotext://selections"); +const QUrl KoTextDocument::LayoutTextPageUrl = QUrl("kotext://layoutTextPage"); Q_DECLARE_METATYPE(QTextFrame*) diff --git a/libs/kotext/KoTextDocument.h b/libs/kotext/KoTextDocument.h index 9cc6e79..dd90616 100644 --- a/libs/kotext/KoTextDocument.h +++ b/libs/kotext/KoTextDocument.h @@ -181,7 +181,8 @@ public: FootNotesFrame, RelativeTabs, HeadingList, - Selections + Selections, + LayoutTextPage /// this is used for setting the correct page variable on the first resize and should not be used for other purposes }; static const QUrl StyleManagerURL; @@ -198,6 +199,7 @@ public: static const QUrl RelativeTabsURL; static const QUrl HeadingListURL; static const QUrl SelectionsURL; + static const QUrl LayoutTextPageUrl; private: QTextDocument *m_document; diff --git a/libs/kotext/KoTextPage.h b/libs/kotext/KoTextPage.h index b85e9d6..ff0dc50 100644 --- a/libs/kotext/KoTextPage.h +++ b/libs/kotext/KoTextPage.h @@ -24,6 +24,7 @@ #include <QString> #include <QRectF> +#include <QMetaType> /** * Interface for a single OpenDocumentText page. @@ -84,4 +85,6 @@ public: }; +Q_DECLARE_METATYPE(KoTextPage*) + #endif diff --git a/libs/textlayout/KoTextDocumentLayout.cpp b/libs/textlayout/KoTextDocumentLayout.cpp index 1528f2d..b44c4f2 100644 --- a/libs/textlayout/KoTextDocumentLayout.cpp +++ b/libs/textlayout/KoTextDocumentLayout.cpp @@ -428,7 +428,11 @@ void KoTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int positi QTextCharFormat cf = format.toCharFormat(); KoInlineObject *obj = d->inlineTextObjectManager->inlineTextObject(cf); if (obj) { - obj->resize(document(), item, position, cf, paintDevice()); + QTextDocument *doc = document(); + QVariant v; + v.setValue(d->anchoringRootArea->page()); + doc->addResource(KoTextDocument::LayoutTextPage, QUrl("kotext://layoutTextPage"), v); + obj->resize(doc, item, position, cf, paintDevice()); registerInlineObject(item); } } diff --git a/plugins/variables/PageVariable.cpp b/plugins/variables/PageVariable.cpp index 3e9646d..4ffdb1e 100644 --- a/plugins/variables/PageVariable.cpp +++ b/plugins/variables/PageVariable.cpp @@ -84,13 +84,19 @@ void PageVariable::resize(const QTextDocument *document, QTextInlineObject objec { KoTextPage *page = 0; if (m_type != PageCount) { +#if 0 // the code is left here to do some testing KoTextDocumentLayout *lay = qobject_cast<KoTextDocumentLayout*>(document->documentLayout()); + KoTextLayoutRootArea *rootArea = 0; + KoTextPage *page2 = 0; if (lay) { - KoTextLayoutRootArea *rootArea = lay->rootAreaForPosition(posInDocument); + rootArea = lay->rootAreaForPosition(posInDocument); if (rootArea) { - page = rootArea->page(); + page2 = rootArea->page(); } } +#endif + page = document->resource(KoTextDocument::LayoutTextPage, KoTextDocument::LayoutTextPageUrl).value<KoTextPage*>(); + //qDebug() << __PRETTY_FUNCTION__ << lay << rootArea << page << page2; } int pagenumber = 0; _______________________________________________ calligra-devel mailing list calligra-devel@kde.org https://mail.kde.org/mailman/listinfo/calligra-devel