summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Netto <joaonetto901@gmail.com>2019-07-08 20:43:19 -0300
committerJoão Netto <joaonetto901@gmail.com>2019-07-08 21:31:08 -0300
commit04e8309d18fa2f90ed93930e7eb689e523c7eb44 (patch)
tree12e1c863a311fe435ff7c1930176d779c4c8954f
parent6afe59eb8bcb223d28eef5bb364ebb4d35ed0f59 (diff)
Added option to set the form available to print
-rw-r--r--qt5/src/poppler-form.cc16
-rw-r--r--qt5/src/poppler-form.h12
-rw-r--r--qt5/tests/check_forms.cpp20
3 files changed, 48 insertions, 0 deletions
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index fa9c3312..111d5b09 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -207,6 +207,22 @@ void FormField::setVisible(bool value)
m_formData->fm->getWidgetAnnotation()->setFlags(flags);
}
+bool FormField::isPrintable() const
+{
+ return (m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagPrint);
+}
+
+void FormField::setPrintable(bool value)
+{
+ unsigned int flags = m_formData->fm->getWidgetAnnotation()->getFlags();
+ if (value) {
+ flags |= Annot::flagPrint;
+ } else {
+ flags &= ~Annot::flagPrint;
+ }
+ m_formData->fm->getWidgetAnnotation()->setFlags(flags);
+}
+
Link* FormField::activationAction() const
{
Link* action = nullptr;
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index f4c64589..ac00da26 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -155,6 +155,18 @@ namespace Poppler {
void setVisible(bool value);
/**
+ Whether this field is printable.
+ \since 0.79
+ */
+ bool isPrintable() const;
+
+ /**
+ Set whether this field is printable.
+ \since 0.79
+ */
+ void setPrintable(bool value);
+
+ /**
The activation action of this form field.
\note It may be null.
diff --git a/qt5/tests/check_forms.cpp b/qt5/tests/check_forms.cpp
index ec48ce91..f139ed1f 100644
--- a/qt5/tests/check_forms.cpp
+++ b/qt5/tests/check_forms.cpp
@@ -14,6 +14,7 @@ private slots:
void testCheckbox();// Test for issue #655
void testCheckboxIssue159();// Test for issue #159
void testSetIcon();// Test that setIcon will always be valid.
+ void testSetPrintable();
};
void TestForms::testCheckbox()
@@ -148,5 +149,24 @@ void TestForms::testSetIcon()
QVERIFY( Poppler::FormFieldIconData::getData( anmIcon )->icon );
}
+void TestForms::testSetPrintable()
+{
+ QScopedPointer< Poppler::Document > document(Poppler::Document::load(TESTDATADIR "/unittestcases/form_set_icon.pdf"));
+ QVERIFY( document );
+
+ QScopedPointer< Poppler::Page > page(document->page(0));
+ QVERIFY( page );
+
+ QList<Poppler::FormField*> forms = page->formFields();
+
+ Q_FOREACH (Poppler::FormField *field, forms) {
+ field->setPrintable( true );
+ QCOMPARE( field->isPrintable(), true );
+
+ field->setPrintable( false );
+ QCOMPARE( field->isPrintable(), false );
+ }
+}
+
QTEST_GUILESS_MAIN(TestForms)
#include "check_forms.moc"