[poppler] poppler/Catalog.cc poppler/Catalog.h qt4/src utils/pdfinfo.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Sat Nov 3 06:02:25 PDT 2012
poppler/Catalog.cc | 19 +++++++++++++++++++
poppler/Catalog.h | 9 +++++++++
qt4/src/poppler-document.cc | 16 ++++++++++++++++
qt4/src/poppler-qt4.h | 18 ++++++++++++++++++
utils/pdfinfo.cc | 19 ++++++++++---------
5 files changed, 72 insertions(+), 9 deletions(-)
New commits:
commit 0f7c17d7f92d4cdfbd8816dba666aeed924d8bc2
Author: Fabio D'Urso <fabiodurso at hotmail.it>
Date: Fri Nov 2 10:54:17 2012 +0100
qt4: Export information about the document form type
This patch also wraps the code that checks the form type and moves it
from pdfinfo to the Catalog class.
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 0f42356..cf6dff0 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -24,6 +24,7 @@
// Copyright (C) 2008, 2011 Pino Toscano <pino at kde.org>
// Copyright (C) 2009 Ilya Gorenbein <igorenbein at finjan.com>
// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -864,6 +865,24 @@ Object *Catalog::getDests()
return &dests;
}
+Catalog::FormType Catalog::getFormType()
+{
+ Object xfa;
+ FormType res = NoForm;
+
+ if (acroForm.isDict()) {
+ acroForm.dictLookup("XFA", &xfa);
+ if (xfa.isStream() || xfa.isArray()) {
+ res = XfaForm;
+ } else {
+ res = AcroForm;
+ }
+ xfa.free();
+ }
+
+ return res;
+}
+
Form *Catalog::getForm()
{
if (!form) {
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index cdb1f13..ef469ec 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -20,6 +20,7 @@
// Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
// Copyright (C) 2008, 2011 Pino Toscano <pino at kde.org>
// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -153,6 +154,14 @@ public:
OCGs *getOptContentConfig() { return optContent; }
+ enum FormType
+ {
+ NoForm,
+ AcroForm,
+ XfaForm
+ };
+
+ FormType getFormType();
Form* getForm();
ViewerPreferences *getViewerPreferences();
diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 0cf1d45..ee56ed6 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -6,6 +6,7 @@
* Copyright (C) 2010, 2011 Hib Eris <hib at hiberis.nl>
* Copyright (C) 2012 Koji Otani <sho at bbr.jp>
* Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
+ * Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
*
* 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
@@ -612,6 +613,21 @@ namespace Poppler {
return true;
}
+ Document::FormType Document::formType() const
+ {
+ switch ( m_doc->doc->getCatalog()->getFormType() )
+ {
+ case Catalog::NoForm:
+ return Document::NoForm;
+ case Catalog::AcroForm:
+ return Document::AcroForm;
+ case Catalog::XfaForm:
+ return Document::XfaForm;
+ }
+
+ return Document::NoForm; // make gcc happy
+ }
+
QDateTime convertDate( char *dateString )
{
int year, mon, day, hour, min, sec, tzHours, tzMins;
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index 3002e65..f4f6fc6 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -853,6 +853,17 @@ delete it;
Q_DECLARE_FLAGS( RenderHints, RenderHint )
/**
+ Form types
+
+ \since 0.22
+ */
+ enum FormType {
+ NoForm, ///< Document doesn't contain forms
+ AcroForm, ///< AcroForm
+ XfaForm ///< Adobe XML Forms Architecture (XFA), currently unsupported
+ };
+
+ /**
Set a color display profile for the current document.
\param outputProfileA is a \c cmsHPROFILE of the LCMS library.
@@ -1364,6 +1375,13 @@ QString subject = m_doc->info("Subject");
bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const;
/**
+ Returns the type of forms contained in the document
+
+ \since 0.22
+ */
+ FormType formType() const;
+
+ /**
Destructor.
*/
~Document();
diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc
index 799a35c..bd8b56d 100644
--- a/utils/pdfinfo.cc
+++ b/utils/pdfinfo.cc
@@ -229,16 +229,17 @@ int main(int argc, char *argv[]) {
doc->getStructTreeRoot()->isDict() ? "yes" : "no");
// print form info
- if ((acroForm = doc->getCatalog()->getAcroForm())->isDict()) {
- acroForm->dictLookup("XFA", &xfa);
- if (xfa.isStream() || xfa.isArray()) {
- printf("Form: XFA\n");
- } else {
+ switch (doc->getCatalog()->getFormType())
+ {
+ case Catalog::NoForm:
+ printf("Form: none\n");
+ break;
+ case Catalog::AcroForm:
printf("Form: AcroForm\n");
- }
- xfa.free();
- } else {
- printf("Form: none\n");
+ break;
+ case Catalog::XfaForm:
+ printf("Form: XFA\n");
+ break;
}
// print page count
More information about the poppler
mailing list