[poppler]
poppler/qt4/src: poppler-page.cc, 1.17, 1.18 poppler-qt4.h,
1.29, 1.30
Albert Astals Cid
aacid at kemper.freedesktop.org
Thu May 4 12:10:57 PDT 2006
Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv1848/qt4/src
Modified Files:
poppler-page.cc poppler-qt4.h
Log Message:
* qt4/src/poppler-qt4.h:
* qt4/src/poppler-page.cc: Implement search functionality
more code to make oKular qt4popplered possible, probably not most quickest code around, feel free to comment/optimize
Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- poppler-page.cc 1 May 2006 18:33:47 -0000 1.17
+++ poppler-page.cc 4 May 2006 19:10:55 -0000 1.18
@@ -151,6 +151,49 @@
return result;
}
+bool Page::search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive) const
+{
+ const QChar * str = text.unicode();
+ int len = text.length();
+ QVector<Unicode> u(len);
+ for (int i = 0; i < len; ++i) u[i] = str[i].unicode();
+
+ GBool sCase;
+ if (caseSensitive == CaseSensitive) sCase = gTrue;
+ else sCase = gFalse;
+
+ bool found = false;
+ double sLeft, sTop, sRight, sBottom;
+ sLeft = rect.left();
+ sTop = rect.top();
+ sRight = rect.right();
+ sBottom = rect.bottom();
+
+ // fetch ourselves a textpage
+ TextOutputDev td(NULL, gTrue, gFalse, gFalse);
+ m_page->parentDoc->m_doc->doc.displayPage( &td, m_page->index + 1, 72, 72, 0, false, true, false );
+ TextPage *textPage=td.takeText();
+
+ if (direction == FromTop)
+ found = textPage->findText( u.data(), len,
+ gTrue, gTrue, gFalse, gFalse, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
+ else if ( direction == NextResult )
+ found = textPage->findText( u.data(), len,
+ gFalse, gTrue, gTrue, gFalse, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
+ else if ( direction == PreviousResult )
+ found = textPage->findText( u.data(), len,
+ gTrue, gFalse, gFalse, gTrue, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
+
+ delete textPage;
+
+ rect.setLeft( sLeft );
+ rect.setTop( sTop );
+ rect.setRight( sRight );
+ rect.setBottom( sBottom );
+
+ return found;
+}
+
QList<TextBox*> Page::textList() const
{
TextOutputDev *output_dev;
Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- poppler-qt4.h 1 May 2006 18:33:47 -0000 1.29
+++ poppler-qt4.h 4 May 2006 19:10:55 -0000 1.30
@@ -314,6 +314,22 @@
If rect is null, all text on the page is given
**/
QString text(const QRectF &rect) const;
+
+
+ enum SearchDirection { FromTop, NextResult, PreviousResult };
+ enum SearchMode { CaseSensitive, CaseInsensitive };
+
+ /**
+ Returns true if the specified text was found.
+
+ \param text the text the search
+ \param rect in all directions is used to return where the text was found, for NextResult and PreviousResult
+ indicates where to continue searching for
+ \param direction in which direction do the search
+ \param caseSensitive be case sensitive?
+ **/
+ bool search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive) const;
+
/**
Returns a list of text of the page
More information about the poppler
mailing list