[poppler] poppler/Form.cc poppler/Form.h qt5/src
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Mar 20 22:21:35 UTC 2018
poppler/Form.cc | 32 ++++++++++++++++++++++++++++++++
poppler/Form.h | 4 +++-
qt5/src/poppler-form.cc | 6 ++++++
qt5/src/poppler-form.h | 7 +++++++
4 files changed, 48 insertions(+), 1 deletion(-)
New commits:
commit 327c342a932d8df731ec02a6b22792004206c2db
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Tue Mar 20 23:07:15 2018 +0100
Add read only setter for form fields
Read only is modifiable from AcroForm scripts.
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 11b16c91..76545d17 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -19,6 +19,7 @@
// Copyright 2015 André Esser <bepandre at hotmail.com>
// Copyright 2017 Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
// Copyright 2017 Bernd Kuhls <berndkuhls at hotmail.com>
+// Copyright 2018 Andre Heinecke <aheinecke at intevation.de>
//
//========================================================================
@@ -135,6 +136,11 @@ bool FormWidget::isReadOnly() const
return field->isReadOnly();
}
+void FormWidget::setReadOnly(bool value)
+{
+ return field->setReadOnly(value);
+}
+
int FormWidget::encodeID (unsigned pageNum, unsigned fieldNum)
{
return (pageNum << 4*sizeof(unsigned)) + fieldNum;
@@ -939,6 +945,32 @@ void FormField::updateChildrenAppearance()
}
}
+void FormField::setReadOnly (bool value)
+{
+ if (value == readOnly) {
+ return;
+ }
+
+ readOnly = value;
+
+ Dict* dict = obj.getDict();
+
+ const Object obj1 = Form::fieldLookup(dict, "Ff");
+ int flags = 0;
+ if (obj1.isInt()) {
+ flags = obj1.getInt();
+ }
+ if (value) {
+ flags |= 1;
+ } else {
+ flags &= ~1;
+ }
+
+ dict->set("Ff", Object(flags));
+ xref->setModifiedObject(&obj, ref);
+ updateChildrenAppearance();
+}
+
//------------------------------------------------------------------------
// FormFieldButton
//------------------------------------------------------------------------
diff --git a/poppler/Form.h b/poppler/Form.h
index 8f7cb377..a4c59fb1 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -15,6 +15,7 @@
// Copyright 2015 André Esser <bepandre at hotmail.com>
// Copyright 2017 Roland Hieber <r.hieber at pengutronix.de>
// Copyright 2017 Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
+// Copyright 2018 Andre Heinecke <aheinecke at intevation.de>
//
//========================================================================
@@ -118,6 +119,7 @@ public:
GBool isModified () const;
bool isReadOnly() const;
+ void setReadOnly(bool value);
LinkAction *getActivationAction(); // The caller should not delete the result
LinkAction *getAdditionalAction(Annot::FormAdditionalActionsType type); // The caller should delete the result
@@ -300,7 +302,7 @@ public:
Object* getObj() { return &obj; }
Ref getRef() { return ref; }
- void setReadOnly (bool b) { readOnly = b; }
+ void setReadOnly (bool b);
bool isReadOnly () const { return readOnly; }
GooString* getDefaultAppearance() const { return defaultAppearance; }
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index eed3dd9d..eee504b3 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -5,6 +5,7 @@
* Copyright (C) 2012, Adam Reichold <adamreichold at myopera.com>
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth at web.de>
* Copyright (C) 2017, Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
+ * Copyright (C) 2018, Andre Heinecke <aheinecke at intevation.de>
*
* 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
@@ -151,6 +152,11 @@ bool FormField::isReadOnly() const
return m_formData->fm->isReadOnly();
}
+void FormField::setReadOnly(bool value)
+{
+ m_formData->fm->setReadOnly(value);
+}
+
bool FormField::isVisible() const
{
return !(m_formData->fm->getWidgetAnnotation()->getFlags() & Annot::flagHidden);
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index a5cc0377..d52f7e4b 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -5,6 +5,7 @@
* Copyright (C) 2016, Hanno Meyer-Thurow <h.mth at web.de>
* Copyright (C) 2017, Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
* Copyright (C) 2017, Tobias C. Berner <tcberner at freebsd.org>
+ * Copyright (C) 2018, Andre Heinecke <aheinecke at intevation.de>
*
* 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
@@ -110,6 +111,12 @@ namespace Poppler {
bool isReadOnly() const;
/**
+ Set whether this form field is read-only.
+ \since 0.64
+ */
+ void setReadOnly(bool value);
+
+ /**
Whether this form field is visible.
*/
bool isVisible() const;
More information about the poppler
mailing list