diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index 1025393..4058626 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc @@ -172,18 +172,18 @@ poppler_page_get_duration (PopplerPage *page) } /** - * poppler_page_get_transition: + * poppler_page_get_transition_ex: * @page: a #PopplerPage * * Returns the transition effect of @page * - * Return value: a #PopplerPageTransition or %NULL. + * Return value: a #PopplerPageTransitionEx or %NULL. **/ -PopplerPageTransition * -poppler_page_get_transition (PopplerPage *page) +PopplerPageTransitionEx * +poppler_page_get_transition_ex (PopplerPage *page) { PageTransition *trans; - PopplerPageTransition *transition; + PopplerPageTransitionEx *transition; Object obj; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); @@ -196,7 +196,7 @@ poppler_page_get_transition (PopplerPage *page) return NULL; } - transition = poppler_page_transition_new (); + transition = poppler_page_transition_ex_new (); switch (trans->getType ()) { @@ -248,7 +248,7 @@ poppler_page_get_transition (PopplerPage *page) POPPLER_PAGE_TRANSITION_INWARD : POPPLER_PAGE_TRANSITION_OUTWARD; - transition->duration = trans->getDuration(); + transition->duration = trans->getDurationReal(); transition->angle = trans->getAngle(); transition->scale = trans->getScale(); transition->rectangular = trans->isRectangular(); @@ -258,6 +258,36 @@ poppler_page_get_transition (PopplerPage *page) return transition; } +/** + * poppler_page_get_transition: + * @page: a #PopplerPage + * + * Returns the transition effect of @page + * + * Return value: a #PopplerPageTransition or %NULL. + * + * Deprecated, only exists for backward compatibility. Use poppler_page_get_transition_ex instead. + **/ +PopplerPageTransition * +poppler_page_get_transition (PopplerPage *page) +{ + PopplerPageTransitionEx *transition = poppler_page_get_transition_ex (page); + if (transition == NULL) + return NULL; + + PopplerPageTransition *result = poppler_page_transition_new (); + result->type = transition->type; + result->alignment = transition->alignment; + result->direction = transition->direction; + result->duration = ceil(transition->duration); + result->angle = transition->angle; + result->scale = transition->scale; + result->rectangular = transition->rectangular; + poppler_page_transition_ex_free(transition); + + return result; +} + static TextPage * poppler_page_get_text_page (PopplerPage *page) { @@ -1930,7 +1960,7 @@ poppler_image_mapping_free (PopplerImageMapping *mapping) g_slice_free (PopplerImageMapping, mapping); } -/* Page Transition */ +/* Old Page Transition (deprecated) */ POPPLER_DEFINE_BOXED_TYPE (PopplerPageTransition, poppler_page_transition, poppler_page_transition_copy, poppler_page_transition_free) @@ -1979,6 +2009,55 @@ poppler_page_transition_free (PopplerPageTransition *transition) g_free (transition); } +/* Page Transition */ +POPPLER_DEFINE_BOXED_TYPE (PopplerPageTransitionEx, poppler_page_transition_ex, + poppler_page_transition_ex_copy, + poppler_page_transition_ex_free) + +/** + * poppler_page_transition_ex_new: + * + * Creates a new #PopplerPageTransitionEx + * + * Returns: a new #PopplerPageTransitionEx, use poppler_page_transition_ex_free() to free it + */ +PopplerPageTransitionEx * +poppler_page_transition_ex_new (void) +{ + return (PopplerPageTransitionEx *) g_new0 (PopplerPageTransitionEx, 1); +} + +/** + * poppler_page_transition_ex_copy: + * @transition: a #PopplerPageTransitionEx to copy + * + * Creates a copy of @transition + * + * Returns: a new allocated copy of @transition + */ +PopplerPageTransitionEx * +poppler_page_transition_ex_copy (PopplerPageTransitionEx *transition) +{ + PopplerPageTransitionEx *new_transition; + + new_transition = poppler_page_transition_ex_new (); + *new_transition = *transition; + + return new_transition; +} + +/** + * poppler_page_transition_ex_free: + * @transition: a #PopplerPageTransitionEx + * + * Frees the given #PopplerPageTransitionEx + */ +void +poppler_page_transition_ex_free (PopplerPageTransitionEx *transition) +{ + g_free (transition); +} + /* Form Field Mapping Type */ POPPLER_DEFINE_BOXED_TYPE (PopplerFormFieldMapping, poppler_form_field_mapping, poppler_form_field_mapping_copy, diff --git a/glib/poppler-page.h b/glib/poppler-page.h index 63fe362..9586baa 100644 --- a/glib/poppler-page.h +++ b/glib/poppler-page.h @@ -57,6 +57,7 @@ int poppler_page_get_index (PopplerPage *pa gchar *poppler_page_get_label (PopplerPage *page); double poppler_page_get_duration (PopplerPage *page); PopplerPageTransition *poppler_page_get_transition (PopplerPage *page); +PopplerPageTransitionEx *poppler_page_get_transition_ex (PopplerPage *page); gboolean poppler_page_get_thumbnail_size (PopplerPage *page, int *width, int *height); @@ -265,7 +266,7 @@ PopplerLinkMapping *poppler_link_mapping_new (void); PopplerLinkMapping *poppler_link_mapping_copy (PopplerLinkMapping *mapping); void poppler_link_mapping_free (PopplerLinkMapping *mapping); -/* Page Transition */ +/* Old Page Transition (deprecated) */ #define POPPLER_TYPE_PAGE_TRANSITION (poppler_page_transition_get_type ()) /** @@ -288,7 +289,8 @@ void poppler_link_mapping_free (PopplerLinkMapping *mapping); * Only for #POPPLER_PAGE_TRANSITION_FLY transition type * * A #PopplerPageTransition structures describes a visual transition - * to use when moving between pages during a presentation + * to use when moving between pages during a presentation. + * It is deprecated and exists for backward compatibility. #PopplerPageTransitionEx should be used instead. */ struct _PopplerPageTransition { @@ -306,6 +308,47 @@ PopplerPageTransition *poppler_page_transition_new (void); PopplerPageTransition *poppler_page_transition_copy (PopplerPageTransition *transition); void poppler_page_transition_free (PopplerPageTransition *transition); +/* Page Transition */ +#define POPPLER_TYPE_PAGE_TRANSITION_EX (poppler_page_transition_ex_get_type ()) + +/** + * PopplerPageTransitionEx: + * @type: the type of transtition + * @alignment: the dimension in which the transition effect shall occur. + * Only for #POPPLER_PAGE_TRANSITION_SPLIT and #POPPLER_PAGE_TRANSITION_BLINDS transition types + * @direction: the direccion of motion for the transition effect. + * Only for #POPPLER_PAGE_TRANSITION_SPLIT, #POPPLER_PAGE_TRANSITION_BOX and #POPPLER_PAGE_TRANSITION_FLY + * transition types + * @duration: the duration of the transition effect + * @angle: the direction in which the specified transition effect shall moves, + * expressed in degrees counterclockwise starting from a left-to-right direction. + * Only for #POPPLER_PAGE_TRANSITION_WIPE, #POPPLER_PAGE_TRANSITION_GLITTER, #POPPLER_PAGE_TRANSITION_FLY, + * #POPPLER_PAGE_TRANSITION_COVER, #POPPLER_PAGE_TRANSITION_UNCOVER and #POPPLER_PAGE_TRANSITION_PUSH + * transition types + * @scale: the starting or ending scale at which the changes shall be drawn. + * Only for #POPPLER_PAGE_TRANSITION_FLY transition type + * @rectangular: whether the area that will be flown is rectangular and opaque. + * Only for #POPPLER_PAGE_TRANSITION_FLY transition type + * + * A #PopplerPageTransitionEx structures describes a visual transition + * to use when moving between pages during a presentation. + */ +struct _PopplerPageTransitionEx +{ + PopplerPageTransitionType type; + PopplerPageTransitionAlignment alignment; + PopplerPageTransitionDirection direction; + gdouble duration; + gint angle; + gdouble scale; + gboolean rectangular; +}; + +GType poppler_page_transition_ex_get_type (void) G_GNUC_CONST; +PopplerPageTransitionEx *poppler_page_transition_ex_new (void); +PopplerPageTransitionEx *poppler_page_transition_ex_copy (PopplerPageTransitionEx *transition); +void poppler_page_transition_ex_free (PopplerPageTransitionEx *transition); + /* Mapping between areas on the current page and images */ #define POPPLER_TYPE_IMAGE_MAPPING (poppler_image_mapping_get_type ()) diff --git a/glib/poppler.h b/glib/poppler.h index 4df9c0e..a557799 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -182,6 +182,7 @@ typedef struct _PopplerTextAttributes PopplerTextAttributes; typedef struct _PopplerColor PopplerColor; typedef struct _PopplerLinkMapping PopplerLinkMapping; typedef struct _PopplerPageTransition PopplerPageTransition; +typedef struct _PopplerPageTransitionEx PopplerPageTransitionEx; typedef struct _PopplerImageMapping PopplerImageMapping; typedef struct _PopplerFormFieldMapping PopplerFormFieldMapping; typedef struct _PopplerAnnotMapping PopplerAnnotMapping; diff --git a/poppler/PageTransition.cc b/poppler/PageTransition.cc index 441634c..13b8c0b 100644 --- a/poppler/PageTransition.cc +++ b/poppler/PageTransition.cc @@ -80,8 +80,8 @@ PageTransition::PageTransition (Object *trans) { obj.free(); // get duration - if (dict->lookup("D", &obj)->isInt()) { - duration = obj.getInt(); + if (dict->lookup("D", &obj)->isNum()) { + duration = obj.getNum(); } obj.free(); diff --git a/poppler/PageTransition.h b/poppler/PageTransition.h index e892c6c..591eb2a 100644 --- a/poppler/PageTransition.h +++ b/poppler/PageTransition.h @@ -24,6 +24,7 @@ #endif #include "Object.h" +#include //------------------------------------------------------------------------ // PageTransition @@ -71,8 +72,11 @@ public: // Get type PageTransitionType getType() { return type; } + // Get duration as integer (for backwards compatibility only) + int getDuration() { return ceil(duration);} + // Get duration - int getDuration() { return duration;} + double getDurationReal() {return duration;} // Get alignment PageTransitionAlignment getAlignment() { return alignment; } @@ -92,7 +96,7 @@ public: private: PageTransitionType type; // transition style - int duration; // duration of the effect in seconds + double duration; // duration of the effect in seconds PageTransitionAlignment alignment; // dimension of the effect PageTransitionDirection direction; // direction of motion int angle; // direction in degrees diff --git a/qt4/src/poppler-page-transition.cc b/qt4/src/poppler-page-transition.cc index cde8818..187ee22 100644 --- a/qt4/src/poppler-page-transition.cc +++ b/qt4/src/poppler-page-transition.cc @@ -68,6 +68,11 @@ int PageTransition::duration() const return data->pt->getDuration(); } +double PageTransition::durationReal() const +{ + return data->pt->getDurationReal(); +} + PageTransition::Alignment PageTransition::alignment() const { return (Poppler::PageTransition::Alignment)data->pt->getAlignment(); diff --git a/qt4/src/poppler-page-transition.h b/qt4/src/poppler-page-transition.h index e7f39e2..cd879bb 100644 --- a/qt4/src/poppler-page-transition.h +++ b/qt4/src/poppler-page-transition.h @@ -109,11 +109,18 @@ class POPPLER_QT4_EXPORT PageTransition { Type type() const; /** - \brief Get duration of the transition in seconds. + \brief Get duration of the transition in seconds as integer + + \deprecated This function is left for backward compatibility, use durationReal() instead. */ int duration() const; /** + \brief Get duration of the transition in seconds + */ + double durationReal() const; + + /** \brief Get dimension in which the transition effect occurs. */ Alignment alignment() const; diff --git a/qt5/src/poppler-page-transition.cc b/qt5/src/poppler-page-transition.cc index cde8818..187ee22 100644 --- a/qt5/src/poppler-page-transition.cc +++ b/qt5/src/poppler-page-transition.cc @@ -68,6 +68,11 @@ int PageTransition::duration() const return data->pt->getDuration(); } +double PageTransition::durationReal() const +{ + return data->pt->getDurationReal(); +} + PageTransition::Alignment PageTransition::alignment() const { return (Poppler::PageTransition::Alignment)data->pt->getAlignment(); diff --git a/qt5/src/poppler-page-transition.h b/qt5/src/poppler-page-transition.h index 2d408a5..5e35fae 100644 --- a/qt5/src/poppler-page-transition.h +++ b/qt5/src/poppler-page-transition.h @@ -109,11 +109,18 @@ class POPPLER_QT5_EXPORT PageTransition { Type type() const; /** - \brief Get duration of the transition in seconds. + \brief Get duration of the transition in seconds as integer + + \deprecated This function is left for backward compatibility, use durationReal() instead. */ int duration() const; /** + \brief Get duration of the transition in seconds + */ + double durationReal() const; + + /** \brief Get dimension in which the transition effect occurs. */ Alignment alignment() const;