[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kword/part
From: Thomas Zander <zander () kde ! org>
Date: 2010-09-16 19:47:55
Message-ID: 20100916194755.5CB84AC871 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1176142 by zander:
Make positioning of page background work
M +22 -5 frames/KWFrameLayout.cpp
M +11 -1 tests/TestFrameLayout.cpp
--- trunk/koffice/kword/part/frames/KWFrameLayout.cpp #1176141:1176142
@@ -293,10 +293,23 @@
main[0] = 0;
QRectF pageRect(left, page.offsetInDocument(), width, page.height());
foreach (KWFrame *frame, framesInPage(pageRect)) {
- KWTextFrameSet *textFrameSet = dynamic_cast<KWTextFrameSet*>(frame->frameSet());
- if (textFrameSet == 0 || textFrameSet->textFrameSetType() == KWord::OtherTextFrameSet)
+ KWTextFrameSet *textFrameSet = 0;
+ switch (frame->frameSet()->type()) {
+ case KWord::BackgroundFrameSet:
+ pageBackground = frame;
+ continue;
+ case KWord::TextFrameSet:
+ textFrameSet = static_cast<KWTextFrameSet*>(frame->frameSet());
+ if (textFrameSet->textFrameSetType() == KWord::OtherTextFrameSet) {
minZIndex = qMin(minZIndex, frame->shape()->zIndex());
- if (textFrameSet == 0) continue;
+ continue;
+ }
+ break;
+ case KWord::OtherFrameSet:
+ minZIndex = qMin(minZIndex, frame->shape()->zIndex());
+ continue;
+ }
+ Q_ASSERT(textFrameSet);
switch (textFrameSet->textFrameSetType()) {
case KWord::OddPagesHeaderTextFrameSet:
case KWord::EvenPagesHeaderTextFrameSet: {
@@ -346,9 +359,13 @@
footer->shape()->setZIndex(--minZIndex);
if (header)
header->shape()->setZIndex(--minZIndex);
- if (pageBackground)
- pageBackground->shape()->setZIndex(--minZIndex);
+ if (pageBackground) {
+ KoShape *bs = pageBackground->shape();
+ bs->setZIndex(--minZIndex);
+ bs->setSize(pageRect.size());
+ bs->setPosition(pageRect.topLeft());
}
+ }
// spread space across items.
qreal heightLeft = page.height();
--- trunk/koffice/kword/part/tests/TestFrameLayout.cpp #1176141:1176142
@@ -562,9 +562,19 @@
bfl.createNewFramesForPage(4);
QCOMPARE(bfl.m_backgroundFrameSet->frameCount(), 2);
- foreach (KWFrame *frame, bfl.m_backgroundFrameSet->frames()) {
+ KWFrameSet *bfs = bfl.m_backgroundFrameSet;
+ foreach (KWFrame *frame, bfs->frames()) {
QCOMPARE(frame->shape()->background(), page1.pageStyle().background());
}
+
+ // run layout to position and size them.
+ for (int i = 1; i <= 4; ++i)
+ bfl.layoutFramesOnPage(i);
+
+ QCOMPARE(bfs->frames()[0]->shape()->size(), QSizeF(page1.width(), page1.height()));
+ QCOMPARE(bfs->frames()[0]->shape()->position(), QPointF());
+ QCOMPARE(bfs->frames()[1]->shape()->size(), QSizeF(page2.width(), page2.height()));
+ QCOMPARE(bfs->frames()[1]->shape()->position(), QPointF(0, page2.offsetInDocument()));
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic