Commit 1cd91539 authored by Brad Hards's avatar Brad Hards
Browse files

Add support for page layout to the Qt4 bindings, plus

test cases.
parent 4e050aef
......@@ -10,6 +10,14 @@
2005-07-07 Brad Hards <bradh@frogmouth.net>
* qt4/src/poppler-document.cc:
* qt4/src/poppler-qt4.h: Add pageLayout() function for Qt4
bindings
* qt4/tests/check_pagelayout_single.cpp:
* qt4/tests/check_pagelayout_none.cpp:
* Makefile.am: Add unit tests for pageLayout()
* glib/poppler-document.cc (convert_page_mode): Update to
reflect the Catalog API change. I'm not that good at glib,
so this has a non-zero chance of being pure crackrock.
......
......@@ -112,6 +112,28 @@ namespace Poppler {
}
}
Document::PageLayout Document::pageLayout(void) const
{
switch (m_doc->doc.getCatalog()->getPageLayout()) {
case Catalog::pageLayoutNone:
return NoLayout;
case Catalog::pageLayoutSinglePage:
return SinglePage;
case Catalog::pageLayoutOneColumn:
return OneColumn;
case Catalog::pageLayoutTwoColumnLeft:
return TwoColumnLeft;
case Catalog::pageLayoutTwoColumnRight:
return TwoColumnRight;
case Catalog::pageLayoutTwoPageLeft:
return TwoPageLeft;
case Catalog::pageLayoutTwoPageRight:
return TwoPageRight;
default:
return NoLayout;
}
}
int Document::numPages() const
{
return m_doc->doc.getNumPages();
......
......@@ -176,7 +176,7 @@ namespace Poppler {
public:
/**
The mode
The page mode
*/
enum PageMode {
UseNone, ///< No mode - neither document outline nor thumbnail images are visible
......@@ -187,6 +187,19 @@ namespace Poppler {
UseAttach ///< Attachments panel visible
};
/**
The page layout
*/
enum PageLayout {
NoLayout, ///< Layout not specified
SinglePage, ///< Display a single page
OneColumn, ///< Display a single column of pages
TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left
TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right
TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left
TwoPageRight, ///< Display the pages two at a time, with odd-numbered pages on the right
};
/**
Load the document from a file on disk
......@@ -223,10 +236,19 @@ namespace Poppler {
int numPages() const;
/**
The type of mode that is in use
The type of mode that should be used by the application
when the document is opened. Note that while this is
called page mode, it is really viewer application mode.
*/
PageMode pageMode() const;
/**
The layout that pages should be shown in when the document
is first opened. This basically describes how pages are
shown relative to each other.
*/
PageLayout pageLayout() const;
/**
Provide the passwords required to unlock the document
*/
......
......@@ -40,7 +40,9 @@ TESTS = \
check_pagemode_attach \
check_pagemode_none \
check_pagemode_thumbs \
check_pagemode_oc
check_pagemode_oc \
check_pagelayout_none \
check_pagelayout_single
check_PROGRAMS = $(TESTS)
......@@ -71,3 +73,9 @@ check_pagemode_thumbs_LDADD = $(LDADDS)
check_pagemode_oc_SOURCES = check_pagemode_oc.cpp
check_pagemode_oc_LDADD = $(LDADDS)
check_pagelayout_single_SOURCES = check_pagelayout_single.cpp
check_pagelayout_single_LDADD = $(LDADDS)
check_pagelayout_none_SOURCES = check_pagelayout_none.cpp
check_pagelayout_none_LDADD = $(LDADDS)
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/UseNone.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageLayout() == Poppler::Document::NoLayout ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/FullScreen.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageLayout() == Poppler::Document::SinglePage ) )
{
exit(1);
}
exit(0);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment