Bug 106356 - [PATCH] Qt5: Support additional widget actions in PDF Forms
Summary: [PATCH] Qt5: Support additional widget actions in PDF Forms
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: qt frontend (show other bugs)
Version: unspecified
Hardware: All All
: medium enhancement
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-02 14:51 UTC by Andre Heinecke
Modified: 2018-05-17 22:46 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Support additional widget actions in PDF Forms (4.10 KB, patch)
2018-05-02 14:51 UTC, Andre Heinecke
Details | Splinter Review
Support additional widget actions in PDF Forms - Updated 1 (2.88 KB, patch)
2018-05-08 07:51 UTC, Andre Heinecke
Details | Splinter Review

Description Andre Heinecke 2018-05-02 14:51:39 UTC
Created attachment 139277 [details] [review]
Support additional widget actions in PDF Forms

This adds support for actions associated with form fields
through corresponding annotation widgets.

The description about this change with tests and examples can be found in KDE's phabricator:

https://phabricator.kde.org/T8627
Comment 1 Albert Astals Cid 2018-05-04 13:45:23 UTC
I'm not totally convinced, but shouldn't we also add

Annot::actionPageOpening
Annot::actionPageClosing
Annot::actionPageVisible
Annot::actionPageInvisible

?
Comment 2 Andre Heinecke 2018-05-04 13:48:47 UTC
I didn't add them because we don't need them in Okular. The difference for those actions is that we don't need the link between formfield <-> annotation, so they can still be handled without problems through the Page / Annotation API.

But I don't think it would hurt. Should I update the patch?
Comment 3 Albert Astals Cid 2018-05-04 14:55:28 UTC
I think we should really go for

     Link* additionalAction(AdditionalActionType type) const;
     Link* additionalAction(Annotation::AdditionalActionType type) const;

It most probably makes the implementation code simpler too. What do you think?
Comment 4 Andre Heinecke 2018-05-04 15:10:57 UTC
I thought that combining both in a single enumeration might be a good idea because I saw:

 * The widget annotation represents a widget (form field) on a page.
 *
 * \note This class is just provided for consistency of the annotation API,
 *       use the FormField classes to get all the form-related information.

So I thought that it makes sense API wise to have everything related to FormFields declared in poppler-form / the FormField class. Currently there is also no dependency from poppler-form.h to poppler-annotation.h.

From an implementation standpoint, yes it would make the type differentiation in popler-form.cc FormField::additionalAction simpler by splitting both branches into two functions.
But as an API user I find it simpler to only have to care about a single AdditionalAction enum.

At least in Okular reducing both enum's to a single AdditionalActionType enum helps so that we don't need duplicated API to carry / access them there. I found it more elegant to directly "abstract" the difference away in the poppler-qt api.
Comment 5 Albert Astals Cid 2018-05-06 15:38:26 UTC
(In reply to Andre Heinecke from comment #4)
> I thought that combining both in a single enumeration might be a good idea
> because I saw:
> 
>  * The widget annotation represents a widget (form field) on a page.
>  *
>  * \note This class is just provided for consistency of the annotation API,
>  *       use the FormField classes to get all the form-related information.
> 
> So I thought that it makes sense API wise to have everything related to
> FormFields declared in poppler-form / the FormField class. Currently there
> is also no dependency from poppler-form.h to poppler-annotation.h.
> 
> From an implementation standpoint, yes it would make the type
> differentiation in popler-form.cc FormField::additionalAction simpler by
> splitting both branches into two functions.
> But as an API user I find it simpler to only have to care about a single
> AdditionalAction enum.
> 
> At least in Okular reducing both enum's to a single AdditionalActionType
> enum helps so that we don't need duplicated API to carry / access them
> there. I found it more elegant to directly "abstract" the difference away in
> the poppler-qt api.

I don't agree it's a good abstraction, you're duplicating API, by having "the same enum values" in two different places, which for people that are "not you or me" makes you wonder why that happens or if one is the new and the other the old, or what.

I think adding a new function accepting the annotation enums, is exactly fullfiling that "this class is just provided for consistency" comment.

You know you want the MousePressed action, but since there is that comment you go to the form field classes, and there you go, there's exactly the function accepting what you want.

Why is it any different for Okular?
Comment 6 Andre Heinecke 2018-05-08 07:01:46 UTC
(In reply to Albert Astals Cid from comment #5)
> I don't agree it's a good abstraction, you're duplicating API, by having
> "the same enum values" in two different places, which for people that are
> "not you or me" makes you wonder why that happens or if one is the new and
> the other the old, or what.

Ok.
 
> I think adding a new function accepting the annotation enums, is exactly
> fullfiling that "this class is just provided for consistency" comment.
> 
> You know you want the MousePressed action, but since there is that comment
> you go to the form field classes, and there you go, there's exactly the
> function accepting what you want.
> 
> Why is it any different for Okular?

In Okular I also didn't want to add a new additionalAction function / Enum to Okular::FormField with an additional underlying QHash for the new actions but found it more elegant to reuse the old structure and just extend it for the new actions.
But yes, it does not make much difference and you are right that the API is more direct if we split it.

I'll update the patches accordingly.
Comment 7 Andre Heinecke 2018-05-08 07:51:05 UTC
Created attachment 139422 [details] [review]
Support additional widget actions in PDF Forms - Updated 1

Updated to use a separate function for the Annotation additional actions.

I wonder if we should forward declare the Annotation::AdditionalActionType enum to avoid including poppler-annotation.h in poppler-form.h.
Which type should such a declaration use?
Comment 8 Albert Astals Cid 2018-05-17 22:46:38 UTC
Pushed


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.