From cf6f8123af19aca4200b58a454652f68ce8132e2 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 30 Dec 2005 22:31:32 +0000 Subject: Puting PageTransition implementation into poppler "core", both Qt and Qt4 frontends use it. --- qt/Makefile.am | 2 +- qt/poppler-page.cc | 111 ++--------------------------------------------------- qt/poppler-qt.h | 72 +--------------------------------- 3 files changed, 7 insertions(+), 178 deletions(-) (limited to 'qt') diff --git a/qt/Makefile.am b/qt/Makefile.am index 78c5b236..91757085 100644 --- a/qt/Makefile.am +++ b/qt/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = \ poppler_includedir = $(includedir)/poppler poppler_include_HEADERS = \ - poppler-qt.h + poppler-qt.h ../poppler/PageTransition.h lib_LTLIBRARIES=libpoppler-qt.la libpoppler_qt_la_SOURCES = \ diff --git a/qt/poppler-page.cc b/qt/poppler-page.cc index 6e292a3f..691e02d3 100644 --- a/qt/poppler-page.cc +++ b/qt/poppler-page.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -31,110 +32,6 @@ namespace Poppler { -class PageTransitionData { - public: - Object *trans; -}; - -//------------------------------------------------------------------------ -// PageTransition -//------------------------------------------------------------------------ - -PageTransition::PageTransition(const PageTransitionData &data) - : type(Replace), - duration(1), - alignment(Horizontal), - direction(Inward), - angle(0), - scale(1.0), - rectangular(false) -{ - Object obj; - Object *dictObj = data.trans; - - if (dictObj->isDict()) { - Dict *transDict = dictObj->getDict(); - - if (transDict->lookup("S", &obj)->isName()) { - const char *s = obj.getName(); - if (strcmp("R", s) == 0) - type = Replace; - else if (strcmp("Split", s) == 0) - type = Split; - else if (strcmp("Blinds", s) == 0) - type = Blinds; - else if (strcmp("Box", s) == 0) - type = Box; - else if (strcmp("Wipe", s) == 0) - type = Wipe; - else if (strcmp("Dissolve", s) == 0) - type = Dissolve; - else if (strcmp("Glitter", s) == 0) - type = Glitter; - else if (strcmp("Fly", s) == 0) - type = Fly; - else if (strcmp("Push", s) == 0) - type = Push; - else if (strcmp("Cover", s) == 0) - type = Cover; - else if (strcmp("Uncover", s) == 0) - type = Push; - else if (strcmp("Fade", s) == 0) - type = Cover; - } - obj.free(); - - if (transDict->lookup("D", &obj)->isInt()) { - duration = obj.getInt(); - } - obj.free(); - - if (transDict->lookup("Dm", &obj)->isName()) { - const char *dm = obj.getName(); - if ( strcmp( "H", dm ) == 0 ) - alignment = Horizontal; - else if ( strcmp( "V", dm ) == 0 ) - alignment = Vertical; - } - obj.free(); - - if (transDict->lookup("M", &obj)->isName()) { - const char *m = obj.getName(); - if ( strcmp( "I", m ) == 0 ) - direction = Inward; - else if ( strcmp( "O", m ) == 0 ) - direction = Outward; - } - obj.free(); - - if (transDict->lookup("Di", &obj)->isInt()) { - angle = obj.getInt(); - } - obj.free(); - - if (transDict->lookup("Di", &obj)->isName()) { - if ( strcmp( "None", obj.getName() ) == 0 ) - angle = 0; - } - obj.free(); - - if (transDict->lookup("SS", &obj)->isReal()) { - scale = obj.getReal(); - } - obj.free(); - - if (transDict->lookup("B", &obj)->isBool()) { - rectangular = obj.getBool(); - } - obj.free(); - } -} - -PageTransition::~PageTransition() -{ -} - - class PageData { public: const Document *doc; @@ -268,9 +165,9 @@ PageTransition *Page::getTransition() const if (!data->transition) { Object o; - PageTransitionData ptd; - ptd.trans = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o); - data->transition = new PageTransition(ptd); + PageTransitionParams params; + params.dictObj = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o); + data->transition = new PageTransition(params); o.free(); } return data->transition; diff --git a/qt/poppler-qt.h b/qt/poppler-qt.h index 22bd6cdf..c0172a15 100644 --- a/qt/poppler-qt.h +++ b/qt/poppler-qt.h @@ -24,6 +24,8 @@ #include #include +#include + namespace Poppler { class Document; @@ -118,76 +120,6 @@ private: FontInfoData *data; }; -class PageTransitionData; -class PageTransition -{ -friend class Page; -public: - enum Type { - Replace, - Split, - Blinds, - Box, - Wipe, - Dissolve, - Glitter, - Fly, - Push, - Cover, - Uncover, - Fade - }; - - enum Alignment { - Horizontal, - Vertical - }; - - enum Direction { - Inward, - Outward - }; - - - // Destructor - ~PageTransition(); - - // Get type of the transition. - Type getType() const { return type; } - - // Get duration of the transition in seconds. - int getDuration() const { return duration; } - - // Get dimension in which the transition effect - // occurs. - Alignment getAlignment() const { return alignment; } - - // Get direction of motion of the transition effect. - Direction getDirection() const { return direction; } - - // Get direction in which the transition effect moves. - int getAngle() const { return angle; } - - // Get starting or ending scale. - double getScale() const { return scale; } - - // Returns true if the area to be flown is rectangular and - // opaque. - bool isRectangular() const { return rectangular; } - -private: - // Construct a new PageTransition object from a page dictionary. - PageTransition( const PageTransitionData &data ); - - Type type; - int duration; - Alignment alignment; - Direction direction; - int angle; - double scale; - bool rectangular; -}; - class PageData; class Page { friend class Document; -- cgit v1.2.3