From d51d2f674fb01bf6d958799919614cac8782311f Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Mon, 8 Jan 2024 17:49:38 +0100 Subject: [PATCH] Remove code related to qtxmlpatterns (#11755) --- package/fedora/freecad.spec | 1 - src/Mod/TechDraw/App/CMakeLists.txt | 10 +- src/Mod/TechDraw/App/QDomNodeModel.cpp | 363 ------------------------- src/Mod/TechDraw/App/QDomNodeModel.h | 70 ----- src/Mod/TechDraw/Gui/CMakeLists.txt | 6 - tools/build/Docker/debian.sh | 2 +- tools/build/Docker/fedora.sh | 2 +- tools/build/Docker/ubuntu.sh | 2 +- 8 files changed, 5 insertions(+), 451 deletions(-) delete mode 100644 src/Mod/TechDraw/App/QDomNodeModel.cpp delete mode 100644 src/Mod/TechDraw/App/QDomNodeModel.h diff --git a/package/fedora/freecad.spec b/package/fedora/freecad.spec index 46fb097d5b..643668a64c 100644 --- a/package/fedora/freecad.spec +++ b/package/fedora/freecad.spec @@ -73,7 +73,6 @@ BuildRequires: qt5-qtwebengine-devel #BuildRequires: qt5-qtwebkit-devel BuildRequires: qt5-qtsvg-devel BuildRequires: qt5-qttools-static -BuildRequires: qt5-qtxmlpatterns-devel BuildRequires: fmt-devel diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt index c1602a200c..994a077017 100644 --- a/src/Mod/TechDraw/App/CMakeLists.txt +++ b/src/Mod/TechDraw/App/CMakeLists.txt @@ -20,19 +20,13 @@ set(TechDrawLIBS PartDesign ) -if(FREECAD_QT_MAJOR_VERSION EQUAL 5) - include_directories( - ${QtXmlPatterns_INCLUDE_DIRS} - ) -endif() - include_directories( ${QtConcurrent_INCLUDE_DIRS} ${QtCore_INCLUDE_DIR} ${QtGui_INCLUDE_DIR} ${QtWidgets_INCLUDE_DIRS} ) -set(QtXmlPatternsLib ${QtXmlPatterns_LIBRARIES}) + list(APPEND TechDrawLIBS ${QtConcurrent_LIBRARIES} ${QtCore_LIBRARIES} @@ -273,7 +267,7 @@ endif(FREECAD_USE_PCH) add_library(TechDraw SHARED ${TechDraw_SRCS} ${Draw_SRCS} ${TechDrawAlgos_SRCS} ${Geometry_SRCS} ${Python_SRCS}) -target_link_libraries(TechDraw ${TechDrawLIBS};${QtXmlPatternsLib};${TechDraw}) +target_link_libraries(TechDraw ${TechDrawLIBS} ${TechDraw}) ADD_CUSTOM_COMMAND(TARGET TechDraw POST_BUILD diff --git a/src/Mod/TechDraw/App/QDomNodeModel.cpp b/src/Mod/TechDraw/App/QDomNodeModel.cpp deleted file mode 100644 index 702902ff34..0000000000 --- a/src/Mod/TechDraw/App/QDomNodeModel.cpp +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright (c) 2011 Stanislaw Adaszewski, portions (c) 2019 Tomas Pavlicek -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of Stanislaw Adaszewski nor the -// names of other contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// * Used under BSD license 2.0 * - -#include "PreCompiled.h" - -#include -#include -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -#include "QDomNodeModel.h" -#include -#include -#include -#include - - -class PrivateDomNodeWrapper: public QDomNode -{ -public: - PrivateDomNodeWrapper(const QDomNode& other): - QDomNode(other) - { - } - - PrivateDomNodeWrapper(QDomNodePrivate *otherImpl): - QDomNode(otherImpl) - { - } - - QDomNodePrivate* getImpl() - { - return impl; - } -}; - -QDomNodeModel::QDomNodeModel(QXmlNamePool pool, QDomDocument doc, bool parsedReadOnly): - m_Pool(pool), m_Doc(doc), m_ReadOnly(parsedReadOnly) -{ - -} - -QUrl QDomNodeModel::baseUri (const QXmlNodeModelIndex &) const -{ - // TODO: Not implemented. - return QUrl(); -} - -#include - -QXmlNodeModelIndex::DocumentOrder QDomNodeModel::compareOrder ( - const QXmlNodeModelIndex & ni1, - const QXmlNodeModelIndex & ni2 ) const -{ - QDomNode n1 = toDomNode(ni1); - QDomNode n2 = toDomNode(ni2); - - if (n1 == n2) - return QXmlNodeModelIndex::Is; - - if (m_ReadOnly) - { - int i1 = n1.lineNumber(); - int i2 = n2.lineNumber(); - - if (i1 < i2) - return QXmlNodeModelIndex::Precedes; - - if (i1 > i2) - return QXmlNodeModelIndex::Follows; - - i1 = n1.columnNumber(); - i2 = n2.columnNumber(); - - if (i1 < i2) - return QXmlNodeModelIndex::Precedes; - - if (i1 > i2) - return QXmlNodeModelIndex::Follows; - - return QXmlNodeModelIndex::Is; - } - - QVector p1(path(n1)); - QVector p2(path(n2)); - - if (p1.at(0) != p2.at(0)) - return QXmlNodeModelIndex::Is; // When root is not common, return obvious nonsense - - int s = p1.size() < p2.size() ? p1.size() : p2.size(); - for (int i = 1; i < s; ++i) - { - if (p1.at(i) != p2.at(i)) - { - QDomNode c = p1.at(i - 1).firstChild(); - while (!c.isNull()) - { - if (c == p1.at(i)) - return QXmlNodeModelIndex::Precedes; - if (c == p2.at(i)) - return QXmlNodeModelIndex::Follows; - - c = c.nextSibling(); - } - - return QXmlNodeModelIndex::Is; // Should be impossible! - } - } - - return QXmlNodeModelIndex::Is; // Should be impossible! -} - -QUrl QDomNodeModel::documentUri (const QXmlNodeModelIndex&) const -{ - // TODO: Not implemented. - return QUrl(); -} - -QXmlNodeModelIndex QDomNodeModel::elementById ( const QXmlName & id ) const -{ - return fromDomNode(m_Doc.elementById(id.toClarkName(m_Pool))); -} - -QXmlNodeModelIndex::NodeKind QDomNodeModel::kind ( const QXmlNodeModelIndex & ni ) const -{ - QDomNode n = toDomNode(ni); - if (n.isAttr()) - return QXmlNodeModelIndex::Attribute; - else if (n.isText()) - return QXmlNodeModelIndex::Text; - else if (n.isComment()) - return QXmlNodeModelIndex::Comment; - else if (n.isDocument()) - return QXmlNodeModelIndex::Document; - else if (n.isElement()) - return QXmlNodeModelIndex::Element; - else if (n.isProcessingInstruction()) - return QXmlNodeModelIndex::ProcessingInstruction; - - return (QXmlNodeModelIndex::NodeKind) 0; -} - -QXmlName QDomNodeModel::name ( const QXmlNodeModelIndex & ni ) const -{ - QDomNode n = toDomNode(ni); - - if (n.isAttr() || n.isElement()) { - if (!n.namespaceURI().isEmpty()) - return QXmlName(m_Pool, n.localName(), n.namespaceURI(), n.prefix()); - - QString p = n.prefix(); - QString t = n.nodeName(); - - if (p.isEmpty()) - { - int c = t.indexOf(QLatin1Char(':')); - if (c < 0) - p = QString::fromUtf8(""); - else - { - p = t.left(c); - t = t.mid(c + 1); - } - } - - QVector ns(namespaceBindings(ni)); - int x; - for (x = 0; x < ns.size(); ++x) - if (ns.at(x).prefix(m_Pool) == p) break; - - if (x < ns.size()) - return QXmlName(m_Pool, t, ns.at(x).namespaceUri(m_Pool), p); - } - - return QXmlName(m_Pool, n.nodeName(), QString(), QString()); -} - -QVector QDomNodeModel::namespaceBindings(const QXmlNodeModelIndex & ni) const -{ - QDomNode n = toDomNode(ni); - bool xmlNamespaceWasDefined = false; - - QVector res; - while (!n.isNull()) - { - QDomNamedNodeMap attrs = n.attributes(); - for (int i = 0; i < attrs.size(); ++i) - { - QString a = attrs.item(i).nodeName(); - - QString p; - if (a == QString::fromUtf8("xmlns")) - p = QString::fromUtf8(""); - else if (a.startsWith(QString::fromUtf8("xmlns:"))) - p = a.mid(6); - - if (!p.isNull()) - { - int x; - for (x = 0; x < res.size(); ++x) - if (res.at(x).prefix(m_Pool) == p) break; - - if (x >= res.size()) { - res.append(QXmlName(m_Pool, QString::fromUtf8("xmlns"), attrs.item(i).nodeValue(), p)); - if (p == QString::fromLatin1("xml")) - xmlNamespaceWasDefined = true; - } - } - } - - n = n.parentNode(); - } - - // Per the XML standard: - // "The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but - // need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to - // this namespace name, and it MUST NOT be declared as the default namespace." - // - // If the document does not specifically include this namespace, add it now: - if (!xmlNamespaceWasDefined) { - res.append(QXmlName(m_Pool, QString::fromUtf8("xmlns"), QString::fromLatin1("http://www.w3.org/XML/1998/namespace"), QString::fromLatin1("xml"))); - } - - return res; -} - -QVector QDomNodeModel::nodesByIdref(const QXmlName&) const -{ - // TODO: Not implemented. - return QVector(); -} - -QXmlNodeModelIndex QDomNodeModel::root ( const QXmlNodeModelIndex & ni ) const -{ - QDomNode n = toDomNode(ni); - while (!n.parentNode().isNull()) - n = n.parentNode(); - - return fromDomNode(n); -} - -QSourceLocation QDomNodeModel::sourceLocation(const QXmlNodeModelIndex&) const -{ - // TODO: Not implemented. - return QSourceLocation(); -} - -QString QDomNodeModel::stringValue ( const QXmlNodeModelIndex & ni ) const -{ - QDomNode n = toDomNode(ni); - - if (n.isProcessingInstruction()) - return n.toProcessingInstruction().data(); - else if (n.isText()) - return n.toText().data(); - else if (n.isComment()) - return n.toComment().data(); - else if (n.isElement()) - return n.toElement().text(); - else if (n.isDocument()) - return n.toDocument().documentElement().text(); - else if (n.isAttr()) - return n.toAttr().value(); - - return QString(); -} - -QVariant QDomNodeModel::typedValue ( const QXmlNodeModelIndex & ni ) const -{ - return QVariant::fromValue(stringValue(ni)); -} - -QXmlNodeModelIndex QDomNodeModel::fromDomNode(const QDomNode &n) const -{ - if (n.isNull()) - return QXmlNodeModelIndex(); - - return createIndex(PrivateDomNodeWrapper(n).getImpl(), 0); -} - -QDomNode QDomNodeModel::toDomNode(const QXmlNodeModelIndex &ni) const -{ - return PrivateDomNodeWrapper((QDomNodePrivate*) ni.data()); -} - -QVector QDomNodeModel::path(const QDomNode &n) const -{ - QVector res; - QDomNode cur = n; - while (!cur.isNull()) - { - res.push_back(cur); - cur = cur.parentNode(); - } - - std::reverse(res.begin(), res.end()); - return res; -} - -int QDomNodeModel::childIndex(const QDomNode &n) const -{ - QDomNodeList children = n.parentNode().childNodes(); - for (int i = 0; i < children.size(); i++) - if (children.at(i) == n) - return i; - - return -1; -} - -QVector QDomNodeModel::attributes ( const QXmlNodeModelIndex & ni ) const -{ - QDomElement n = toDomNode(ni).toElement(); - QDomNamedNodeMap attrs = n.attributes(); - QVector res; - for (int i = 0; i < attrs.size(); i++) - { - res.push_back(fromDomNode(attrs.item(i))); - } - return res; -} - -QXmlNodeModelIndex QDomNodeModel::nextFromSimpleAxis ( SimpleAxis axis, const QXmlNodeModelIndex & ni) const -{ - QDomNode n = toDomNode(ni); - switch(axis) - { - case Parent: - return fromDomNode(n.parentNode()); - - case FirstChild: - return fromDomNode(n.firstChild()); - - case PreviousSibling: - return fromDomNode(n.previousSibling()); - - case NextSibling: - return fromDomNode(n.nextSibling()); - } - - return QXmlNodeModelIndex(); -} -#endif diff --git a/src/Mod/TechDraw/App/QDomNodeModel.h b/src/Mod/TechDraw/App/QDomNodeModel.h deleted file mode 100644 index de1d55b94e..0000000000 --- a/src/Mod/TechDraw/App/QDomNodeModel.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2011 Stanislaw Adaszewski, portions (c) 2019 Tomas Pavlicek -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of Stanislaw Adaszewski nor the -// names of other contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// * Used under BSD license 2.0 * - -#ifndef QDOMNODEMODEL_H_ -#define QDOMNODEMODEL_H_ - -#include - -#include -#include -#include - - -class TechDrawExport QDomNodeModel: public QAbstractXmlNodeModel -{ -public: - QDomNodeModel(QXmlNamePool, QDomDocument, bool parsedReadOnly = false); - QUrl baseUri ( const QXmlNodeModelIndex & n ) const; - QXmlNodeModelIndex::DocumentOrder compareOrder ( const QXmlNodeModelIndex & ni1, const QXmlNodeModelIndex & ni2 ) const; - QUrl documentUri ( const QXmlNodeModelIndex & n ) const; - QXmlNodeModelIndex elementById ( const QXmlName & id ) const; - QXmlNodeModelIndex::NodeKind kind ( const QXmlNodeModelIndex & ni ) const; - QXmlName name ( const QXmlNodeModelIndex & ni ) const; - QVector namespaceBindings ( const QXmlNodeModelIndex & n ) const; - QVector nodesByIdref ( const QXmlName & idref ) const; - QXmlNodeModelIndex root ( const QXmlNodeModelIndex & n ) const; - QSourceLocation sourceLocation ( const QXmlNodeModelIndex & index ) const; - QString stringValue ( const QXmlNodeModelIndex & n ) const; - QVariant typedValue ( const QXmlNodeModelIndex & node ) const; - -public: - QXmlNodeModelIndex fromDomNode (const QDomNode&) const; - QDomNode toDomNode(const QXmlNodeModelIndex &) const; - QVector path(const QDomNode&) const; - int childIndex(const QDomNode&) const; - -protected: - QVector attributes ( const QXmlNodeModelIndex & element ) const; - QXmlNodeModelIndex nextFromSimpleAxis ( SimpleAxis axis, const QXmlNodeModelIndex & origin) const; - -private: - mutable QXmlNamePool m_Pool; - mutable QDomDocument m_Doc; - bool m_ReadOnly; -}; - -#endif // QDOMNODEMODEL_H_ diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index 9b77c388eb..c199ab9bea 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -24,12 +24,6 @@ include_directories( ${XercesC_INCLUDE_DIRS} ) -if(FREECAD_QT_MAJOR_VERSION EQUAL 5) - include_directories( - ${QtXmlPatterns_INCLUDE_DIRS} - ) -endif() - # The XML files set(TechDrawGui_XML_SRCS ) diff --git a/tools/build/Docker/debian.sh b/tools/build/Docker/debian.sh index 2fd181a679..c0be1bc08d 100755 --- a/tools/build/Docker/debian.sh +++ b/tools/build/Docker/debian.sh @@ -8,7 +8,7 @@ apt-get install --no-install-recommends --yes build-essential cmake doxygen \ libocct-draw-dev libocct-foundation-dev libocct-modeling-algorithms-dev \ libocct-modeling-data-dev libocct-ocaf-dev libocct-visualization-dev \ libopencv-dev libproj-dev libpyside2-dev libqt5svg5-dev libqt5webkit5-dev \ - libqt5xmlpatterns5-dev libshiboken2-dev libvtk9-dev libvtk9-qt-dev \ + libshiboken2-dev libvtk9-dev libvtk9-qt-dev \ libvtk-dicom-dev libx11-dev libxerces-c-dev libxmu-dev libxmuu-dev \ libzipios++-dev netgen netgen-headers pyside2-tools python3-dev \ python3-matplotlib python3-pivy python3-ply python3-pyside2.qtsvg \ diff --git a/tools/build/Docker/fedora.sh b/tools/build/Docker/fedora.sh index 2819f855fd..3d06e6812e 100644 --- a/tools/build/Docker/fedora.sh +++ b/tools/build/Docker/fedora.sh @@ -4,6 +4,6 @@ dnf --assumeyes install boost-devel cmake Coin3 Coin3-devel desktop-file-utils d libXmu-devel med med-devel mesa-libGLU-devel ode-devel opencascade-devel \ opencv-devel openmpi-devel pcl-devel pyside2-tools python3 python3-devel \ python3-matplotlib python3-pivy python3-pyside2-devel qt5-qtsvg-devel \ - qt5-qttools-static qt5-qtxmlpatterns qt5-qtxmlpatterns-devel qt-devel \ + qt5-qttools-static qt-devel \ qt-webkit-devel smesh-devel SoQt-devel swig tbb-devel vtk xerces-c xerces-c-devel diff --git a/tools/build/Docker/ubuntu.sh b/tools/build/Docker/ubuntu.sh index c342a2283a..7f3a30a444 100644 --- a/tools/build/Docker/ubuntu.sh +++ b/tools/build/Docker/ubuntu.sh @@ -8,7 +8,7 @@ apt-get install --no-install-recommends --yes build-essential cmake doxygen git libocct-draw-dev libocct-foundation-dev libocct-modeling-algorithms-dev \ libocct-modeling-data-dev libocct-ocaf-dev libocct-visualization-dev \ libopencv-dev libproj-dev libpyside2-dev libqt5svg5-dev libqt5webkit5-dev \ - libqt5xmlpatterns5-dev libshiboken2-dev libvtk9-dev libvtk9-qt-dev \ + libshiboken2-dev libvtk9-dev libvtk9-qt-dev \ libvtk-dicom-dev libx11-dev libxerces-c-dev libxmu-dev libxmuu-dev \ libzipios++-dev netgen netgen-headers pyside2-tools python3-dev \ python3-matplotlib python3-pivy python3-ply python3-pyside2.qtsvg \