Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/xpdf/FormWidget.cc
diff options
context:
space:
mode:
authorMartin Kretzschmar <mkretzschmar@src.gnome.org>2002-09-18 20:32:18 (GMT)
committer Martin Kretzschmar <mkretzschmar@src.gnome.org>2002-09-18 20:32:18 (GMT)
commit7aac8dc8533347e21311b15186e0af82f1b22fd6 (patch)
tree02650bb02c8a1d8468c22f50ff151885d233016b /pdf/xpdf/FormWidget.cc
parentd99fb4f4acd14fcdbda968abd907547dcc7af40c (diff)
Synched with Xpdf 0.92
this adds "decryption" support testing this code after six weeks immediately gives me segfaults (image drawing) :-O must have fixed that later without knowing :-O
Diffstat (limited to 'pdf/xpdf/FormWidget.cc')
-rw-r--r--pdf/xpdf/FormWidget.cc129
1 files changed, 129 insertions, 0 deletions
diff --git a/pdf/xpdf/FormWidget.cc b/pdf/xpdf/FormWidget.cc
new file mode 100644
index 0000000..76428d0
--- /dev/null
+++ b/pdf/xpdf/FormWidget.cc
@@ -0,0 +1,129 @@
+//========================================================================
+//
+// FormWidget.cc
+//
+// Copyright 2000 Derek B. Noonburg
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include "gmem.h"
+#include "Object.h"
+#include "Gfx.h"
+#include "FormWidget.h"
+
+//------------------------------------------------------------------------
+// FormWidget
+//------------------------------------------------------------------------
+
+FormWidget::FormWidget(Dict *dict) {
+ Object obj1, obj2;
+ double t;
+
+ ok = gFalse;
+
+ if (dict->lookup("AP", &obj1)->isDict()) {
+ obj1.dictLookupNF("N", &obj2);
+ //~ this doesn't handle appearances with multiple states --
+ //~ need to look at AS key to get state and then get the
+ //~ corresponding entry from the N dict
+ if (obj2.isRef()) {
+ obj2.copy(&appearance);
+ ok = gTrue;
+ }
+ obj2.free();
+ }
+ obj1.free();
+
+ if (dict->lookup("Rect", &obj1)->isArray() &&
+ obj1.arrayGetLength() == 4) {
+ //~ should check object types here
+ obj1.arrayGet(0, &obj2);
+ xMin = obj2.getNum();
+ obj2.free();
+ obj1.arrayGet(1, &obj2);
+ yMin = obj2.getNum();
+ obj2.free();
+ obj1.arrayGet(2, &obj2);
+ xMax = obj2.getNum();
+ obj2.free();
+ obj1.arrayGet(3, &obj2);
+ yMax = obj2.getNum();
+ obj2.free();
+ if (xMin > xMax) {
+ t = xMin; xMin = xMax; xMax = t;
+ }
+ if (yMin > yMax) {
+ t = yMin; yMin = yMax; yMax = t;
+ }
+ } else {
+ //~ this should return an error
+ xMin = yMin = 0;
+ xMax = yMax = 1;
+ }
+ obj1.free();
+}
+
+FormWidget::~FormWidget() {
+ appearance.free();
+}
+
+void FormWidget::draw(Gfx *gfx) {
+ Object obj;
+
+ if (appearance.fetch(&obj)->isStream()) {
+ gfx->doWidgetForm(&obj, xMin, yMin, xMax, yMax);
+ }
+ obj.free();
+}
+
+//------------------------------------------------------------------------
+// FormWidgets
+//------------------------------------------------------------------------
+
+FormWidgets::FormWidgets(Object *annots) {
+ FormWidget *widget;
+ Object obj1, obj2;
+ int size;
+ int i;
+
+ widgets = NULL;
+ size = 0;
+ nWidgets = 0;
+
+ if (annots->isArray()) {
+ for (i = 0; i < annots->arrayGetLength(); ++i) {
+ if (annots->arrayGet(i, &obj1)->isDict()) {
+ obj1.dictLookup("Subtype", &obj2);
+ if (obj2.isName("Widget") ||
+ obj2.isName("Stamp")) {
+ widget = new FormWidget(obj1.getDict());
+ if (widget->isOk()) {
+ if (nWidgets >= size) {
+ size += 16;
+ widgets = (FormWidget **)grealloc(widgets,
+ size * sizeof(FormWidget *));
+ }
+ widgets[nWidgets++] = widget;
+ } else {
+ delete widget;
+ }
+ }
+ obj2.free();
+ }
+ obj1.free();
+ }
+ }
+}
+
+FormWidgets::~FormWidgets() {
+ int i;
+
+ for (i = 0; i < nWidgets; ++i) {
+ delete widgets[i];
+ }
+ gfree(widgets);
+}