[poppler] Form-Reset and Print [patches]
Guillermo Amaral
gamaral at kdab.com
Fri Jun 11 21:35:15 PDT 2010
Hi Guys,
I wanted to send in these patches, they allow handling of reset-form and print
actions respectably.
Please check them out, and if you have any questions please don't hesitate to
ask.
Cheers,
GA
--
Guillermo Amaral | guillermo.amaral at kdab.com | Software Desperado
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
diff --git a/qt4/src/poppler-link.h b/qt4/src/poppler-link.h
index 6d42cbe..48b558d 100644
--- a/qt4/src/poppler-link.h
+++ b/qt4/src/poppler-link.h
@@ -357,7 +357,8 @@ class POPPLER_QT4_EXPORT LinkAction : public Link
EndPresentation = 9,
Find = 10,
GoToPage = 11,
- Close = 12 };
+ Close = 12,
+ Print = 13 };
/**
* The action of the current LinkAction
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 6dbf50f..8aea6ce 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -129,6 +129,8 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
popplerLink = new LinkAction( linkArea, LinkAction::Find );
else if ( !strcmp( name, "FullScreen" ) )
popplerLink = new LinkAction( linkArea, LinkAction::Presentation );
+ else if ( !strcmp( name, "Print" ) )
+ popplerLink = new LinkAction( linkArea, LinkAction::Print );
else if ( !strcmp( name, "Close" ) )
{
// acroread closes the document always, doesnt care whether
-------------- next part --------------
diff --git a/poppler/Link.cc b/poppler/Link.cc
index 5d7b779..9c51f27 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -124,6 +124,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(obj2.getName());
+
// unknown action
} else if (obj2.isName()) {
action = new LinkUnknown(obj2.getName());
@@ -856,6 +860,18 @@ LinkOCGState::StateList::~StateList() {
}
//------------------------------------------------------------------------
+// LinkFormClear
+//------------------------------------------------------------------------
+
+LinkResetForm::LinkResetForm(char *actionA) {
+ action = new GooString(actionA);
+}
+
+LinkResetForm::~LinkResetForm() {
+ delete action;
+}
+
+//------------------------------------------------------------------------
// LinkUnknown
//------------------------------------------------------------------------
diff --git a/poppler/Link.h b/poppler/Link.h
index ea10375..962d596 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -53,6 +53,7 @@ enum LinkActionKind {
actionSound, // sound action
actionJavaScript, // JavaScript action
actionOCGState, // Set-OCG-State action
+ actionResetForm, // Reset form action
actionUnknown // anything else
};
@@ -429,6 +430,31 @@ private:
};
//------------------------------------------------------------------------
+// LinkResetForm
+//------------------------------------------------------------------------
+
+class LinkResetForm: public LinkAction {
+public:
+
+ // Build a LinkResetForm with the specified action type.
+ LinkResetForm(char *actionA);
+
+ // Destructor.
+ virtual ~LinkResetForm();
+
+ // Was the LinkResetForm create successfully?
+ virtual GBool isOk() { return action != NULL; }
+
+ // Accessors.
+ virtual LinkActionKind getKind() { return actionResetForm; }
+ GooString *getAction() { return action; }
+
+private:
+
+ GooString *action; // action subtype
+};
+
+//------------------------------------------------------------------------
// LinkUnknown
//------------------------------------------------------------------------
diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc
index 6224b68..4ce4465 100644
--- a/qt4/src/poppler-form.cc
+++ b/qt4/src/poppler-form.cc
@@ -139,14 +139,24 @@ Link* FormField::activationAction() const
Object tmp;
Object *obj = m_formData->fm->getObj();
Link* action = 0;
+ ::LinkAction *act = 0;
+
if (obj->dictLookup("A", &tmp)->isDict())
{
- ::LinkAction *act = ::LinkAction::parseAction(&tmp, m_formData->doc->doc->getCatalog()->getBaseURI());
- if (act)
- {
- action = PageData::convertLinkActionToLink(act, m_formData->doc, QRectF());
- delete act;
- }
+ act = ::LinkAction::parseAction(&tmp, m_formData->doc->doc->getCatalog()->getBaseURI());
+ }
+ else if (obj->dictLookup("AA", &tmp)->isDict())
+ {
+ Object tmp1;
+ if (tmp.dictLookup("D", &tmp1)->isDict())
+ act = ::LinkAction::parseAction(&tmp1, m_formData->doc->doc->getCatalog()->getBaseURI());
+ tmp1.free();
+ }
+
+ if (act)
+ {
+ action = PageData::convertLinkActionToLink(act, m_formData->doc, QRectF());
+ delete act;
}
tmp.free();
return action;
diff --git a/qt4/src/poppler-link.cc b/qt4/src/poppler-link.cc
index de06242..80c390c 100644
--- a/qt4/src/poppler-link.cc
+++ b/qt4/src/poppler-link.cc
@@ -179,6 +179,19 @@ class LinkMoviePrivate : public LinkPrivate
}
#endif
+class LinkFormActionPrivate : public LinkPrivate
+{
+ public:
+ LinkFormActionPrivate( const QRectF &area );
+
+ LinkFormAction::ActionType type;
+};
+
+ LinkFormActionPrivate::LinkFormActionPrivate( const QRectF &area )
+ : LinkPrivate( area )
+ {
+ }
+
static void cvtUserToDev(::Page *page, double xu, double yu, int *xd, int *yd) {
double ctm[6];
@@ -581,4 +594,27 @@ class LinkMoviePrivate : public LinkPrivate
}
#endif
+ // LinkFormAction
+ LinkFormAction::LinkFormAction( const QRectF &linkArea, ActionType actionType )
+ : Link( *new LinkFormActionPrivate( linkArea ) )
+ {
+ Q_D( LinkFormAction );
+ d->type = actionType;
+ }
+
+ LinkFormAction::~LinkFormAction()
+ {
+ }
+
+ LinkFormAction::ActionType LinkFormAction::actionType() const
+ {
+ Q_D( const LinkFormAction );
+ return d->type;
+ }
+
+ Link::LinkType LinkFormAction::linkType() const
+ {
+ return FormAction;
+ }
+
}
diff --git a/qt4/src/poppler-link.h b/qt4/src/poppler-link.h
index 6d42cbe..f037642 100644
--- a/qt4/src/poppler-link.h
+++ b/qt4/src/poppler-link.h
@@ -39,6 +39,7 @@ class LinkJavaScriptPrivate;
class LinkMoviePrivate;
class LinkDestinationData;
class LinkDestinationPrivate;
+class LinkFormActionPrivate;
class SoundObject;
/**
@@ -182,7 +183,8 @@ class POPPLER_QT4_EXPORT Link
Action, ///< A "standard" action to be executed in the viewer
Sound, ///< A link representing a sound to be played
Movie, ///< An action to be executed on a movie
- JavaScript ///< A JavaScript code to be interpreted \since 0.10
+ JavaScript, ///< A JavaScript code to be interpreted \since 0.10
+ FormAction ///< A "form" action to be executed in the viewer
};
/**
@@ -484,6 +486,46 @@ class POPPLER_QT4_EXPORT LinkMovie : public Link
};
#endif
+/**
+ * \brief "Form" action request.
+ *
+ * The LinkFormAction class represents a link that request a "form" action
+ * to be performed by the viewer on the displayed document.
+ */
+class POPPLER_QT4_EXPORT LinkFormAction : public Link
+{
+ public:
+ /**
+ * The possible types of actions
+ */
+ enum ActionType { Submit = 1,
+ Reset = 2,
+ ImportData = 3 };
+
+ /**
+ * The action of the current LinkFormAction
+ */
+ ActionType actionType() const;
+
+ /**
+ * Create a new Action link, that executes a specified action
+ * on the document.
+ *
+ * \param linkArea the active area of the link
+ * \param actionType which action should be executed
+ */
+ LinkFormAction( const QRectF &linkArea, ActionType actionType );
+ /**
+ * Destructor.
+ */
+ ~LinkFormAction();
+ LinkType linkType() const;
+
+ private:
+ Q_DECLARE_PRIVATE( LinkFormAction )
+ Q_DISABLE_COPY( LinkFormAction )
+};
+
}
#endif
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 6dbf50f..b0b2871 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -174,6 +174,10 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
copyString( m_uri, m->getTitle()->getCString() );
*/ break;
+ case actionResetForm:
+ popplerLink = new LinkFormAction( linkArea, LinkFormAction::Reset );
+ break;
+
case actionUnknown:
break;
}
More information about the poppler
mailing list