mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 02:45:38 +00:00
Fixed free text selection for rotated pages
svn path=/trunk/playground/graphics/okular/; revision=617621
This commit is contained in:
parent
486095425b
commit
4fe8bdce53
22
core/area.h
22
core/area.h
|
@ -331,13 +331,14 @@ template <class NormalizedShape, class Shape> class RegularArea : public QList<
|
|||
~RegularArea();
|
||||
bool contains( double x, double y ) const;
|
||||
bool contains( const NormalizedShape& shape ) const;
|
||||
bool intersects (const RegularArea<NormalizedShape,Shape> * area) const;
|
||||
bool intersects (const NormalizedShape& shape) const;
|
||||
void appendArea (const RegularArea<NormalizedShape,Shape> *area);
|
||||
bool intersects( const RegularArea<NormalizedShape,Shape> *area ) const;
|
||||
bool intersects( const NormalizedShape& shape ) const;
|
||||
void appendArea( const RegularArea<NormalizedShape,Shape> *area );
|
||||
void appendShape( const NormalizedShape& shape );
|
||||
void simplify ();
|
||||
void simplify();
|
||||
bool isNull() const;
|
||||
QList<Shape> geometry( int xScale, int yScale, int dx=0,int dy=0 ) const;
|
||||
void transform( const QMatrix &matrix );
|
||||
};
|
||||
|
||||
template <class NormalizedShape, class Shape>
|
||||
|
@ -513,6 +514,19 @@ QList<Shape> RegularArea<NormalizedShape, Shape>::geometry( int xScale, int ySca
|
|||
return ret;
|
||||
}
|
||||
|
||||
template <class NormalizedShape, class Shape>
|
||||
void RegularArea<NormalizedShape, Shape>::transform( const QMatrix &matrix )
|
||||
{
|
||||
if ( !this )
|
||||
return;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < this->count(); ++i )
|
||||
givePtr( (*this)[i] )->transform( matrix );
|
||||
}
|
||||
|
||||
typedef RegularArea<NormalizedRect,QRect> RegularAreaRect;
|
||||
|
||||
class HighlightAreaRect : public RegularAreaRect
|
||||
|
|
|
@ -256,7 +256,10 @@ QString Page::text( const RegularAreaRect * area ) const
|
|||
if ( !d->m_text )
|
||||
return ret;
|
||||
|
||||
ret = d->m_text->text( area );
|
||||
RegularAreaRect rotatedArea = *area;
|
||||
rotatedArea.transform( d->rotationMatrix().inverted() );
|
||||
|
||||
ret = d->m_text->text( &rotatedArea );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -270,9 +273,6 @@ void Page::rotateAt( int orientation )
|
|||
deleteHighlights();
|
||||
deleteTextSelections();
|
||||
|
||||
if ( d->m_text )
|
||||
d->m_text->transform( d->rotationMatrix() );
|
||||
|
||||
if ( ( d->m_orientation + d->m_rotation ) % 2 != ( d->m_orientation + neworientation ) % 2 )
|
||||
qSwap( d->m_width, d->m_height );
|
||||
|
||||
|
@ -374,8 +374,6 @@ void Page::setTextPage( TextPage * textPage )
|
|||
{
|
||||
delete d->m_text;
|
||||
|
||||
textPage->transform( d->rotationMatrix() );
|
||||
|
||||
d->m_text = textPage;
|
||||
}
|
||||
|
||||
|
|
|
@ -623,8 +623,8 @@ void PDFGenerator::generatePixmap( Okular::PixmapRequest * request )
|
|||
docLock.unlock();
|
||||
if ( genTextPage )
|
||||
{
|
||||
QList<Poppler::TextBox*> textList = p->textList((Poppler::Page::Rotation)request->page()->rotation());
|
||||
page->setTextPage( abstractTextPage(textList, page->height(), page->width(), request->page()->totalOrientation()) );
|
||||
QList<Poppler::TextBox*> textList = p->textList((Poppler::Page::Rotation)request->page()->orientation());
|
||||
page->setTextPage( abstractTextPage(textList, page->height(), page->width(), request->page()->orientation()) );
|
||||
qDeleteAll(textList);
|
||||
}
|
||||
delete p;
|
||||
|
@ -647,11 +647,15 @@ void PDFGenerator::generateSyncTextPage( Okular::Page * page )
|
|||
// build a TextList...
|
||||
Poppler::Page *pp = pdfdoc->page( page->number() );
|
||||
docLock.lock();
|
||||
QList<Poppler::TextBox*> textList = pp->textList((Poppler::Page::Rotation)page->rotation());
|
||||
QList<Poppler::TextBox*> textList = pp->textList((Poppler::Page::Rotation)page->orientation());
|
||||
docLock.unlock();
|
||||
delete pp;
|
||||
// ..and attach it to the page
|
||||
page->setTextPage( abstractTextPage(textList, page->height(), page->width(), page->totalOrientation()) );
|
||||
|
||||
const double pageWidth = ( page->rotation() % 2 ? page->height() : page->width() );
|
||||
const double pageHeight = ( page->rotation() % 2 ? page->width() : page->height() );
|
||||
|
||||
page->setTextPage( abstractTextPage(textList, pageHeight, pageWidth, (Poppler::Page::Rotation)page->orientation()));
|
||||
qDeleteAll(textList);
|
||||
}
|
||||
|
||||
|
@ -1291,7 +1295,7 @@ void PDFGenerator::threadFinished()
|
|||
if ( !outText.isEmpty() )
|
||||
{
|
||||
request->page()->setTextPage( abstractTextPage( outText ,
|
||||
request->page()->height(), request->page()->width(),request->page()->totalOrientation()));
|
||||
request->page()->height(), request->page()->width(),request->page()->orientation()));
|
||||
qDeleteAll(outText);
|
||||
}
|
||||
bool genObjectRects = request->id() & (PAGEVIEW_ID | PRESENTATION_ID);
|
||||
|
@ -1471,7 +1475,7 @@ void PDFPixmapGeneratorThread::run()
|
|||
|
||||
if ( genTextPage )
|
||||
{
|
||||
d->m_textList = pp->textList((Poppler::Page::Rotation)d->currentRequest->page()->rotation());
|
||||
d->m_textList = pp->textList((Poppler::Page::Rotation)d->currentRequest->page()->orientation());
|
||||
}
|
||||
delete pp;
|
||||
|
||||
|
|
Loading…
Reference in a new issue