]>
git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/FormWidget.cxx
76428d05e6da8e325c1cea32124d0215cae76df0
1 //========================================================================
5 // Copyright 2000 Derek B. Noonburg
7 //========================================================================
10 #pragma implementation
16 #include "FormWidget.h"
18 //------------------------------------------------------------------------
20 //------------------------------------------------------------------------
22 FormWidget::FormWidget(Dict
*dict
) {
28 if (dict
->lookup("AP", &obj1
)->isDict()) {
29 obj1
.dictLookupNF("N", &obj2
);
30 //~ this doesn't handle appearances with multiple states --
31 //~ need to look at AS key to get state and then get the
32 //~ corresponding entry from the N dict
34 obj2
.copy(&appearance
);
41 if (dict
->lookup("Rect", &obj1
)->isArray() &&
42 obj1
.arrayGetLength() == 4) {
43 //~ should check object types here
44 obj1
.arrayGet(0, &obj2
);
47 obj1
.arrayGet(1, &obj2
);
50 obj1
.arrayGet(2, &obj2
);
53 obj1
.arrayGet(3, &obj2
);
57 t
= xMin
; xMin
= xMax
; xMax
= t
;
60 t
= yMin
; yMin
= yMax
; yMax
= t
;
63 //~ this should return an error
70 FormWidget::~FormWidget() {
74 void FormWidget::draw(Gfx
*gfx
) {
77 if (appearance
.fetch(&obj
)->isStream()) {
78 gfx
->doWidgetForm(&obj
, xMin
, yMin
, xMax
, yMax
);
83 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
87 FormWidgets::FormWidgets(Object
*annots
) {
97 if (annots
->isArray()) {
98 for (i
= 0; i
< annots
->arrayGetLength(); ++i
) {
99 if (annots
->arrayGet(i
, &obj1
)->isDict()) {
100 obj1
.dictLookup("Subtype", &obj2
);
101 if (obj2
.isName("Widget") ||
102 obj2
.isName("Stamp")) {
103 widget
= new FormWidget(obj1
.getDict());
104 if (widget
->isOk()) {
105 if (nWidgets
>= size
) {
107 widgets
= (FormWidget
**)grealloc(widgets
,
108 size
* sizeof(FormWidget
*));
110 widgets
[nWidgets
++] = widget
;
122 FormWidgets::~FormWidgets() {
125 for (i
= 0; i
< nWidgets
; ++i
) {