[poppler] qt4/src qt5/src

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Mar 4 14:41:50 PST 2014


 qt4/src/poppler-document.cc |   17 +++++++++++++++++
 qt4/src/poppler-qt4.h       |   10 +++++++++-
 qt5/src/poppler-document.cc |   17 +++++++++++++++++
 qt5/src/poppler-qt5.h       |   10 +++++++++-
 4 files changed, 52 insertions(+), 2 deletions(-)

New commits:
commit b346df59ef0775f5bd74a9f7379b5f430ccd7b79
Author: Adam Reichold <adamreichold at myopera.com>
Date:   Tue Mar 4 23:40:59 2014 +0100

    Qt: Expose document-supplied text direction

diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index de7e36d..a1b0b11 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -7,6 +7,7 @@
  * Copyright (C) 2012 Koji Otani <sho at bbr.jp>
  * Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
  * Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
+ * Copyright (C) 2014 Adam Reichold <adamreichold at myopera.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,6 +33,7 @@
 #include <PDFDoc.h>
 #include <Stream.h>
 #include <Catalog.h>
+#include <ViewerPreferences.h>
 #include <DateInfo.h>
 #include <GfxState.h>
 
@@ -193,6 +195,21 @@ namespace Poppler {
 	}
     }
 
+    Qt::LayoutDirection Document::textDirection() const
+    {
+        if (!m_doc->doc->getCatalog()->getViewerPreferences())
+            return Qt::LayoutDirectionAuto;
+
+        switch (m_doc->doc->getCatalog()->getViewerPreferences()->getDirection()) {
+        case ViewerPreferences::directionL2R:
+            return Qt::LeftToRight;
+        case ViewerPreferences::directionR2L:
+            return Qt::RightToLeft;
+        default:
+            return Qt::LayoutDirectionAuto;
+        }
+    }
+
     int Document::numPages() const
     {
 	return m_doc->doc->getNumPages();
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index 72874ec..30295cf 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -12,7 +12,7 @@
  * Copyright (C) 2012, Guillermo A. Amaral B. <gamaral at kde.org>
  * Copyright (C) 2012, Fabio D'Urso <fabiodurso at hotmail.it>
  * Copyright (C) 2012, Tobias Koenig <tobias.koenig at kdab.com>
- * Copyright (C) 2012 Adam Reichold <adamreichold at myopera.com>
+ * Copyright (C) 2012, 2014 Adam Reichold <adamreichold at myopera.com>
  * Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -990,6 +990,14 @@ delete it;
 	PageLayout pageLayout() const;
 
 	/**
+	   The predominant reading order for text as supplied by
+	   the document's viewer preferences.
+
+	   \since 0.26
+	*/
+	Qt::LayoutDirection textDirection() const;
+
+	/**
 	   Provide the passwords required to unlock the document
 
 	   \param ownerPassword the Latin1-encoded owner password to use in
diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc
index 158d506..21f0633 100644
--- a/qt5/src/poppler-document.cc
+++ b/qt5/src/poppler-document.cc
@@ -7,6 +7,7 @@
  * Copyright (C) 2012 Koji Otani <sho at bbr.jp>
  * Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
  * Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
+ * Copyright (C) 2014 Adam Reichold <adamreichold at myopera.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,6 +33,7 @@
 #include <PDFDoc.h>
 #include <Stream.h>
 #include <Catalog.h>
+#include <ViewerPreferences.h>
 #include <DateInfo.h>
 #include <GfxState.h>
 
@@ -193,6 +195,21 @@ namespace Poppler {
 	}
     }
 
+    Qt::LayoutDirection Document::textDirection() const
+    {
+        if (!m_doc->doc->getCatalog()->getViewerPreferences())
+            return Qt::LayoutDirectionAuto;
+
+        switch (m_doc->doc->getCatalog()->getViewerPreferences()->getDirection()) {
+        case ViewerPreferences::directionL2R:
+            return Qt::LeftToRight;
+        case ViewerPreferences::directionR2L:
+            return Qt::RightToLeft;
+        default:
+            return Qt::LayoutDirectionAuto;
+        }
+    }
+
     int Document::numPages() const
     {
 	return m_doc->doc->getNumPages();
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index 0eb0b44..6f36088 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -12,7 +12,7 @@
  * Copyright (C) 2012, Guillermo A. Amaral B. <gamaral at kde.org>
  * Copyright (C) 2012, Fabio D'Urso <fabiodurso at hotmail.it>
  * Copyright (C) 2012, Tobias Koenig <tobias.koenig at kdab.com>
- * Copyright (C) 2012 Adam Reichold <adamreichold at myopera.com>
+ * Copyright (C) 2012, 2014 Adam Reichold <adamreichold at myopera.com>
  * Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
  * Copyright (C) 2013 Anthony Granger <grangeranthony at gmail.com>
  *
@@ -979,6 +979,14 @@ delete it;
 	PageLayout pageLayout() const;
 
 	/**
+	   The predominant reading order for text as supplied by
+	   the document's viewer preferences.
+
+	   \since 0.26
+	*/
+	Qt::LayoutDirection textDirection() const;
+
+	/**
 	   Provide the passwords required to unlock the document
 
 	   \param ownerPassword the Latin1-encoded owner password to use in


More information about the poppler mailing list