[krita/wolthera/T5411-modernise-calligraphy-tool] /: Make Krita build with KOXML_USE_QDOM defined

Boudewijn Rempt null at kde.org
Fri Mar 24 10:17:37 UTC 2017


Git commit 514b87617ad9e2e06c17bd5bfe9db7c868df32b4 by Boudewijn Rempt.
Committed on 24/03/2017 at 10:07.
Pushed by rempt into branch 'wolthera/T5411-modernise-calligraphy-tool'.

Make Krita build with KOXML_USE_QDOM defined

This "fixes" all the places where KoXml::asQDomElement was used,
which was broken. It looks like nobody built like this since, oh,
2010 or so... It's a first step towards not using the KoXmlReader
code at all anymore.

There is no visible performance regression, but I didn't do real
benchmarking. But at least, with the ifdef working, we can do
benchmarking again.

In the text shape, some parts are just rudely ifdeffed out, mostly
to do with RDF, which krita doesn't need anyway, or changetracking,
which krita also doesn't need.

The really tricky bit is that in several places we used KoXmlDocument
with stripSpaces set to true, and I'm not sure what not being able
to set that flag will have.

KOXML_USE_QDOM is defined now, so Wolthera can continue with
the calligraphy tool; before merging to master, we should undefine
it again. Maybe we should make it a cmake option, if we're not just
going to remove KoXmlReader altogether.

CCMAIL:kimageshop at kde.org

CC'ing the calligra developers since this might be of interest for
Calligra, too: either calligra should remove KOXmlReaderForward.h,
or make the ifdef work again -- which is likely much tricker than
it was for krita.

CCMAIL:calligra-devel at kde.org

M  +1    -1    libs/flake/KoFilterEffect.h
M  +1    -1    libs/flake/KoFilterEffectRegistry.h
M  +1    -1    libs/flake/KoFrameShape.h
M  +2    -1    libs/flake/KoMarker.h
M  +1    -4    libs/flake/KoMarkerCollection.cpp
M  +1    -1    libs/flake/KoMarkerCollection.h
M  +1    -1    libs/flake/KoOdfGradientBackground.h
M  +2    -2    libs/flake/KoOdfWorkaround.h
M  +1    -1    libs/flake/KoShapeAnchor.h
M  +1    -1    libs/flake/KoTextShapeDataBase.h
M  +7    -6    libs/flake/KoUnavailShape.cpp
M  +1    -1    libs/flake/svg/SvgCssHelper.h
M  +3    -2    libs/flake/svg/SvgParser.cpp
M  +1    -1    libs/flake/svg/SvgShape.h
M  +1    -1    libs/flake/svg/SvgStyleParser.h
M  +1    -1    libs/flake/svg/SvgUtil.h
M  +2    -1    libs/odf/KoColumns.h
M  +1    -5    libs/odf/KoOdfReadStore.cpp
M  +4    -0    libs/odf/tests/TestXmlReaderWithoutSpaces.cpp
M  +8    -10   libs/store/KoXmlReader.cpp
M  +12   -10   libs/store/KoXmlReader.h
M  +1    -1    libs/store/KoXmlReaderForward.h
M  +1    -3    libs/ui/flake/kis_shape_layer.cc
M  +1    -1    plugins/flake/artistictextshape/ArtisticTextLoadingContext.h
M  +1    -1    plugins/flake/textshape/kotext/KoSection.h
M  +3    -1    plugins/flake/textshape/kotext/changetracker/KoChangeTracker.cpp
M  +6    -1    plugins/flake/textshape/kotext/opendocument/KoTextWriter_p.cpp
M  +19   -19   plugins/flake/textshape/kotext/styles/KoTableCellStyle.cpp
M  +8    -0    plugins/impex/kra/kra_converter.cpp
M  +1    -1    plugins/impex/libkra/kis_kra_loader.cpp

https://commits.kde.org/krita/514b87617ad9e2e06c17bd5bfe9db7c868df32b4

diff --git a/libs/flake/KoFilterEffect.h b/libs/flake/KoFilterEffect.h
index f0173f79c51..2817f2861ce 100644
--- a/libs/flake/KoFilterEffect.h
+++ b/libs/flake/KoFilterEffect.h
@@ -27,7 +27,7 @@ class QRectF;
 class KoXmlWriter;
 class KoFilterEffectRenderContext;
 class KoFilterEffectLoadingContext;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 
 #include "kritaflake_export.h"
 #include <QList>
diff --git a/libs/flake/KoFilterEffectRegistry.h b/libs/flake/KoFilterEffectRegistry.h
index c79213c7451..1176385d2fb 100644
--- a/libs/flake/KoFilterEffectRegistry.h
+++ b/libs/flake/KoFilterEffectRegistry.h
@@ -25,7 +25,7 @@
 
 #include "kritaflake_export.h"
 
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoFilterEffectLoadingContext;
 class KoFilterEffect;
 
