[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/calligra/2.9] words/part: Fix loading textshapes with flowing text in weird order.
From: C. Boemann <cbo () boemann ! dk>
Date: 2015-02-06 22:48:41
Message-ID: E1YJrhZ-0004I9-J5 () scm ! kde ! org
[Download RAW message or body]
Git commit eb69a0cb75991db01d33f39dee53928b8930fba9 by C. Boemann.
Committed on 06/02/2015 at 22:17.
Pushed by boemann into branch 'calligra/2.9'.
Fix loading textshapes with flowing text in weird order.
We basically didn't expect such a weird order, but now we do a two step loading,
first recording the order, and only then actually placing the textflow in that order
BUG: 327565
M +2 -0 words/part/KWOdfLoader.cpp
M +32 -26 words/part/KWOdfSharedLoadingData.cpp
M +4 -1 words/part/KWOdfSharedLoadingData.h
http://commits.kde.org/calligra/eb69a0cb75991db01d33f39dee53928b8930fba9
diff --git a/words/part/KWOdfLoader.cpp b/words/part/KWOdfLoader.cpp
index 09f4602..f3f399b 100644
--- a/words/part/KWOdfLoader.cpp
+++ b/words/part/KWOdfLoader.cpp
@@ -234,6 +234,8 @@ bool KWOdfLoader::load(KoOdfReadStore &odfStore)
loader.loadBody(body, cursor); // now let's load the body from the ODF \
KoXmlElement.
+ sharedData->connectFlowingTextShapes();
+
if (loadUpdater) {
loadUpdater->setProgress(100);
}
diff --git a/words/part/KWOdfSharedLoadingData.cpp \
b/words/part/KWOdfSharedLoadingData.cpp index f1aa616..6595135 100644
--- a/words/part/KWOdfSharedLoadingData.cpp
+++ b/words/part/KWOdfSharedLoadingData.cpp
@@ -49,7 +49,6 @@ KWOdfSharedLoadingData::KWOdfSharedLoadingData(KWOdfLoader *loader)
void KWOdfSharedLoadingData::shapeInserted(KoShape *shape, const KoXmlElement \
&element, KoShapeLoadingContext &context) {
-
shape->removeAdditionalAttribute("text:anchor-type");
const KoXmlElement *style = 0;
if (element.hasAttributeNS(KoXmlNS::draw, "style-name")) {
@@ -60,32 +59,11 @@ void KWOdfSharedLoadingData::shapeInserted(KoShape *shape, const \
KoXmlElement &e
KoTextShapeData *text = qobject_cast<KoTextShapeData*>(shape->userData());
if (text) {
- KWTextFrameSet *fs = 0;
- KWFrame *previous = m_nextFrames.value(shape->name());
- if (previous)
- fs = dynamic_cast<KWTextFrameSet*>(KWFrameSet::from(previous->shape()));
- if (fs == 0) {
- fs = new KWTextFrameSet(m_loader->document());
- fs->setName(m_loader->document()->uniqueFrameSetName(shape->name()));
- m_loader->document()->addFrameSet(fs);
- }
-
- KWFrame *frame = new KWFrame(shape, fs);
- if (style) {
- if (! fillFrameProperties(frame, *style))
- return; // done
- }
-
KoXmlElement textBox(KoXml::namedItemNS(element, KoXmlNS::draw, \
"text-box"));
- if (frame && !textBox.isNull()) {
- QString nextFrame = textBox.attributeNS(KoXmlNS::draw, \
"chain-next-name");
- if (! nextFrame.isEmpty()) {
-#ifndef NDEBUG
- if (m_nextFrames.contains(nextFrame))
- kWarning(32001) << "Document has two frames with the same \
'chain-next-name' value, strange things may happen";
-#endif
- m_nextFrames.insert(nextFrame, frame);
- }
+ if (!textBox.isNull()) {
+ QString nextName = textBox.attributeNS(KoXmlNS::draw, \
"chain-next-name"); + m_nextShapeNames.insert(shape, nextName);
+ m_shapesToProcess.append(shape);
if (textBox.hasAttributeNS(KoXmlNS::fo, "min-height")) {
shape->setMinimumHeight(KoUnit::parseValue(textBox.attributeNS(KoXmlNS::fo, \
"min-height"))); @@ -95,6 +73,11 @@ void \
KWOdfSharedLoadingData::shapeInserted(KoShape *shape, const KoXmlElement &e \
shape->setSize(newSize); }
}
+ KWTextFrameSet *fs = new KWTextFrameSet(m_loader->document());
+ fs->setName(m_loader->document()->uniqueFrameSetName(shape->name()));
+ KWFrame *frame = new KWFrame(shape, fs);
+ if (style)
+ fillFrameProperties(frame, *style);
}
} else {
KWFrameSet *fs = new KWFrameSet();
@@ -114,3 +97,26 @@ bool KWOdfSharedLoadingData::fillFrameProperties(KWFrame *frame, \
const KoXmlElem
return true;
}
+
+void KWOdfSharedLoadingData::connectFlowingTextShapes()
+{
+ while (!m_shapesToProcess.isEmpty()) {
+ KoShape *shape = m_shapesToProcess.takeFirst();
+ KWTextFrameSet *fs = dynamic_cast<KWTextFrameSet \
*>(KWFrameSet::from(shape)); + m_loader->document()->addFrameSet(fs);
+
+ while (shape) {
+ QString nextName = m_nextShapeNames[shape];
+ shape = 0;
+
+ foreach (KoShape *s, m_shapesToProcess) {
+ if (s->name() == nextName) {
+ shape = s;
+ m_shapesToProcess.removeAll(shape);
+ new KWFrame(shape, fs);
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/words/part/KWOdfSharedLoadingData.h \
b/words/part/KWOdfSharedLoadingData.h index 83e6f64..9ab7ed3 100644
--- a/words/part/KWOdfSharedLoadingData.h
+++ b/words/part/KWOdfSharedLoadingData.h
@@ -35,6 +35,8 @@ class KWOdfSharedLoadingData : public KoTextSharedLoadingData
public:
explicit KWOdfSharedLoadingData(KWOdfLoader *loader);
+ void connectFlowingTextShapes();
+
protected:
virtual void shapeInserted(KoShape *shape, const KoXmlElement &element, \
KoShapeLoadingContext &context);
@@ -46,7 +48,8 @@ private:
bool fillFrameProperties(KWFrame *frame, const KoXmlElement &style);
KWOdfLoader *m_loader;
- QHash<QString, KWFrame*> m_nextFrames; // store the 'chain-next-name' property \
to the frame it was found on + QHash<KoShape *, QString> m_nextShapeNames; // \
store the 'chain-next-name' + QList<KoShape *> m_shapesToProcess;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic