Commit 0f7c17d7 authored by Fabio D'Urso's avatar Fabio D'Urso Committed by Albert Astals Cid
Browse files

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.
parent f3f5a166
......@@ -24,6 +24,7 @@
// Copyright (C) 2008, 2011 Pino Toscano <pino@kde.org>
// Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com>
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@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) {
......
......@@ -20,6 +20,7 @@
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2008, 2011 Pino Toscano <pino@kde.org>
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@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();
......
......@@ -6,6 +6,7 @@
* Copyright (C) 2010, 2011 Hib Eris <hib@hiberis.nl>
* Copyright (C) 2012 Koji Otani <sho@bbr.jp>
* Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
* Copyright (C) 2012 Fabio D'Urso <fabiodurso@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;
......
......@@ -852,6 +852,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.
......@@ -1363,6 +1374,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.
*/
......
......@@ -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
......
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