From c143ec1ac6feb4df8a4086a96fb35d91ac3596d7 Mon Sep 17 00:00:00 2001 From: Marek Kasik Date: Mon, 15 Jun 2015 11:29:46 +0200 Subject: [PATCH 3/4] Add support for ResetForm action to Link class Add LinkResetForm class which stores information needed for resetting of fields of forms. --- poppler/Link.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ poppler/Link.h | 27 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/poppler/Link.cc b/poppler/Link.cc index 4ab5f52..5811610 100644 --- a/poppler/Link.cc +++ b/poppler/Link.cc @@ -126,6 +126,10 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { } else if (obj2.isName("SetOCGState")) { action = new LinkOCGState(obj); + // ResetForm action + } else if (obj2.isName("ResetForm")) { + action = new LinkResetForm (obj); + // unknown action } else if (obj2.isName()) { action = new LinkUnknown(obj2.getName()); @@ -879,6 +883,45 @@ LinkOCGState::StateList::~StateList() { } //------------------------------------------------------------------------ +// LinkResetForm +//------------------------------------------------------------------------ + +LinkResetForm::LinkResetForm(Object *obj) { + Object obj1, obj2; + + fields = NULL; + exclude = gFalse; + + if (obj->dictLookup("Fields", &obj1)->isArray()) { + fields = new GooList (obj1.arrayGetLength()); + for (int i = 0; i < obj1.arrayGetLength(); ++i) { + obj1.arrayGetNF (i, &obj2); + if (obj2.isName()) + fields->append (new GooString (obj2.getName ())); + else if (obj2.isRef()) + fields->append (GooString::format("{0:d} {1:d} R", obj2.getRef().num, obj2.getRef().gen)); + obj2.free(); + } + } + obj1.free(); + + if (obj->dictLookup("Flags", &obj1)->isInt()) { + int flags = obj1.getInt(); + + if (flags & 0x1) + exclude = gTrue; + } + obj1.free(); +} + +LinkResetForm::~LinkResetForm() { + if (fields) { + deleteGooList (fields, GooString); + fields = NULL; + } +} + +//------------------------------------------------------------------------ // LinkUnknown //------------------------------------------------------------------------ diff --git a/poppler/Link.h b/poppler/Link.h index fc2abe6..0c36f10 100644 --- a/poppler/Link.h +++ b/poppler/Link.h @@ -56,6 +56,7 @@ enum LinkActionKind { actionSound, // sound action actionJavaScript, // JavaScript action actionOCGState, // Set-OCG-State action + actionResetForm, // ResetForm action actionUnknown // anything else }; @@ -444,6 +445,32 @@ private: }; //------------------------------------------------------------------------ +// LinkResetForm +//------------------------------------------------------------------------ + +class LinkResetForm: public LinkAction { +public: + + // Build a LinkResetForm. + LinkResetForm(Object *nameObj); + + virtual ~LinkResetForm(); + + virtual GBool isOk() { return gTrue; } + + virtual LinkActionKind getKind() { return actionResetForm; } + + GooList *getFields() { return fields; } + GBool getExclude() { return exclude; } + +private: + + GooList *fields; + GBool exclude; +}; + + +//------------------------------------------------------------------------ // LinkUnknown //------------------------------------------------------------------------ -- 2.4.3