Commit 64e7cd8e authored by Pino Toscano's avatar Pino Toscano

Optionally, read the "button" form fields from poppler.

Enable the support for them only if the poppler version is recent enough (atm, git master of around 9 hours ago).

svn path=/trunk/KDE/kdegraphics/okular/; revision=773549
parent 03ea6ff5
......@@ -14,6 +14,17 @@ int main()
" POPPLER_HAVE_PSCONVERTER_SETOUTPUTDEVICE)
macro_bool_to_01(POPPLER_HAVE_PSCONVERTER_SETOUTPUTDEVICE _POPPLER_HAVE_PSCONVERTER_SETOUTPUTDEVICE)
check_cxx_source_compiles("
#include <poppler-qt4.h>
#include <poppler-form.h>
int main()
{
Poppler::FormFieldButton * button = 0;
return 0;
}
" POPPLER_HAVE_FORMFIELDBUTTON)
macro_bool_to_01(POPPLER_HAVE_FORMFIELDBUTTON _POPPLER_HAVE_FORMFIELDBUTTON)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
......
......@@ -3,3 +3,6 @@
/* Defined if Poppler::PSConverter has setOutputDevice */
#define POPPLER_HAVE_PSCONVERTER_SETOUTPUTDEVICE ${_POPPLER_HAVE_PSCONVERTER_SETOUTPUTDEVICE}
/* Defined if Poppler::FormFieldButton is available */
#define POPPLER_HAVE_FORMFIELDBUTTON ${_POPPLER_HAVE_FORMFIELDBUTTON}
......@@ -9,6 +9,84 @@
#include "formfields.h"
#ifdef POPPLER_HAVE_FORMFIELDBUTTON
PopplerFormFieldButton::PopplerFormFieldButton( Poppler::FormFieldButton * field )
: Okular::FormFieldButton(), m_field( field )
{
m_rect = Okular::NormalizedRect::fromQRectF( m_field->rect() );
}
PopplerFormFieldButton::~PopplerFormFieldButton()
{
delete m_field;
}
Okular::NormalizedRect PopplerFormFieldButton::rect() const
{
return m_rect;
}
int PopplerFormFieldButton::id() const
{
return m_field->id();
}
QString PopplerFormFieldButton::name() const
{
return m_field->name();
}
QString PopplerFormFieldButton::uiName() const
{
return m_field->uiName();
}
bool PopplerFormFieldButton::isReadOnly() const
{
return m_field->isReadOnly();
}
bool PopplerFormFieldButton::isVisible() const
{
return m_field->isVisible();
}
Okular::FormFieldButton::ButtonType PopplerFormFieldButton::buttonType() const
{
switch ( m_field->buttonType() )
{
case Poppler::FormFieldButton::Push:
return Okular::FormFieldButton::Push;
case Poppler::FormFieldButton::CheckBox:
return Okular::FormFieldButton::CheckBox;
case Poppler::FormFieldButton::Radio:
return Okular::FormFieldButton::Radio;
}
return Okular::FormFieldButton::Push;
}
QString PopplerFormFieldButton::caption() const
{
return m_field->caption();
}
bool PopplerFormFieldButton::state() const
{
return m_field->state();
}
void PopplerFormFieldButton::setState( bool state )
{
m_field->setState( state );
}
QList< int > PopplerFormFieldButton::siblings() const
{
return m_field->siblings();
}
#endif
PopplerFormFieldText::PopplerFormFieldText( Poppler::FormFieldText * field )
: Okular::FormFieldText(), m_field( field )
{
......
......@@ -13,6 +13,37 @@
#include <poppler-form.h>
#include "core/form.h"
#include <config-okular-poppler.h>
#ifdef POPPLER_HAVE_FORMFIELDBUTTON
class PopplerFormFieldButton : public Okular::FormFieldButton
{
public:
PopplerFormFieldButton( Poppler::FormFieldButton * field );
virtual ~PopplerFormFieldButton();
// inherited from Okular::FormField
virtual Okular::NormalizedRect rect() const;
virtual int id() const;
virtual QString name() const;
virtual QString uiName() const;
virtual bool isReadOnly() const;
virtual bool isVisible() const;
// inherited from Okular::FormFieldButton
virtual ButtonType buttonType() const;
virtual QString caption() const;
virtual bool state() const;
virtual void setState( bool state );
virtual QList< int > siblings() const;
private:
Poppler::FormFieldButton * m_field;
Okular::NormalizedRect m_rect;
};
#endif
class PopplerFormFieldText : public Okular::FormFieldText
{
public:
......
......@@ -1386,6 +1386,11 @@ void PDFGenerator::addFormFields( Poppler::Page * popplerPage, Okular::Page * pa
Okular::FormField * of = 0;
switch ( f->type() )
{
#ifdef POPPLER_HAVE_FORMFIELDBUTTON
case Poppler::FormField::FormButton:
of = new PopplerFormFieldButton( static_cast<Poppler::FormFieldButton*>( f ) );
break;
#endif
case Poppler::FormField::FormText:
of = new PopplerFormFieldText( static_cast<Poppler::FormFieldText*>( f ) );
break;
......
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