The internal search is a pretty bad concept, as the Document provides it for free

svn path=/trunk/playground/graphics/okular/; revision=598553
remotes/origin/KDE/4.0
Pino Toscano 20 years ago
parent 03e01b97f6
commit a62cd3aa2f
  1. 16
      core/generator.cpp
  2. 22
      core/generator.h
  3. 5
      generators/chm/generator_chm.cpp
  4. 1
      generators/chm/generator_chm.h
  5. 55
      generators/poppler/generator_pdf.cpp
  6. 6
      generators/poppler/generator_pdf.h

@ -79,22 +79,6 @@ bool Generator::supportsSearching() const
return false;
}
bool Generator::prefersInternalSearching() const
{
return false;
}
RegularAreaRect * Generator::findText( const QString&, SearchDir, const bool,
const RegularAreaRect*, Page* ) const
{
return 0;
}
QString Generator::getText( const RegularAreaRect*, Page* ) const
{
return QString();
}
bool Generator::supportsRotation() const
{
return false;

@ -182,28 +182,6 @@ class OKULAR_EXPORT Generator : public QObject
*/
virtual bool supportsSearching() const;
/**
* This method returns whether the generator prefers internal searching. Default is false.
*/
virtual bool prefersInternalSearching() const;
/**
* This method returns the rectangular of the area where the given @p text can be found
* on the given @p page.
*
* The search can be influenced by the parameters @p direction, @p caseSensitive and
* @p lastRect
*
* If no match is found, 0 is returned.
*/
virtual RegularAreaRect * findText( const QString &text, SearchDir direction, const bool caseSensitive,
const RegularAreaRect *lastRect, Page *page ) const;
/**
* This method returns the text which is enclosed by the given @p area on the given @p page.
*/
virtual QString getText( const RegularAreaRect *area, Page *page ) const;
/**
* Returns whether the generator supports rotation of the pages. Default is false.
*/

@ -372,11 +372,6 @@ bool CHMGenerator::supportsSearching() const
return true;
}
bool CHMGenerator::prefersInternalSearching() const
{
return false;
}
QString CHMGenerator::metaData( const QString &key, const QString &option ) const
{
if ( key == "NamedViewport" && !option.isEmpty() )

@ -44,7 +44,6 @@ class CHMGenerator : public Okular::Generator
void generateSyncTextPage( Okular::Page * page );
bool supportsSearching() const;
bool prefersInternalSearching() const;
QString metaData( const QString & key, const QString & option ) const;

@ -385,61 +385,6 @@ void PDFGenerator::loadPages(QVector<Okular::Page*> &pagesVector, int rotation,
}
}
QString PDFGenerator::getText( const Okular::RegularAreaRect * area, Okular::Page * page ) const
{
QRect rect = area->first()->geometry((int)page->width(),(int)page->height());
Poppler::Page *pp = pdfdoc->page( page->number() );
QString text = pp->text(rect);
delete pp;
return text;
}
Okular::RegularAreaRect * PDFGenerator::findText (const QString & text, Okular::SearchDir dir,
const bool strictCase, const Okular::RegularAreaRect * sRect, Okular::Page * page ) const
{
dir = sRect ? Okular::NextRes : Okular::FromTop;
QRectF rect;
if ( dir == Okular::NextRes )
{
// when using thein ternal search we only play with normrects
rect.setLeft( sRect->first()->left * page->width() );
rect.setTop( sRect->first()->top * page->height() );
rect.setRight( sRect->first()->right * page->width() );
rect.setBottom( sRect->first()->bottom * page->height() );
}
// this loop is only for 'bad case' Reses
bool found = false;
Poppler::Page *pp = pdfdoc->page( page->number() );
docLock.lock();
Poppler::Page::SearchMode sm;
if (strictCase) sm = Poppler::Page::CaseSensitive;
else sm = Poppler::Page::CaseInsensitive;
while ( !found )
{
if ( dir == Okular::FromTop ) found = pp->search(text, rect, Poppler::Page::FromTop, sm);
else if ( dir == Okular::NextRes ) found = pp->search(text, rect, Poppler::Page::NextResult, sm);
else if ( dir == Okular::PrevRes ) found = pp->search(text, rect, Poppler::Page::PreviousResult, sm);
// if not found (even in case unsensitive search), terminate
if ( !found )
break;
}
docLock.unlock();
delete pp;
// if the page was found, return a new normalizedRect
if ( found )
{
Okular::RegularAreaRect *ret=new Okular::RegularAreaRect;
ret->append (new Okular::NormalizedRect( rect.left() / page->width(), rect.top() / page->height(),
rect.right() / page->width(), rect.bottom() / page->height() ) );
return ret;
}
return 0;
}
const Okular::DocumentInfo * PDFGenerator::generateDocumentInfo()
{
if ( docInfoDirty )

@ -73,12 +73,6 @@ class PDFGenerator : public Okular::Generator
bool supportsSearching() const { return true; };
bool supportsRotation() const { return true; };
bool prefersInternalSearching() const { return false; };
Okular::RegularAreaRect * findText (const QString & text, Okular::SearchDir dir,
const bool strictCase, const Okular::RegularAreaRect * lastRect,
Okular::Page * page ) const;
QString getText( const Okular::RegularAreaRect * area, Okular::Page * page ) const;
// [INHERITED] print page using an already configured kprinter
bool print( KPrinter& printer );

Loading…
Cancel
Save