Commit d576e28a authored by Enrico Ros's avatar Enrico Ros

More naming changes. KPDFPage is perfectly in shape now.

I'm working on Annotations stuff now, expect good news after the freeze!

svn path=/trunk/kdegraphics/kpdf/; revision=387781
parent 5b0c32e4
......@@ -246,22 +246,22 @@ void PDFGenerator::generatePixmap( PixmapRequest * request )
bool genTextPage = !page->hasSearchPage() && (request->width == page->width()) &&
(request->height == page->height());
// generate links and image rects if rendering pages on pageview
bool genRects = request->id == PAGEVIEW_ID;
bool genObjectRects = request->id == PAGEVIEW_ID;
// 0. LOCK [waits for the thread end]
docLock.lock();
// 1. Set OutputDev parameters and Generate contents
// note: thread safety is set on 'false' for the GUI (this) thread
kpdfOutputDev->setParams( request->width, request->height, genTextPage, genRects, genRects, false );
pdfdoc->displayPage( kpdfOutputDev, page->number() + 1, fakeDpiX, fakeDpiY, 0, true, genRects );
kpdfOutputDev->setParams( request->width, request->height, genTextPage, genObjectRects, genObjectRects, false );
pdfdoc->displayPage( kpdfOutputDev, page->number() + 1, fakeDpiX, fakeDpiY, 0, true, genObjectRects );
// 2. Take data from outputdev and attach it to the Page
page->setPixmap( request->id, kpdfOutputDev->takePixmap() );
if ( genTextPage )
page->setSearchPage( kpdfOutputDev->takeTextPage() );
if ( genRects )
page->setRects( kpdfOutputDev->takeRects() );
if ( genObjectRects )
page->setObjectRects( kpdfOutputDev->takeObjectRects() );
// 3. UNLOCK [re-enables shared access]
docLock.unlock();
......@@ -663,14 +663,14 @@ void PDFGenerator::customEvent( QCustomEvent * event )
PixmapRequest * request = static_cast< PixmapRequest * >( event->data() );
QImage * outImage = generatorThread->takeImage();
TextPage * outTextPage = generatorThread->takeTextPage();
QValueList< ObjectRect * > outRects = generatorThread->takeRects();
QValueList< ObjectRect * > outRects = generatorThread->takeObjectRects();
request->page->setPixmap( request->id, new QPixmap( *outImage ) );
delete outImage;
if ( outTextPage )
request->page->setSearchPage( outTextPage );
if ( !outRects.isEmpty() )
request->page->setRects( outRects );
request->page->setObjectRects( outRects );
// 3. tell generator that data has been taken
generatorThread->endGeneration();
......@@ -780,7 +780,7 @@ TextPage * PDFPixmapGeneratorThread::takeTextPage() const
return tp;
}
QValueList< ObjectRect * > PDFPixmapGeneratorThread::takeRects() const
QValueList< ObjectRect * > PDFPixmapGeneratorThread::takeObjectRects() const
{
d->m_rectsTaken = true;
return d->m_rects;
......@@ -804,16 +804,16 @@ void PDFPixmapGeneratorThread::run()
( height == page->height() );
// generate links and image rects if rendering pages on pageview
bool genPageRects = d->currentRequest->id == PAGEVIEW_ID;
bool genObjectRects = d->currentRequest->id == PAGEVIEW_ID;
// 0. LOCK s[tart locking XPDF thread unsafe classes]
d->generator->docLock.lock();
// 1. set OutputDev parameters and Generate contents
d->generator->kpdfOutputDev->setParams( width, height, genTextPage,
genPageRects, genPageRects, TRUE /*thread safety*/ );
genObjectRects, genObjectRects, TRUE /*thread safety*/ );
d->generator->pdfdoc->displayPage( d->generator->kpdfOutputDev, page->number() + 1,
fakeDpiX, fakeDpiY, 0, true, genPageRects );
fakeDpiX, fakeDpiY, 0, true, genObjectRects );
// 2. grab data from the OutputDev and store it locally (note takeIMAGE)
#ifndef NDEBUG
......@@ -824,7 +824,7 @@ void PDFPixmapGeneratorThread::run()
#endif
d->m_image = d->generator->kpdfOutputDev->takeImage();
d->m_textPage = d->generator->kpdfOutputDev->takeTextPage();
d->m_rects = d->generator->kpdfOutputDev->takeRects();
d->m_rects = d->generator->kpdfOutputDev->takeObjectRects();
d->m_rectsTaken = false;
// 3. [UNLOCK] mutex
......
......@@ -119,7 +119,7 @@ class PDFPixmapGeneratorThread : public QThread
// methods for getting contents from the GUI thread
QImage * takeImage() const;
TextPage * takeTextPage() const;
QValueList< ObjectRect * > takeRects() const;
QValueList< ObjectRect * > takeObjectRects() const;
private:
// can't be called from the outside (but from startGeneration)
......
......@@ -91,7 +91,7 @@ TextPage * KPDFOutputDev::takeTextPage()
return text;
}
QValueList< ObjectRect * > KPDFOutputDev::takeRects()
QValueList< ObjectRect * > KPDFOutputDev::takeObjectRects()
{
if ( m_rects.isEmpty() )
return m_rects;
......
......@@ -56,7 +56,7 @@ class KPDFOutputDev : public SplashOutputDev
QPixmap * takePixmap();
QImage * takeImage();
TextPage * takeTextPage();
QValueList< ObjectRect * > takeRects();
QValueList< ObjectRect * > takeObjectRects();
/** inherited from OutputDev */
// Start a page.
......
......@@ -69,7 +69,7 @@ bool KPDFPage::hasBookmark() const
return m_bookmarked;
}
bool KPDFPage::hasRect( double x, double y ) const
bool KPDFPage::hasObjectRect( double x, double y ) const
{
if ( m_rects.count() < 1 )
return false;
......@@ -173,7 +173,7 @@ const QString KPDFPage::getText( const NormalizedRect & rect ) const
return result;
}
const ObjectRect * KPDFPage::getRect( double x, double y ) const
const ObjectRect * KPDFPage::getObjectRect( double x, double y ) const
{
QValueList< ObjectRect * >::const_iterator it = m_rects.begin(), end = m_rects.end();
for ( ; it != end; ++it )
......@@ -206,7 +206,7 @@ void KPDFPage::setBookmark( bool state )
m_bookmarked = state;
}
void KPDFPage::setRects( const QValueList< ObjectRect * > rects )
void KPDFPage::setObjectRects( const QValueList< ObjectRect * > rects )
{
QValueList< ObjectRect * >::iterator it = m_rects.begin(), end = m_rects.end();
for ( ; it != end; ++it )
......@@ -231,7 +231,7 @@ void KPDFPage::setHighlight( int s_id, NormalizedRect * &rect, const QColor & co
rect = hr;
}
void KPDFPage::setTransition( const KPDFPageTransition * transition )
void KPDFPage::setTransition( KPDFPageTransition * transition )
{
delete m_transition;
m_transition = transition;
......@@ -253,7 +253,7 @@ void KPDFPage::deletePixmapsAndRects()
for ( ; it != end; ++it )
delete *it;
m_pixmaps.clear();
// delete PageRects
// delete ObjectRects
QValueList< ObjectRect * >::iterator rIt = m_rects.begin(), rEnd = m_rects.end();
for ( ; rIt != rEnd; ++rIt )
delete *rIt;
......
......@@ -20,6 +20,7 @@ class KPDFPageTransition;
class NormalizedRect;
class ObjectRect;
class HighlightRect;
class Annotation;
/**
* @short Collector for all the data belonging to a page.
......@@ -48,22 +49,25 @@ class KPDFPage
bool hasPixmap( int p_id, int width = -1, int height = -1 ) const;
bool hasSearchPage() const;
bool hasBookmark() const;
bool hasRect( double x, double y ) const;
bool hasObjectRect( double x, double y ) const;
bool hasHighlights( int s_id = -1 ) const;
//bool hasAnnotation( double x, double y ) const;
bool hasTransition() const;
NormalizedRect * findText( const QString & text, bool keepCase, NormalizedRect * last = 0 ) const;
const QString getText( const NormalizedRect & rect ) const;
const ObjectRect * getRect( double x, double y ) const;
const ObjectRect * getObjectRect( double x, double y ) const;
//const Annotation * getAnnotation( double x, double y ) const;
const KPDFPageTransition * getTransition() const;
// oprations: set/delete contents (by KPDFDocument)
// operations: set/delete contents (by KPDFDocument)
void setPixmap( int p_id, QPixmap * pixmap );
void setSearchPage( TextPage * text );
void setBookmark( bool state );
void setRects( const QValueList< ObjectRect * > rects );
void setObjectRects( const QValueList< ObjectRect * > rects );
void setHighlight( int s_id, NormalizedRect * &r, const QColor & color );
void setTransition( const KPDFPageTransition * transition );
//void setAnnotation( Annotation * annotation );
void setTransition( KPDFPageTransition * transition );
void deletePixmap( int p_id );
void deletePixmapsAndRects();
void deleteHighlights( int s_id = -1 );
......@@ -78,7 +82,8 @@ class KPDFPage
TextPage * m_text;
QValueList< ObjectRect * > m_rects;
QValueList< HighlightRect * > m_highlights;
const KPDFPageTransition * m_transition;
//QValueList< Annotation * > m_annotations;
KPDFPageTransition * m_transition;
};
......@@ -116,9 +121,11 @@ class NormalizedRect
class ObjectRect : public NormalizedRect
{
public:
// definition of the types of storable objects
enum ObjectType { Link, Image };
ObjectRect( double left, double top, double right, double bottom,
ObjectType t, void * object );
// default constructor: initialize all parameters
ObjectRect( double l, double t, double r, double b, ObjectType typ, void * obj );
~ObjectRect();
// query type and get a const pointer to the stored object
......@@ -135,8 +142,9 @@ class ObjectRect : public NormalizedRect
*/
struct HighlightRect : public NormalizedRect
{
// more publicly accessed fields
// searchID of the highlight owner
int s_id;
// color of the highlight
QColor color;
};
......
......@@ -19,7 +19,7 @@
#include "pagepainter.h"
#include "core/page.h"
#include "conf/settings.h"
#include <kdebug.h>
void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
QPainter * destPainter, const QRect & limits, int width, int height )
{
......
......@@ -876,7 +876,7 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
{
double nX = (double)(e->x() - pageItem->geometry().left()) / (double)pageItem->width(),
nY = (double)(e->y() - pageItem->geometry().top()) / (double)pageItem->height();
const ObjectRect * rect = pageItem->page()->getRect( nX, nY );
const ObjectRect * rect = pageItem->page()->getObjectRect( nX, nY );
if ( rect )
{
// handle click over a link/image
......@@ -1437,7 +1437,7 @@ void PageView::updateCursor( const QPoint &p )
nY = (double)(p.y() - pageItem->geometry().top()) / (double)pageItem->height();
// if over a ObjectRect (of type Link) change cursor to hand
const ObjectRect * r = pageItem->page()->getRect( nX, nY );
const ObjectRect * r = pageItem->page()->getObjectRect( nX, nY );
d->mouseOnRect = r && r->objectType() == ObjectRect::Link;
if ( d->mouseOnRect )
setCursor( pointingHandCursor );
......
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