Commit 57af0207 authored by Albert Astals Cid's avatar Albert Astals Cid

* qt4/src/poppler-page.cc:

        * qt4/src/poppler-private.h:
        * qt4/src/poppler-qt4.h:
        * qt4/src/poppler-textbox.cc: Add nextWord(), hasSpaceAfter() and
        edge() to TextBox

More things to make poppler-qt4Okular nearer
parent 61b12639
2006-05-01 Albert Astals Cid <aacid@kde.org>
* qt4/src/poppler-page.cc:
* qt4/src/poppler-private.h:
* qt4/src/poppler-qt4.h:
* qt4/src/poppler-textbox.cc: Add nextWord(), hasSpaceAfter() and
edge() to TextBox
2006-05-01 Albert Astals Cid <aacid@kde.org>
* qt4/src/poppler-document.cc:
......
......@@ -19,6 +19,7 @@
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
#include <QtCore/QFile>
#include <QtCore/QMap>
#include <QtGui/QImage>
#include <QtGui/QPixmap>
#include <GlobalParams.h>
......@@ -168,6 +169,8 @@ QList<TextBox*> Page::textList() const
return output_list;
}
QMap<TextWord *, TextBox*> wordBoxMap;
for (int i = 0; i < word_list->getLength(); i++) {
TextWord *word = word_list->get(i);
QString string = QString::fromUtf8(word->getText()->getCString());
......@@ -175,10 +178,21 @@ QList<TextBox*> Page::textList() const
word->getBBox(&xMin, &yMin, &xMax, &yMax);
TextBox* text_box = new TextBox(string, QRectF(xMin, yMin, xMax-xMin, yMax-yMin));
text_box->m_data->hasSpaceAfter = word->hasSpaceAfter() == gTrue;
text_box->m_data->edge.reserve(word->getLength() + 1);
for (int j = 0; j <= word->getLength(); ++j) text_box->m_data->edge[j] = word->getEdge(j);
wordBoxMap.insert(word, text_box);
output_list.append(text_box);
}
for (int i = 0; i < word_list->getLength(); i++) {
TextWord *word = word_list->get(i);
TextBox* text_box = wordBoxMap[word];
text_box->m_data->nextWord = wordBoxMap[word->nextWord()];
}
delete word_list;
delete output_dev;
......
......@@ -194,6 +194,17 @@ namespace Poppler {
FontInfo::Type type;
};
class TextBoxData
{
public:
QString text;
QRectF bBox;
TextBox *nextWord;
QVector<double> edge; // "near" edge x or y coord of each char
// (plus one extra entry for the last char)
bool hasSpaceAfter;
};
}
......@@ -24,6 +24,7 @@
#include <QtCore/QByteArray>
#include <QtCore/QDateTime>
#include <QtCore/QVector>
#include <QtGui/QPixmap>
#include <QtXml/QDomDocument>
......@@ -52,6 +53,7 @@ namespace Poppler {
the text is found.
*/
class TextBox {
friend class Page;
public:
/**
The default constructor sets the text and the rectangle the
......@@ -71,6 +73,12 @@ namespace Poppler {
*/
const QRectF &boundingBox() const;
TextBox *nextWord() const;
double edge(int i) const;
bool hasSpaceAfter() const;
private:
TextBoxData *m_data;
};
......
......@@ -19,16 +19,10 @@
#define UNSTABLE_POPPLER_QT4
#include "poppler-qt4.h"
#include "poppler-private.h"
namespace Poppler {
class TextBoxData
{
public:
QString text;
QRectF bBox;
};
TextBox::TextBox(const QString& text, const QRectF &bBox)
{
m_data = new TextBoxData();
......@@ -46,4 +40,19 @@ const QRectF &TextBox::boundingBox() const
return m_data->bBox;
};
TextBox *TextBox::nextWord() const
{
return m_data->nextWord;
}
double TextBox::edge(int i) const
{
return m_data->edge[i];
}
bool TextBox::hasSpaceAfter() const
{
return m_data->hasSpaceAfter;
}
}
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