summaryrefslogtreecommitdiff
path: root/qt4
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2006-05-01 18:33:47 +0000
committerAlbert Astals Cid <aacid@kde.org>2006-05-01 18:33:47 +0000
commit57af0207334ff1a407899370281ebb90fe953a32 (patch)
tree92721bfc30f5bc94b27613e83b162d0ea0790817 /qt4
parent61b126390f764fd38c79b6a64160a7dc7870bd4a (diff)
* 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
Diffstat (limited to 'qt4')
-rw-r--r--qt4/src/poppler-page.cc14
-rw-r--r--qt4/src/poppler-private.h11
-rw-r--r--qt4/src/poppler-qt4.h8
-rw-r--r--qt4/src/poppler-textbox.cc23
4 files changed, 49 insertions, 7 deletions
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 69d38a87..3236ac1b 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.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;
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index 3bcc1f57..f65fa34f 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -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;
+ };
+
}
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index af2652d8..ee701aa0 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -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;
};
diff --git a/qt4/src/poppler-textbox.cc b/qt4/src/poppler-textbox.cc
index d6d29099..ec223c0b 100644
--- a/qt4/src/poppler-textbox.cc
+++ b/qt4/src/poppler-textbox.cc
@@ -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;
+}
+
}