1 //========================================================================
2 //
3 // Form.cc
4 //
5 // Copyright 2012 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #include <aconf.h>
10 
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
13 #endif
14 
15 #include "GlobalParams.h"
16 #include "Error.h"
17 #include "Object.h"
18 #include "PDFDoc.h"
19 #include "AcroForm.h"
20 #include "XFAForm.h"
21 #include "Form.h"
22 
23 //------------------------------------------------------------------------
24 // Form
25 //------------------------------------------------------------------------
26 
load(PDFDoc * docA,Catalog * catalog,Object * acroFormObj)27 Form *Form::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObj) {
28   Form *form;
29   Object xfaObj, catDict, needsRenderingObj;
30 
31   if (!acroFormObj->isDict()) {
32     error(errSyntaxError, -1, "AcroForm object is wrong type");
33     return NULL;
34   }
35   //~ temporary: create an XFAForm only for XFAF, not for dynamic XFA
36   acroFormObj->dictLookup("XFA", &xfaObj);
37   docA->getXRef()->getCatalog(&catDict);
38   catDict.dictLookup("NeedsRendering", &needsRenderingObj);
39   catDict.free();
40   if (globalParams->getEnableXFA() &&
41       !xfaObj.isNull() &&
42       !(needsRenderingObj.isBool() && needsRenderingObj.getBool())) {
43     form = XFAForm::load(docA, acroFormObj, &xfaObj);
44   } else {
45     form = AcroForm::load(docA, catalog, acroFormObj);
46   }
47   xfaObj.free();
48   needsRenderingObj.free();
49   return form;
50 }
51 
Form(PDFDoc * docA)52 Form::Form(PDFDoc *docA) {
53   doc = docA;
54 }
55 
~Form()56 Form::~Form() {
57 }
58 
59 //------------------------------------------------------------------------
60 // FormField
61 //------------------------------------------------------------------------
62 
FormField()63 FormField::FormField() {
64 }
65 
~FormField()66 FormField::~FormField() {
67 }
68