Commit 901abc0b authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Rever addition of rectExtractText that is used only in one place

parent 760c8664
......@@ -2207,7 +2207,35 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
}
// if we support text generation
QString selectedText = rectExtractText(selectionRect, Okular::TextPage::AnyPixelTextAreaInclusionBehaviour);
QString selectedText;
if (d->document->supportsSearching())
{
// grab text in selection by extracting it from all intersected pages
const Okular::Page * okularPage=0;
QVector< PageViewItem * >::const_iterator iIt = d->items.constBegin(), iEnd = d->items.constEnd();
for ( ; iIt != iEnd; ++iIt )
{
PageViewItem * item = *iIt;
if ( !item->isVisible() )
continue;
const QRect & itemRect = item->croppedGeometry();
if ( selectionRect.intersects( itemRect ) )
{
// request the textpage if there isn't one
okularPage= item->page();
kWarning() << "checking if page" << item->pageNumber() << "has text:" << okularPage->hasTextPage();
if ( !okularPage->hasTextPage() )
d->document->requestTextPage( okularPage->number() );
// grab text in the rect that intersects itemRect
QRect relativeRect = selectionRect.intersect( itemRect );
relativeRect.translate( -item->uncroppedGeometry().topLeft() );
Okular::RegularAreaRect rects;
rects.append( Okular::NormalizedRect( relativeRect, item->uncroppedWidth(), item->uncroppedHeight() ) );
selectedText += okularPage->text( &rects );
}
}
}
// popup that ask to copy:text and copy/save:image
KMenu menu( this );
......@@ -2922,42 +2950,6 @@ PageViewItem * PageView::pickItemOnPoint( int x, int y )
return item;
}
const QString PageView::rectExtractText(const QRect &selectionRect, const Okular::TextPage::TextAreaInclusionBehaviour b)
{
QString selectedText;
// if we support text generation
if (d->document->supportsSearching())
{
// grab text in selection by extracting it from all intersected pages
const Okular::Page * okularPage=0;
QVector< PageViewItem * >::const_iterator iIt = d->items.constBegin(), iEnd = d->items.constEnd();
for ( ; iIt != iEnd; ++iIt )
{
PageViewItem * item = *iIt;
if ( !item->isVisible() )
continue;
const QRect & itemRect = item->croppedGeometry();
if ( selectionRect.intersects( itemRect ) )
{
// request the textpage if there isn't one
okularPage= item->page();
kWarning() << "checking if page" << item->pageNumber() << "has text:" << okularPage->hasTextPage();
if ( !okularPage->hasTextPage() )
d->document->requestTextPage( okularPage->number() );
// grab text in the rect that intersects itemRect
QRect relativeRect = selectionRect.intersect( itemRect );
relativeRect.translate( -item->uncroppedGeometry().topLeft() );
Okular::RegularAreaRect rects;
rects.append( Okular::NormalizedRect( relativeRect, item->uncroppedWidth(), item->uncroppedHeight() ) );
selectedText += okularPage->text( &rects, b );
}
}
}
return selectedText;
}
void PageView::textSelectionClear()
{
// something to clear
......
......@@ -26,7 +26,6 @@
#include "core/area.h"
#include "core/observer.h"
#include "core/view.h"
#include "core/textpage.h"
class KAction;
class KActionCollection;
......@@ -157,8 +156,6 @@ Q_OBJECT
void updateItemSize( PageViewItem * item, int columnWidth, int rowHeight );
// return the widget placed on a certain point or 0 if clicking on empty space
PageViewItem * pickItemOnPoint( int x, int y );
// extract text from a rectangular region
const QString rectExtractText(const QRect &selectionRect, const Okular::TextPage::TextAreaInclusionBehaviour b);
// start / modify / clear selection rectangle
void selectionStart( const QPoint & pos, const QColor & color, bool aboveAll = false );
void selectionEndPoint( const QPoint & pos );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment