Hello, attached is a proposal to add a method to the Qt frontend by which viewers can determine the predominant text direction from the viewer preferences in the document's catalog.
Best regards, Adam.
>From 6e8226c6b294ff10ed2c8c4d3db9327bc71feae2 Mon Sep 17 00:00:00 2001 From: Adam Reichold <[email protected]> Date: Mon, 3 Mar 2014 18:21:21 +0100 Subject: [PATCH] Expose document-supplied text direction in Qt frontend. Adds a method textDirection to the class Document of the Qt4 and Qt5 frontends returning the document-supplied predominant reading order for text which may be used by viewers to determine the relative positioning of pages when displayed side by side or printed n-up. --- qt4/src/poppler-document.cc | 16 ++++++++++++++++ qt4/src/poppler-qt4.h | 8 ++++++++ qt5/src/poppler-document.cc | 16 ++++++++++++++++ qt5/src/poppler-qt5.h | 8 ++++++++ 4 files changed, 48 insertions(+) diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc index de7e36d..a2be73c 100644 --- a/qt4/src/poppler-document.cc +++ b/qt4/src/poppler-document.cc @@ -32,6 +32,7 @@ #include <PDFDoc.h> #include <Stream.h> #include <Catalog.h> +#include <ViewerPreferences.h> #include <DateInfo.h> #include <GfxState.h> @@ -193,6 +194,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..9dffb68 100644 --- a/qt4/src/poppler-qt4.h +++ b/qt4/src/poppler-qt4.h @@ -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..528ff53 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -32,6 +32,7 @@ #include <PDFDoc.h> #include <Stream.h> #include <Catalog.h> +#include <ViewerPreferences.h> #include <DateInfo.h> #include <GfxState.h> @@ -193,6 +194,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..2050703 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -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 -- 1.9.0
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