diff --git a/libs/flake/KoFrameShape.h b/libs/flake/KoFrameShape.h
index 062bfd2ffda..466a85e1e45 100644
--- a/libs/flake/KoFrameShape.h
+++ b/libs/flake/KoFrameShape.h
@@ -23,7 +23,7 @@
 #include "kritaflake_export.h"
 
 class KoShapeLoadingContext;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class QString;
 
 /**
diff --git a/libs/flake/KoMarker.h b/libs/flake/KoMarker.h
index a50bc27b4fa..2413ced08b8 100644
--- a/libs/flake/KoMarker.h
+++ b/libs/flake/KoMarker.h
@@ -26,7 +26,8 @@
 #include "kritaflake_export.h"
 #include <KoFlake.h>
 
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
+
 class KoShapeLoadingContext;
 class KoShapeSavingContext;
 class QString;
diff --git a/libs/flake/KoMarkerCollection.cpp b/libs/flake/KoMarkerCollection.cpp
index 22c53dffca4..f723f34dee1 100644
--- a/libs/flake/KoMarkerCollection.cpp
+++ b/libs/flake/KoMarkerCollection.cpp
@@ -70,15 +70,12 @@ void KoMarkerCollection::loadMarkersFromFile(const QString &svgFile)
 
     if (!file.open(QIODevice::ReadOnly)) return;
 
-    QXmlStreamReader reader(&file);
-    reader.setNamespaceProcessing(false);
-
     QString errorMsg;
     int errorLine = 0;
     int errorColumn;
 
     KoXmlDocument doc;
-    bool ok = doc.setContent(&reader, &errorMsg, &errorLine, &errorColumn);
+    bool ok = doc.setContent(&file, false, &errorMsg, &errorLine, &errorColumn);
     if (!ok) {
         errKrita << "Parsing error in " << svgFile << "! Aborting!" << endl
         << " In line: " << errorLine << ", column: " << errorColumn << endl
diff --git a/libs/flake/KoMarkerCollection.h b/libs/flake/KoMarkerCollection.h
index 56a280da9fe..044b79d963c 100644
--- a/libs/flake/KoMarkerCollection.h
+++ b/libs/flake/KoMarkerCollection.h
@@ -28,7 +28,7 @@
 #include <QMetaType>
 
 class KoMarker;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoShapeLoadingContext;
 
 class KRITAFLAKE_EXPORT KoMarkerCollection : public QObject
diff --git a/libs/flake/KoOdfGradientBackground.h b/libs/flake/KoOdfGradientBackground.h
index 2170ef2aacd..bd5210e3638 100644
--- a/libs/flake/KoOdfGradientBackground.h
+++ b/libs/flake/KoOdfGradientBackground.h
@@ -27,7 +27,7 @@
 class QImage;
 
 class KoOdfGradientBackgroundPrivate;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoGenStyles;
 class KoGenStyle;
 
diff --git a/libs/flake/KoOdfWorkaround.h b/libs/flake/KoOdfWorkaround.h
index 684828c37d7..038f4cf8c9d 100644
--- a/libs/flake/KoOdfWorkaround.h
+++ b/libs/flake/KoOdfWorkaround.h
@@ -28,7 +28,7 @@
 
 #include <QSharedPointer>
 
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoShape;
 class KoShapeLoadingContext;
 class QPen;
@@ -103,7 +103,7 @@ namespace KoOdfWorkaround
     KRITAFLAKE_EXPORT void fixMissingFillRule(Qt::FillRule &fillRule, KoShapeLoadingContext &context);
 
     /**
-     * OpenOffice resizes text shapes with autogrow in both directions. If the text box is saved to 
+     * OpenOffice resizes text shapes with autogrow in both directions. If the text box is saved to
      * small the text will not fit and it needs to be adjusted during the first layout.
      * This methods returns true if we need to adjust the layout. The adjusting is handled at a different place.
      */
diff --git a/libs/flake/KoShapeAnchor.h b/libs/flake/KoShapeAnchor.h
index 8a3e7004162..06b3465e7e3 100644
--- a/libs/flake/KoShapeAnchor.h
+++ b/libs/flake/KoShapeAnchor.h
@@ -25,7 +25,7 @@
 
 
 class KoShape;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoShapeLoadingContext;
 class KoShapeSavingContext;
 class KoShapeAnchorPrivate;
