[poppler] Form-Reset and Print [patches]
Guillermo Amaral
gamaral at kdab.com
Mon Jun 14 01:02:37 PDT 2010
On Mon, Jun 14, 2010 at 09:48:08AM +0200, Carlos Garcia Campos wrote:
> Excerpts from Guillermo Amaral's message of lun jun 14 09:45:07 +0200 2010:
> > On Mon, Jun 14, 2010 at 09:34:27AM +0200, Carlos Garcia Campos wrote:
> > > Excerpts from Guillermo Amaral's message of lun jun 14 05:37:16 +0200 2010:
> > > > On Sun, Jun 13, 2010 at 11:02:56PM +0100, Albert Astals Cid wrote:
> > > > > A Diumenge, 13 de juny de 2010, Guillermo Amaral va escriure:
> > > > > > On Sun, Jun 13, 2010 at 10:21:35AM +0200, Carlos Garcia Campos wrote:
> > > > > > > Excerpts from Guillermo Amaral's message of dom jun 13 04:40:44 +0200
> > > > > 2010:
> > > > > > > > Albert Astals Cid <aacid at kde.org> wrote:
> > > > > > > > > A Dissabte, 12 de juny de 2010, Guillermo Amaral va escriure:
> > > > > > > > >> 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.
> > > > > > > > >
> > > > > > > > > Do you have a document that uses them?
> > > > > > > > >
> > > > > > > > I do, but I dunno if I can share them ATM, looking into it.
> > > > > > > > But I did make a test pdf that uses both features. :-)
> > > > > > > >
> > > > > > > > > Also what is the point of
> > > > > > > > >
> > > > > > > > > + } else if (obj2.isName("ResetForm")) {
> > > > > > > > > + action = new LinkResetForm(obj2.getName());
> > > > > > > > >
> > > > > > > > As usual, you are right aacid :) I try a little to hard not to break
> > > > > > > > the flow of other programs, I think I went to far lol (fixed)
> > > > > > > >
> > > > > > > > > And
> > > > > > > > > if (obj->dictLookup("AA", &tmp)->isDict())
> > > > > > > > > seems like an unrelated fix, can you please explain it too?
> > > > > > > > >
> > > > > > > > Mixed them up, that one should be in the print patch (moved).
> > > > > > > > Sometimes the AA dict is used to hold a ref to the named object. I
> > > > > > > > have seen it in two docs so far, it seems to happen when people set
> > > > > > > > an action to happen on mouse down instead of mouse up. It should not
> > > > > > > > break anything else (as far as I can see).
> > > > > > >
> > > > > > > We should definitely add support for additional actions properly in
> > > > > > > poppler.
> > > > > > >
> > > > > > > > diff --git a/poppler/Link.cc b/poppler/Link.cc
> > > > > > > > index 5d7b779..e3d6ce7 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();
> > > > > > > > +
> > > > > > > >
> > > > > > > > // unknown action
> > > > > > > > } else if (obj2.isName()) {
> > > > > > > >
> > > > > > > > action = new LinkUnknown(obj2.getName());
> > > > > > > >
> > > > > > > > @@ -856,6 +860,18 @@ LinkOCGState::StateList::~StateList() {
> > > > > > > >
> > > > > > > > }
> > > > > > > >
> > > > > > > > //--------------------------------------------------------------------
> > > > > > > > ----
> > > > > > > >
> > > > > > > > +// LinkFormClear
> > > > > > > > +//--------------------------------------------------------------------
> > > > > > > > ---- +
> > > > > > > > +LinkResetForm::LinkResetForm() {
> > > > > > > > + action = new GooString("ResetForm");
> > > > > > >
> > > > > > > this is redundant, you already know it's a LinkResetForm object. You
> > > > > > > should parse Fields and Flags here.
> > > > > >
> > > > > > Yeah it's a partial patch, it allows the client to know it has to reset..
> > > > > > I guess I could make it reset the fields in the fieldlist here and just
> > > > > > notify the client the form values have changed or something? what do you
> > > > > > guys think?
> > > > > >
> > > > > > As far as it being redundant T_T yep totally. but I do see that
> > > > > > the getAction() accessor returns said action GooString ptr, as I said
> > > > > > before I don't want to rock the boat; I'm guessing that method is used
> > > > > > some place else so I don't want to take it out willy nilly. But I do want
> > > > > > to make it clear (if it's not totally obvious already) that I'm not
> > > > > > completely familiar with the popplers code. ;-)
> > > > >
> > > > > getAction() used somewhere? It's not virtual and you don't use it anywhere, so
> > > > > where is it going to be used?
> > > > >
> > > >
> > > > Mmm thought it was lol, dammit.
> > > > Anyway, I added the missing features to the reset form patch today, check it out.
> > > >
> > > > Cheers,
> > > > GA
> > > >
> > > > diff --git a/poppler/Link.cc b/poppler/Link.cc
> > > > index 5d7b779..abb17b6 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(obj);
> > > > +
> > > > // unknown action
> > > > } else if (obj2.isName()) {
> > > > action = new LinkUnknown(obj2.getName());
> > > > @@ -856,6 +860,40 @@ LinkOCGState::StateList::~StateList() {
> > > > }
> > > >
> > > > //------------------------------------------------------------------------
> > > > +// LinkResetForm
> > > > +//------------------------------------------------------------------------
> > > > +
> > > > +LinkResetForm::LinkResetForm(Object *obj) {
> > > > + Object obj1;
> > > > +
> > > > + fieldList = new GooList();
> > > > + flags = 0;
> > > > +
> > > > + if (obj->dictLookup("Fields", &obj1)->isArray()) {
> > > > + for (int i = 0; i < obj1.arrayGetLength(); ++i) {
> > > > + Object obj2;
> > > > + obj1.arrayGetNF(i, &obj2);
> > > > + fieldList->append(obj2.getString()->copy());
> > > > + obj2.free();
> > > > + }
> > >
> > > Fields items can be either strings or indirect references depending on
> > > Flags, and both kinds can be mixed. This will fail if obj2 is not a
> > > string.
> >
> > Have a copy of the spec your using? or more info on the flags? the PDF
> > spec I got from adobe I have only mentions bit 1 for (include/exclude). :S
> >
> http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf
Thanks Carlos, I have the same spec it seems. Can you point me to the
section? The one I used was 12.7.5.3; it mentions only one flag.
Thanks again,
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
More information about the poppler
mailing list