[poppler] CMakeLists.txt qt5/src qt6/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 13 16:45:32 UTC 2020


 CMakeLists.txt              |    6 +--
 qt5/src/poppler-qt5.h       |    2 -
 qt6/src/CMakeLists.txt      |    2 -
 qt6/src/poppler-document.cc |   17 --------
 qt6/src/poppler-private.cc  |   87 --------------------------------------------
 qt6/src/poppler-private.h   |    2 -
 qt6/src/poppler-qt6.h       |   27 -------------
 7 files changed, 6 insertions(+), 137 deletions(-)

New commits:
commit 31731735e1176136b4f853762a4da59e61064f80
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Jul 13 18:40:24 2020 +0200

    Deprecated Document::toc in qt5 and remove it in qt6
    
    Use Document::outline instead
    
    Allows us to not link to QtXml anymore in qt6

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 855ed842..76502a8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -163,9 +163,9 @@ if (ENABLE_QT5)
 endif()
 
 if (ENABLE_QT6)
-  find_package(Qt6 COMPONENTS Core Gui Xml Widgets Test QUIET)
-  if (NOT (Qt6Core_FOUND AND Qt6Gui_FOUND AND Qt6Xml_FOUND AND Qt6Widgets_FOUND AND Qt6Test_FOUND))
-    message("-- Package Qt6Core or Qt6Gui or Qt6Xml or Qt6Widgets or Qt6Test not found")
+  find_package(Qt6 COMPONENTS Core Gui Widgets Test QUIET)
+  if (NOT (Qt6Core_FOUND AND Qt6Gui_FOUND AND Qt6Widgets_FOUND AND Qt6Test_FOUND))
+    message("-- Package Qt6Core or Qt6Gui or Qt6Widgets or Qt6Test not found")
     set(ENABLE_QT6 OFF)
   endif()
 endif()
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index 3bcf2e33..5e78c9e5 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -1706,7 +1706,7 @@ QString subject = m_doc->info("Subject");
 
       \returns the TOC, or NULL if the Document does not have one
     */
-    QDomDocument *toc() const;
+    Q_DECL_DEPRECATED QDomDocument *toc() const;
 
     /**
        Gets the outline of the document
diff --git a/qt6/src/CMakeLists.txt b/qt6/src/CMakeLists.txt
index 4af085e1..3ea54420 100644
--- a/qt6/src/CMakeLists.txt
+++ b/qt6/src/CMakeLists.txt
@@ -42,7 +42,7 @@ if(MINGW AND BUILD_SHARED_LIBS)
     get_target_property(POPPLER_QT6_SOVERSION poppler-qt6 SOVERSION)
     set_target_properties(poppler-qt6 PROPERTIES SUFFIX "-${POPPLER_QT6_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
 endif()
-target_link_libraries(poppler-qt6 poppler Qt6::Core Qt6::Gui Qt6::Xml ${FREETYPE_LIBRARIES})
+target_link_libraries(poppler-qt6 poppler Qt6::Core Qt6::Gui ${FREETYPE_LIBRARIES})
 if(MSVC)
 target_link_libraries(poppler-qt6 poppler ${poppler_LIBS})
 endif()
diff --git a/qt6/src/poppler-document.cc b/qt6/src/poppler-document.cc
index c3778196..55b1858f 100644
--- a/qt6/src/poppler-document.cc
+++ b/qt6/src/poppler-document.cc
@@ -571,23 +571,6 @@ bool Document::hasEmbeddedFiles() const
     return (!(0 == m_doc->doc->getCatalog()->numEmbeddedFiles()));
 }
 
-QDomDocument *Document::toc() const
-{
-    Outline *outline = m_doc->doc->getOutline();
-    if (!outline)
-        return nullptr;
-
-    const std::vector<::OutlineItem *> *items = outline->getItems();
-    if (!items || items->size() < 1)
-        return nullptr;
-
-    QDomDocument *toc = new QDomDocument();
-    if (items->size() > 0)
-        m_doc->addTocChildren(toc, toc, items);
-
-    return toc;
-}
-
 QVector<OutlineItem> Document::outline() const
 {
     QVector<OutlineItem> result;
diff --git a/qt6/src/poppler-private.cc b/qt6/src/poppler-private.cc
index 4d4e1c5f..44a9a6dc 100644
--- a/qt6/src/poppler-private.cc
+++ b/qt6/src/poppler-private.cc
@@ -176,63 +176,6 @@ Annot::AdditionalActionsType toPopplerAdditionalActionType(Annotation::Additiona
     return Annot::actionCursorEntering;
 }
 
-static void linkActionToTocItem(const ::LinkAction *a, DocumentData *doc, QDomElement *e)
-{
-    if (!a || !e)
-        return;
-
-    switch (a->getKind()) {
-    case actionGoTo: {
-        // page number is contained/referenced in a LinkGoTo
-        const LinkGoTo *g = static_cast<const LinkGoTo *>(a);
-        const LinkDest *destination = g->getDest();
-        if (!destination && g->getNamedDest()) {
-            // no 'destination' but an internal 'named reference'. we could
-            // get the destination for the page now, but it's VERY time consuming,
-            // so better storing the reference and provide the viewport on demand
-            const GooString *s = g->getNamedDest();
-            QChar *charArray = new QChar[s->getLength()];
-            for (int i = 0; i < s->getLength(); ++i)
-                charArray[i] = QChar(s->c_str()[i]);
-            QString aux(charArray, s->getLength());
-            e->setAttribute(QStringLiteral("DestinationName"), aux);
-            delete[] charArray;
-        } else if (destination && destination->isOk()) {
-            LinkDestinationData ldd(destination, nullptr, doc, false);
-            e->setAttribute(QStringLiteral("Destination"), LinkDestination(ldd).toString());
-        }
-        break;
-    }
-    case actionGoToR: {
-        // page number is contained/referenced in a LinkGoToR
-        const LinkGoToR *g = static_cast<const LinkGoToR *>(a);
-        const LinkDest *destination = g->getDest();
-        if (!destination && g->getNamedDest()) {
-            // no 'destination' but an internal 'named reference'. we could
-            // get the destination for the page now, but it's VERY time consuming,
-            // so better storing the reference and provide the viewport on demand
-            const GooString *s = g->getNamedDest();
-            QChar *charArray = new QChar[s->getLength()];
-            for (int i = 0; i < s->getLength(); ++i)
-                charArray[i] = QChar(s->c_str()[i]);
-            QString aux(charArray, s->getLength());
-            e->setAttribute(QStringLiteral("DestinationName"), aux);
-            delete[] charArray;
-        } else if (destination && destination->isOk()) {
-            LinkDestinationData ldd(destination, nullptr, doc, g->getFileName() != nullptr);
-            e->setAttribute(QStringLiteral("Destination"), LinkDestination(ldd).toString());
-        }
-        e->setAttribute(QStringLiteral("ExternalFileName"), g->getFileName()->c_str());
-        break;
-    }
-    case actionURI: {
-        const LinkURI *u = static_cast<const LinkURI *>(a);
-        e->setAttribute(QStringLiteral("DestinationURI"), u->getURI().c_str());
-    }
-    default:;
-    }
-}
-
 DocumentData::~DocumentData()
 {
     qDeleteAll(m_embeddedFiles);
@@ -248,36 +191,6 @@ void DocumentData::init()
     m_optContentModel = nullptr;
 }
 
-void DocumentData::addTocChildren(QDomDocument *docSyn, QDomNode *parent, const std::vector<::OutlineItem *> *items)
-{
-    for (::OutlineItem *outlineItem : *items) {
-        // iterate over every object in 'items'
-
-        // 1. create element using outlineItem's title as tagName
-        QString name;
-        const Unicode *uniChar = outlineItem->getTitle();
-        int titleLength = outlineItem->getTitleLength();
-        name = unicodeToQString(uniChar, titleLength);
-        if (name.isEmpty())
-            continue;
-
-        QDomElement item = docSyn->createElement(name);
-        parent->appendChild(item);
-
-        // 2. find the page the link refers to
-        const ::LinkAction *a = outlineItem->getAction();
-        linkActionToTocItem(a, this, &item);
-
-        item.setAttribute(QStringLiteral("Open"), QVariant((bool)outlineItem->isOpen()).toString());
-
-        // 3. recursively descend over children
-        outlineItem->open();
-        const std::vector<::OutlineItem *> *children = outlineItem->getKids();
-        if (children)
-            addTocChildren(docSyn, &item, children);
-    }
-}
-
 FormWidget *FormFieldData::getFormWidget(const FormField *f)
 {
     return f->m_formData->fm;
diff --git a/qt6/src/poppler-private.h b/qt6/src/poppler-private.h
index 3caaf236..11c8c1a9 100644
--- a/qt6/src/poppler-private.h
+++ b/qt6/src/poppler-private.h
@@ -143,8 +143,6 @@ public:
     DocumentData(const DocumentData &) = delete;
     DocumentData &operator=(const DocumentData &) = delete;
 
-    void addTocChildren(QDomDocument *docSyn, QDomNode *parent, const std::vector<::OutlineItem *> *items);
-
     void setPaperColor(const QColor &color) { paperColor = color; }
 
     void fillMembers()
diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h
index a4ad1884..b129db94 100644
--- a/qt6/src/poppler-qt6.h
+++ b/qt6/src/poppler-qt6.h
@@ -48,8 +48,8 @@
 
 #include <QtCore/QByteArray>
 #include <QtCore/QDateTime>
+#include <QtCore/QIODevice>
 #include <QtCore/QSet>
-#include <QtXml/QDomDocument>
 #include "poppler-export.h"
 
 class EmbFile;
@@ -1576,31 +1576,6 @@ QString subject = m_doc->info("Subject");
     */
     bool hasEmbeddedFiles() const;
 
-    /**
-      Gets the table of contents (TOC) of the Document.
-
-      The caller is responsible for the returned object.
-
-      In the tree the tag name is the 'screen' name of the entry. A tag can have
-      attributes. Here follows the list of tag attributes with meaning:
-      - Destination: A string description of the referred destination
-      - DestinationName: A 'named reference' to the viewport
-      - ExternalFileName: A link to a external filename
-      - Open: A bool value that tells whether the subbranch of the item is open or not
-
-      Resolving the final destination for each item can be done in the following way:
-      - first, checking for 'Destination': if not empty, then a LinkDestination
-        can be constructed straight with it
-      - as second step, if the 'DestinationName' is not empty, then the destination
-        can be resolved using linkDestination()
-
-      Note also that if 'ExternalFileName' is not emtpy, then the destination refers
-      to that document (and not to the current one).
-
-      \returns the TOC, or NULL if the Document does not have one
-    */
-    QDomDocument *toc() const;
-
     /**
        Gets the outline of the document
 


More information about the poppler mailing list