diff --git a/libs/flake/KoTextShapeDataBase.h b/libs/flake/KoTextShapeDataBase.h
index e217ff78758..36f4aab9a84 100644
--- a/libs/flake/KoTextShapeDataBase.h
+++ b/libs/flake/KoTextShapeDataBase.h
@@ -25,7 +25,7 @@
 #include "KoShapeUserData.h"
 
 class KoTextShapeDataBasePrivate;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoShapeLoadingContext;
 class KoShapeSavingContext;
 class KoGenStyle;
diff --git a/libs/flake/KoUnavailShape.cpp b/libs/flake/KoUnavailShape.cpp
index 240a9d2ba19..3e407cb2202 100644
--- a/libs/flake/KoUnavailShape.cpp
+++ b/libs/flake/KoUnavailShape.cpp
@@ -51,23 +51,23 @@
 
 
 // The XML of a frame looks something like this:
-// 
+//
 // 1. <draw:frame ...attributes...>
 // 2.   <draw:object xlink:href="./Object1" ...more attributes>
 // 3.   <draw:image xlink:href="./ObjectReplacements/Object1" ...more attributes>
 // 4. </draw:frame>
 //
 // or
-// 
+//
 // 1. <draw:frame ...attributes...>
-// 2.   <math:math>...inline xml here...</math:math>    
+// 2.   <math:math>...inline xml here...</math:math>
 // 3.   <draw:image xlink:href="./ObjectReplacements/Object1" ...more attributes>
 // 4. </draw:frame>
 //
 // We define each Xml statement on lines 2 and 3 above as an "object".
 // (Strictly only the first child element is an object in the ODF sense,
 // but we have to have some terminology here.)
-// 
+//
 // In an ODF frame, only the first line, i.e. the first object
 // contains the real contents.  All the rest of the objects are used /
 // shown if we cannot handle the first one.  The most common cases are
@@ -76,7 +76,7 @@
 //
 // Sometimes, e.g. in the case of an embedded document, the reference
 // points not to a file but to a directory structure inside the ODF
-// store. 
+// store.
 //
 // When we load and save in the UnavailShape, we have to be general
 // enough to cover all possible cases of references and inline XML,
@@ -554,6 +554,7 @@ void KoUnavailShape::Private::storeXmlRecursive(const KoXmlElement &el, KoXmlWri
     const QByteArray name(el.nodeName().toLatin1());
     writer.startElement(name.constData());
 
+#ifndef KOXML_USE_QDOM
     // Copy all the attributes, including namespaces.
     QList< QPair<QString, QString> >  attributeNames = el.attributeFullNames();
     for (int i = 0; i < attributeNames.size(); ++i) {
@@ -581,7 +582,7 @@ void KoUnavailShape::Private::storeXmlRecursive(const KoXmlElement &el, KoXmlWri
                                                                attrPair.second));
         }
     }
-
+#endif
     // Child elements
     // Loop through all the child elements of the draw:frame.
     KoXmlNode n = el.firstChild();
