libokularGenerator_poppler links

svn path=/branches/work/kde4/playground/graphics/okular/; revision=522254
This commit is contained in:
Albert Astals Cid 2006-03-24 21:45:59 +00:00
parent 8b41489e2f
commit b98637741d
5 changed files with 39 additions and 40 deletions

View file

@ -1,7 +1,7 @@
kde_module_LTLIBRARIES = \
libokularGenerator_poppler.la
INCLUDES = -I$(srcdir)/../.. $(POPPLER_CFLAGS) $(all_includes)
INCLUDES = -I$(srcdir)/../.. -I../.. $(POPPLER_CFLAGS) $(all_includes)
libokularGenerator_poppler_la_LIBADD = ../../core/liboKularcore.la ../../conf/liboKularconf.la \
$(POPPLER_LIBS) $(LIB_KDEPRINT) $(LIB_KDEUI) -lm

View file

@ -13,12 +13,11 @@
#include <qevent.h>
#include <qimage.h>
#include <qapplication.h>
#include <qpaintdevicemetrics.h>
#include <qregexp.h>
#include <qpoint.h>
#include <kapplication.h>
#include <kauthorized.h>
#include <klocale.h>
#include <kpassdlg.h>
#include <kpassworddialog.h>
#include <kwallet.h>
#include <kprinter.h>
#include <ktempfile.h>
@ -108,13 +107,13 @@ PDFGenerator::~PDFGenerator()
delete globalParams;
}
void PDFGenerator::setOrientation(QValueVector<KPDFPage*> & pagesVector, int orientation)
void PDFGenerator::setOrientation(QVector<KPDFPage*> & pagesVector, int orientation)
{
loadPages(pagesVector,orientation,true);
}
//BEGIN Generator inherited functions
bool PDFGenerator::loadDocument( const QString & filePath, QValueVector<KPDFPage*> & pagesVector )
bool PDFGenerator::loadDocument( const QString & filePath, QVector<KPDFPage*> & pagesVector )
{
#ifndef NDEBUG
if ( pdfdoc )
@ -132,7 +131,7 @@ bool PDFGenerator::loadDocument( const QString & filePath, QValueVector<KPDFPage
KWallet::Wallet * wallet = 0;
while ( !pdfdoc->isOk() && pdfdoc->getErrorCode() == errEncrypted )
{
QCString password;
QByteArray password;
// 1.A. try to retrieve the first password from the kde wallet system
if ( !triedWallet )
@ -165,7 +164,7 @@ bool PDFGenerator::loadDocument( const QString & filePath, QValueVector<KPDFPage
firstInput = false;
// if the user presses cancel, abort opening
if ( KPasswordDialog::getPassword( password, prompt ) != KPasswordDialog::Accepted )
if ( KPasswordDialog::getPassword( 0, password, prompt ) != KPasswordDialog::Accepted )
break;
}
@ -202,7 +201,7 @@ bool PDFGenerator::loadDocument( const QString & filePath, QValueVector<KPDFPage
return true;
}
void PDFGenerator::loadPages(QValueVector<KPDFPage*> &pagesVector, int rotation, bool clear)
void PDFGenerator::loadPages(QVector<KPDFPage*> &pagesVector, int rotation, bool clear)
{
// TODO XPDF 3.01 check
// KPDFTextDev td;
@ -271,7 +270,7 @@ RegularAreaRect * PDFGenerator::findText (const QString & text, SearchDir dir,
// create a xpf's Unicode (unsigned int) array for the given text
const QChar * str = text.unicode();
int len = text.length();
QMemArray<Unicode> u(len);
QVector<Unicode> u(len);
for (int i = 0; i < len; ++i)
u[i] = str[i].unicode();
@ -295,13 +294,13 @@ RegularAreaRect * PDFGenerator::findText (const QString & text, SearchDir dir,
while ( !found )
{
if ( dir == FromTop )
found = textPage->findText( const_cast<Unicode*>(static_cast<const Unicode*>(u)), len,
found = textPage->findText( u.data(), len,
gTrue, gTrue, gFalse, gFalse, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
else if ( dir == NextRes )
found = textPage->findText( const_cast<Unicode*>(static_cast<const Unicode*>(u)), len,
found = textPage->findText( u.data(), len,
gFalse, gTrue, gTrue, gFalse, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
else if ( dir == PrevRes )
found = textPage->findText( const_cast<Unicode*>(static_cast<const Unicode*>(u)), len,
found = textPage->findText( u.data(), len,
gTrue, gFalse, gFalse, gTrue, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
// if not found (even in case unsensitive search), terminate
@ -440,7 +439,7 @@ const DocumentFonts * PDFGenerator::generateDocumentFonts()
bool PDFGenerator::isAllowed( int permissions )
{
#if !KPDF_FORCE_DRM
if (kapp->authorize("skip_drm") && !KpdfSettings::obeyDRM()) return true;
if (KAuthorized::authorize("skip_drm") && !KpdfSettings::obeyDRM()) return true;
#endif
bool b = true;
@ -555,9 +554,8 @@ bool PDFGenerator::print( KPrinter& printer )
dummy.setFullPage(true);
dummy.setPageSize((QPrinter::PageSize)(ps.isEmpty() ? KGlobal::locale()->pageSize() : pageNameToPageSize(ps)));
QPaintDeviceMetrics metrics(&dummy);
globalParams->setPSPaperWidth(metrics.width());
globalParams->setPSPaperHeight(metrics.height());
globalParams->setPSPaperWidth(dummy.width());
globalParams->setPSPaperHeight(dummy.height());
}
KTempFile tf( QString::null, ".ps" );
@ -565,7 +563,7 @@ bool PDFGenerator::print( KPrinter& printer )
if (psOut->isOk())
{
QValueList<int> pageList;
QList<int> pageList;
if (!printer.previewOnly())
{
@ -587,7 +585,7 @@ bool PDFGenerator::print( KPrinter& printer )
// needs to be here so that the file is flushed, do not merge with the one
// in the else
delete psOut;
printer.printFiles(tf.name(), true);
printer.printFiles(QStringList(tf.name()), true);
return true;
}
else
@ -1275,9 +1273,9 @@ void PDFGenerator::addAnnotations( Page * pdfPage, KPDFPage * page )
QMap< int, Annotation * > annotationsMap;
QMap< int, PopupWindow * > popupsMap;
// lists of Windows and Revisions that needs resolution
QValueList< ResolveRevision > resolveRevList;
QValueList< ResolveWindow > resolvePopList;
QValueList< PostProcessText > ppTextList;
QLinkedList< ResolveRevision > resolveRevList;
QLinkedList< ResolveWindow > resolvePopList;
QLinkedList< PostProcessText > ppTextList;
// build a normalized transform matrix for this page at 100% scale
GfxState * gfxState = new GfxState( 72.0, 72.0, pdfPage->getMediaBox(), pdfPage->getRotate(), gTrue );
@ -1573,7 +1571,7 @@ void PDFGenerator::addAnnotations( Page * pdfPage, KPDFPage * page )
for ( int m = 0; m < pathsNumber; m++ )
{
// transform each path in a list of normalized points ..
QValueList<NormalizedPoint> localList;
QLinkedList<NormalizedPoint> localList;
Object pointsArray;
pathsArray.arrayGet( m, &pointsArray );
if ( pointsArray.isArray() )
@ -1841,7 +1839,7 @@ void PDFGenerator::addAnnotations( Page * pdfPage, KPDFPage * page )
/** 2 - RESOLVE POPUPS (popup.* -> annotation.window) */
if ( !resolvePopList.isEmpty() && !popupsMap.isEmpty() )
{
QValueList< ResolveWindow >::iterator it = resolvePopList.begin(),
QLinkedList< ResolveWindow >::iterator it = resolvePopList.begin(),
end = resolvePopList.end();
for ( ; it != end; ++it )
{
@ -1885,7 +1883,7 @@ void PDFGenerator::addAnnotations( Page * pdfPage, KPDFPage * page )
// append children to parents
int excludeIDs[ resolveRevList.count() ]; // can't even reach this size
int excludeIndex = 0; // index in excludeIDs array
QValueList< ResolveRevision >::iterator it = resolveRevList.begin(), end = resolveRevList.end();
QLinkedList< ResolveRevision >::iterator it = resolveRevList.begin(), end = resolveRevList.end();
for ( ; it != end; ++it )
{
const ResolveRevision & request = *it;
@ -1915,7 +1913,7 @@ void PDFGenerator::addAnnotations( Page * pdfPage, KPDFPage * page )
/** 4 - POSTPROCESS TextAnnotations (when window geom is embedded) */
if ( !ppTextList.isEmpty() )
{
QValueList< PostProcessText >::const_iterator it = ppTextList.begin(), end = ppTextList.end();
QLinkedList< PostProcessText >::const_iterator it = ppTextList.begin(), end = ppTextList.end();
for ( ; it != end; ++it )
{
const PostProcessText & request = *it;
@ -2107,7 +2105,7 @@ void PDFGenerator::customEvent( QCustomEvent * event )
PixmapRequest * request = static_cast< PixmapRequest * >( event->data() );
QImage * outImage = generatorThread->takeImage();
TextPage * outTextPage = generatorThread->takeTextPage();
QValueList< ObjectRect * > outRects = generatorThread->takeObjectRects();
QLinkedList< ObjectRect * > outRects = generatorThread->takeObjectRects();
request->page->setPixmap( request->id, new QPixmap( *outImage ) );
delete outImage;
@ -2139,7 +2137,7 @@ struct PPGThreadPrivate
// internal temp stored items. don't delete this.
QImage * m_image;
TextPage * m_textPage;
QValueList< ObjectRect * > m_rects;
QLinkedList< ObjectRect * > m_rects;
bool m_rectsTaken;
};
@ -2161,7 +2159,7 @@ PDFPixmapGeneratorThread::~PDFPixmapGeneratorThread()
delete d->m_textPage;
if ( !d->m_rectsTaken && d->m_rects.count() )
{
QValueList< ObjectRect * >::iterator it = d->m_rects.begin(), end = d->m_rects.end();
QLinkedList< ObjectRect * >::iterator it = d->m_rects.begin(), end = d->m_rects.end();
for ( ; it != end; ++it )
delete *it;
}
@ -2225,7 +2223,7 @@ TextPage * PDFPixmapGeneratorThread::takeTextPage() const
return tp;
}
QValueList< ObjectRect * > PDFPixmapGeneratorThread::takeObjectRects() const
QLinkedList< ObjectRect * > PDFPixmapGeneratorThread::takeObjectRects() const
{
d->m_rectsTaken = true;
return d->m_rects;

View file

@ -11,6 +11,7 @@
#ifndef _KPDF_GENERATOR_PDF_H_
#define _KPDF_GENERATOR_PDF_H_
#include <qevent.h>
#include <qmutex.h>
#include <qcolor.h>
#include <qstring.h>
@ -54,8 +55,8 @@ class PDFGenerator : public Generator
virtual ~PDFGenerator();
// [INHERITED] load a document and fill up the pagesVector
bool loadDocument( const QString & fileName, QValueVector<KPDFPage*> & pagesVector );
void loadPages(QValueVector<KPDFPage*> &pagesVector, int rotation=-1, bool clear=false);
bool loadDocument( const QString & fileName, QVector<KPDFPage*> & pagesVector );
void loadPages(QVector<KPDFPage*> &pagesVector, int rotation=-1, bool clear=false);
// [INHERITED] document informations
const DocumentInfo * generateDocumentInfo();
const DocumentSynopsis * generateDocumentSynopsis();
@ -83,7 +84,7 @@ class PDFGenerator : public Generator
KPDFPage * page );
QString * getText( const RegularAreaRect * area, KPDFPage * page );
void setOrientation(QValueVector<KPDFPage*> & pagesVector, int orientation);
void setOrientation(QVector<KPDFPage*> & pagesVector, int orientation);
// [INHERITED] print page using an already configured kprinter
bool print( KPrinter& printer );
@ -163,7 +164,7 @@ class PDFPixmapGeneratorThread : public QThread
// methods for getting contents from the GUI thread
QImage * takeImage() const;
TextPage * takeTextPage() const;
QValueList< ObjectRect * > takeObjectRects() const;
QLinkedList< ObjectRect * > takeObjectRects() const;
private:
// can't be called from the outside (but from startGeneration)

View file

@ -80,11 +80,11 @@ QImage * KPDFOutputDev::takeImage()
return img;
}
QValueList< ObjectRect * > KPDFOutputDev::takeObjectRects()
QLinkedList< ObjectRect * > KPDFOutputDev::takeObjectRects()
{
if ( m_rects.isEmpty() )
return m_rects;
QValueList< ObjectRect * > rectsCopy( m_rects );
QLinkedList< ObjectRect * > rectsCopy( m_rects );
m_rects.clear();
return rectsCopy;
}
@ -217,7 +217,7 @@ void KPDFOutputDev::clear()
// delete rects
if ( m_rects.count() )
{
QValueList< ObjectRect * >::iterator it = m_rects.begin(), end = m_rects.end();
QLinkedList< ObjectRect * >::iterator it = m_rects.begin(), end = m_rects.end();
for ( ; it != end; ++it )
delete *it;
m_rects.clear();

View file

@ -22,7 +22,7 @@
#define USE_FIXEDPOINT 0
#define SPLASH_CMYK 0
#include <qvaluelist.h>
#include <qlinkedlist.h>
#include "PDFDoc.h" // for 'Object'
#include "SplashOutputDev.h"
@ -57,7 +57,7 @@ class KPDFOutputDev : public SplashOutputDev
// takes pointers out of the class (so deletion it's up to others)
QPixmap * takePixmap();
QImage * takeImage();
QValueList< ObjectRect * > takeObjectRects();
QLinkedList< ObjectRect * > takeObjectRects();
/** inherited from OutputDev */
// End a page.
@ -87,7 +87,7 @@ class KPDFOutputDev : public SplashOutputDev
PDFDoc * m_doc;
QPixmap * m_pixmap;
QImage * m_image;
QValueList< ObjectRect * > m_rects; // objectRects (links/images)
QLinkedList< ObjectRect * > m_rects; // objectRects (links/images)
};
#endif