[poppler] 5 commits - qt4/src qt4/tests
Pino Toscano
pino at kemper.freedesktop.org
Thu Feb 7 09:08:16 PST 2008
qt4/src/poppler-link-extractor-private.h | 3 -
qt4/src/poppler-link-extractor.cc | 17 ++++----
qt4/src/poppler-page-private.h | 3 +
qt4/src/poppler-page.cc | 63 +++++++++++++------------------
qt4/tests/CMakeLists.txt | 1
5 files changed, 43 insertions(+), 44 deletions(-)
New commits:
commit ee9f85915feb86b54ace1a403baa13bbdd7c3966
Author: Pino Toscano <pino at kde.org>
Date: Thu Feb 7 18:07:53 2008 +0100
Having a PageData is mandatory.
Just assert when constructing instead of checking for it in each link iteration.
diff --git a/qt4/src/poppler-link-extractor.cc b/qt4/src/poppler-link-extractor.cc
index 55a6d79..101f62f 100644
--- a/qt4/src/poppler-link-extractor.cc
+++ b/qt4/src/poppler-link-extractor.cc
@@ -29,6 +29,7 @@ namespace Poppler
LinkExtractorOutputDev::LinkExtractorOutputDev(PageData *data)
: m_data(data)
{
+ Q_ASSERT(m_data);
::Page *popplerPage = m_data->page;
m_pageCropWidth = popplerPage->getCropWidth();
m_pageCropHeight = popplerPage->getCropHeight();
@@ -43,7 +44,7 @@ LinkExtractorOutputDev::~LinkExtractorOutputDev()
void LinkExtractorOutputDev::processLink(::Link *link, Catalog *catalog)
{
- if (!link->isOk() || !m_data)
+ if (!link->isOk())
return;
double left, top, right, bottom;
commit ad4b1361f6c25359e6ddb38599bfc1e4e3e80408
Author: Pino Toscano <pino at kde.org>
Date: Thu Feb 7 18:03:30 2008 +0100
Precalc stuff we don't need to recalc in each link iteration.
diff --git a/qt4/src/poppler-link-extractor-private.h b/qt4/src/poppler-link-extractor-private.h
index acf3794..ba6b0fc 100644
--- a/qt4/src/poppler-link-extractor-private.h
+++ b/qt4/src/poppler-link-extractor-private.h
@@ -44,8 +44,9 @@ class LinkExtractorOutputDev : public OutputDev
QList< Link* > links();
private:
- ::Page *m_popplerPage;
PageData *m_data;
+ double m_pageCropWidth;
+ double m_pageCropHeight;
QList< Link* > m_links;
};
diff --git a/qt4/src/poppler-link-extractor.cc b/qt4/src/poppler-link-extractor.cc
index 2405db3..55a6d79 100644
--- a/qt4/src/poppler-link-extractor.cc
+++ b/qt4/src/poppler-link-extractor.cc
@@ -29,8 +29,10 @@ namespace Poppler
LinkExtractorOutputDev::LinkExtractorOutputDev(PageData *data)
: m_data(data)
{
- m_popplerPage = m_data->parentDoc->doc->getCatalog()->getPage(m_data->index + 1);
- GfxState gfxState(72.0, 72.0, m_popplerPage->getCropBox(), m_popplerPage->getRotate(), gTrue);
+ ::Page *popplerPage = m_data->page;
+ m_pageCropWidth = popplerPage->getCropWidth();
+ m_pageCropHeight = popplerPage->getCropHeight();
+ GfxState gfxState(72.0, 72.0, popplerPage->getCropBox(), popplerPage->getRotate(), gTrue);
setDefaultCTM(gfxState.getCTM());
}
@@ -51,10 +53,10 @@ void LinkExtractorOutputDev::processLink(::Link *link, Catalog *catalog)
cvtUserToDev(left, top, &leftAux, &topAux);
cvtUserToDev(right, bottom, &rightAux, &bottomAux);
- linkArea.setLeft((double)leftAux / (double)m_popplerPage->getCropWidth());
- linkArea.setTop((double)topAux / (double)m_popplerPage->getCropHeight());
- linkArea.setRight((double)rightAux / (double)m_popplerPage->getCropWidth());
- linkArea.setBottom((double)bottomAux / (double)m_popplerPage->getCropHeight());
+ linkArea.setLeft((double)leftAux / m_pageCropWidth);
+ linkArea.setTop((double)topAux / m_pageCropHeight);
+ linkArea.setRight((double)rightAux / m_pageCropWidth);
+ linkArea.setBottom((double)bottomAux / m_pageCropHeight);
Link *popplerLink = m_data->convertLinkActionToLink(link->getAction(), linkArea);
if (popplerLink)
commit 82432dbc62a0879f4513640c2e0f594fda9347ad
Author: Pino Toscano <pino at kde.org>
Date: Thu Feb 7 17:51:50 2008 +0100
Store the ::Page internally, so we don't need to get it again everytime.
diff --git a/qt4/src/poppler-page-private.h b/qt4/src/poppler-page-private.h
index b72a901..1545790 100644
--- a/qt4/src/poppler-page-private.h
+++ b/qt4/src/poppler-page-private.h
@@ -21,6 +21,8 @@
#include "poppler-private.h"
+class Page;
+
namespace Poppler
{
@@ -29,6 +31,7 @@ public:
Link* convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea);
DocumentData *parentDoc;
+ ::Page *page;
int index;
PageTransition *transition;
};
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 5f9b52a..48c19ed 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -161,6 +161,7 @@ Page::Page(DocumentData *doc, int index) {
m_page = new PageData();
m_page->index = index;
m_page->parentDoc = doc;
+ m_page->page = doc->doc->getCatalog()->getPage(m_page->index + 1);
m_page->transition = 0;
}
@@ -258,21 +259,19 @@ QString Page::text(const QRectF &r) const
GooString *s;
PDFRectangle *rect;
QString result;
- ::Page *p;
output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse);
m_page->parentDoc->doc->displayPageSlice(output_dev, m_page->index + 1, 72, 72,
0, false, true, false, -1, -1, -1, -1);
- p = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
if (r.isNull())
{
- rect = p->getCropBox();
+ rect = m_page->page->getCropBox();
s = output_dev->getText(rect->x1, rect->y1, rect->x2, rect->y2);
}
else
{
double height, y1, y2;
- height = p->getCropHeight();
+ height = m_page->page->getCropHeight();
y1 = height - r.top();
y2 = height - r.bottom();
s = output_dev->getText(r.left(), y1, r.right(), y2);
@@ -387,7 +386,7 @@ PageTransition *Page::transition() const
if (!m_page->transition) {
Object o;
PageTransitionParams params;
- params.dictObj = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1)->getTrans(&o);
+ params.dictObj = m_page->page->getTrans(&o);
if (params.dictObj->isDict()) m_page->transition = new PageTransition(params);
o.free();
}
@@ -398,9 +397,8 @@ Link *Page::action( PageAction act ) const
{
if ( act == Page::Opening || act == Page::Closing )
{
- ::Page *p = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
Object o;
- p->getActions(&o);
+ m_page->page->getActions(&o);
if (!o.isDict())
{
o.free();
@@ -426,13 +424,11 @@ Link *Page::action( PageAction act ) const
QSizeF Page::pageSizeF() const
{
- ::Page *p;
-
- p = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
- if ( ( Page::Landscape == orientation() ) || (Page::Seascape == orientation() ) ) {
- return QSizeF( p->getCropHeight(), p->getCropWidth() );
+ Page::Orientation orient = orientation();
+ if ( ( Page::Landscape == orient ) || (Page::Seascape == orient ) ) {
+ return QSizeF( m_page->page->getCropHeight(), m_page->page->getCropWidth() );
} else {
- return QSizeF( p->getCropWidth(), p->getCropHeight() );
+ return QSizeF( m_page->page->getCropWidth(), m_page->page->getCropHeight() );
}
}
@@ -443,7 +439,7 @@ QSize Page::pageSize() const
Page::Orientation Page::orientation() const
{
- int rotation = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1)->getRotate();
+ const int rotation = m_page->page->getRotate();
switch (rotation) {
case 90:
return Page::Landscape;
@@ -461,9 +457,7 @@ Page::Orientation Page::orientation() const
void Page::defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown)
{
- ::Page *p;
- p = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
- p->getDefaultCTM(CTM, dpiX, dpiY, rotate, gFalse, upsideDown);
+ m_page->page->getDefaultCTM(CTM, dpiX, dpiY, rotate, gFalse, upsideDown);
}
QList<Link*> Page::links() const
@@ -478,7 +472,7 @@ QList<Link*> Page::links() const
QList<Annotation*> Page::annotations() const
{
Object annotArray;
- ::Page *pdfPage = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
+ ::Page *pdfPage = m_page->page;
pdfPage->getAnnots( &annotArray );
if ( !annotArray.isArray() || annotArray.arrayGetLength() < 1 )
{
@@ -1262,7 +1256,7 @@ QList<Annotation*> Page::annotations() const
QList<FormField*> Page::formFields() const
{
QList<FormField*> fields;
- ::Page *p = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
+ ::Page *p = m_page->page;
::FormPageWidgets * form = p->getPageWidgets();
int formcount = form->getNumWidgets();
for (int i = 0; i < formcount; ++i)
@@ -1295,10 +1289,7 @@ QList<FormField*> Page::formFields() const
double Page::duration() const
{
- ::Page *p;
- p = m_page->parentDoc->doc->getCatalog()->getPage(m_page->index + 1);
- if (p) return p->getDuration();
- else return -1;
+ return m_page->page->getDuration();
}
QString Page::label() const
commit 8ec51f7ca518aa6a4a69f30d373722d05f50cf07
Author: Pino Toscano <pino at kde.org>
Date: Thu Feb 7 16:48:16 2008 +0100
Compile the stress-poppler-dir test as well.
diff --git a/qt4/tests/CMakeLists.txt b/qt4/tests/CMakeLists.txt
index bd32548..b17da53 100644
--- a/qt4/tests/CMakeLists.txt
+++ b/qt4/tests/CMakeLists.txt
@@ -35,6 +35,7 @@ qt4_add_simpletest(test-password-qt4 test-password-qt4.cpp)
qt4_add_simpletest(poppler-fonts poppler-fonts.cpp)
qt4_add_simpletest(poppler_attachments poppler-attachments.cpp)
qt4_add_simpletest(stress-poppler-qt4 stress-poppler-qt4.cpp)
+qt4_add_simpletest(stress-poppler-dir stress-poppler-dir.cpp)
qt4_add_qtest(check_attachments check_attachments.cpp)
qt4_add_qtest(check_dateConversion check_dateConversion.cpp)
commit 8a946b76ae2e7c2c5238b4e580c1c226eb457dc9
Author: Pino Toscano <pino at kde.org>
Date: Thu Feb 7 01:07:28 2008 +0100
Micro-touches to the debug messages.
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 3573604..5f9b52a 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -515,7 +515,7 @@ QList<Annotation*> Page::annotations() const
annotArray.arrayGet( j, &annot );
if ( !annot.isDict() )
{
- qDebug() << "PDFGenerator: annot not dictionary." << endl;
+ qDebug() << "PDFGenerator: annot not dictionary.";
annot.free();
continue;
}
@@ -531,7 +531,7 @@ QList<Annotation*> Page::annotations() const
XPDFReader::lookupName( annotDict, "Subtype", subType );
if ( subType.isEmpty() )
{
- qDebug() << "annot has no Subtype" << endl;
+ qDebug() << "Annot has no Subtype";
annot.free();
continue;
}
@@ -618,7 +618,7 @@ QList<Annotation*> Page::annotations() const
int num = XPDFReader::lookupNumArray( annotDict, (char*)((subType == "Line") ? "L" : "Vertices"), c, 100 );
if ( num < 4 || (num % 2) != 0 )
{
- qDebug() << "L/Vertices wrong fol Line/Poly." << endl;
+ qDebug() << "L/Vertices wrong fol Line/Poly.";
delete annotation;
annot.free();
continue;
@@ -760,7 +760,7 @@ QList<Annotation*> Page::annotations() const
int num = XPDFReader::lookupNumArray( annotDict, "QuadPoints", c, 80 );
if ( num < 8 || (num % 8) != 0 )
{
- qDebug() << "Wrong QuadPoints for a Highlight annotation." << endl;
+ qDebug() << "Wrong QuadPoints for a Highlight annotation.";
delete annotation;
annot.free();
continue;
@@ -806,7 +806,7 @@ QList<Annotation*> Page::annotations() const
annotDict->lookup( "InkList", &pathsArray );
if ( !pathsArray.isArray() || pathsArray.arrayGetLength() < 1 )
{
- qDebug() << "InkList not present for ink annot" << endl;
+ qDebug() << "InkList not present for ink annot";
delete annotation;
annot.free();
continue;
@@ -884,7 +884,7 @@ QList<Annotation*> Page::annotations() const
int num = XPDFReader::lookupNumArray( annotDict, "QuadPoints", c, 8 );
if ( num > 0 && num != 8 )
{
- qDebug() << "Wrong QuadPoints for a Link annotation." << endl;
+ qDebug() << "Wrong QuadPoints for a Link annotation.";
delete annotation;
annot.free();
continue;
@@ -920,7 +920,7 @@ QList<Annotation*> Page::annotations() const
{
// MISSING: Caret, FileAttachment, Sound, Movie, Widget,
// Screen, PrinterMark, TrapNet, Watermark, 3D
- qDebug() << "annotation '" << subType << "' not supported" << endl;
+ qDebug() << "Annotation" << subType << "not supported";
annot.free();
continue;
}
@@ -930,7 +930,7 @@ QList<Annotation*> Page::annotations() const
double r[4];
if ( XPDFReader::lookupNumArray( annotDict, "Rect", r, 4 ) != 4 )
{
- qDebug() << "Rect is missing for annotation." << endl;
+ qDebug() << "Rect is missing for annotation.";
annot.free();
continue;
}
@@ -1149,7 +1149,7 @@ QList<Annotation*> Page::annotations() const
if ( addToPage )
{
if ( annotationsMap.contains( annotID ) )
- qDebug() << "PDFGenerator: clash for annotations with ID:" << annotID << endl;
+ qDebug() << "Clash for annotations with ID:" << annotID;
annotationsMap[ annotID ] = annotation;
}
} // end Annotation/PopupWindow parsing loop
@@ -1164,8 +1164,8 @@ QList<Annotation*> Page::annotations() const
const ResolveWindow & request = *it;
if ( !popupsMap.contains( request.popupWindowID ) )
// warn aboud problems in popup resolving logic
- qDebug() << "PDFGenerator: can't resolve popup "
- << request.popupWindowID << "." << endl;
+ qDebug() << "Cannot resolve popup"
+ << request.popupWindowID << ".";
else
{
// set annotation's window properties taking ones from popup
@@ -1208,8 +1208,8 @@ QList<Annotation*> Page::annotations() const
int parentID = request.prevAnnotationID;
if ( !annotationsMap.contains( parentID ) )
// warn about problems in reparenting logic
- qDebug() << "PDFGenerator: can't reparent annotation to "
- << parentID << "." << endl;
+ qDebug() << "Cannot reparent annotation to"
+ << parentID << ".";
else
{
// compile and add a Revision structure to the parent annotation
More information about the poppler
mailing list