Commit 984ce7f9 authored by Albert Astals Cid's avatar Albert Astals Cid

2007-02-25 Pino Toscano <pino@kde.org>

            reviewed by: Albert Astals Cid <aacid@kde.org>

        * qt4/src/Doxyfile:
        * qt4/src/Makefile.am:
        * qt4/src/poppler-annotation-helper.h:
        * qt4/src/poppler-form.cc:
        * qt4/src/poppler-form.h:
        * qt4/src/poppler-page.cc:
        * qt4/src/poppler-private.h:
        * qt4/src/poppler-qt4.h:
                Beginning of interactive forms support, first implementation in the
                Qt4 frontend. It supports text and choice fields in a basic way.
parent de7a90fc
2007-02-25 Pino Toscano <pino@kde.org>
reviewed by: Albert Astals Cid <aacid@kde.org>
* qt4/src/Doxyfile:
* qt4/src/Makefile.am:
* qt4/src/poppler-annotation-helper.h:
* qt4/src/poppler-form.cc:
* qt4/src/poppler-form.h:
* qt4/src/poppler-page.cc:
* qt4/src/poppler-private.h:
* qt4/src/poppler-qt4.h:
Beginning of interactive forms support, first implementation in the
Qt4 frontend. It supports text and choice fields in a basic way.
2007-02-25 Albert Astals Cid <aacid@kde.org>
* configure.ac:
......
......@@ -447,6 +447,7 @@ WARN_LOGFILE =
INPUT = \
Mainpage.dox \
poppler-annotation.h \
poppler-form.h \
poppler-link.h \
poppler-qt4.h \
../../qt/poppler-page-transition.h
......
......@@ -12,6 +12,7 @@ poppler_include_HEADERS = \
poppler-qt4.h \
poppler-link.h \
poppler-annotation.h \
poppler-form.h \
../../qt/poppler-page-transition.h
lib_LTLIBRARIES = libpoppler-qt4.la
......@@ -26,6 +27,7 @@ libpoppler_qt4_la_SOURCES = \
poppler-annotation.cc \
../../qt/poppler-page-transition.cc \
poppler-sound.cc \
poppler-form.cc \
poppler-annotation-helper.h \
poppler-private.h
......
......@@ -26,15 +26,15 @@ class XPDFReader
{
public:
// find named symbol and parse it
static void lookupName( Dict *, const char *, QString & dest );
static void lookupString( Dict *, const char *, QString & dest );
static void lookupBool( Dict *, const char *, bool & dest );
static void lookupInt( Dict *, const char *, int & dest );
static void lookupNum( Dict *, const char *, double & dest );
static int lookupNumArray( Dict *, const char *, double * dest, int len );
static void lookupColor( Dict *, const char *, QColor & color );
static void lookupIntRef( Dict *, const char *, int & dest );
static void lookupDate( Dict *, const char *, QDateTime & dest );
static inline void lookupName( Dict *, const char *, QString & dest );
static inline void lookupString( Dict *, const char *, QString & dest );
static inline void lookupBool( Dict *, const char *, bool & dest );
static inline void lookupInt( Dict *, const char *, int & dest );
static inline void lookupNum( Dict *, const char *, double & dest );
static inline int lookupNumArray( Dict *, const char *, double * dest, int len );
static inline void lookupColor( Dict *, const char *, QColor & color );
static inline void lookupIntRef( Dict *, const char *, int & dest );
static inline void lookupDate( Dict *, const char *, QDateTime & dest );
// transform from user coords to normalized ones using the matrix M
static inline void transform( double * M, double x, double y, QPointF &res );
};
......
......@@ -26,6 +26,7 @@
#include <GlobalParams.h>
#include <PDFDoc.h>
#include <Catalog.h>
#include <Form.h>
#include <ErrorCodes.h>
#include <TextOutputDev.h>
#if defined(HAVE_SPLASH)
......@@ -37,6 +38,7 @@
#include "poppler-private.h"
#include "poppler-page-transition-private.h"
#include "poppler-annotation-helper.h"
#include "poppler-form.h"
namespace Poppler {
......@@ -1235,6 +1237,40 @@ QList<Annotation*> Page::annotations() const
return annotationsMap.values();
}
QList<FormField*> Page::formFields() const
{
QList<FormField*> fields;
::Page *p = m_page->parentDoc->m_doc->doc->getCatalog()->getPage(m_page->index + 1);
::FormPageWidgets * form = p->getPageWidgets();
int formcount = form->getNumWidgets();
for (int i = 0; i < formcount; ++i)
{
::FormWidget *fm = form->getWidget(i);
FormField * ff = NULL;
switch (fm->getType())
{
case formText:
{
ff = new FormFieldText(m_page->parentDoc->m_doc, p, static_cast<FormWidgetText*>(fm));
}
break;
case formChoice:
{
ff = new FormFieldChoice(m_page->parentDoc->m_doc, p, static_cast<FormWidgetChoice*>(fm));
}
break;
default: ;
}
if (ff)
fields.append(ff);
}
return fields;
}
double Page::duration() const
{
::Page *p;
......
......@@ -33,7 +33,7 @@
#include <SplashOutputDev.h>
#endif
class FormWidget;
namespace Poppler {
......@@ -55,6 +55,15 @@ namespace Poppler {
return new UGooString(u, len);
}
static QString GooStringToQString(GooString* goo) {
if (!goo)
return QString();
const char *aux = UGooString(*goo).getCString();
QString res(aux);
delete[] aux;
return res;
}
class LinkDestinationData
{
public:
......@@ -284,6 +293,47 @@ namespace Poppler {
bool hasSpaceAfter;
};
class FormFieldData
{
public:
FormFieldData(DocumentData *_doc, ::Page *p, ::FormWidget *w) :
doc(_doc), page(p), fm(w), flags(0), annoflags(0)
{
}
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;
QRectF box;
int flags;
int annoflags;
};
}
......@@ -45,6 +45,8 @@ namespace Poppler {
class PageData;
class FormField;
class TextBoxData;
/**
......@@ -375,6 +377,11 @@ namespace Poppler {
*/
QList<Annotation*> annotations() const;
/**
Returns the form fields on the page
*/
QList<FormField*> formFields() const;
/**
Returns the page duration. That is the time, in seconds, that the page
should be displayed before the presentation automatically advances to the next page.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment