Commit e64f6341 authored by Albert Astals Cid's avatar Albert Astals Cid

PAtch to add some more functions to the qt binding by Stefan Kebekus

parent 8bd8cb41
2005-11-21 Albert Astals Cid <aacid@kde.org>
* qt/poppler-page.cc:
* qt/poppler-qt.h: Some more functions, patch by Stefan Kebekus
2005-11-21 Albert Astals Cid <aacid@kde.org>
* qt/Makefile.am: Fix build problems some people were having
......
......@@ -156,6 +156,11 @@ Page::~Page()
}
void Page::renderToPixmap(QPixmap **q, int x, int y, int w, int h) const
{
renderToPixmap(q, x, y, w, h, 72.0, 72.0);
}
void Page::renderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const
{
SplashOutputDev *output_dev;
SplashBitmap *bitmap;
......@@ -167,7 +172,7 @@ void Page::renderToPixmap(QPixmap **q, int x, int y, int w, int h) const
output_dev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
output_dev->startDoc(data->doc->data->doc.getXRef ());
data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72,
data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, xres, yres,
0, false, false, false, -1, -1, -1, -1);
bitmap = output_dev->getBitmap ();
color_ptr = bitmap->getDataPtr ();
......@@ -223,6 +228,41 @@ QString Page::getText(const Rectangle &r) const
return result;
}
QValueList<TextBox*> Page::textList() const
{
TextOutputDev *output_dev;
QValueList<TextBox*> output_list;
output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse);
data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72,
0, false, false, false, -1, -1, -1, -1);
TextWordList *word_list = output_dev->makeWordList();
if (!word_list) {
delete output_dev;
return output_list;
}
for (int i = 0; i < word_list->getLength(); i++) {
TextWord *word = word_list->get(i);
QString string = QString::fromUtf8(word->getText()->getCString());
double xMin, yMin, xMax, yMax;
word->getBBox(&xMin, &yMin, &xMax, &yMax);
TextBox* text_box = new TextBox(string, Rectangle(xMin, yMin, xMax, yMax));
output_list.append(text_box);
}
delete word_list;
delete output_dev;
return output_list;
}
PageTransition *Page::getTransition() const
{
if (!data->transition)
......@@ -236,4 +276,31 @@ PageTransition *Page::getTransition() const
return data->transition;
}
QSize Page::pageSize() const
{
::Page *p = data->doc->data->doc.getCatalog()->getPage(data->index + 1);
return QSize( (int)p->getMediaWidth(), (int)p->getMediaHeight() );
}
Page::Orientation Page::orientation() const
{
::Page *p = data->doc->data->doc.getCatalog()->getPage(data->index + 1);
int rotation = p->getRotate();
switch (rotation) {
case 90:
return Page::Landscape;
break;
case 180:
return Page::UpsideDown;
break;
case 270:
return Page::Seascape;
break;
default:
return Page::Portrait;
}
}
}
......@@ -43,6 +43,21 @@ class Rectangle
double m_y2;
};
class TextBox
{
public:
TextBox(const QString& text, const Rectangle &bBox) :
m_text(text), m_bBox(bBox) {};
QString getText() const { return m_text; };
Rectangle getBoundingBox() const { return m_bBox; };
private:
QString m_text;
Rectangle m_bBox;
};
class PageTransitionData;
class PageTransition
{
......@@ -118,18 +133,44 @@ class Page {
friend class Document;
public:
~Page();
void renderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const;
/**
* This is a convenience function that is equivalent to
* renderToPixmap() with xres and yres set to 72.0. We keep it
* only for binary compatibility
**/
void renderToPixmap(QPixmap **q, int x, int y, int w, int h) const;
/**
* Returns the size of the page in points
**/
QSize pageSize() const;
/**
* Returns the text that is inside the Rectangle r
* If r is a null Rectangle all text of the page is given
**/
QString getText(const Rectangle &r) const;
QValueList<TextBox*> textList() const;
/**
* Returns the transition of this page
**/
PageTransition *getTransition() const;
enum Orientation {
Landscape,
Portrait,
Seascape,
UpsideDown
};
/**
* The orientation of the page
**/
Orientation orientation() const;
private:
Page(const Document *doc, int index);
......
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