[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra/textlayout-anchors-boemann=5D_/=3A_Rework_?=
From: Casper Boemann <cbo () boemann ! dk>
Date: 2011-04-30 21:06:22
Message-ID: 20110430210622.D3F48A60B0 () git ! kde ! org
[Download RAW message or body]
Git commit 562787c4c8d3b7fcf5e9c11e30e5df7e476069bd by Casper Boemann.
Committed on 30/04/2011 at 20:55.
Pushed by boemann into branch 'textlayout-anchors-boemann'.
Rework obstructions a bit in preparation for anchors and fix so that it actually \
works again.
M +13 -17 libs/textlayout/KoTextDocumentLayout.cpp
M +2 -2 libs/textlayout/KoTextDocumentLayout.h
M +1 -1 libs/textlayout/KoTextLayoutArea.cpp
M +2 -3 libs/textlayout/KoTextLayoutRootAreaProvider.h
M +1 -1 libs/textlayout/tests/MockRootAreaProvider.cpp
M +1 -1 libs/textlayout/tests/MockRootAreaProvider.h
M +5 -7 plugins/textshape/SimpleRootAreaProvider.cpp
M +1 -1 plugins/textshape/SimpleRootAreaProvider.h
M +3 -16 words/part/KWRootAreaProvider.cpp
M +1 -1 words/part/KWRootAreaProvider.h
http://commits.kde.org/calligra/562787c4c8d3b7fcf5e9c11e30e5df7e476069bd
diff --git a/libs/textlayout/KoTextDocumentLayout.cpp \
b/libs/textlayout/KoTextDocumentLayout.cpp index d8425fb..9936c20 100644
--- a/libs/textlayout/KoTextDocumentLayout.cpp
+++ b/libs/textlayout/KoTextDocumentLayout.cpp
@@ -88,7 +88,8 @@ public:
QList<KoTextAnchor *> textAnchors; // list of all inserted inline objects
int textAnchorIndex; // index of last not positioned inline object inside \
textAnchors
- QHash<KoShape*,KoTextLayoutObstruction*> obstructions; // all obstructions \
created in positionInlineObjects because KoTextAnchor from m_textAnchors is in text + \
QHash<KoShape*,KoTextLayoutObstruction*> anchoredObstructions; // all obstructions \
created in positionInlineObjects because KoTextAnchor from m_textAnchors is in text + \
QList<KoTextLayoutObstruction*> freeObstructions; // obstructions affecting the \
current rootArea, and not anchored
qreal defaultTabSizing;
qreal y;
@@ -350,9 +351,9 @@ void KoTextDocumentLayout::resetAnchor(int resetPosition)
(*iter)->anchorStrategy()->reset();
// delete obstruction
- if (d->obstructions.contains((*iter)->shape())) {
- KoTextLayoutObstruction *obstruction = \
d->obstructions.value((*iter)->shape());
- d->obstructions.remove((*iter)->shape());
+ if (d->anchoredObstructions.contains((*iter)->shape())) {
+ KoTextLayoutObstruction *obstruction = \
d->anchoredObstructions.value((*iter)->shape()); + \
d->anchoredObstructions.remove((*iter)->shape()); delete obstruction;
}
(*iter)->setAnchorStrategy(0);
@@ -436,6 +437,8 @@ void KoTextDocumentLayout::layout()
if (shouldLayout) {
QSizeF size = d->provider->suggestSize(rootArea);
+ d->freeObstructions = d->provider->relevantObstructions(rootArea);
+
rootArea->setReferenceRect(0, size.width(), d->y, d->y + size.height());
// Layout all that can fit into that root area
@@ -478,6 +481,7 @@ void KoTextDocumentLayout::layout()
if (rootArea) {
d->rootAreaList.append(rootArea);
QSizeF size = d->provider->suggestSize(rootArea);
+ d->freeObstructions = d->provider->relevantObstructions(rootArea);
rootArea->setReferenceRect(0, size.width(), d->y, d->y + size.height());
// Layout all that can fit into that root area
rootArea->layout(d->layoutPosition);
@@ -557,8 +561,8 @@ void KoTextDocumentLayout::registerInlineObject(const \
QTextInlineObject &inlineO
void KoTextDocumentLayout::unregisterAllObstructions()
{
- qDeleteAll(d->obstructions);
- d->obstructions.clear();
+ qDeleteAll(d->anchoredObstructions);
+ d->anchoredObstructions.clear();
}
KoInlineObjectExtent KoTextDocumentLayout::inlineObjectExtent(const QTextFragment \
&fragment) @@ -568,19 +572,11 @@ KoInlineObjectExtent \
KoTextDocumentLayout::inlineObjectExtent(const QTextFragmen return \
KoInlineObjectExtent(); }
-QList<KoTextLayoutObstruction *> KoTextDocumentLayout::relevantObstructions(const \
QRectF &rect) +QList<KoTextLayoutObstruction *> \
KoTextDocumentLayout::currentObstructions() {
- QList<KoTextLayoutObstruction*> currentObstructions;
+// QList<KoTextLayoutObstruction*> currentObstructions;
- currentObstructions = d->provider->relevantObstructions(rect, \
currentObstructions);
- /*
- // add current page children obstructions to currentObstructions
- foreach(KoShape *childShape, shapes()) {
- if (d->obstructions.contains(childShape)) {
- currentObstructions.append(d->obstructions.value(childShape));
- }
- }*/
- return currentObstructions;
+ return d->freeObstructions;
}
QList<KoTextLayoutRootArea *> KoTextDocumentLayout::rootAreas() const
diff --git a/libs/textlayout/KoTextDocumentLayout.h \
b/libs/textlayout/KoTextDocumentLayout.h index 146dd10..bbbcf2b 100644
--- a/libs/textlayout/KoTextDocumentLayout.h
+++ b/libs/textlayout/KoTextDocumentLayout.h
@@ -156,8 +156,8 @@ public:
/// reimplemented from QAbstractTextDocumentLayout
virtual void documentChanged(int position, int charsRemoved, int charsAdded);
- /// Return a list of obstructions intersecting rect
- QList<KoTextLayoutObstruction *> relevantObstructions(const QRectF &rect);
+ /// Return a list of obstructions intersecting current root area (during layout)
+ QList<KoTextLayoutObstruction *> currentObstructions();
QList<KoTextLayoutRootArea *> rootAreas() const;
QList<KoShape*> shapes() const;
diff --git a/libs/textlayout/KoTextLayoutArea.cpp \
b/libs/textlayout/KoTextLayoutArea.cpp index fb749c2..b49fac7 100644
--- a/libs/textlayout/KoTextLayoutArea.cpp
+++ b/libs/textlayout/KoTextLayoutArea.cpp
@@ -727,7 +727,7 @@ bool KoTextLayoutArea::layoutBlock(FrameIterator *cursor)
// So now is the time to create the lines of this paragraph
RunAroundHelper runAroundHelper;
- runAroundHelper.setObstructions(documentLayout()->relevantObstructions(QRect(left(),top(),right() \
- left(), m_maximalAllowedBottom - top()))); + \
runAroundHelper.setObstructions(documentLayout()->currentObstructions());
qreal maxLineHeight = 0;
qreal y_justBelowDropCaps = 0;
diff --git a/libs/textlayout/KoTextLayoutRootAreaProvider.h \
b/libs/textlayout/KoTextLayoutRootAreaProvider.h index 863d202..5c14e90 100644
--- a/libs/textlayout/KoTextLayoutRootAreaProvider.h
+++ b/libs/textlayout/KoTextLayoutRootAreaProvider.h
@@ -60,9 +60,8 @@ public:
/// Returns a suggested a size for the root area
virtual QSizeF suggestSize(KoTextLayoutRootArea *rootArea) = 0;
- /// Return a list of obstructions intersecting rect
- /// Obstructions present in the excludingThese list will not be returned
- virtual QList<KoTextLayoutObstruction *> relevantObstructions(const QRectF \
&rect, const QList<KoTextLayoutObstruction *> &excludingThese) = 0; + /// Return a \
list of obstructions intersecting root area + virtual \
QList<KoTextLayoutObstruction *> relevantObstructions(KoTextLayoutRootArea *rootArea) \
= 0;
};
diff --git a/libs/textlayout/tests/MockRootAreaProvider.cpp \
b/libs/textlayout/tests/MockRootAreaProvider.cpp index 7f6cd73..030c85c 100644
--- a/libs/textlayout/tests/MockRootAreaProvider.cpp
+++ b/libs/textlayout/tests/MockRootAreaProvider.cpp
@@ -44,7 +44,7 @@ QSizeF MockRootAreaProvider::suggestSize(KoTextLayoutRootArea \
*rootArea) return QSizeF(200,1000);
}
-QList<KoTextLayoutObstruction *> MockRootAreaProvider::relevantObstructions(const \
QRectF &rect, const QList<KoTextLayoutObstruction *> &excludingThese) \
+QList<KoTextLayoutObstruction *> \
MockRootAreaProvider::relevantObstructions(KoTextLayoutRootArea *rootArea) {
QList<KoTextLayoutObstruction*> obstructions;
diff --git a/libs/textlayout/tests/MockRootAreaProvider.h \
b/libs/textlayout/tests/MockRootAreaProvider.h index 51df516..0a2dac6 100644
--- a/libs/textlayout/tests/MockRootAreaProvider.h
+++ b/libs/textlayout/tests/MockRootAreaProvider.h
@@ -32,7 +32,7 @@ public:
virtual void releaseAllAfter(KoTextLayoutRootArea *afterThis);
virtual void doPostLayout(KoTextLayoutRootArea *rootArea, bool isNewRootArea) {}
virtual QSizeF suggestSize(KoTextLayoutRootArea *rootArea);
- virtual QList<KoTextLayoutObstruction *> relevantObstructions(const QRectF \
&rect, const QList<KoTextLayoutObstruction *> &excludingThese); + virtual \
QList<KoTextLayoutObstruction *> relevantObstructions(KoTextLayoutRootArea \
*rootArea);
KoTextLayoutRootArea *m_area;
};
diff --git a/plugins/textshape/SimpleRootAreaProvider.cpp \
b/plugins/textshape/SimpleRootAreaProvider.cpp index 8348099..062141a 100644
--- a/plugins/textshape/SimpleRootAreaProvider.cpp
+++ b/plugins/textshape/SimpleRootAreaProvider.cpp
@@ -115,15 +115,13 @@ QSizeF SimpleRootAreaProvider::suggestSize(KoTextLayoutRootArea \
*rootArea) return size;
}
-QList<KoTextLayoutObstruction *> SimpleRootAreaProvider::relevantObstructions(const \
QRectF &rect, const QList<KoTextLayoutObstruction *> &excludingThese) \
+QList<KoTextLayoutObstruction *> \
SimpleRootAreaProvider::relevantObstructions(KoTextLayoutRootArea *rootArea) {
QList<KoTextLayoutObstruction*> obstructions;
- QRectF canvasRect = rect;
- canvasRect.moveTop(rect.top() - m_area->top());
- QTransform transform = m_textShape->absoluteTransformation(0);
- canvasRect = transform.mapRect(canvasRect);
-
+/*
+ m_textShape->boundingRect();
QList<KoShape *> shapes;
- //shapes = manager->shapesAt(canvasRect):
+ shapes = manager->shapesAt(canvasRect):
+*/
return obstructions;
}
diff --git a/plugins/textshape/SimpleRootAreaProvider.h \
b/plugins/textshape/SimpleRootAreaProvider.h index 2829a36..5f90d25 100644
--- a/plugins/textshape/SimpleRootAreaProvider.h
+++ b/plugins/textshape/SimpleRootAreaProvider.h
@@ -39,7 +39,7 @@ public:
virtual QSizeF suggestSize(KoTextLayoutRootArea *rootArea);
- virtual QList<KoTextLayoutObstruction *> relevantObstructions(const QRectF \
&rect, const QList<KoTextLayoutObstruction *> &excludingThese); + virtual \
QList<KoTextLayoutObstruction *> relevantObstructions(KoTextLayoutRootArea \
*rootArea);
TextShape *m_textShape;
diff --git a/words/part/KWRootAreaProvider.cpp b/words/part/KWRootAreaProvider.cpp
index 56e13b2..61a1b69 100755
--- a/words/part/KWRootAreaProvider.cpp
+++ b/words/part/KWRootAreaProvider.cpp
@@ -161,6 +161,7 @@ KoTextLayoutRootArea \
*KWRootAreaProvider::provide(KoTextDocumentLayout *document }
m_pages.append(area);
+
return area;
}
@@ -310,28 +311,14 @@ QSizeF KWRootAreaProvider::suggestSize(KoTextLayoutRootArea \
*rootArea) return shape->size();
}
-QList<KoTextLayoutObstruction *> KWRootAreaProvider::relevantObstructions(const \
QRectF &textRect, const QList<KoTextLayoutObstruction *> &excludingThese) \
+QList<KoTextLayoutObstruction *> \
KWRootAreaProvider::relevantObstructions(KoTextLayoutRootArea *rootArea) {
QList<KoTextLayoutObstruction*> obstructions;
- KoTextLayoutRootArea *rootArea = 0;
- foreach (KoTextLayoutRootArea *area, m_pages) {
- if (area->boundingRect().intersects(textRect)) {
- rootArea = area;
- break;
- }
- }
- if (!rootArea) {
- return obstructions;
- }
-
KoShape *currentShape = rootArea->associatedShape();
// let's convert into canvas/KWDocument coords
- QRectF rect = textRect;
- rect.moveTop(rect.top() - rootArea->top());
- QTransform transform = currentShape->absoluteTransformation(0);
- rect = transform.mapRect(rect);
+ QRectF rect = currentShape->boundingRect();
//TODO would probably be faster if we could use the RTree of the shape manager
foreach (KWFrameSet *fs, m_textFrameSet->kwordDocument()->frameSets()) {
diff --git a/words/part/KWRootAreaProvider.h b/words/part/KWRootAreaProvider.h
index a84ab9f..b72bcca 100755
--- a/words/part/KWRootAreaProvider.h
+++ b/words/part/KWRootAreaProvider.h
@@ -43,7 +43,7 @@ public:
virtual void doPostLayout(KoTextLayoutRootArea *rootArea, bool isNewRootArea);
virtual bool suggestPageBreak(KoTextLayoutRootArea *beforeThis);
virtual QSizeF suggestSize(KoTextLayoutRootArea *rootArea);
- virtual QList<KoTextLayoutObstruction *> relevantObstructions(const QRectF \
&rect, const QList<KoTextLayoutObstruction *> &excludingThese); + virtual \
QList<KoTextLayoutObstruction *> relevantObstructions(KoTextLayoutRootArea \
*rootArea); private:
KWTextFrameSet *m_textFrameSet;
QList<KoTextLayoutRootArea *> m_pages;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic