[poppler] 2 commits - qt5/src qt5/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Sep 22 18:09:09 UTC 2018


 qt5/src/poppler-page.cc           |    4 +++
 qt5/src/poppler-qt5.h             |    9 ++++++-
 qt5/tests/CMakeLists.txt          |    1 
 qt5/tests/poppler-page-labels.cpp |   48 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 1 deletion(-)

New commits:
commit e39fceea516b8c1b17d8719433a1e3e81cc32cee
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Sep 22 19:42:52 2018 +0200

    qt5: Add simple tool to print the labels of pages

diff --git a/qt5/tests/CMakeLists.txt b/qt5/tests/CMakeLists.txt
index e808f181..13768031 100644
--- a/qt5/tests/CMakeLists.txt
+++ b/qt5/tests/CMakeLists.txt
@@ -53,6 +53,7 @@ qt5_add_simpletest(stress-poppler-qt5 stress-poppler-qt5.cpp)
 qt5_add_simpletest(stress-poppler-dir-qt5 stress-poppler-dir.cpp)
 qt5_add_simpletest(stress-threads-qt5 stress-threads-qt5.cpp)
 qt5_add_simpletest(poppler-qt5-texts poppler-texts.cpp)
+qt5_add_simpletest(poppler-qt5-page-labels poppler-page-labels.cpp)
 
 qt5_add_qtest(check_qt5_attachments check_attachments.cpp)
 qt5_add_qtest(check_qt5_dateConversion check_dateConversion.cpp)
diff --git a/qt5/tests/poppler-page-labels.cpp b/qt5/tests/poppler-page-labels.cpp
new file mode 100644
index 00000000..5f1b504d
--- /dev/null
+++ b/qt5/tests/poppler-page-labels.cpp
@@ -0,0 +1,48 @@
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+
+#include <iostream>
+#include <memory>
+
+#include <poppler-qt5.h>
+
+int main( int argc, char **argv )
+{
+    QCoreApplication a( argc, argv );               // QApplication required!
+
+    if (!( argc == 2 ))
+    {
+        qWarning() << "usage: poppler-page-labels filename";
+        exit(1);
+    }
+
+    Poppler::Document *doc = Poppler::Document::load(argv[1]);
+    if (!doc || doc->isLocked())
+    {
+        qWarning() << "doc not loaded";
+        exit(1);
+    }
+
+    for ( int i = 0; i < doc->numPages(); i++ )
+    {
+      int j = 0;
+      std::cout << "*** Label of Page " << i << std::endl;
+      std::cout << std::flush;
+
+      std::unique_ptr<Poppler::Page> page(doc->page(i));
+
+      if (!page)
+          continue;
+
+      const QByteArray utf8str = page->label().toUtf8();
+      for ( j = 0; j < utf8str.size(); j++ )
+        std::cout << utf8str[j];
+      std::cout << std::endl;
+
+      std::unique_ptr<Poppler::Page> pageFromPageLabel(doc->page(page->label()));
+      const int indexFromPageLabel = pageFromPageLabel ? pageFromPageLabel->index() : -1;
+      if (indexFromPageLabel != i)
+        std::cout << "WARNING: Page label didn't link back to the same page index " << indexFromPageLabel << " " << i << std::endl;
+    }
+    delete doc;
+}
commit bc165c4ee67a950e0478b00792f9d160801735bf
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Sep 22 19:20:31 2018 +0200

    qt5: Add Page::index()

diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc
index b48ee959..45358213 100644
--- a/qt5/src/poppler-page.cc
+++ b/qt5/src/poppler-page.cc
@@ -986,5 +986,9 @@ QString Page::label() const
   return UnicodeParsedString(&goo);
 }
 
+int Page::index() const
+{
+  return m_page->index;
+}
 
 }
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index b70644f7..2998180e 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -1,7 +1,7 @@
 /* poppler-qt.h: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
  * Copyright (C) 2005, 2007, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2015, 2017, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2015, 2017, 2018, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus at math.uni-koeln.de>
  * Copyright (C) 2006-2011, Pino Toscano <pino at kde.org>
  * Copyright (C) 2009 Shawn Rutledge <shawn.t.rutledge at gmail.com>
@@ -960,6 +960,13 @@ delete it;
 	**/
 	QString label() const;
 	
+	/**
+	   Returns the index of the page, or a null string is the page has no label.
+
+	 \since 0.70
+	**/
+	int index() const;
+
     private:
 	Q_DISABLE_COPY(Page)
 


More information about the poppler mailing list