[poppler] poppler/qt4/src: poppler-page.cc, 1.16, 1.17 poppler-private.h, 1.8, 1.9 poppler-qt4.h, 1.28, 1.29 poppler-textbox.cc, 1.1, 1.2

Albert Astals Cid aacid at kemper.freedesktop.org
Mon May 1 11:33:50 PDT 2006


Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv23812/qt4/src

Modified Files:
	poppler-page.cc poppler-private.h poppler-qt4.h 
	poppler-textbox.cc 
Log Message:
        * 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


Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- poppler-page.cc	4 Apr 2006 21:01:01 -0000	1.16
+++ poppler-page.cc	1 May 2006 18:33:47 -0000	1.17
@@ -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 @@
     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 @@
     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;
   

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- poppler-private.h	1 May 2006 13:32:31 -0000	1.8
+++ poppler-private.h	1 May 2006 18:33:47 -0000	1.9
@@ -194,6 +194,17 @@
 		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;
+    };
+
 }
 
 

Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- poppler-qt4.h	1 May 2006 13:32:31 -0000	1.28
+++ poppler-qt4.h	1 May 2006 18:33:47 -0000	1.29
@@ -24,6 +24,7 @@
 
 #include <QtCore/QByteArray>
 #include <QtCore/QDateTime>
+#include <QtCore/QVector>
 #include <QtGui/QPixmap>
 #include <QtXml/QDomDocument>
 
@@ -52,6 +53,7 @@
 	the text is found.
     */
     class TextBox {
+    friend class Page;
     public:
       /**
 	 The default constructor sets the text and the rectangle the
@@ -71,6 +73,12 @@
       */
       const QRectF &boundingBox() const;
 
+      TextBox *nextWord() const;
+
+      double edge(int i) const;
+
+      bool hasSpaceAfter() const;
+
     private:
 	TextBoxData *m_data;
     };

Index: poppler-textbox.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-textbox.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- poppler-textbox.cc	3 Dec 2005 22:20:54 -0000	1.1
+++ poppler-textbox.cc	1 May 2006 18:33:47 -0000	1.2
@@ -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 @@
 	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;
+}
+
 }



More information about the poppler mailing list