diff options
author | Albert Astals Cid <aacid@kde.org> | 2008-03-11 23:58:05 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2008-03-11 23:58:05 +0100 |
commit | 821858f5c36786955d9475044bfee57f5060ad2f (patch) | |
tree | f5c505f3a676c606d3f703f97f97d2571cc0546c | |
parent | d7e642732ced592362d9787bddadb7a110dcc5a5 (diff) |
Return char bounding box instead of edge, it's much more useful for character positioning
-rw-r--r-- | qt4/src/poppler-page.cc | 8 | ||||
-rw-r--r-- | qt4/src/poppler-private.h | 3 | ||||
-rw-r--r-- | qt4/src/poppler-qt4.h | 6 | ||||
-rw-r--r-- | qt4/src/poppler-textbox.cc | 4 |
4 files changed, 11 insertions, 10 deletions
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index f02e033a..8ae6ccd3 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -362,8 +362,12 @@ QList<TextBox*> Page::textList(Rotation rotate) const 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.append(word->getEdge(j)); + text_box->m_data->charBBoxes.reserve(word->getLength()); + for (int j = 0; j < word->getLength(); ++j) + { + word->getCharBBox(j, &xMin, &yMin, &xMax, &yMax); + text_box->m_data->charBBoxes.append(QRectF(xMin, yMin, xMax-xMin, yMax-yMin)); + } wordBoxMap.insert(word, text_box); diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h index 3774d200..6f55f18b 100644 --- a/qt4/src/poppler-private.h +++ b/qt4/src/poppler-private.h @@ -302,8 +302,7 @@ namespace Poppler { 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) + QVector<QRectF> charBBoxes; // the boundingRect of each character bool hasSpaceAfter; }; diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h index 726fd759..5deedd8b 100644 --- a/qt4/src/poppler-qt4.h +++ b/qt4/src/poppler-qt4.h @@ -93,11 +93,9 @@ namespace Poppler { TextBox *nextWord() const; /** - Returns the position of \p i -th edge of the current word. - - For a text() of \em n characters, there are \em n+1 edges. + Returns the bounding box of the \p i -th characted of the word. */ - double edge(int i) const; + QRectF charBoundingBox(int i) const; /** Returns whether there is a space character after this text box diff --git a/qt4/src/poppler-textbox.cc b/qt4/src/poppler-textbox.cc index 840b389e..a17ab626 100644 --- a/qt4/src/poppler-textbox.cc +++ b/qt4/src/poppler-textbox.cc @@ -48,9 +48,9 @@ TextBox *TextBox::nextWord() const return m_data->nextWord; } -double TextBox::edge(int i) const +QRectF TextBox::charBoundingBox(int i) const { - return m_data->edge.value(i, 0.0); + return m_data->charBBoxes.value(i); } bool TextBox::hasSpaceAfter() const |