diff --git a/libs/flake/svg/SvgCssHelper.h b/libs/flake/svg/SvgCssHelper.h
index a3f26dfc32f..5ddd5b31414 100644
--- a/libs/flake/svg/SvgCssHelper.h
+++ b/libs/flake/svg/SvgCssHelper.h
@@ -22,7 +22,7 @@
 
 #include <QStringList>
 
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 
 class SvgCssHelper
 {
diff --git a/libs/flake/svg/SvgParser.cpp b/libs/flake/svg/SvgParser.cpp
index 970730f12f1..35de6b99720 100644
--- a/libs/flake/svg/SvgParser.cpp
+++ b/libs/flake/svg/SvgParser.cpp
@@ -42,6 +42,7 @@
 #include <KoPathShapeLoader.h>
 #include <commands/KoShapeGroupCommand.h>
 #include <commands/KoShapeUngroupCommand.h>
+#include <KoXmlReader.h>
 #include <KoImageCollection.h>
 #include <KoColorBackground.h>
 #include <KoGradientBackground.h>
@@ -159,7 +160,7 @@ SvgFilterHelper* SvgParser::findFilter(const QString &id, const QString &href)
         return 0;
 
     const KoXmlElement &e = m_context.definition(id);
-    if (e.childNodesCount() == 0) {
+    if (KoXml::childNodesCount(e) == 0) {
         QString mhref = e.attribute("xlink:href").mid(1);
 
         if (m_context.hasDefinition(mhref))
@@ -1292,7 +1293,7 @@ QList<KoShape*> SvgParser::parseSingleElement(const KoXmlElement &b)
         shapes += parseContainer(b);
         m_context.popGraphicsContext();
     } else if (b.tagName() == "defs") {
-        if (b.childNodesCount() > 0) {
+        if (KoXml::childNodesCount(b) > 0) {
             /**
              * WARNING: 'defs' are basically 'display:none' style, therefore they should not play
              *          any role in shapes outline calculation. But setVisible(false) shapes do!
diff --git a/libs/flake/svg/SvgShape.h b/libs/flake/svg/SvgShape.h
index 70f11ad1ae7..26d1d042e11 100644
--- a/libs/flake/svg/SvgShape.h
+++ b/libs/flake/svg/SvgShape.h
@@ -24,7 +24,7 @@
 
 class SvgSavingContext;
 class SvgLoadingContext;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 
 /// An interface providing svg loading and saving routines
 class KRITAFLAKE_EXPORT SvgShape
diff --git a/libs/flake/svg/SvgStyleParser.h b/libs/flake/svg/SvgStyleParser.h
index c5439e3294c..93a0c8eb4f8 100644
--- a/libs/flake/svg/SvgStyleParser.h
+++ b/libs/flake/svg/SvgStyleParser.h
@@ -30,7 +30,7 @@ typedef QMap<QString, QString> SvgStyles;
 
 class SvgLoadingContext;
 class SvgGraphicsContext;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class QColor;
 class QGradient;
 
diff --git a/libs/flake/svg/SvgUtil.h b/libs/flake/svg/SvgUtil.h
index 5b16cb3c256..793d76ee7da 100644
--- a/libs/flake/svg/SvgUtil.h
+++ b/libs/flake/svg/SvgUtil.h
@@ -26,7 +26,7 @@
 class QString;
 class SvgGraphicsContext;
 class QTransform;
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 
 class KRITAFLAKE_EXPORT SvgUtil
 {
diff --git a/libs/odf/KoColumns.h b/libs/odf/KoColumns.h
index dc6b4e829e6..cf068a0cf9e 100644
--- a/libs/odf/KoColumns.h
+++ b/libs/odf/KoColumns.h
@@ -29,8 +29,9 @@
 #include <QtGlobal>
 #include <QColor>
 
+#include <KoXmlReaderForward.h>
+
 class KoGenStyle;
-class KoXmlElement;
 
 
 /** structure for columns */
diff --git a/libs/odf/KoOdfReadStore.cpp b/libs/odf/KoOdfReadStore.cpp
index c02e88d0df0..505dd7d138a 100644
--- a/libs/odf/KoOdfReadStore.cpp
+++ b/libs/odf/KoOdfReadStore.cpp
@@ -127,11 +127,7 @@ bool KoOdfReadStore::loadAndParse(QIODevice *fileDevice, KoXmlDocument &doc, QSt
     if (!fileDevice->isOpen()) {
         fileDevice->open(QIODevice::ReadOnly);
     }
-
-    QXmlStreamReader reader(fileDevice);
-    reader.setNamespaceProcessing(true);
-
-    bool ok = doc.setContent(&reader, &errorMsg, &errorLine, &errorColumn);
+    bool ok = doc.setContent(fileDevice, true, &errorMsg, &errorLine, &errorColumn);
     if (!ok) {
         errorOdf << "Parsing error in " << fileName << "! Aborting!" << endl
         << " In line: " << errorLine << ", column: " << errorColumn << endl
diff --git a/libs/odf/tests/TestXmlReaderWithoutSpaces.cpp b/libs/odf/tests/TestXmlReaderWithoutSpaces.cpp
index 1d3449ed3e3..e0b71077468 100644
--- a/libs/odf/tests/TestXmlReaderWithoutSpaces.cpp
+++ b/libs/odf/tests/TestXmlReaderWithoutSpaces.cpp
@@ -16,6 +16,7 @@ class TestXmlReaderWithoutSpaces : public QObject
 {
     Q_OBJECT
 private Q_SLOTS:
+#ifndef KOXML_USE_QDOM
     void testNode();
     void testElement();
     void testAttributes();
@@ -38,8 +39,10 @@ private Q_SLOTS:
     void testSimpleOpenDocumentFormula();
     void testLargeOpenDocumentSpreadsheet();
     void testExternalOpenDocumentSpreadsheet(const QString& filename);
+#endif
 };
 
+#ifndef KOXML_USE_QDOM
 void TestXmlReaderWithoutSpaces::testNode()
 {
     QString errorMsg;
@@ -2690,6 +2693,7 @@ void TestXmlReaderWithoutSpaces::testExternalOpenDocumentSpreadsheet(const QStri
     // uncomment to check the XML
     xmlfile.remove();
 }
+#endif
 
 QTEST_GUILESS_MAIN(TestXmlReaderWithoutSpaces)
 #include <TestXmlReaderWithoutSpaces.moc>
diff --git a/libs/store/KoXmlReader.cpp b/libs/store/KoXmlReader.cpp
index 5e1d00c2fed..7a6c626992d 100644
--- a/libs/store/KoXmlReader.cpp
+++ b/libs/store/KoXmlReader.cpp
@@ -71,12 +71,12 @@
 
 #include <QTextCodec>
 #include <QTextDecoder>
+#include <QXmlStreamReader>
 
 #ifndef KOXML_USE_QDOM
 
 #include <QtXml>
 #include <QDomDocument>
-#include <QXmlStreamReader>
 #include <QXmlStreamEntityResolver>
 
 #include <QBuffer>
@@ -815,7 +815,7 @@ private:
     QString textData;
     // reference counting
     unsigned long refCount;
-    friend class KoXmlElement;
+    friend #include <KoXmlReaderForward.h>
 };
 
 KoXmlNodeData KoXmlNodeData::null;
@@ -2253,7 +2253,7 @@ KoXmlElement KoXml::namedItemNS(const KoXmlNode& node, const QString& nsURI,
                                 const QString& localName, KoXmlNamedItemType type)
 {
 #ifdef KOXML_USE_QDOM
-Q_ASSERT(false);
+    Q_UNUSED(type)
     return namedItemNS(node, nsURI, localName);
 #else
     return node.namedItemNS(nsURI, localName, type).toElement();
@@ -2314,7 +2314,7 @@ void KoXml::asQDomNode(QDomDocument& ownerDoc, const KoXmlNode& node)
 {
     Q_ASSERT(!node.isDocument());
 #ifdef KOXML_USE_QDOM
-    ownerDoc.appendChild(ownerDoc.importNode(node));
+    ownerDoc.appendChild(ownerDoc.importNode(node, true));
 #else
     node.asQDomNode(ownerDoc);
 #endif
@@ -2340,12 +2340,10 @@ QDomDocument KoXml::asQDomDocument(const KoXmlDocument& document)
 #endif
 }
 
-bool KoXml::setDocument(KoXmlDocument& doc, QIODevice* device,
-                        bool namespaceProcessing, QString* errorMsg, int* errorLine,
-                        int* errorColumn)
+bool KoXml::setDocument(KoXmlDocument& doc, QIODevice *device,
+                        bool namespaceProcessing,
+                        QString *errorMsg, int *errorLine, int *errorColumn)
 {
-    QXmlStreamReader reader(device);
-    reader.setNamespaceProcessing(namespaceProcessing);
-    bool result = doc.setContent(&reader, errorMsg, errorLine, errorColumn);
+    bool result = doc.setContent(device, namespaceProcessing, errorMsg, errorLine, errorColumn);
     return result;
 }
diff --git a/libs/store/KoXmlReader.h b/libs/store/KoXmlReader.h
index 0443dd83493..7827b6bbaff 100644
--- a/libs/store/KoXmlReader.h
+++ b/libs/store/KoXmlReader.h
@@ -30,14 +30,6 @@
 
 class QIODevice;
 
-#ifndef KOXML_USE_QDOM
-
-class QXmlStreamReader;
-
-class KoXmlNodeData;
-class KoXmlDocumentData;
-class QDomDocument;
-class QStringList;
 
 /**
  * The office-text-content-prelude type.
@@ -48,6 +40,16 @@ enum KoXmlNamedItemType {
     //KoXmlTextContentEpilogue ///< office-text-content-epilogue
 };
 
+#ifndef KOXML_USE_QDOM
+
+class QXmlStreamReader;
+
+class KoXmlNodeData;
+class KoXmlDocumentData;
+class QDomDocument;
+class QStringList;
+
+
 /**
 * KoXmlNode represents a node in a DOM tree.
 *
@@ -394,7 +396,7 @@ KRITASTORE_EXPORT QStringList attributeNames(const KoXmlNode& node);
  * NOTE:
  * - If ownerDoc is not empty, this may fail, @see QDomDocument
  * - @p node must not be a KoXmlDocument, use asQDomDocument()
- * 
+ *
  * @see asQDomDocument, asQDomElement
  */
 KRITASTORE_EXPORT void asQDomNode(QDomDocument& ownerDoc, const KoXmlNode& node);
@@ -403,7 +405,7 @@ KRITASTORE_EXPORT void asQDomNode(QDomDocument& ownerDoc, const KoXmlNode& node)
  * Convert KoXmlNode classes to the corresponding QDom classes, which has
  * @p ownerDoc as the owner document (QDomDocument instance).
  * The converted @p element (and its children) is added to ownerDoc.
- * 
+ *
  * NOTE: If ownerDoc is not empty, this may fail, @see QDomDocument
  *
  */
diff --git a/libs/store/KoXmlReaderForward.h b/libs/store/KoXmlReaderForward.h
index f49a7c1cb99..9aa79ad0a8f 100644
--- a/libs/store/KoXmlReaderForward.h
+++ b/libs/store/KoXmlReaderForward.h
@@ -22,7 +22,7 @@
 #define KOXMLREADERFORWARD_H
 
 // use standard QDom, useful to test KoXml classes against Qt's QDom
-//#define KOXML_USE_QDOM
+#define KOXML_USE_QDOM
 
 #ifdef KOXML_USE_QDOM
 
diff --git a/libs/ui/flake/kis_shape_layer.cc b/libs/ui/flake/kis_shape_layer.cc
index 157c517adbf..5b5e628f11e 100644
--- a/libs/ui/flake/kis_shape_layer.cc
+++ b/libs/ui/flake/kis_shape_layer.cc
@@ -408,15 +408,13 @@ bool KisShapeLayer::saveShapesToStore(KoStore *store, QList<KoShape *> shapes, c
 
 QList<KoShape *> KisShapeLayer::createShapesFromSvg(QIODevice *device, const QString &baseXmlDir, const QRectF &rectInPixels, qreal resolutionPPI, KoDocumentResourceManager *resourceManager, QSizeF *fragmentSize)
 {
-    QXmlStreamReader reader(device);
-    reader.setNamespaceProcessing(false);
 
     QString errorMsg;
     int errorLine = 0;
     int errorColumn;
 
     KoXmlDocument doc;
-    bool ok = doc.setContent(&reader, &errorMsg, &errorLine, &errorColumn);
+    bool ok = doc.setContent(device, false, &errorMsg, &errorLine, &errorColumn);
     if (!ok) {
         errKrita << "Parsing error in " << "contents.svg" << "! Aborting!" << endl
         << " In line: " << errorLine << ", column: " << errorColumn << endl
diff --git a/plugins/flake/artistictextshape/ArtisticTextLoadingContext.h b/plugins/flake/artistictextshape/ArtisticTextLoadingContext.h
index 2d34d2ea702..82889a36669 100644
--- a/plugins/flake/artistictextshape/ArtisticTextLoadingContext.h
+++ b/plugins/flake/artistictextshape/ArtisticTextLoadingContext.h
@@ -27,7 +27,7 @@
 
 typedef QList<qreal> CharTransforms;
 
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class SvgGraphicsContext;
 
 class ArtisticTextLoadingContext
diff --git a/plugins/flake/textshape/kotext/KoSection.h b/plugins/flake/textshape/kotext/KoSection.h
index 7d4e29e9ea5..12dd9c2dedb 100644
--- a/plugins/flake/textshape/kotext/KoSection.h
+++ b/plugins/flake/textshape/kotext/KoSection.h
@@ -29,7 +29,7 @@
 #include <QScopedPointer>
 #include <QTextCursor>
 
-class KoXmlElement;
+#include <KoXmlReaderForward.h>
 class KoShapeSavingContext;
 class KoTextSharedLoadingData;
 class KoSectionEnd;
diff --git a/plugins/flake/textshape/kotext/changetracker/KoChangeTracker.cpp b/plugins/flake/textshape/kotext/changetracker/KoChangeTracker.cpp
index 1a6658c4ad4..fd0e3a84b2d 100644
--- a/plugins/flake/textshape/kotext/changetracker/KoChangeTracker.cpp
+++ b/plugins/flake/textshape/kotext/changetracker/KoChangeTracker.cpp
@@ -381,6 +381,7 @@ KoFormatChangeInformation *KoChangeTracker::formatChangeInformation(int formatCh
 
 void KoChangeTracker::loadOdfChanges(const KoXmlElement& element)
 {
+#ifndef KOXML_USE_QDOM
     if (element.namespaceURI() == KoXmlNS::text) {
         KoXmlElement tag;
         forEachElement(tag, element) {
@@ -452,6 +453,7 @@ void KoChangeTracker::loadOdfChanges(const KoXmlElement& element)
            }
         }
     }
+#endif
 }
 
 int KoChangeTracker::getLoadedChangeId(const QString &odfId) const
@@ -530,7 +532,7 @@ QTextDocumentFragment KoChangeTracker::generateDeleteFragment(const QTextCursor
         for (int i = cursor.anchor();i <= cursor.position(); i++) {
             if (document->characterAt(i) == QChar::ObjectReplacementCharacter) {
                 editCursor.setPosition(i+1);
-	    }
+        }
         }
     }
 
diff --git a/plugins/flake/textshape/kotext/opendocument/KoTextWriter_p.cpp b/plugins/flake/textshape/kotext/opendocument/KoTextWriter_p.cpp
index 0f4e92a38a5..a78a2c79d21 100644
--- a/plugins/flake/textshape/kotext/opendocument/KoTextWriter_p.cpp
+++ b/plugins/flake/textshape/kotext/opendocument/KoTextWriter_p.cpp
@@ -386,6 +386,7 @@ QString KoTextWriter::Private::saveTableCellStyle(const QTextTableCellFormat& ce
 
 void KoTextWriter::Private::saveInlineRdf(KoTextInlineRdf* rdf, TagInformation* tagInfos)
 {
+#ifndef KOXML_USE_QDOM
     QBuffer rdfXmlData;
     KoXmlWriter rdfXmlWriter(&rdfXmlData);
     rdfXmlWriter.startDocument("rdf");
@@ -404,6 +405,7 @@ void KoTextWriter::Private::saveInlineRdf(KoTextInlineRdf* rdf, TagInformation*
             attributeName.prepend("xml");
         tagInfos->addAttribute(attributeName, mainElement.attribute(attributeNameNS.second));
     }
+#endif
 }
 
 /*
@@ -1095,6 +1097,8 @@ void KoTextWriter::Private::addNameSpaceDefinitions(QString &generatedXmlString)
 
 void KoTextWriter::Private::writeAttributes(QTextStream &outputXmlStream, KoXmlElement &element)
 {
+#ifndef KOXML_USE_QDOM
+
     QList<QPair<QString, QString> > attributes = element.attributeFullNames();
 
     foreach (const Attribute &attributeNamePair, attributes) {
@@ -1105,6 +1109,7 @@ void KoTextWriter::Private::writeAttributes(QTextStream &outputXmlStream, KoXmlE
             //To Be Added when needed
         }
     }
+#endif
 }
 
 void KoTextWriter::Private::writeNode(QTextStream &outputXmlStream, KoXmlNode &node, bool writeOnlyChildren)
@@ -1113,7 +1118,7 @@ void KoTextWriter::Private::writeNode(QTextStream &outputXmlStream, KoXmlNode &n
         outputXmlStream  << node.toText().data();
     } else if (node.isElement()) {
         KoXmlElement element = node.toElement();
-        if ((element.localName() == "removed-content") && !element.childNodesCount()) {
+        if ((element.localName() == "removed-content") && !KoXml::childNodesCount(element)) {
             return;
         }
 
diff --git a/plugins/flake/textshape/kotext/styles/KoTableCellStyle.cpp b/plugins/flake/textshape/kotext/styles/KoTableCellStyle.cpp
index 0005a3f5e9c..51ee414ddda 100644
--- a/plugins/flake/textshape/kotext/styles/KoTableCellStyle.cpp
+++ b/plugins/flake/textshape/kotext/styles/KoTableCellStyle.cpp
@@ -54,7 +54,7 @@ KoTableCellStyle::RotationAlignment rotationAlignmentFromString(const QString& a
         return KoTableCellStyle::RAlignCenter;
     if (align == "top")
         return KoTableCellStyle::RAlignTop;
-    
+
     return KoTableCellStyle::RAlignNone;
 }
 
@@ -608,12 +608,12 @@ void KoTableCellStyle::loadOdf(const KoXmlElement *element, KoShapeLoadingContex
     }
 
     paragraphStyle()->loadOdf(element, scontext, true); // load the par and char properties
-
+#ifndef KOXML_USE_QDOM
     // Borders - we don't handle inheritance unfortunately - hope it's not a big problem
     KoBorder borders = this->borders();
     borders.loadOdf(element->namedItemNS(KoXmlNS::style, "table-cell-properties").toElement());
     setBorders(borders);
-
+#endif
     context.styleStack().save();
     QString family = element->attributeNS(KoXmlNS::style, "family", "table-cell");
     context.addStyles(element, family.toLocal8Bit().constData());   // Load all parents - only because we don't support inheritance.
@@ -673,54 +673,54 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext &context, KoStyle
     if (styleStack.hasProperty(KoXmlNS::style, "shrink-to-fit")) {
         setShrinkToFit(styleStack.property(KoXmlNS::style, "shrink-to-fit") == "true");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "print-content")) {
         setPrintContent(styleStack.property(KoXmlNS::style, "print-content") == "true");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "repeat-content")) {
         setRepeatContent(styleStack.property(KoXmlNS::style, "repeat-content") == "true");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "repeat-content")) {
         setRepeatContent(styleStack.property(KoXmlNS::style, "repeat-content") == "true");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "decimal-places")) {
         bool ok;
         int value = styleStack.property(KoXmlNS::style, "decimal-places").toInt(&ok);
         if (ok)
             setDecimalPlaces(value);
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "rotation-angle")) {
         setRotationAngle(KoUnit::parseAngle(styleStack.property(KoXmlNS::style, "rotation-angle")));
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "glyph-orientation-vertical"))
     {
         setVerticalGlyphOrientation(styleStack.property(KoXmlNS::style, "glyph-orientation-vertical") == "auto");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "direction")) {
         if (styleStack.property(KoXmlNS::style, "direction") == "ltr")
             setDirection(KoTableCellStyle::LeftToRight);
         else
             setDirection(KoTableCellStyle::TopToBottom);
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "rotation-align")) {
         setRotationAlignment(rotationAlignmentFromString(styleStack.property(KoXmlNS::style, "rotation-align")));
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "text-align-source")) {
         setAlignFromType(styleStack.property(KoXmlNS::style, "text-align-source") == "value-type");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::fo, "wrap-option")) {
         setWrap(styleStack.property(KoXmlNS::fo, "wrap-option") == "wrap");
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "cell-protect")) {
         QString protection = styleStack.property(KoXmlNS::style, "cell-protect");
         if (protection == "none")
@@ -742,7 +742,7 @@ void KoTableCellStyle::loadOdfProperties(KoShapeLoadingContext &context, KoStyle
         else
             setAlignment(KoText::valignmentFromString(verticalAlign));
     }
-    
+
     if (styleStack.hasProperty(KoXmlNS::style, "writing-mode"))
         setTextDirection(KoText::directionFromString(styleStack.property(KoXmlNS::style, "writing-mode")));
 }
@@ -785,10 +785,10 @@ void KoTableCellStyle::saveOdf(KoGenStyle &style, KoShapeSavingContext &context)
     Q_D(KoTableCellStyle);
     QList<int> keys = d->stylesPrivate.keys();
     bool donePadding = false;
-    if (hasProperty(QTextFormat::TableCellLeftPadding) && 
-            hasProperty(QTextFormat::TableCellRightPadding) && 
-            hasProperty(QTextFormat::TableCellTopPadding) && 
-            hasProperty(QTextFormat::TableCellBottomPadding) && 
+    if (hasProperty(QTextFormat::TableCellLeftPadding) &&
+            hasProperty(QTextFormat::TableCellRightPadding) &&
+            hasProperty(QTextFormat::TableCellTopPadding) &&
+            hasProperty(QTextFormat::TableCellBottomPadding) &&
             leftPadding() == rightPadding() &&
             topPadding() == bottomPadding() &&
             topPadding() == leftPadding()) {
diff --git a/plugins/impex/kra/kra_converter.cpp b/plugins/impex/kra/kra_converter.cpp
index 20dd1a6b9ff..87a7b6d1019 100644
--- a/plugins/impex/kra/kra_converter.cpp
+++ b/plugins/impex/kra/kra_converter.cpp
@@ -65,7 +65,11 @@ KisImageBuilder_Result KraConverter::buildImage(QIODevice *io)
     bool success;
     {
         if (m_store->hasFile("root") || m_store->hasFile("maindoc.xml")) {   // Fallback to "old" file format (maindoc.xml)
+#ifdef KOXML_USE_QDOM
+            KoXmlDocument doc;
+#else
             KoXmlDocument doc = KoXmlDocument(true);
+#endif
 
             bool ok = oldLoadAndParse(m_store, "root", doc);
             if (ok)
@@ -81,7 +85,11 @@ KisImageBuilder_Result KraConverter::buildImage(QIODevice *io)
         }
 
         if (m_store->hasFile("documentinfo.xml")) {
+#ifdef KOXML_USE_QDOM
+            KoXmlDocument doc;
+#else
             KoXmlDocument doc = KoXmlDocument(true);
+#endif
             if (oldLoadAndParse(m_store, "documentinfo.xml", doc)) {
                 m_doc->documentInfo()->load(doc);
             }
diff --git a/plugins/impex/libkra/kis_kra_loader.cpp b/plugins/impex/libkra/kis_kra_loader.cpp
index d9fac5a1e8c..23f9267e166 100644
--- a/plugins/impex/libkra/kis_kra_loader.cpp
+++ b/plugins/impex/libkra/kis_kra_loader.cpp
@@ -558,7 +558,7 @@ KisNodeSP KisKraLoader::loadNodes(const KoXmlElement& element, KisImageSP image,
                     if (node) {
                         image->nextLayerName(); // Make sure the nameserver is current with the number of nodes.
                         image->addNode(node, parent);
-                        if (node->inherits("KisLayer") && child.childNodesCount() > 0) {
+                        if (node->inherits("KisLayer") && KoXml::childNodesCount(child) > 0) {
                             loadNodes(child.toElement(), image, node);
                         }
                     }


More information about the kimageshop mailing list