[poppler] 3 commits - qt4/src
Pino Toscano
pino at kemper.freedesktop.org
Sun Feb 10 17:27:52 PST 2008
qt4/src/poppler-embeddedfile.cc | 33 ++++++++----------------
qt4/src/poppler-form.cc | 55 ++++++++++++++++++++++++++++++++++++++++
qt4/src/poppler-form.h | 54 +++++++++++++++++++++++++++++++++++++++
qt4/src/poppler-page.cc | 6 ++++
qt4/src/poppler-private.h | 1
5 files changed, 126 insertions(+), 23 deletions(-)
New commits:
commit ada05055c91e967dc3e2af32a2176dd12cb7fe70
Author: Pino Toscano <pino at kde.org>
Date: Mon Feb 11 02:27:19 2008 +0100
Preliminary support for "button" form fields (ie, push buttons, check boxes, and radio buttons).
diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc
index 7f90840..74dd0a4 100644
--- a/qt4/src/poppler-form.cc
+++ b/qt4/src/poppler-form.cc
@@ -126,6 +126,61 @@ bool FormField::isVisible() const
}
+FormFieldButton::FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w)
+ : FormField(*new FormFieldData(doc, p, w))
+{
+}
+
+FormFieldButton::~FormFieldButton()
+{
+}
+
+FormFieldButton::FormType FormFieldButton::type() const
+{
+ return FormField::FormButton;
+}
+
+FormFieldButton::ButtonType FormFieldButton::buttonType() const
+{
+ FormWidgetButton* fwb = static_cast<FormWidgetButton*>(m_formData->fm);
+ switch (fwb->getButtonType())
+ {
+ case formButtonCheck:
+ return FormFieldButton::CheckBox;
+ break;
+ case formButtonPush:
+ return FormFieldButton::Push;
+ break;
+ case formButtonRadio:
+ return FormFieldButton::Radio;
+ break;
+ }
+ return FormFieldButton::CheckBox;
+}
+
+QString FormFieldButton::caption() const
+{
+ FormWidgetButton* fwb = static_cast<FormWidgetButton*>(m_formData->fm);
+ // HACK push buttons seems to have a null GooString for the caption
+ if (fwb->getButtonType() == formButtonPush)
+ return QString();
+
+ return fwb->getOnStr() ? QString::fromUtf8(fwb->getOnStr()) : QString();
+}
+
+bool FormFieldButton::state() const
+{
+ FormWidgetButton* fwb = static_cast<FormWidgetButton*>(m_formData->fm);
+ return fwb->getState();
+}
+
+void FormFieldButton::setState( bool state )
+{
+ FormWidgetButton* fwb = static_cast<FormWidgetButton*>(m_formData->fm);
+ fwb->setState((GBool)state);
+}
+
+
FormFieldText::FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w)
: FormField(*new FormFieldData(doc, p, w))
{
diff --git a/qt4/src/poppler-form.h b/qt4/src/poppler-form.h
index 47724fa..20370f0 100644
--- a/qt4/src/poppler-form.h
+++ b/qt4/src/poppler-form.h
@@ -100,6 +100,60 @@ namespace Poppler {
};
/**
+ A form field that represents a choice field.
+ */
+ class FormFieldButton : public FormField {
+ public:
+
+ /**
+ * The types of button field.
+ */
+ enum ButtonType
+ {
+ Push, ///< A simple push button.
+ CheckBox, ///< A check box.
+ Radio ///< A radio button.
+ };
+
+ /// \cond PRIVATE
+ FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w);
+ /// \endcond
+ virtual ~FormFieldButton();
+
+ virtual FormType type() const;
+
+ /**
+ The particular type of the button field.
+ */
+ ButtonType buttonType() const;
+
+ /**
+ * The caption to be used for a @ref Push button.
+ *
+ * May be a null string if the push button has no particular caption
+ * set for that @p type .
+ *
+ * Always a null string if the button is not a push button.
+ *
+ * @param type is the type of the caption
+ */
+ QString caption() const;
+
+ /**
+ The state of the button.
+ */
+ bool state() const;
+
+ /**
+ Sets the state of the button to the new \p state .
+ */
+ void setState( bool state );
+
+ private:
+ Q_DISABLE_COPY(FormFieldButton)
+ };
+
+ /**
A form field that represents a text input.
*/
class FormFieldText : public FormField {
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 0ebdad2..3453324 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -1265,6 +1265,12 @@ QList<FormField*> Page::formFields() const
FormField * ff = NULL;
switch (fm->getType())
{
+ case formButton:
+ {
+ ff = new FormFieldButton(m_page->parentDoc, p, static_cast<FormWidgetButton*>(fm));
+ }
+ break;
+
case formText:
{
ff = new FormFieldText(m_page->parentDoc, p, static_cast<FormWidgetText*>(fm));
commit 278b33f25df418ef12798100002845a3e2ceebd3
Merge: c730b33... fdb0a4a...
Author: Pino Toscano <pino at kde.org>
Date: Mon Feb 11 00:57:24 2008 +0100
Merge branch 'master' of ssh://pino@git.freedesktop.org/git/poppler/poppler
commit c730b33f1ec2032c4b8c2660738448d954eb0f7d
Author: Pino Toscano <pino at kde.org>
Date: Mon Feb 11 00:46:20 2008 +0100
Keep the EmbFile object, and use this for getting the data.
diff --git a/qt4/src/poppler-embeddedfile.cc b/qt4/src/poppler-embeddedfile.cc
index 5761c46..5d7e8be 100644
--- a/qt4/src/poppler-embeddedfile.cc
+++ b/qt4/src/poppler-embeddedfile.cc
@@ -34,67 +34,56 @@ namespace Poppler
class EmbeddedFileData
{
public:
- QString m_label;
- QString m_description;
- int m_size;
- QDateTime m_modDate;
- QDateTime m_createDate;
- QByteArray m_checksum;
- Object m_streamObject;
+ EmbFile *embfile;
};
EmbeddedFile::EmbeddedFile(EmbFile *embfile)
{
m_embeddedFile = new EmbeddedFileData();
- m_embeddedFile->m_label = QString(embfile->name()->getCString());
- m_embeddedFile->m_description = UnicodeParsedString(embfile->description());
- m_embeddedFile->m_size = embfile->size();
- m_embeddedFile->m_modDate = convertDate(embfile->modDate()->getCString());
- m_embeddedFile->m_createDate = convertDate(embfile->createDate()->getCString());
- m_embeddedFile->m_checksum = QByteArray::fromRawData(embfile->checksum()->getCString(), embfile->checksum()->getLength());
- embfile->streamObject().copy(&m_embeddedFile->m_streamObject);
+ m_embeddedFile->embfile = embfile;
}
EmbeddedFile::~EmbeddedFile()
{
- m_embeddedFile->m_streamObject.free();
+ delete m_embeddedFile->embfile;
delete m_embeddedFile;
}
QString EmbeddedFile::name() const
{
- return m_embeddedFile->m_label;
+ return QString(m_embeddedFile->embfile->name()->getCString());
}
QString EmbeddedFile::description() const
{
- return m_embeddedFile->m_description;
+ return UnicodeParsedString(m_embeddedFile->embfile->description());
}
int EmbeddedFile::size() const
{
- return m_embeddedFile->m_size;
+ return m_embeddedFile->embfile->size();
}
QDateTime EmbeddedFile::modDate() const
{
- return m_embeddedFile->m_modDate;
+ return convertDate(m_embeddedFile->embfile->modDate()->getCString());
}
QDateTime EmbeddedFile::createDate() const
{
- return m_embeddedFile->m_createDate;
+ return convertDate(m_embeddedFile->embfile->createDate()->getCString());
}
QByteArray EmbeddedFile::checksum() const
{
- return m_embeddedFile->m_checksum;
+ GooString *goo_checksum = m_embeddedFile->embfile->checksum();
+ return QByteArray::fromRawData(goo_checksum->getCString(), goo_checksum->getLength());
}
QByteArray EmbeddedFile::data()
{
Object obj;
- Stream *stream = m_embeddedFile->m_streamObject.getStream();
+ Stream *stream = m_embeddedFile->embfile->streamObject().getStream();
stream->reset();
int dataLen = 0;
QByteArray fileArray;
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index 29df4a6..32981ae 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -235,7 +235,6 @@ namespace Poppler {
for (int yalv = 0; yalv < numEmb; ++yalv) {
EmbFile *ef = doc->getCatalog()->embeddedFile(yalv);
m_embeddedFiles.append(new EmbeddedFile(ef));
- delete ef;
}
}
}
More information about the poppler
mailing list