[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra/text-layoutrestructure-boemann=5D_words/pa?=
From: Sebastian Sauer <sebastian.sauer () kdab ! com>
Date: 2011-04-09 16:16:04
Message-ID: 20110409161604.62E3CA609B () git ! kde ! org
[Download RAW message or body]
Git commit b4ec9b35b09b7e741f91a9372117efe9e63d793b by Sebastian Sauer.
Committed on 09/04/2011 at 18:15.
Pushed by sebsauer into branch 'text-layoutrestructure-boemann'.
Fix crash caused by KWDocument::endOfLoading bypassing the KWPageInsertCommand
M +13 -7 words/part/KWDocument.cpp
M +3 -24 words/part/KWRootAreaProvider.cpp
M +23 -0 words/part/commands/KWPageInsertCommand.cpp
M +2 -0 words/part/frames/KWFrameLayout.cpp
http://commits.kde.org/calligra/b4ec9b35b09b7e741f91a9372117efe9e63d793b
diff --git a/words/part/KWDocument.cpp b/words/part/KWDocument.cpp
index ad79ef4..9b79df7 100644
--- a/words/part/KWDocument.cpp
+++ b/words/part/KWDocument.cpp
@@ -655,6 +655,7 @@ void KWDocument::endOfLoading() // called by both oasis and \
oldxml foreach (KWFrame *frame, fs->frames())
maxBottom = qMax(maxBottom, frame->shape()->boundingRect().bottom());
}
+#if 0
// The Document we loaded could have specified
// 1) a number of pages
// 2) a number of frames
@@ -668,21 +669,26 @@ void KWDocument::endOfLoading() // called by both oasis and \
oldxml foreach (KWPage page, m_pageManager.pages())
m_magicCurtain->revealFramesForPage(page.pageNumber(), \
page.offsetInDocument()); }
-
+ PageProcessingQueue *ppq = pageQueue();
+#endif
// Here we look at point 'b'. We add pages so at least all frames have a page.
// btw. the observent reader might notice that cases b and c are not mutually \
exclusive ;)
- PageProcessingQueue *ppq = pageQueue();
while (docHeight <= maxBottom) {
kDebug(32001) << "KWDocument::endOfLoading appends a page";
- if (m_pageManager.pageCount() == 0) // apply the firstPageMasterName only on \
the first page
- lastpage = \
m_pageManager.appendPage(m_pageManager.pageStyle(firstPageMasterName));
- else // normally this shouldn't happen cause that loop is only run once...
- lastpage = m_pageManager.appendPage();
- ppq->addPage(lastpage);
+ if (m_pageManager.pageCount() == 0) { // apply the firstPageMasterName only \
on the first page + //lastpage = \
m_pageManager.appendPage(m_pageManager.pageStyle(firstPageMasterName)); + \
lastpage = appendPage(firstPageMasterName); + } else { // normally this \
shouldn't happen cause that loop is only run once... + //lastpage = \
m_pageManager.appendPage(); + lastpage = appendPage();
+ }
docHeight += lastpage.height();
+#if 0
+ ppq->addPage(lastpage);
if (m_magicCurtain) {
m_magicCurtain->revealFramesForPage(lastpage.pageNumber(), \
lastpage.offsetInDocument()); }
+#endif
}
if (updater) updater->setProgress(50);
diff --git a/words/part/KWRootAreaProvider.cpp b/words/part/KWRootAreaProvider.cpp
index 59947dc..7ae07fd 100755
--- a/words/part/KWRootAreaProvider.cpp
+++ b/words/part/KWRootAreaProvider.cpp
@@ -62,36 +62,15 @@ KoTextLayoutRootArea \
*KWRootAreaProvider::provide(KoTextDocumentLayout *document Q_ASSERT(shape);
#endif
+ // Create missing KWPage's and KWTextFrame's
int framesCountBefore = m_textFrameSet->frameCount();
QList<int> pagesCreated;
for(int i = pageManager->pageCount(); i <= rootAreas.count(); ++i) {
KWDocument *kwdoc = \
const_cast<KWDocument*>(m_textFrameSet->kwordDocument()); Q_ASSERT(kwdoc);
- // Create a new KWPage
KWPage page = kwdoc->appendPage();
Q_ASSERT(page.isValid());
- Q_ASSERT(page.pageNumber() >= 1 && page.pageNumber() <= \
pageManager->pageCount());
-
- // Set the y-offset of the new page.
- qreal prevOffset = 0.0;
- qreal prevHeight = 0.0;
- KWPage prevPage = page.previous();
- if (prevPage.isValid()) {
- prevOffset = prevPage.offsetInDocument();
- prevHeight = prevPage.height();
- } else {
- prevHeight = pageManager->defaultPageStyle().pageLayout().height;
- }
-
- page.setOffsetInDocument(prevOffset + prevHeight);
- //page.setHeight(prevHeight);
-
- // Create the KWTextFrame's for the new KWPage
- KWFrameLayout *frlay = kwdoc->frameLayout();
- const int frameCountBefore = m_textFrameSet->frameCount();
- frlay->createNewFramesForPage(page.pageNumber());
- Q_ASSERT_X(frameCountBefore < m_textFrameSet->frameCount(), __FUNCTION__, \
QString("Failed to create new frames for \
page=%1").arg(page.pageNumber()).toLocal8Bit());
pagesCreated << page.pageNumber();
}
@@ -99,8 +78,8 @@ KoTextLayoutRootArea \
*KWRootAreaProvider::provide(KoTextDocumentLayout *document kDebug() << \
"rootAreasCount=" << rootAreas.count() << "frameCount=" << \
m_textFrameSet->frameCount() << "frameCountBefore=" << framesCountBefore << \
"pageCount=" << pageManager->pageCount() << "pagesCreated=" << pagesCreated;
//FIXME don't use m_textFrameSet->frames() cause it can contain other frames too
- Q_ASSERT(rootAreas.count() < m_textFrameSet->frames().count());
- KWFrame *frame = m_textFrameSet->frames()[ rootAreas.count() ];
+ Q_ASSERT(m_textFrameSet->frameCount() >= 1);
+ KWFrame *frame = m_textFrameSet->frames()[ m_textFrameSet->frameCount() - 1 ];
KoShape *shape = frame->shape();
Q_ASSERT(shape);
diff --git a/words/part/commands/KWPageInsertCommand.cpp \
b/words/part/commands/KWPageInsertCommand.cpp index 5f5672f..168d798 100644
--- a/words/part/commands/KWPageInsertCommand.cpp
+++ b/words/part/commands/KWPageInsertCommand.cpp
@@ -85,9 +85,27 @@ void KWPageInsertCommand::redo()
if (! d->pageCreated) { // create the page the first time.
d->pageCreated = true;
+
//KWPage prevPage = m_document->pageManager().page(m_afterPageNum);
KWPageStyle pageStyle = \
d->document->pageManager()->pageStyle(d->masterPageName);
d->page = d->document->pageManager()->insertPage(d->pageNumber, pageStyle);
+ Q_ASSERT(d->page.isValid());
+ Q_ASSERT(d->page.pageNumber() >= 1 && d->page.pageNumber() <= \
d->document->pageManager()->pageCount()); +
+ // Set the y-offset of the new page.
+ KWPage prevPage = d->page.previous();
+ if (prevPage.isValid()) {
+ d->page.setOffsetInDocument(prevPage.offsetInDocument() + \
prevPage.height()); + } else {
+ d->page.setOffsetInDocument(0.0);
+ //d->page.setHeight(pageManager->defaultPageStyle().pageLayout().height);
+ }
+
+ // Create the KWTextFrame's for the new KWPage
+ KWFrameLayout *framelayout = d->document->frameLayout();
+ framelayout->createNewFramesForPage(d->page.pageNumber());
+
+#if 0
// move shapes after this page down.
QList<KoShape *> shapes;
QList<QPointF> previousPositions;
@@ -107,6 +125,11 @@ void KWPageInsertCommand::redo()
if (shapes.count() > 0)
d->shapeMoveCommand = new KoShapeMoveCommand(shapes, previousPositions, \
newPositions); +#else
+ #ifdef __GNUC__
+ #warning FIXME: port to textlayout-rework
+ #endif
+#endif
} else { // we inserted it before, lets do so again.
d->pageData.pageNumber = d->pageNumber;
d->document->pageManager()->priv()->insertPage(d->pageData);
diff --git a/words/part/frames/KWFrameLayout.cpp \
b/words/part/frames/KWFrameLayout.cpp index bc8913c..257e2ca 100644
--- a/words/part/frames/KWFrameLayout.cpp
+++ b/words/part/frames/KWFrameLayout.cpp
@@ -199,6 +199,7 @@ void KWFrameLayout::createNewFramesForPage(int pageNumber)
KWTextFrameSet *fs = getOrCreate(KWord::MainTextFrameSet, page);
QRectF rect(QPointF(page.width(), page.offsetInDocument()),
QSizeF(page.width() / 2, page.height()));
+#if 0
foreach (KWFrame *frame, framesInPage(rect)) {
if (frame->frameSet() == fs) {
columns--;
@@ -208,6 +209,7 @@ void KWFrameLayout::createNewFramesForPage(int pageNumber)
}
}
}
+#endif
while (columns > 0) {
factory.create(page, fs);
columns--;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic