poppler/Form.cc | 20 +++++++++++++ poppler/Form.h | 5 +++ qt4/src/poppler-form.cc | 70 ++++++++++++++++++++++++++-------------------- qt4/src/poppler-private.h | 25 ---------------- 4 files changed, 66 insertions(+), 54 deletions(-)
New commits: commit f9c978fc2ab8a1f901f2136ae95deb9d41076155 Author: Pino Toscano <[email protected]> Date: Sun Feb 27 14:39:52 2011 +0100 [qt4] directly use the dict diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc index b989883..815a8df 100644 --- a/qt4/src/poppler-form.cc +++ b/qt4/src/poppler-form.cc @@ -90,17 +90,17 @@ FormField::FormField(FormFieldData &dd) XPDFReader::transform( MTX, qMax( left, right ), qMin( top, bottom ), bottomRight ); m_formData->box = QRectF(topLeft, QSizeF(bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y())); - Object *obj = m_formData->fm->getObj(); + Dict *dict = m_formData->fm->getObj()->getDict(); Object tmp; // reading the flags - if (obj->isDict() && obj->dictLookup("Ff", &tmp)->isInt()) + if (dict->lookup("Ff", &tmp)->isInt()) { m_formData->flags = tmp.getInt(); } tmp.free(); // reading the widget annotation flags - if (obj->isDict() && obj->dictLookup("F", &tmp)->isInt()) + if (dict->lookup("F", &tmp)->isInt()) { m_formData->annoflags = tmp.getInt(); } commit 071966e48577c515b17a424baeae85ae4fc80a20 Author: Pino Toscano <[email protected]> Date: Sun Feb 27 14:21:11 2011 +0100 [qt4] move textAlignment() as a private function diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc index f3b97b5..b989883 100644 --- a/qt4/src/poppler-form.cc +++ b/qt4/src/poppler-form.cc @@ -32,6 +32,35 @@ #include <math.h> +namespace { + +Qt::Alignment formTextAlignment(Object *obj) +{ + Object tmp; + int align = 0; + if (obj->dictLookup("Q", &tmp)->isInt()) + { + align = tmp.getInt(); + } + tmp.free(); + Qt::Alignment qtalign; + switch (align) + { + case 1: + qtalign = Qt::AlignHCenter; + break; + case 2: + qtalign = Qt::AlignRight; + break; + case 0: + default: + qtalign = Qt::AlignLeft; + } + return qtalign; +} + +} + namespace Poppler { FormField::FormField(FormFieldData &dd) @@ -264,7 +293,7 @@ int FormFieldText::maximumLength() const Qt::Alignment FormFieldText::textAlignment() const { - return m_formData->textAlignment(m_formData->fm->getObj()); + return formTextAlignment(m_formData->fm->getObj()); } bool FormFieldText::canBeSpellChecked() const @@ -342,7 +371,7 @@ void FormFieldChoice::setCurrentChoices( const QList<int> &choice ) Qt::Alignment FormFieldChoice::textAlignment() const { - return m_formData->textAlignment(m_formData->fm->getObj()); + return formTextAlignment(m_formData->fm->getObj()); } bool FormFieldChoice::canBeSpellChecked() const diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h index 6800a8b..105b9aa 100644 --- a/qt4/src/poppler-private.h +++ b/qt4/src/poppler-private.h @@ -260,31 +260,6 @@ namespace Poppler { { } - Qt::Alignment textAlignment(Object *obj) const - { - Object tmp; - int align = 0; - if (obj->dictLookup("Q", &tmp)->isInt()) - { - align = tmp.getInt(); - } - tmp.free(); - Qt::Alignment qtalign; - switch ( align ) - { - case 1: - qtalign = Qt::AlignHCenter; - break; - case 2: - qtalign = Qt::AlignRight; - break; - case 0: - default: - qtalign = Qt::AlignLeft; - } - return qtalign; - } - DocumentData *doc; ::Page *page; ::FormWidget *fm; commit adc236771f11eeb4197064747836e8ed3fbfeba9 Author: Pino Toscano <[email protected]> Date: Sun Feb 27 14:13:50 2011 +0100 [qt4] use FormWidget::getAlternateUiName() ... instead of read the value on our own diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc index 5887300..f3b97b5 100644 --- a/qt4/src/poppler-form.cc +++ b/qt4/src/poppler-form.cc @@ -106,16 +106,11 @@ QString FormField::name() const QString FormField::uiName() const { - Object tmp; - Object *obj = m_formData->fm->getObj(); QString name; - if (obj->dictLookup("TU", &tmp)->isString()) + if (GooString *goo = m_formData->fm->getAlternateUiName()) { - GooString *goo = tmp.getString(); - if (goo) - name = goo->getCString(); + name = QString::fromLatin1(goo->getCString()); } - tmp.free(); return name; } commit 9f111483cf6196dedf3cee380c3e5224776203ea Author: Pino Toscano <[email protected]> Date: Sun Feb 27 14:12:16 2011 +0100 forms: read the TU field as alternateUiName diff --git a/poppler/Form.cc b/poppler/Form.cc index a433215..7ca27cb 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -84,6 +84,13 @@ FormWidget::FormWidget(XRef *xrefA, Object *aobj, unsigned num, Ref aref, FormFi } obj1.free(); + if (dict->lookup("TU", &obj1)->isString()) { + alternateUiName = obj1.getString()->copy(); + } else { + alternateUiName = NULL; + } + obj1.free(); + if(dict->lookup("TM", &obj1)->isString()) { mappingName = obj1.getString()->copy(); } else { @@ -141,6 +148,7 @@ FormWidget::FormWidget(XRef *xrefA, Object *aobj, unsigned num, Ref aref, FormFi FormWidget::~FormWidget() { delete partialName; + delete alternateUiName; delete mappingName; delete fullyQualifiedName; obj.free (); diff --git a/poppler/Form.h b/poppler/Form.h index 31505ad..5f40945 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -87,6 +87,7 @@ public: double getFontSize () { return fontSize; } GooString *getPartialName() const { return partialName; } + GooString *getAlternateUiName() const { return alternateUiName; } GooString *getMappingName() const { return mappingName; } GooString *getFullyQualifiedName(); @@ -114,6 +115,7 @@ protected: GBool defaultsLoaded; GBool modified; GooString *partialName; // T field + GooString *alternateUiName; // TU field GooString *mappingName; // TM field GooString *fullyQualifiedName; commit cfaadaa9e4a857fcea3b5a2cadacd352de6c469d Author: Pino Toscano <[email protected]> Date: Sun Feb 27 14:07:35 2011 +0100 [qt4] use FormWidget::getPartialName() ... instead of read the value on our own diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc index 0f9b484..5887300 100644 --- a/qt4/src/poppler-form.cc +++ b/qt4/src/poppler-form.cc @@ -96,16 +96,11 @@ int FormField::id() const QString FormField::name() const { - Object tmp; - Object *obj = m_formData->fm->getObj(); QString name; - if (obj->dictLookup("T", &tmp)->isString()) + if (GooString *goo = m_formData->fm->getPartialName()) { - GooString *goo = tmp.getString(); - if (goo) - name = goo->getCString(); + name = QString::fromLatin1(goo->getCString()); } - tmp.free(); return name; } commit 2478896a0c1f6e5842f3d8b172e4cc7e6bd58cd8 Author: Pino Toscano <[email protected]> Date: Sun Feb 27 13:24:09 2011 +0100 [qt4] use the new FormWidget::createActivationAction() diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc index 6224b68..0f9b484 100644 --- a/qt4/src/poppler-form.cc +++ b/qt4/src/poppler-form.cc @@ -136,19 +136,12 @@ bool FormField::isVisible() const Link* FormField::activationAction() const { - Object tmp; - Object *obj = m_formData->fm->getObj(); Link* action = 0; - if (obj->dictLookup("A", &tmp)->isDict()) + if (::LinkAction *act = m_formData->fm->createActivationAction(m_formData->doc->doc->getCatalog())) { - ::LinkAction *act = ::LinkAction::parseAction(&tmp, m_formData->doc->doc->getCatalog()->getBaseURI()); - if (act) - { - action = PageData::convertLinkActionToLink(act, m_formData->doc, QRectF()); - delete act; - } + action = PageData::convertLinkActionToLink(act, m_formData->doc, QRectF()); + delete act; } - tmp.free(); return action; } commit 1dcb683a5c2dd6a1de654e90a4394f65d63dc296 Author: Pino Toscano <[email protected]> Date: Sun Feb 27 13:22:48 2011 +0100 add FormWidget::createActivationAction() used to get and create a new activation action object of a form widget diff --git a/poppler/Form.cc b/poppler/Form.cc index 74e8d90..a433215 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -37,6 +37,7 @@ #include "PDFDocEncoding.h" #include "Annot.h" #include "Catalog.h" +#include "Link.h" //return a newly allocated char* containing an UTF16BE string of size length char* pdfDocEncodingToUTF16 (GooString* orig, int* length) @@ -229,6 +230,17 @@ GooString* FormWidget::getFullyQualifiedName() { return fullyQualifiedName; } +LinkAction *FormWidget::createActivationAction(Catalog *catalog) +{ + Object tmp; + LinkAction *act = NULL; + if (obj.dictLookup("A", &tmp)->isDict()) { + act = LinkAction::parseAction(&tmp, catalog ? catalog->getBaseURI() : NULL); + } + tmp.free(); + return act; +} + FormWidgetButton::FormWidgetButton (XRef *xrefA, Object *aobj, unsigned num, Ref ref, FormField *p) : FormWidget(xrefA, aobj, num, ref, p) { diff --git a/poppler/Form.h b/poppler/Form.h index 106c556..31505ad 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -27,6 +27,7 @@ class Array; class Dict; class Annot; class Catalog; +class LinkAction; enum FormFieldType { formButton, @@ -93,6 +94,8 @@ public: bool isReadOnly() const; + LinkAction *createActivationAction(Catalog *catalog); + // return the unique ID corresponding to pageNum/fieldNum static int encodeID (unsigned pageNum, unsigned fieldNum); // decode id and retrieve pageNum and fieldNum _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
