[poppler] qt5/src qt5/tests
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 9 07:08:31 UTC 2019
qt5/src/poppler-form.cc | 16 ++++++++++++++++
qt5/src/poppler-form.h | 12 ++++++++++++
qt5/tests/check_forms.cpp | 20 ++++++++++++++++++++
3 files changed, 48 insertions(+)
New commits:
commit 04e8309d18fa2f90ed93930e7eb689e523c7eb44
Author: João Netto <joaonetto901 at gmail.com>
Date: Mon Jul 8 20:43:19 2019 -0300
Added option to set the form available to print
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"
More information about the poppler
mailing list