Commit 1aa48d6b authored by Albert Astals Cid's avatar Albert Astals Cid

Add PageTransition class and PageTransition* Page::getTransition() const; to...

Add PageTransition class and PageTransition* Page::getTransition() const; to the qt frontend. Code almost 100% copied from xpdf code inside kpdf
parent 9d4327ee
2005-06-26 Albert Astals Cid <aacid@kde.org>
* qt/poppler-page.cc:
* qt/poppler-page.h: Add PageTransition class and
PageTransition* Page::getTransition() const; to the qt frontend.
2005-06-26 Martin Kretzschmar <martink@gnome.org> 2005-06-26 Martin Kretzschmar <martink@gnome.org>
* glib/.cvsignore: add poppler-enums.[ch]. * glib/.cvsignore: add poppler-enums.[ch].
......
/* poppler-page.cc: qt interface to poppler /* poppler-page.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, Tobias Koening
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -30,20 +31,127 @@ ...@@ -30,20 +31,127 @@
namespace Poppler { 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 { class PageData {
public: public:
const Document *doc; const Document *doc;
int index; int index;
PageTransition *transition;
}; };
Page::Page(const Document *doc, int index) { Page::Page(const Document *doc, int index) {
data = new PageData(); data = new PageData();
data->index = index; data->index = index;
data->doc = doc; data->doc = doc;
data->transition = 0;
} }
Page::~Page() Page::~Page()
{ {
delete data->transition;
delete data; delete data;
} }
...@@ -105,4 +213,17 @@ QString Page::getText(const Rectangle &r) const ...@@ -105,4 +213,17 @@ QString Page::getText(const Rectangle &r) const
return result; return result;
} }
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);
o.free();
}
return data->transition;
}
} }
/* poppler-qt.h: qt interface to poppler /* poppler-qt.h: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, Tobias Koening
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
namespace Poppler { namespace Poppler {
class Document; class Document;
class Page;
/* A rectangle on a page, with coordinates in PDF points. */ /* A rectangle on a page, with coordinates in PDF points. */
class Rectangle class Rectangle
...@@ -41,6 +43,76 @@ class Rectangle ...@@ -41,6 +43,76 @@ class Rectangle
double m_y2; double m_y2;
}; };
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 PageData;
class Page { class Page {
friend class Document; friend class Document;
...@@ -53,6 +125,12 @@ class Page { ...@@ -53,6 +125,12 @@ class Page {
* If r is a null Rectangle all text of the page is given * If r is a null Rectangle all text of the page is given
**/ **/
QString getText(const Rectangle &r) const; QString getText(const Rectangle &r) const;
/**
* Returns the transition of this page
**/
PageTransition *getTransition() const;
private: private:
Page(const Document *doc, int index); Page(const Document *doc, int index);
PageData *data; PageData *data;
......
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