2006-07-20 20:47:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2006-10-22 13:34:47 +00:00
|
|
|
#include <kdebug.h>
|
2006-10-25 15:35:53 +00:00
|
|
|
#include <kicon.h>
|
2006-03-21 20:00:24 +00:00
|
|
|
|
2005-11-20 15:30:15 +00:00
|
|
|
#include "generator.h"
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
using namespace Okular;
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
class Generator::Private
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
: m_document( 0 )
|
|
|
|
{
|
|
|
|
}
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
Document * m_document;
|
2006-10-25 15:35:53 +00:00
|
|
|
};
|
|
|
|
|
2006-10-22 11:25:08 +00:00
|
|
|
Generator::Generator()
|
2006-10-25 17:43:15 +00:00
|
|
|
: d( new Private )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Generator::~Generator()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
delete d;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::canGenerateTextPage() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Generator::generateSyncTextPage( Page* )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const DocumentInfo * Generator::generateDocumentInfo()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const DocumentSynopsis * Generator::generateDocumentSynopsis()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const DocumentFonts * Generator::generateDocumentFonts()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const QList<EmbeddedFile*> * Generator::embeddedFiles() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return 0;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Generator::PageSizeMetric Generator::pagesSizeMetric() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return None;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::isAllowed( int ) const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return true;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Generator::getXMLFile() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return QString();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Generator::setupGUI( KActionCollection*, QToolBox* )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Generator::freeGUI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::supportsSearching() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::supportsRotation() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Generator::rotationChanged( int, int )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::supportsPaperSizes () const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList Generator::paperSizes () const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return QStringList();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Generator::setPaperSize( QVector<Page*>&, int )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::canConfigurePrinter() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::print( KPrinter& )
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-28 19:18:36 +00:00
|
|
|
QVariant Generator::metaData( const QString&, const QVariant& ) const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-28 19:18:36 +00:00
|
|
|
return QVariant();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Generator::reparseConfig()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Generator::addPages( KConfigDialog* )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
ExportFormat::List Generator::exportFormats() const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return ExportFormat::List();
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
bool Generator::exportTo( const QString&, const ExportFormat& )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return false;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
void Generator::setDocument( Document *document )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
d->m_document = document;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
void Generator::signalRequestDone( PixmapRequest * request )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
if ( d->m_document )
|
|
|
|
d->m_document->requestDone( request );
|
|
|
|
else
|
|
|
|
Q_ASSERT( !"No document set for generator in signalRequestDone!" );
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
Document * Generator::document() const
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 15:35:53 +00:00
|
|
|
return d->m_document;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
class PixmapRequest::Private
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
public:
|
|
|
|
int mId;
|
|
|
|
int mPageNumber;
|
|
|
|
int mWidth;
|
|
|
|
int mHeight;
|
|
|
|
int mPriority;
|
|
|
|
bool mAsynchronous;
|
|
|
|
Page *mPage;
|
2006-10-25 15:35:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PixmapRequest::PixmapRequest( int id, int pageNumber, int width, int height, int priority, bool asynchronous )
|
|
|
|
: d( new Private )
|
2006-10-20 16:51:46 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
d->mId = id;
|
|
|
|
d->mPageNumber = pageNumber;
|
|
|
|
d->mWidth = width;
|
|
|
|
d->mHeight = height;
|
|
|
|
d->mPriority = priority;
|
|
|
|
d->mAsynchronous = asynchronous;
|
2006-10-20 16:51:46 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
PixmapRequest::~PixmapRequest()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
delete d;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::id() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mId;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::pageNumber() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mPageNumber;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::width() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mWidth;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PixmapRequest::height() const
|
2006-10-22 11:25:08 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mHeight;
|
2006-10-22 11:25:08 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
int PixmapRequest::priority() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mPriority;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PixmapRequest::asynchronous() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mAsynchronous;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Page* PixmapRequest::page() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mPage;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PixmapRequest::setPriority( int priority )
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
d->mPriority = priority;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PixmapRequest::setAsynchronous( bool asynchronous )
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
d->mAsynchronous = asynchronous;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PixmapRequest::setPage( Page *page )
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
d->mPage = page;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
2006-11-20 07:53:32 +00:00
|
|
|
void PixmapRequest::swap()
|
|
|
|
{
|
|
|
|
qSwap( d->mWidth, d->mHeight );
|
|
|
|
}
|
|
|
|
|
2006-10-25 15:35:53 +00:00
|
|
|
class ExportFormat::Private
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
public:
|
|
|
|
Private( const QString &description, const KMimeType::Ptr &mimeType, const KIcon &icon = KIcon() )
|
|
|
|
: mDescription( description ), mMimeType( mimeType ), mIcon( icon )
|
|
|
|
{
|
|
|
|
}
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
QString mDescription;
|
|
|
|
KMimeType::Ptr mMimeType;
|
|
|
|
KIcon mIcon;
|
2006-10-25 15:35:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat()
|
2006-10-25 17:43:15 +00:00
|
|
|
: d( new Private( QString(), KMimeType::Ptr() ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat( const QString &description, const KMimeType::Ptr &mimeType )
|
2006-10-25 17:43:15 +00:00
|
|
|
: d( new Private( description, mimeType ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType )
|
2006-10-25 17:43:15 +00:00
|
|
|
: d( new Private( description, mimeType, icon ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::~ExportFormat()
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
delete d;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat::ExportFormat( const ExportFormat &other )
|
2006-10-25 17:43:15 +00:00
|
|
|
: d( new Private( QString(), KMimeType::Ptr() ) )
|
2006-10-25 15:35:53 +00:00
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
*d = *other.d;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ExportFormat& ExportFormat::operator=( const ExportFormat &other )
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
if ( this == &other )
|
|
|
|
return *this;
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
*d = *other.d;
|
2006-10-25 15:35:53 +00:00
|
|
|
|
2006-10-25 17:43:15 +00:00
|
|
|
return *this;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ExportFormat::description() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mDescription;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KMimeType::Ptr ExportFormat::mimeType() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mMimeType;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KIcon ExportFormat::icon() const
|
|
|
|
{
|
2006-10-25 17:43:15 +00:00
|
|
|
return d->mIcon;
|
2006-10-25 15:35:53 +00:00
|
|
|
}
|
2006-10-22 11:25:08 +00:00
|
|
|
|
2006-11-17 22:15:15 +00:00
|
|
|
class SourceReference::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
: row( 0 ), column( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString filename;
|
|
|
|
int row;
|
|
|
|
int column;
|
|
|
|
};
|
|
|
|
|
|
|
|
SourceReference::SourceReference( const QString &fileName, int row, int column )
|
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
d->filename = fileName;
|
|
|
|
d->row = row;
|
|
|
|
d->column = column;
|
|
|
|
}
|
|
|
|
|
|
|
|
SourceReference::~SourceReference()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SourceReference::fileName() const
|
|
|
|
{
|
|
|
|
return d->filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SourceReference::row() const
|
|
|
|
{
|
|
|
|
return d->row;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SourceReference::column() const
|
|
|
|
{
|
|
|
|
return d->column;
|
|
|
|
}
|
|
|
|
|
2006-10-22 13:34:47 +00:00
|
|
|
kdbgstream& operator<<( kdbgstream &str, const Okular::PixmapRequest &req )
|
2005-11-20 15:30:15 +00:00
|
|
|
{
|
2006-10-22 13:34:47 +00:00
|
|
|
QString s = QString( "%1 PixmapRequest (id: %2) (%3x%4), prio %5, pageNo %6" )
|
2006-10-25 15:35:53 +00:00
|
|
|
.arg( QString( req.asynchronous() ? "Async" : "Sync" ) )
|
|
|
|
.arg( req.id() )
|
|
|
|
.arg( req.width() )
|
|
|
|
.arg( req.height() )
|
|
|
|
.arg( req.priority() )
|
|
|
|
.arg( req.pageNumber() );
|
2006-10-22 13:34:47 +00:00
|
|
|
str << s;
|
|
|
|
return str;
|
2005-11-20 15:30:15 +00:00
|
|
|
}
|
2006-06-10 12:59:09 +00:00
|
|
|
|
|
|
|
#include "generator.moc"
|