[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra=5D_words/part=3A_Initial_try_to_fix_the_pr?=
From: Sebastian Sauer <sebastian.sauer () kdab ! com>
Date: 2011-05-17 12:49:59
Message-ID: 20110517124959.5965AA60A4 () git ! kde ! org
[Download RAW message or body]
Git commit e3e0372fc6b81282a5139ad8f3cb7f53b9532f36 by Sebastian Sauer.
Committed on 17/05/2011 at 14:50.
Pushed by sebsauer into branch 'master'.
Initial try to fix the problem with copy-headers being to height.
M +45 -0 words/part/KWRootAreaProvider.cpp
M +23 -0 words/part/frames/KWFrame.cpp
M +10 -0 words/part/frames/KWFrame.h
M +19 -1 words/part/frames/KWFrameSet.cpp
http://commits.kde.org/calligra/e3e0372fc6b81282a5139ad8f3cb7f53b9532f36
diff --git a/words/part/KWRootAreaProvider.cpp b/words/part/KWRootAreaProvider.cpp
index 57cf682..81559cc 100755
--- a/words/part/KWRootAreaProvider.cpp
+++ b/words/part/KWRootAreaProvider.cpp
@@ -333,6 +333,50 @@ void KWRootAreaProvider::doPostLayout(KoTextLayoutRootArea *rootArea, bool isNew
rootArea->setBottom(rootArea->top() + newSize.height());
//rootArea->associatedShape()->setAbsolutePosition(centerpos);
+//TODO we would need to do something like the following to relayout all affected
+//pages again but that is so terrible slow that it's unusable. We need to find
+//a better solution for that.
+#if 0
+ // the list of pages that need
+ QList<int> relayoutPages;
+
+ // transfer the new size to the copy-shapes
+ if (KWFrame *frame = dynamic_cast<KWFrame*>(rootArea->associatedShape()->applicationData())) {
+ foreach(KWFrame* f, frame->copies()) {
+ if (f->shape()) {
+ f->shape()->setSize(newSize);
+ KWPage p = pageManager->page(f->shape());
+ if (p.isValid() && !relayoutPages.contains(p.pageNumber()))
+ relayoutPages.append(p.pageNumber());
+ }
+ }
+ }
+
+ if (isHeaderFooter) {
+ // adjust the minimum frame height for headers and footer
+ Q_ASSERT(m_textFrameSet->frameCount() > 0);
+ KWFrame *frame = static_cast<KWFrame*>(m_textFrameSet->frames().first());
+ if (frame->minimumFrameHeight() != newSize.height()) {
+ frame->setMinimumFrameHeight(newSize.height());
+ if (!relayoutPages.contains(page.pageNumber()))
+ relayoutPages.append(page.pageNumber());
+ }
+ }
+
+ qSort(relayoutPages);
+ foreach(int pageNumber, relayoutPages)
+ m_textFrameSet->kwordDocument()->frameLayout()->layoutFramesOnPage(pageNumber);
+#else
+
+ // transfer the new size to the copy-shapes
+ if (KWFrame *frame = dynamic_cast<KWFrame*>(rootArea->associatedShape()->applicationData())) {
+ foreach(KWFrame* f, frame->copies()) {
+ if (f->shape()) {
+ f->shape()->setSize(newSize);
+ }
+ }
+ }
+
if (isHeaderFooter) {
// adjust the minimum frame height for headers and footer
Q_ASSERT(m_textFrameSet->frameCount() > 0);
@@ -344,6 +388,7 @@ void KWRootAreaProvider::doPostLayout(KoTextLayoutRootArea *rootArea, bool isNew
m_textFrameSet->kwordDocument()->frameLayout()->layoutFramesOnPage(page.pageNumber());
}
}
+#endif
}
#if 0
diff --git a/words/part/frames/KWFrame.cpp b/words/part/frames/KWFrame.cpp
index 8339637..27dc8cf 100644
--- a/words/part/frames/KWFrame.cpp
+++ b/words/part/frames/KWFrame.cpp
@@ -96,7 +96,14 @@ qreal KWFrame::minimumFrameHeight() const
void KWFrame::setMinimumFrameHeight(qreal minimumFrameHeight)
{
+ if (m_minimumFrameHeight == minimumFrameHeight)
+ return;
m_minimumFrameHeight = minimumFrameHeight;
+
+ // transfer the minimumFrameHeight to the copy-shapes
+ foreach(KWFrame* copyFrame, m_copyShapes) {
+ copyFrame->setMinimumFrameHeight(m_minimumFrameHeight);
+ }
}
void KWFrame::cleanupShape(KoShape* shape)
@@ -136,6 +143,22 @@ void KWFrame::setFrameSet(KWFrameSet *fs)
fs->addFrame(this);
}
+QList<KWFrame*> KWFrame::copies() const
+{
+ return m_copyShapes;
+}
+
+void KWFrame::addCopy(KWFrame* frame)
+{
+ if (!m_copyShapes.contains(frame))
+ m_copyShapes.append(frame);
+}
+
+void KWFrame::removeCopy(KWFrame* frame)
+{
+ m_copyShapes.removeAll(frame);
+}
+
void KWFrame::copySettings(const KWFrame *frame)
{
setFrameBehavior(frame->frameBehavior());
diff --git a/words/part/frames/KWFrame.h b/words/part/frames/KWFrame.h
index cc91573..a052541 100644
--- a/words/part/frames/KWFrame.h
+++ b/words/part/frames/KWFrame.h
@@ -129,6 +129,15 @@ public:
}
/**
+ * Returns the list of copy-shapes, see @a KWCopyShape , that
+ * are copies of this KWFrame.
+ */
+ QList<KWFrame*> copies() const;
+
+ void addCopy(KWFrame* frame);
+ void removeCopy(KWFrame* frame);
+
+ /**
* States if this frame is a copy of the previous one.
* If this frame is a copy, then this frame is drawn with the same content as the
* previous frame in this frameset.
@@ -160,6 +169,7 @@ private:
KWFrameSet *m_frameSet;
qreal m_minimumFrameHeight;
+ QList<KWFrame*> m_copyShapes;
};
#endif
diff --git a/words/part/frames/KWFrameSet.cpp b/words/part/frames/KWFrameSet.cpp
index 742ad3e..4af6903 100644
--- a/words/part/frames/KWFrameSet.cpp
+++ b/words/part/frames/KWFrameSet.cpp
@@ -56,13 +56,30 @@ void KWFrameSet::addFrame(KWFrame *frame)
m_frames.append(frame); // this one first, so we don't enter the addFrame twice.
frame->setFrameSet(this);
setupFrame(frame);
+ if (frame->isCopy()) {
+ KWCopyShape* copyShape = dynamic_cast<KWCopyShape*>(frame->shape());
+ if (copyShape && copyShape->original()) {
+ KWFrame *originalFrame = dynamic_cast<KWFrame*>(copyShape->original()->applicationData());
+ if (originalFrame) {
+ originalFrame->addCopy(frame);
+ }
+ }
+ }
emit frameAdded(frame);
}
void KWFrameSet::removeFrame(KWFrame *frame, KoShape *shape)
{
Q_ASSERT(frame);
- if (!frame->isCopy()) {
+ if (frame->isCopy()) {
+ KWCopyShape* copyShape = dynamic_cast<KWCopyShape*>(frame->shape());
+ if (copyShape && copyShape->original()) {
+ KWFrame *originalFrame = dynamic_cast<KWFrame*>(copyShape->original()->applicationData());
+ if (originalFrame) {
+ originalFrame->removeCopy(frame);
+ }
+ }
+ } else {
#if 0
// Loop over all frames to see if there is a copy frame that references the removed
// frame; if it does, then mark the copy as obsolete
@@ -74,6 +91,7 @@ void KWFrameSet::removeFrame(KWFrame *frame, KoShape *shape)
}
}
#else
+//TODO use the copyFrame-list the KWFrame's remembers now
// Loop over all frames to see if there is a copy frame that references the removed
// frame; if it does, then delete the copy too.
for(int i = frames().count() - 1; i >= 0; --i) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic