add a postscript export overload that takes a QFile*, so we can properly use KTemporaryFile with printing

svn path=/trunk/KDE/kdegraphics/okular/; revision=709582
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 2498bea799
commit ee925f2e58
  1. 6
      generators/djvu/generator_djvu.cpp
  2. 20
      generators/djvu/kdjvu.cpp
  3. 7
      generators/djvu/kdjvu.h

@ -207,12 +207,10 @@ bool DjVuGenerator::print( KPrinter& printer )
tf.setSuffix( ".ps" );
if ( !tf.open() )
return false;
QString tempfilename = tf.fileName();
tf.close();
if ( m_djvu->exportAsPostScript( tempfilename, pageList ) )
if ( m_djvu->exportAsPostScript( &tf, pageList ) )
{
return printer.printFiles( QStringList( tempfilename ), true );
return printer.printFiles( QStringList( tf.fileName() ), true );
}
return false;
}

@ -897,11 +897,25 @@ bool KDjVu::exportAsPostScript( const QString & fileName, const QList<int>& page
if ( !d->m_djvu_document || fileName.trimmed().isEmpty() || pageList.isEmpty() )
return false;
QByteArray fn = QFile::encodeName( fileName );
FILE* f = fopen( fn.constData(), "w+" );
QFile f( fileName );
f.open( QIODevice::ReadWrite );
bool ret = exportAsPostScript( &f, pageList );
if ( ret )
{
f.close();
}
return ret;
}
bool KDjVu::exportAsPostScript( QFile* file, const QList<int>& pageList ) const
{
if ( !d->m_djvu_document || !file || pageList.isEmpty() )
return false;
FILE* f = fdopen( file->handle(), "w+" );
if ( !f )
{
kDebug() << "KDjVu::exportAsPostScript(): error while opening the file";
kDebug() << "error while getting the FILE*";
return false;
}

@ -20,6 +20,7 @@
#include <qvector.h>
class QDomDocument;
class QFile;
/**
* @brief Qt (KDE) encapsulation of the DjVuLibre
@ -258,6 +259,12 @@ class KDjVu : public QObject
*/
bool exportAsPostScript( const QString & fileName, const QList<int>& pageList ) const;
/**
* Export the currently open document as PostScript file.
* \returns whether the exporting was successful
*/
bool exportAsPostScript( QFile* file, const QList<int>& pageList ) const;
/**
* Return the list of the text entities for the specified \p page, that matches the
* specified \p granularity.

Loading…
Cancel
Save