OSDN Git Service

okular: drop non-native printing support
authorIvailo Monev <xakepa10@gmail.com>
Fri, 11 Nov 2022 10:57:18 +0000 (12:57 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 11 Nov 2022 11:06:20 +0000 (13:06 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
24 files changed:
okular/CMakeLists.txt
okular/core/document.cpp
okular/core/document.h
okular/core/fileprinter.cpp [deleted file]
okular/core/generator.h
okular/core/utils.cpp
okular/core/utils.h
okular/generators/comicbook/generator_comicbook.cpp
okular/generators/djvu/generator_djvu.cpp
okular/generators/djvu/generator_djvu.h
okular/generators/dvi/CMakeLists.txt
okular/generators/dvi/dviRenderer.cpp
okular/generators/dvi/dviRenderer.h
okular/generators/dvi/dviexport.cpp [deleted file]
okular/generators/dvi/dviexport.h [deleted file]
okular/generators/dvi/generator_dvi.cpp
okular/generators/dvi/generator_dvi.h
okular/generators/poppler/generator_pdf.cpp
okular/generators/spectre/generator_ghostview.cpp
okular/generators/spectre/generator_ghostview.h
okular/generators/xps/generator_xps.cpp
okular/part.cpp
okular/ui/fileprinterpreview.cpp [deleted file]
okular/ui/fileprinterpreview.h [deleted file]

index 5b2ef6b..a5149dd 100644 (file)
@@ -63,12 +63,30 @@ add_feature_info(okular_gs
     "PostScript support in Okular"
 )
 
+find_program(PS2PDF_EXECUTABLE NAMES ps2pdf)
+add_feature_info(okular_ps2pdf
+    PS2PDF_EXECUTABLE
+    "PostScript support in Okular"
+)
+
+find_program(LATEX_EXECUTABLE NAMES latex)
+add_feature_info(okular_latex
+    LATEX_EXECUTABLE
+    "LaTeX support in Okular"
+)
+
 find_program(KPSEWHICH_EXECUTABLE NAMES kpsewhich)
 add_feature_info(okular_kpsewhich
     KPSEWHICH_EXECUTABLE
     "DVI support in Okular"
 )
 
+find_program(DVIPNG_EXECUTABLE NAMES dvipng)
+add_feature_info(okular_dvipng
+    DVIPNG_EXECUTABLE
+    "DVI support in Okular"
+)
+
 option(
     OKULAR_FORCE_DRM
     "Forces okular to check for DRM to decide if you can copy/print protected pdf. (default=no)"
@@ -122,7 +140,6 @@ set(okularcore_SRCS
     core/tilesmanager.cpp
     core/utils.cpp
     core/view.cpp
-    core/fileprinter.cpp
     core/chooseenginewidget.ui
     core/textdocumentsettings.ui
 )
@@ -214,7 +231,6 @@ set(okularpart_SRCS
     ui/annotationtools.cpp
     ui/annotationwidgets.cpp
     ui/bookmarklist.cpp
-    ui/fileprinterpreview.cpp
     ui/findbar.cpp
     ui/formwidgets.cpp
     ui/guiutils.cpp
index 7e582d0..009daff 100644 (file)
@@ -3793,10 +3793,6 @@ Document::PrintingType Document::printingSupport() const
         {
             return NativePrinting;
         }
-        if ( d->m_generator->hasFeature( Generator::PrintPostscript ) )
-        {
-            return PostscriptPrinting;
-        }
     }
 
     return NoPrinting;
@@ -3817,24 +3813,8 @@ QString Document::printError() const
     Q_ASSERT( err != Generator::NoPrintError );
     switch ( err )
     {
-        case Generator::TemporaryFileOpenPrintError:
-            return i18n( "Could not open a temporary file" );
-        case Generator::FileConversionPrintError:
-            return i18n( "Print conversion failed" );
-        case Generator::PrintingProcessCrashPrintError:
-            return i18n( "Printing process crashed" );
-        case Generator::PrintingProcessStartPrintError:
-            return i18n( "Printing process could not start" );
-        case Generator::PrintToFilePrintError:
-            return i18n( "Printing to file failed" );
         case Generator::InvalidPrinterStatePrintError:
             return i18n( "Printer was in invalid state" );
-        case Generator::UnableToFindFilePrintError:
-            return i18n( "Unable to find file to print" );
-        case Generator::NoFileToPrintError:
-            return i18n( "There was no file to print" );
-        case Generator::NoBinaryToPrintError:
-            return i18n( "Could not find a suitable binary for printing. Make sure CUPS lpr binary is available" );
         case Generator::InvalidPageSizePrintError:
             return i18n( "The page print size is invalid" );
         case Generator::NoPrintError:
index 9a4f889..fcc903f 100644 (file)
@@ -559,8 +559,7 @@ class OKULAR_EXPORT Document : public QObject
         enum PrintingType
         {
             NoPrinting,            ///< Printing Not Supported
-            NativePrinting,        ///< Native Cross-Platform Printing
-            PostscriptPrinting     ///< Postscript file printing
+            NativePrinting        ///< Native Cross-Platform Printing
         };
 
         /**
diff --git a/okular/core/fileprinter.cpp b/okular/core/fileprinter.cpp
deleted file mode 100644 (file)
index fd4906b..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007,2010 by John Layt <john@layt.net>                  *
- *                                                                         *
- *   FilePrinterPreview based on KPrintPreview (originally LGPL)           *
- *   Copyright (c) 2007 Alex Merry <huntedhacker@tiscali.co.uk>            *
- *                                                                         *
- *   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.                                   *
- ***************************************************************************/
-
-#include "fileprinter.h"
-
-#include <QtGui/QPrinter>
-#include <QPrintEngine>
-#include <QStringList>
-#include <QSize>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#include <QtGui/QLabel>
-#include <QtGui/qevent.h>
-
-#include <KProcess>
-#include <KShell>
-#include <kstandarddirs.h>
-#include <ktempdir.h>
-#include <kdebug.h>
-
-#include "debug_p.h"
-
-using namespace Okular;
-
-int FilePrinter::printFile( QPrinter &printer, const QString file,
-                            QPrinter::Orientation documentOrientation, FileDeletePolicy fileDeletePolicy,
-                            PageSelectPolicy pageSelectPolicy, const QString &pageRange )
-{
-    FilePrinter fp;
-    return fp.doPrintFiles( printer, QStringList( file ), fileDeletePolicy, pageSelectPolicy, pageRange, 
-                            documentOrientation );
-}
-
-int FilePrinter::doPrintFiles( QPrinter &printer, QStringList fileList, FileDeletePolicy fileDeletePolicy,
-                               PageSelectPolicy pageSelectPolicy, const QString &pageRange,
-                               QPrinter::Orientation documentOrientation )
-{
-
-    if ( fileList.size() < 1 ) {
-        return -8;
-    }
-
-    for (QStringList::ConstIterator it = fileList.constBegin(); it != fileList.constEnd(); ++it) {
-        if (!QFile::exists(*it)) {
-            return -7;
-        }
-    }
-
-    if ( printer.printerState() == QPrinter::Aborted || printer.printerState() == QPrinter::Error ) {
-        return -6;
-    }
-
-    QString exe;
-    QStringList argList;
-    int ret;
-
-    //Decide what executable to use to print with, need the CUPS version of lpr if available
-    //Some distros name the CUPS version of lpr as lpr-cups or lpr.cups so try those first 
-    //before default to lpr, or failing that to lp
-
-    if ( !KStandardDirs::findExe("lpr-cups").isEmpty() ) {
-        exe = "lpr-cups";
-    } else if ( !KStandardDirs::findExe("lpr.cups").isEmpty() ) {
-        exe = "lpr.cups";
-    } else if ( !KStandardDirs::findExe("lpr").isEmpty() ) {
-        exe = "lpr";
-    } else if ( !KStandardDirs::findExe("lp").isEmpty() ) {
-        exe = "lp";
-    } else {
-        return -9;
-    }
-
-    bool useCupsOptions = cupsAvailable();
-    argList = printArguments( printer, fileDeletePolicy, pageSelectPolicy, 
-                                useCupsOptions, pageRange, exe, documentOrientation ) << fileList;
-    kDebug(OkularDebug) << "Executing" << exe << "with arguments" << argList;
-
-    ret = KProcess::execute( exe, argList );
-
-    return ret;
-}
-
-QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage, const QList<int> &selectedPageList )
-{
-    return pageList( printer, lastPage, 0, selectedPageList );
-}
-
-QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage,
-                                  int currentPage, const QList<int> &selectedPageList )
-{
-    if ( printer.printRange() == QPrinter::Selection) {
-        return selectedPageList;
-    }
-
-    int startPage, endPage;
-    QList<int> list;
-
-    if ( printer.printRange() == QPrinter::PageRange ) {
-        startPage = printer.fromPage();
-        endPage = printer.toPage();
-    } else if ( printer.printRange() == QPrinter::CurrentPage) {
-        startPage = currentPage;
-        endPage = currentPage;
-    } else { //AllPages
-        startPage = 1;
-        endPage = lastPage;
-    }
-
-    for (int i = startPage; i <= endPage; i++ ) {
-        list << i;
-    }
-
-    return list;
-}
-
-QString FilePrinter::pageRange( QPrinter &printer, int lastPage, const QList<int> &selectedPageList )
-{
-    if ( printer.printRange() == QPrinter::Selection) {
-        return pageListToPageRange( selectedPageList );
-    }
-
-    if ( printer.printRange() == QPrinter::PageRange ) {
-        return QString("%1-%2").arg(printer.fromPage()).arg(printer.toPage());
-    }
-
-    return QString("1-%2").arg( lastPage );
-}
-
-QString FilePrinter::pageListToPageRange( const QList<int> &pageList )
-{
-    QString pageRange;
-    int count = pageList.count();
-    int i = 0;
-    int seqStart = i;
-    int seqEnd;
-
-    while ( i != count ) {
-
-        if ( i + 1 == count || pageList[i] + 1 != pageList[i+1] ) {
-
-            seqEnd = i;
-
-            if ( !pageRange.isEmpty() ) {
-                pageRange.append(",");
-            }
-
-            if ( seqStart == seqEnd ) {
-                pageRange.append(pageList[i]);
-            } else {
-                pageRange.append(QString("%1-%2").arg(seqStart).arg(seqEnd));
-            }
-
-            seqStart = i + 1;
-        }
-
-        i++;
-    }
-
-    return pageRange;
-}
-
-bool FilePrinter::ps2pdfAvailable()
-{
-    return ( !KStandardDirs::findExe("ps2pdf").isEmpty() );
-}
-
-bool FilePrinter::pdf2psAvailable()
-{
-    return ( !KStandardDirs::findExe("pdf2ps").isEmpty() );
-}
-
-bool FilePrinter::cupsAvailable()
-{
-#ifdef Q_WS_X11
-    // Ideally we would have access to the private Qt method
-    // QCUPSSupport::cupsAvailable() to do this as it is very complex routine.
-    // However, if CUPS is available then QPrinter::numCopies() will always return 1
-    // whereas if CUPS is not available it will return the real number of copies.
-    // This behaviour is guaranteed never to change, so we can use it as a reliable substitute.
-    QPrinter testPrinter;
-    testPrinter.setNumCopies( 2 );
-    return ( testPrinter.numCopies() == 1 );
-#else
-    return false;
-#endif
-}
-
-QSize FilePrinter::psPaperSize( QPrinter &printer )
-{
-    QSize size;
-
-    switch ( printer.pageSize() ) {
-    case QPrinter::A0:        size = QSize( 2384, 3370 ); break;
-    case QPrinter::A1:        size = QSize( 1684, 2384 ); break;
-    case QPrinter::A2:        size = QSize( 1191, 1684 ); break;
-    case QPrinter::A3:        size = QSize(  842, 1191 ); break;
-    case QPrinter::A4:        size = QSize(  595,  842 ); break;
-    case QPrinter::A5:        size = QSize(  420,  595 ); break;
-    case QPrinter::A6:        size = QSize(  298,  420 ); break;
-    case QPrinter::A7:        size = QSize(  210,  298 ); break;
-    case QPrinter::A8:        size = QSize(  147,  210 ); break;
-    case QPrinter::A9:        size = QSize(  105,  147 ); break;
-    case QPrinter::B0:        size = QSize( 2835, 4008 ); break;
-    case QPrinter::B1:        size = QSize( 2004, 2835 ); break;
-    case QPrinter::B2:        size = QSize( 1417, 2004 ); break;
-    case QPrinter::B3:        size = QSize( 1001, 1417 ); break;
-    case QPrinter::B4:        size = QSize(  709, 1001 ); break;
-    case QPrinter::B5:        size = QSize(  499,  709 ); break;
-    case QPrinter::B6:        size = QSize(  354,  499 ); break;
-    case QPrinter::B7:        size = QSize(  249,  354 ); break;
-    case QPrinter::B8:        size = QSize(  176,  249 ); break;
-    case QPrinter::B9:        size = QSize(  125,  176 ); break;
-    case QPrinter::B10:       size = QSize(   88,  125 ); break;
-    case QPrinter::C5E:       size = QSize(  459,  649 ); break;
-    case QPrinter::Comm10E:   size = QSize(  297,  684 ); break;
-    case QPrinter::DLE:       size = QSize(  312,  624 ); break;
-    case QPrinter::Executive: size = QSize(  522,  756 ); break;
-    case QPrinter::Folio:     size = QSize(  595,  935 ); break;
-    case QPrinter::Ledger:    size = QSize( 1224,  792 ); break;
-    case QPrinter::Legal:     size = QSize(  612, 1008 ); break;
-    case QPrinter::Letter:    size = QSize(  612,  792 ); break;
-    case QPrinter::Tabloid:   size = QSize(  792, 1224 ); break;
-    case QPrinter::Custom:    return QSize( (int) printer.widthMM() * ( 25.4 / 72 ),
-                                            (int) printer.heightMM() * ( 25.4 / 72 ) );
-    default:                  return QSize();
-    }
-
-    if ( printer.orientation() == QPrinter::Landscape ) {
-        size.transpose();
-    }
-
-    return size;
-}
-
-Generator::PrintError FilePrinter::printError( int c )
-{
-    Generator::PrintError pe;
-    if ( c >= 0 )
-    {
-        pe = Generator::NoPrintError;
-    } 
-    else {
-        switch ( c )
-        {
-            case -1:
-                pe = Generator::PrintingProcessCrashPrintError;
-                break;
-            case -2:
-                pe = Generator::PrintingProcessStartPrintError;
-                break;
-            case -5:
-                pe = Generator::PrintToFilePrintError;
-                break;
-            case -6:
-                pe = Generator::InvalidPrinterStatePrintError;
-                break;
-            case -7:
-                pe = Generator::UnableToFindFilePrintError;
-                break;
-            case -8:
-                pe = Generator::NoFileToPrintError;
-                break;
-            case -9:
-                pe = Generator::NoBinaryToPrintError;
-                break;
-            default:
-                pe = Generator::UnknownPrintError;
-        }
-    }
-    return pe;
-}
-
-
-
-QStringList FilePrinter::printArguments( QPrinter &printer, FileDeletePolicy fileDeletePolicy,
-                                         PageSelectPolicy pageSelectPolicy, bool useCupsOptions,
-                                         const QString &pageRange, const QString &version, 
-                                         QPrinter::Orientation documentOrientation )
-{
-    QStringList argList;
-
-    if ( ! destination( printer, version ).isEmpty() ) {
-        argList << destination( printer, version );
-    }
-
-    if ( ! copies( printer, version ).isEmpty() ) {
-        argList << copies( printer, version );
-    }
-
-    if ( ! jobname( printer, version ).isEmpty() ) {
-        argList << jobname( printer, version );
-    }
-
-    if ( ! pages( printer, pageSelectPolicy, pageRange, useCupsOptions, version ).isEmpty() ) {
-        argList << pages( printer, pageSelectPolicy, pageRange, useCupsOptions, version );
-    }
-
-    if ( useCupsOptions && ! cupsOptions( printer, documentOrientation ).isEmpty() ) {
-        argList << cupsOptions( printer, documentOrientation);
-    }
-
-    if ( ! deleteFile( printer, fileDeletePolicy, version ).isEmpty() ) {
-        argList << deleteFile( printer, fileDeletePolicy, version );
-    }
-
-    if ( version == "lp" ) {
-        argList << "--";
-    }
-
-    return argList;
-}
-
-QStringList FilePrinter::destination( QPrinter &printer, const QString &version )
-{
-    if ( version == "lp" ) {
-        return QStringList("-d") << printer.printerName();
-    }
-
-    if ( version.startsWith( "lpr" ) ) {
-        return QStringList("-P") << printer.printerName();
-    }
-
-    return QStringList();
-}
-
-QStringList FilePrinter::copies( QPrinter &printer, const QString &version )
-{
-    int cp = printer.actualNumCopies();
-
-    if ( version == "lp" ) {
-        return QStringList("-n") << QString("%1").arg( cp );
-    }
-
-    if ( version.startsWith( "lpr" ) ) {
-        return QStringList() << QString("-#%1").arg( cp );
-    }
-
-    return QStringList();
-}
-
-QStringList FilePrinter::jobname( QPrinter &printer, const QString &version )
-{
-    if ( ! printer.docName().isEmpty() ) {
-
-        if ( version == "lp" ) {
-            return QStringList("-t") << printer.docName();
-        }
-
-        if ( version.startsWith( "lpr" ) ) {
-            const QString shortenedDocName = QString::fromUtf8(printer.docName().toUtf8().left(255));
-            return QStringList("-J") << shortenedDocName;
-        }
-    }
-
-    return QStringList();
-}
-
-QStringList FilePrinter::deleteFile( QPrinter &, FileDeletePolicy fileDeletePolicy, const QString &version )
-{
-    if ( fileDeletePolicy == FilePrinter::SystemDeletesFiles && version.startsWith( "lpr" ) ) {
-        return QStringList("-r");
-    }
-
-    return QStringList();
-}
-
-QStringList FilePrinter::pages( QPrinter &printer, PageSelectPolicy pageSelectPolicy, const QString &pageRange,
-                                    bool useCupsOptions, const QString &version )
-{
-    if ( pageSelectPolicy == FilePrinter::SystemSelectsPages ) {
-
-        if ( printer.printRange() == QPrinter::Selection && ! pageRange.isEmpty() ) {
-
-            if ( version == "lp" ) {
-                return QStringList("-P") << pageRange ;
-            }
-
-            if ( version.startsWith( "lpr" ) && useCupsOptions ) {
-                return QStringList("-o") << QString("page-ranges=%1").arg( pageRange );
-            }
-
-        }
-
-        if ( printer.printRange() == QPrinter::PageRange ) {
-
-            if ( version == "lp" ) {
-                return QStringList("-P") << QString("%1-%2").arg( printer.fromPage() )
-                                                            .arg( printer.toPage() );
-            }
-
-            if ( version.startsWith( "lpr" ) && useCupsOptions ) {
-                return QStringList("-o") << QString("page-ranges=%1-%2").arg( printer.fromPage() )
-                                                                        .arg( printer.toPage() );
-            }
-
-        }
-
-    }
-
-    return QStringList(); // AllPages
-}
-
-QStringList FilePrinter::cupsOptions( QPrinter &printer, QPrinter::Orientation documentOrientation )
-{
-    QStringList optionList;
-
-    if ( ! optionMedia( printer ).isEmpty() ) {
-        optionList << optionMedia( printer );
-    }
-
-    if ( ! optionOrientation( printer, documentOrientation ).isEmpty() ) {
-        optionList << optionOrientation( printer, documentOrientation );
-    }
-
-    if ( ! optionDoubleSidedPrinting( printer ).isEmpty() ) {
-        optionList << optionDoubleSidedPrinting( printer );
-    }
-
-    if ( ! optionPageOrder( printer ).isEmpty() ) {
-        optionList << optionPageOrder( printer );
-    }
-
-    if ( ! optionCollateCopies( printer ).isEmpty() ) {
-        optionList << optionCollateCopies( printer );
-    }
-
-    if ( ! optionPageMargins( printer ).isEmpty() ) {
-        optionList << optionPageMargins( printer );
-    }
-
-    optionList << optionCupsProperties( printer );
-
-    return optionList;
-}
-
-QStringList FilePrinter::optionMedia( QPrinter &printer )
-{
-    if ( ! mediaPageSize( printer ).isEmpty() && 
-         ! mediaPaperSource( printer ).isEmpty() ) {
-        return QStringList("-o") <<
-                QString("media=%1,%2").arg( mediaPageSize( printer ) )
-                                      .arg( mediaPaperSource( printer ) );
-    }
-
-    if ( ! mediaPageSize( printer ).isEmpty() ) {
-        return QStringList("-o") <<
-                QString("media=%1").arg( mediaPageSize( printer ) );
-    }
-
-    if ( ! mediaPaperSource( printer ).isEmpty() ) {
-        return QStringList("-o") <<
-                QString("media=%1").arg( mediaPaperSource( printer ) );
-    }
-
-    return QStringList();
-}
-
-QString FilePrinter::mediaPageSize( QPrinter &printer )
-{
-    switch ( printer.pageSize() ) {
-    case QPrinter::A0:         return "A0";
-    case QPrinter::A1:         return "A1";
-    case QPrinter::A2:         return "A2";
-    case QPrinter::A3:         return "A3";
-    case QPrinter::A4:         return "A4";
-    case QPrinter::A5:         return "A5";
-    case QPrinter::A6:         return "A6";
-    case QPrinter::A7:         return "A7";
-    case QPrinter::A8:         return "A8";
-    case QPrinter::A9:         return "A9";
-    case QPrinter::B0:         return "B0";
-    case QPrinter::B1:         return "B1";
-    case QPrinter::B10:        return "B10";
-    case QPrinter::B2:         return "B2";
-    case QPrinter::B3:         return "B3";
-    case QPrinter::B4:         return "B4";
-    case QPrinter::B5:         return "B5";
-    case QPrinter::B6:         return "B6";
-    case QPrinter::B7:         return "B7";
-    case QPrinter::B8:         return "B8";
-    case QPrinter::B9:         return "B9";
-    case QPrinter::C5E:        return "C5";     //Correct Translation?
-    case QPrinter::Comm10E:    return "Comm10"; //Correct Translation?
-    case QPrinter::DLE:        return "DL";     //Correct Translation?
-    case QPrinter::Executive:  return "Executive";
-    case QPrinter::Folio:      return "Folio";
-    case QPrinter::Ledger:     return "Ledger";
-    case QPrinter::Legal:      return "Legal";
-    case QPrinter::Letter:     return "Letter";
-    case QPrinter::Tabloid:    return "Tabloid";
-    case QPrinter::Custom:     return QString("Custom.%1x%2mm")
-                                            .arg( printer.heightMM() )
-                                            .arg( printer.widthMM() );
-    default:                   return QString();
-    }
-}
-
-// What about Upper and MultiPurpose?  And others in PPD???
-QString FilePrinter::mediaPaperSource( QPrinter &printer )
-{
-    switch ( printer.paperSource() ) {
-    case QPrinter::Auto:            return QString();
-    case QPrinter::Cassette:        return "Cassette";
-    case QPrinter::Envelope:        return "Envelope";
-    case QPrinter::EnvelopeManual:  return "EnvelopeManual";
-    case QPrinter::FormSource:      return "FormSource";
-    case QPrinter::LargeCapacity:   return "LargeCapacity";
-    case QPrinter::LargeFormat:     return "LargeFormat";
-    case QPrinter::Lower:           return "Lower";
-    case QPrinter::MaxPageSource:   return "MaxPageSource";
-    case QPrinter::Middle:          return "Middle";
-    case QPrinter::Manual:          return "Manual";
-    case QPrinter::OnlyOne:         return "OnlyOne";
-    case QPrinter::Tractor:         return "Tractor";
-    case QPrinter::SmallFormat:     return "SmallFormat";
-    default:                        return QString();
-    }
-}
-
-QStringList FilePrinter::optionOrientation( QPrinter &printer, QPrinter::Orientation documentOrientation )
-{
-    // portrait and landscape options rotate the document according to the document orientation
-    // If we want to print a landscape document as one would expect it, we have to pass the
-    // portrait option so that the document is not rotated additionally
-    if ( printer.orientation() == documentOrientation ) {
-        // the user wants the document printed as is
-        return QStringList("-o") << "portrait";
-    } else {
-        // the user expects the document being rotated by 90 degrees
-        return QStringList("-o") << "landscape";
-    }
-}
-
-QStringList FilePrinter::optionDoubleSidedPrinting( QPrinter &printer )
-{
-    switch ( printer.duplex() ) {
-    case QPrinter::DuplexNone:       return QStringList("-o") << "sides=one-sided";
-    case QPrinter::DuplexAuto:       if ( printer.orientation() == QPrinter::Landscape ) {
-                                         return QStringList("-o") << "sides=two-sided-short-edge";
-                                     } else {
-                                         return QStringList("-o") << "sides=two-sided-long-edge";
-                                     }
-    case QPrinter::DuplexLongSide:   return QStringList("-o") << "sides=two-sided-long-edge";
-    case QPrinter::DuplexShortSide:  return QStringList("-o") << "sides=two-sided-short-edge";
-    default:                         return QStringList();  //Use printer default
-    }
-}
-
-QStringList FilePrinter::optionPageOrder( QPrinter &printer )
-{
-    if ( printer.pageOrder() == QPrinter::LastPageFirst ) {
-        return QStringList("-o") << "outputorder=reverse";
-    }
-    return QStringList("-o") << "outputorder=normal";
-}
-
-QStringList FilePrinter::optionCollateCopies( QPrinter &printer )
-{
-    if ( printer.collateCopies() ) {
-        return QStringList("-o") << "Collate=True";
-    }
-    return QStringList("-o") << "Collate=False";
-}
-
-QStringList FilePrinter::optionPageMargins( QPrinter &printer )
-{
-    if (printer.printEngine()->property(QPrintEngine::PPK_PageMargins).isNull()) {
-        return QStringList();
-    } else {
-        qreal l, t, r, b;
-        printer.getPageMargins( &l, &t, &r, &b, QPrinter::Point );
-        return QStringList("-o") << QString("page-left=%1").arg(l)
-                       <<  "-o"  << QString("page-top=%1").arg(t)
-                       <<  "-o"  << QString("page-right=%1").arg(r)
-                       <<  "-o"  << QString("page-bottom=%1").arg(b) << "-o" << "fit-to-page";
-    }
-}
-
-QStringList FilePrinter::optionCupsProperties( QPrinter &printer )
-{
-    QStringList dialogOptions = printer.printEngine()->property(QPrintEngine::PrintEnginePropertyKey(0xfe00)).toStringList();
-    QStringList cupsOptions;
-
-    for ( int i = 0; i < dialogOptions.count(); i = i + 2 ) {
-        if ( dialogOptions[i+1].isEmpty() ) {
-            cupsOptions << "-o" << dialogOptions[i];
-        } else {
-            cupsOptions << "-o" << dialogOptions[i] + '=' + dialogOptions[i+1];
-        }
-    }
-
-    return cupsOptions;
-}
-
-/* kate: replace-tabs on; indent-width 4; */
index 82a689c..63b1b83 100644 (file)
@@ -203,7 +203,6 @@ class OKULAR_EXPORT Generator : public QObject
             FontInfo,          ///< Whether the Generator can provide information about the fonts used in the document
             PageSizes,         ///< Whether the Generator can change the size of the document pages.
             PrintNative,       ///< Whether the Generator supports native cross-platform printing (QPainter-based).
-            PrintPostscript,   ///< Whether the Generator supports postscript-based file printing.
             TiledRendering     ///< Whether the Generator can render tiles @since 0.16 (KDE 4.10)
         };
 
@@ -380,15 +379,7 @@ class OKULAR_EXPORT Generator : public QObject
         {
             NoPrintError,                       ///< There was no print error
             UnknownPrintError,
-            TemporaryFileOpenPrintError,
-            FileConversionPrintError,
-            PrintingProcessCrashPrintError,
-            PrintingProcessStartPrintError,
-            PrintToFilePrintError,
             InvalidPrinterStatePrintError,
-            UnableToFindFilePrintError,
-            NoFileToPrintError,
-            NoBinaryToPrintError,
             InvalidPageSizePrintError ///< @since 0.18.2 (KDE 4.12.2)
         };
         
index 9e16593..4eb7d10 100644 (file)
@@ -203,6 +203,34 @@ got_bottom:
     return bbox;
 }
 
+QList<int> Utils::pageList( QPrinter &printer, int lastPage,
+                             int currentPage, const QList<int> &selectedPageList )
+{
+    if ( printer.printRange() == QPrinter::Selection) {
+        return selectedPageList;
+    }
+
+    int startPage, endPage;
+    QList<int> list;
+
+    if ( printer.printRange() == QPrinter::PageRange ) {
+        startPage = printer.fromPage();
+        endPage = printer.toPage();
+    } else if ( printer.printRange() == QPrinter::CurrentPage) {
+        startPage = currentPage;
+        endPage = currentPage;
+    } else { //AllPages
+        startPage = 1;
+        endPage = lastPage;
+    }
+
+    for (int i = startPage; i <= endPage; i++ ) {
+        list << i;
+    }
+
+    return list;
+}
+
 void Okular::copyQIODevice( QIODevice *from, QIODevice *to )
 {
     QByteArray buffer( 65536, '\0' );
index 8419a41..1ad9c84 100644 (file)
@@ -16,6 +16,7 @@
 #include <QRect>
 #include <QImage>
 #include <QWidget>
+#include <QPrinter>
 
 namespace Okular
 {
@@ -83,6 +84,18 @@ class OKULAR_EXPORT Utils
      * @since 0.7 (KDE 4.1)
      */
     static NormalizedRect imageBoundingBox( const QImage* image );
+
+    /** Return the list of pages selected by the user in the Print Dialog
+     *
+     * @param printer the print settings to use
+     * @param lastPage the last page number, needed if AllPages option is selected
+     * @param currentPage the current page number, needed if CurrentPage option is selected
+     * @param selectedPageList list of pages to use if Selection option is selected
+     * @returns Returns list of pages to print
+     */
+    static QList<int> pageList( QPrinter &printer, int lastPage,
+                                int currentPage, const QList<int> &selectedPageList );
+    
 };
 
 }
index 7c109d5..9a9da3d 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <core/document.h>
 #include <core/page.h>
-#include <core/fileprinter.h>
+#include <core/utils.h>
 
 static KAboutData createAboutData()
 {
@@ -82,9 +82,9 @@ bool ComicBookGenerator::print( QPrinter& printer )
 {
     QPainter p( &printer );
 
-    QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
-                                                         document()->currentPage() + 1,
-                                                         document()->bookmarkedPageList() );
+    QList<int> pageList = Okular::Utils::pageList( printer, document()->pages(),
+                                                   document()->currentPage() + 1,
+                                                   document()->bookmarkedPageList() );
 
     for ( int i = 0; i < pageList.count(); ++i ) {
 
index 8333aad..228ae0f 100644 (file)
@@ -16,7 +16,6 @@
 #include <core/page.h>
 #include <core/textpage.h>
 #include <core/utils.h>
-#include <core/fileprinter.h>
 
 #include <qdom.h>
 #include <qmutex.h>
@@ -87,7 +86,6 @@ DjVuGenerator::DjVuGenerator( QObject *parent, const QVariantList &args )
 {
     setFeature( TextExtraction );
     setFeature( Threaded );
-    setFeature( PrintPostscript );
 
     m_djvu = new KDjVu();
     m_djvu->setCacheEnabled( false );
@@ -191,36 +189,6 @@ const Okular::DocumentSynopsis * DjVuGenerator::generateDocumentSynopsis()
     return m_docSyn;
 }
 
-bool DjVuGenerator::print( QPrinter& printer )
-{
-    bool result = false;
-
-    // Create tempfile to write to
-    KTemporaryFile tf;
-    tf.setSuffix( ".ps" );
-    if ( !tf.open() )
-        return false;
-
-    QMutexLocker locker( userMutex() );
-    QList<int> pageList = Okular::FilePrinter::pageList( printer, m_djvu->pages().count(),
-                                                         document()->currentPage() + 1,
-                                                         document()->bookmarkedPageList() );
-
-    if ( m_djvu->exportAsPostScript( &tf, pageList ) )
-    {
-        tf.setAutoRemove( false );
-        const QString fileName = tf.fileName();
-        tf.close();
-        int ret = Okular::FilePrinter::printFile( printer, fileName, document()->orientation(),
-                                                  Okular::FilePrinter::SystemDeletesFiles,
-                                                  Okular::FilePrinter::ApplicationSelectsPages,
-                                                  document()->bookmarkedPageRange() );
-        result = ( ret >=0 );
-    }
-
-    return result;
-}
-
 QVariant DjVuGenerator::metaData( const QString &key, const QVariant &option ) const
 {
     Q_UNUSED( option )
index 93ee4de..60b15e2 100644 (file)
@@ -33,9 +33,6 @@ class DjVuGenerator : public Okular::Generator
         const Okular::DocumentInfo * generateDocumentInfo();
         const Okular::DocumentSynopsis * generateDocumentSynopsis();
 
-        // printing
-        bool print( QPrinter& printer );
-
         QVariant metaData( const QString & key, const QVariant & option ) const;
 
     protected:
index a799e35..6674a14 100644 (file)
@@ -42,7 +42,6 @@ set(okularGenerator_dvi_SRCS
    fontMap.cpp
    fontpool.cpp
    dvisourcesplitter.cpp
-   dviexport.cpp
 )
 
 
index c78073a..569c9e6 100644 (file)
@@ -27,7 +27,6 @@
 #include <kglobal.h>
 #include <klocale.h>
 #include <kmimetype.h>
-#include <kstandarddirs.h>
 #include <kvbox.h>
 
 #include <QApplication>
@@ -721,39 +720,6 @@ QString dviRenderer::PDFencodingToQString(const QString& _pdfstring)
   return pdfstring;
 }
 
-
-void dviRenderer::exportPDF()
-{
-/*
-  KSharedPtr<DVIExport> exporter(new DVIExportToPDF(*this, parentWidget));
-  if (exporter->started())
-    all_exports_[exporter.data()] = exporter;
-*/
-}
-
-
-void dviRenderer::exportPS(const QString& fname, const QStringList& options, QPrinter* printer, QPrinter::Orientation orientation)
-{
-  KSharedPtr<DVIExport> exporter(new DVIExportToPS(*this, fname, options, printer, font_pool.getUseFontHints(), orientation));
-  if (exporter->started())
-    all_exports_[exporter.data()] = exporter;
-}
-
-/*
-void dviRenderer::editor_finished(const DVISourceEditor*)
-{
-  editor_.attach(0);
-}
-*/
-
-void dviRenderer::export_finished(const DVIExport* key)
-{
-  typedef QMap<const DVIExport*, KSharedPtr<DVIExport> > ExportMap;
-  ExportMap::iterator it = all_exports_.find(key);
-  if (it != all_exports_.end())
-    all_exports_.remove(key);
-}
-
 void dviRenderer::setEventLoop(QEventLoop *el) 
 {
   if (el == NULL)
index c286738..9844e52 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "bigEndianByteReader.h"
 //#include "documentRenderer.h"
-#include "dviexport.h"
 //#include "dvisourceeditor.h"
 #include "fontpool.h"
 #include "dviPageInfo.h"
@@ -140,8 +139,6 @@ public:
   void          html_href_special(const QString& msg);
   void          html_anchor_end();
   void          draw_page();
-  void          export_finished(const DVIExport*);
-//void          editor_finished(const DVISourceEditor*);
 
 
 Q_SIGNALS:
@@ -155,9 +152,6 @@ Q_SIGNALS:
 
 
 public slots:
-  void          exportPS(const QString& fname = QString(), const QStringList& options = QStringList(), QPrinter* printer = 0, QPrinter::Orientation orientation = QPrinter::Portrait);
-  void          exportPDF();
-
   void          handleSRCLink(const QString &linkText, const QPoint& point, DocumentWidget *widget);
 
   void          embedPostScript();
@@ -178,7 +172,6 @@ private slots:
 //  void          showThatSourceInformationIsPresent();
 
 private:
-  friend class DVIExportToPS;
   friend class DVIExport;
 //  friend class DVISourceEditor;
 
@@ -300,7 +293,6 @@ private:
 
   drawinf currinf;
   RenderedDocumentPagePixmap* currentlyDrawnPage;
-  QMap<const DVIExport*, KSharedPtr<DVIExport> > all_exports_;
   //KSharedPtr<DVISourceEditor> editor_;
 
   /** Flag if document is modified
diff --git a/okular/generators/dvi/dviexport.cpp b/okular/generators/dvi/dviexport.cpp
deleted file mode 100644 (file)
index 42831f1..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
-/**
- * \file dviexport.h
- * Distributed under the GNU GPL version 2 or (at your option)
- * any later version. See accompanying file COPYING or copy at
- * http://www.gnu.org/copyleft/gpl.html
- *
- * \author Angus Leeming
- * \author Stefan Kebekus
- *
- * Classes DVIExportToPDF and DVIExportToPS control the export
- * of a DVI file to PDF or PostScript format, respectively.
- * Common functionality is factored out into a common base class,
- * DVIExport which itself derives from KShared allowing easy,
- * polymorphic storage of multiple KSharedPtr<DVIExport> variables
- * in a container of all exported processes.
- */
-
-#include <config.h>
-#include <core/fileprinter.h>
-
-#include "dviexport.h"
-
-#include "dviFile.h"
-#include "dviRenderer.h"
-#include "kvs_debug.h"
-
-#include <KStandardDirs>
-#include <kfiledialog.h>
-#include <klocale.h>
-#include <kmessagebox.h>
-#include <kprocess.h>
-#include <ktemporaryfile.h>
-
-#include <QEventLoop>
-#include <QFileInfo>
-#include <QLabel>
-#include <QtGui/QPrinter>
-
-#include <cassert>
-
-
-DVIExport::DVIExport(dviRenderer& parent)
-  : started_(false),
-    process_(0),
-    parent_(&parent)
-{
-  connect( this, SIGNAL(error(QString,int)), &parent, SIGNAL(error(QString,int)) );
-}
-
-
-DVIExport::~DVIExport()
-{
-  delete process_;
-}
-
-
-void DVIExport::start(const QString& command,
-                      const QStringList& args,
-                      const QString& working_directory,
-                      const QString& error_message)
-{
-  assert(!process_);
-
-  process_ = new KProcess;
-  process_->setOutputChannelMode(KProcess::MergedChannels);
-  process_->setNextOpenMode(QIODevice::Text);
-  connect(process_, SIGNAL(readyReadStandardOutput()), this, SLOT(output_receiver()));
-  connect(process_, SIGNAL(finished(int)), this, SLOT(finished(int)));
-
-  *process_ << command << args;
-
-  if (!working_directory.isEmpty())
-    process_->setWorkingDirectory(working_directory);
-
-  error_message_ = error_message;
-
-  process_->start();
-  if (!process_->waitForStarted(-1))
-    kError(kvs::dvi) << command << " failed to start" << endl;
-  else
-    started_ = true;
-
-  if (parent_->m_eventLoop)
-     parent_->m_eventLoop->exec();
-}
-
-
-void DVIExport::abort_process_impl()
-{
-  // deleting process_ kills the external process itself
-  // if it's still running.
-  delete process_;
-  process_ = 0;
-}
-
-
-void DVIExport::finished_impl(int exit_code)
-{
-  if (process_ && exit_code != 0)
-    emit error(error_message_, -1);
-  // Remove this from the store of all export processes.
-  parent_->m_eventLoop->exit( exit_code );
-  parent_->export_finished(this);
-}
-
-
-void DVIExport::output_receiver()
-{
-  if (process_) {
-     QString out = process_->readAllStandardOutput();
-  }
-}
-
-
-DVIExportToPDF::DVIExportToPDF(dviRenderer& parent, const QString& output_name)
-  : DVIExport(parent)
-{
-  // Neither of these should happen. Paranoia checks.
-  if (!parent.dviFile)
-    return;
-  const dvifile& dvi = *(parent.dviFile);
-
-  const QFileInfo input(dvi.filename);
-  if (!input.exists() || !input.isReadable())
-    return;
-
-  if (KStandardDirs::findExe("dvipdfm").isEmpty()) {
-    emit error(i18n("<qt><p>Okular could not locate the program <em>dvipdfm</em> on your computer. This program is "
-                    "essential for the export function to work. You can, however, convert "
-                    "the DVI-file to PDF using the print function of Okular, but that will often "
-                    "produce documents which print okay, but are of inferior quality if viewed in "
-                    "Acrobat Reader. It may be wise to upgrade to a more recent version of your "
-                    "TeX distribution which includes the <em>dvipdfm</em> program.</p>"
-                    "<p>Hint to the perplexed system administrator: Okular uses the PATH environment variable "
-                    "when looking for programs.</p></qt>"), -1);
-    return;
-  }
-
-  // Generate a suggestion for a reasonable file name
-  const QString suggested_name = dvi.filename.left(dvi.filename.indexOf(".")) + ".pdf";
-  if (output_name.isEmpty())
-    return;
-
-  start("dvipdfm",
-        QStringList() << "-o"
-                      << output_name
-                      << dvi.filename,
-        QFileInfo(dvi.filename).absolutePath(),
-        i18n("<qt>The external program 'dvipdfm', which was used to export the file, reported an error. "
-             "You might wish to look at the <strong>document info dialog</strong> which you will "
-             "find in the File-Menu for a precise error report.</qt>"));
-}
-
-
-DVIExportToPS::DVIExportToPS(dviRenderer& parent,
-                             const QString& output_name,
-                             const QStringList& options,
-                             QPrinter* printer,
-                             bool useFontHinting,
-                             QPrinter::Orientation orientation)
-  : DVIExport(parent),
-    printer_(printer),
-    orientation_(orientation)
-{
-  // None of these should happen. Paranoia checks.
-  if (!parent.dviFile)
-    return;
-  const dvifile& dvi = *(parent.dviFile);
-
-  const QFileInfo input(dvi.filename);
-  if (!input.exists() || !input.isReadable())
-    return;
-
-  if (dvi.page_offset.isEmpty())
-    return;
-
-  if (dvi.numberOfExternalNONPSFiles != 0) {
-    emit error(i18n("<qt>This DVI file refers to external graphic files which are not in PostScript format, and cannot be handled by the "
-                    "<em>dvips</em> program that Okular uses internally to print or to export to PostScript. The functionality that "
-                    "you require is therefore unavailable in this version of Okular.</qt>"), -1);
-    return;
-  }
-
-  if (KStandardDirs::findExe("dvips").isEmpty()) {
-    emit error(i18n("<qt><p>Okular could not locate the program <em>dvips</em> on your computer. "
-                    "That program is essential for the export function to work.</p>"
-                    "<p>Hint to the perplexed system administrator: Okular uses the PATH environment "
-                    "variable when looking for programs.</p></qt>"), -1);
-    return;
-  }
-
-  if (output_name.isEmpty())
-    return;
-  
-  output_name_ = output_name;
-
-  // There is a major problem with dvips, at least 5.86 and lower: the
-  // arguments of the option "-pp" refer to TeX-pages, not to
-  // sequentially numbered pages. For instance "-pp 7" may refer to 3
-  // or more pages: one page "VII" in the table of contents, a page
-  // "7" in the text body, and any number of pages "7" in various
-  // appendices, indices, bibliographies, and so forth. KDVI currently
-  // uses the following disgusting workaround: if the "options"
-  // variable is used, the DVI-file is copied to a temporary file, and
-  // all the page numbers are changed into a sequential ordering
-  // (using UNIX files, and taking manually care of CPU byte
-  // ordering). Finally, dvips is then called with the new file, and
-  // the file is afterwards deleted. Isn't that great?
-
-  // A similar problem occurs with DVI files that contain page size
-  // information. On these files, dvips pointblank refuses to change
-  // the page orientation or set another page size. Thus, if the
-  // DVI-file does contain page size information, we remove that
-  // information first.
-
-  // input_name is the name of the DVI which is used by dvips, either
-  // the original file, or a temporary file with a new numbering.
-  QString input_name = dvi.filename;
-  if (!options.isEmpty() || dvi.suggestedPageSize != 0) {
-    // Get a name for a temporary file.
-    tmpfile_name_ = KTemporaryFile::filePath();
-
-    input_name = tmpfile_name_;
-
-    fontPool fp(useFontHinting);
-    dvifile newFile(&dvi, &fp);
-
-    // Renumber pages
-    newFile.renumber();
-
-    const quint16 saved_current_page = parent.current_page;
-    dvifile* saved_dvi = parent.dviFile;
-    parent.dviFile = &newFile;
-    parent.errorMsg = QString();
-
-    // Remove any page size information from the file
-    for (parent.current_page = 0;
-        parent.current_page < newFile.total_pages;
-        parent.current_page++)
-    {
-      if (parent.current_page < newFile.total_pages) {
-        parent.command_pointer =
-          newFile.dvi_Data() + parent.dviFile->page_offset[int(parent.current_page)];
-        parent.end_pointer =
-          newFile.dvi_Data() + parent.dviFile->page_offset[int(parent.current_page+1)];
-      } else {
-        parent.command_pointer = 0;
-        parent.end_pointer = 0;
-      }
-
-      memset((char*) &parent.currinf.data, 0, sizeof(parent.currinf.data));
-      parent.currinf.fonttable = &(parent.dviFile->tn_table);
-      parent.currinf._virtual  = 0;
-      parent.prescan(&dviRenderer::prescan_removePageSizeInfo);
-    }
-
-    parent.current_page = saved_current_page;
-    parent.dviFile = saved_dvi;
-    newFile.saveAs(input_name);
-  }
-
-  QStringList args;
-  if (!printer)
-    // Export hyperlinks
-    args << "-z";
-
-  if (!options.isEmpty())
-    args += options;
-
-  args << input_name
-       << "-o"
-       << output_name_;
-
-  start("dvips",
-        args,
-        QFileInfo(dvi.filename).absolutePath(),
-        i18n("<qt>The external program 'dvips', which was used to export the file, reported an error. "
-             "You might wish to look at the <strong>document info dialog</strong> which you will "
-             "find in the File-Menu for a precise error report.</qt>"));
-}
-
-
-void DVIExportToPS::finished_impl(int exit_code)
-{
-  if (printer_ && !output_name_.isEmpty()) {
-    const QFileInfo output(output_name_);
-    if (output.exists() && output.isReadable()) {
-        // I'm not 100% sure on this, think we still need to select pages in export to ps above
-        Okular::FilePrinter::printFile( (*printer_), output_name_, orientation_,
-                                Okular::FilePrinter::ApplicationDeletesFiles,
-                                Okular::FilePrinter::ApplicationSelectsPages,
-                                QString() );
-    }
-  }
-
-  if (!tmpfile_name_.isEmpty()) {
-     // Delete the file.
-    QFile(tmpfile_name_).remove();
-    tmpfile_name_.clear();
-  }
-
-  DVIExport::finished_impl(exit_code);
-}
-
-
-void DVIExportToPS::abort_process_impl()
-{
-  if (!tmpfile_name_.isEmpty()) {
-     // Delete the file.
-    QFile(tmpfile_name_).remove();
-    tmpfile_name_.clear();
-  }
-
-  printer_ = 0;
-
-  DVIExport::abort_process_impl();
-}
-
-
-#include "moc_dviexport.cpp"
diff --git a/okular/generators/dvi/dviexport.h b/okular/generators/dvi/dviexport.h
deleted file mode 100644 (file)
index e360d05..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
-/**
- * \file dviexport.h
- * Distributed under the GNU GPL version 2 or (at your option)
- * any later version. See accompanying file COPYING or copy at
- * http://www.gnu.org/copyleft/gpl.html
- *
- * \author Angus Leeming
- * \author Stefan Kebekus
- *
- * Classes DVIExportToPDF and DVIExportToPS control the export
- * of a DVI file to PDF or PostScript format, respectively.
- * Common functionality is factored out into a common base class,
- * DVIExport which itself derives from KShared allowing easy,
- * polymorphic storage of multiple KSharedPtr<DVIExport> variables
- * in a container of all exported processes.
- */
-
-#ifndef DVIEXPORT_H
-#define DVIEXPORT_H
-
-#include <ksharedptr.h>
-
-#include <QObject>
-#include <QtGui/QPrinter>
-
-
-class dviRenderer;
-class KProcess;
-#include <QStringList>
-
-
-class DVIExport: public QObject, public QSharedData
-{
-  Q_OBJECT
-public:
-  virtual ~DVIExport();
-
-  /** @c started() Flags whether or not the external process was
-   *  spawned successfully.
-   *  Can be used to decide whether to discard the DVIExport variable,
-   *  or to store it and await notification that the external process
-   *  has finished.
-   */
-  bool started() const { return started_; }
-
-Q_SIGNALS:
-  void error( const QString &message, int duration );
-
-protected:
-  /** @param parent is stored internally in order to inform the parent
-   *  that the external process has finished and that this variable
-   *  can be removed from any stores.
-   */
-  DVIExport(dviRenderer& parent);
-
-  /** Spawns the external process having connected slots to the child
-   *  process's stdin and stdout streams.
-   */
-  void start(const QString& command,
-             const QStringList& args,
-             const QString& working_directory,
-             const QString& error_message);
-
-  /** The real implementation of the abort_process() slot that is
-   *  called when the fontProcessDialog is closed by the user,
-   *  indicating that the export should be halted.
-   */
-  virtual void abort_process_impl();
-
-  /** The real implementation of the finished() slot that is called
-   *  when the external process finishes.
-   *  @param exit_code the exit code retuned by the external process.
-   */
-  virtual void finished_impl(int exit_code);
-
-private slots:
-  /// Calls an impl() inline so that derived classes don't need slots.
-  void abort_process() { abort_process_impl(); }
-  void finished(int exit_code) { finished_impl(exit_code); }
-
-  /** This slot receives all output from the child process's stdin
-   *  and stdout streams.
-   */
-  void output_receiver();
-
-private:
-  QString error_message_;
-  bool started_;
-  KProcess* process_;
-  dviRenderer* parent_;
-};
-
-
-class DVIExportToPDF : public DVIExport
-{
-public:
-  /** @param parent is stored internally in order to inform the parent
-   *  that the external process has finished.
-   *  @param output_name is the name of the PDF file that is
-   *  to contain the exported data.   */
-  DVIExportToPDF(dviRenderer& parent, const QString& output_name);
-};
-
-
-class DVIExportToPS : public DVIExport
-{
-public:
-  /** @param parent is stored internally in order to inform the parent
-   *  that the external process has finished.
-   *  @param output_name is the name of the PostScript file that is
-   *  to contain the exported data.
-   *  @param options extra command line arguments that are to be
-   *  passed to the external process's argv command line.
-   *  @param printer having generated the PostScript file, it is passed
-   *  to @c printer (if not null).
-   *  @param orientation the original orientation of the document
-   */
-  DVIExportToPS(dviRenderer& parent,
-                const QString& output_name,
-                const QStringList& options,
-                QPrinter* printer,
-                bool useFontHinting,
-                QPrinter::Orientation orientation = QPrinter::Portrait);
-
-private:
-  virtual void abort_process_impl();
-  virtual void finished_impl(int exit_code);
-
-  QPrinter* printer_;
-  QString output_name_;
-  QString tmpfile_name_;
-  QPrinter::Orientation orientation_;
-};
-
-#endif
index db9ad45..c79d4d8 100644 (file)
@@ -20,7 +20,6 @@
 #include "dviPageInfo.h"
 #include "dviRenderer.h"
 #include "pageSize.h"
-#include "dviexport.h"
 #include "TeXFont.h"
 
 #include <qapplication.h>
@@ -63,7 +62,6 @@ DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular
     setFeature( Threaded );
     setFeature( TextExtraction );
     setFeature( FontInfo );
-    setFeature( PrintPostscript );
 }
 
 bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page * > &pagesVector )
@@ -535,38 +533,6 @@ void DviGenerator::loadPages( QVector< Okular::Page * > &pagesVector )
             pagesVector[i]->setSourceReferences( refRects.at(i) );
 }
 
-bool DviGenerator::print( QPrinter& printer )
-{
-    // Create tempfile to write to
-    KTemporaryFile tf;
-    tf.setSuffix( ".ps" );
-    if ( !tf.open() )
-        return false;
-
-    QList<int> pageList = Okular::FilePrinter::pageList( printer, 
-                                 m_dviRenderer->totalPages(),
-                                 document()->currentPage() + 1,
-                                 document()->bookmarkedPageList() );
-    QString pages;
-    QStringList printOptions;
-    // List of pages to print.
-    foreach ( int p, pageList )
-    {
-        pages += QString(",%1").arg(p);
-    }
-    if ( !pages.isEmpty() )
-        printOptions << "-pp" << pages.mid(1);
-
-    QEventLoop el;
-    m_dviRenderer->setEventLoop( &el );
-    m_dviRenderer->exportPS( tf.fileName(), printOptions, &printer, document()->orientation() );
-
-    tf.close();
-
-    // Error messages are handled by the generator - ugly, but it works.
-    return true; 
-}
-
 QVariant DviGenerator::metaData( const QString & key, const QVariant & option ) const
 {
     if ( key == "NamedViewport" && !option.toString().isEmpty() )
index 313edfc..8508688 100644 (file)
@@ -39,8 +39,6 @@ class DviGenerator : public Okular::Generator
         // list of fonts
         Okular::FontInfo::List fontsForPage( int page );
 
-        bool print( QPrinter &printer );
-
         QVariant metaData( const QString & key, const QVariant & option ) const;
 
     protected:
index 4c9a7d4..4eb0d7a 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <core/page.h>
 #include <core/pagetransition.h>
-#include <core/fileprinter.h>
 #include <core/utils.h>
 
 #include <poppler/cpp/poppler-toc.h>
@@ -529,7 +528,7 @@ bool PDFGenerator::print(QPrinter &printer)
     }
 
     QPainter qpainter(&printer);
-    const QList<int> okularpageslist = Okular::FilePrinter::pageList(
+    const QList<int> okularpageslist = Okular::Utils::pageList(
         printer, document()->pages(),
         document()->currentPage() + 1,
         document()->bookmarkedPageList()
index c1725ee..42130e1 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <core/document.h>
 #include <core/page.h>
-#include <core/fileprinter.h>
 #include <core/utils.h>
 
 #include "ui_gssettingswidget.h"
@@ -57,8 +56,6 @@ GSGenerator::GSGenerator( QObject *parent, const QVariantList &args ) :
     m_docInfo(0),
     m_request(0)
 {
-    setFeature( PrintPostscript );
-
     GSRendererThread *renderer = GSRendererThread::getCreateRenderer();
     if (!renderer->isRunning()) renderer->start();
     connect(renderer, SIGNAL(imageDone(QImage*,Okular::PixmapRequest*)),
@@ -99,55 +96,6 @@ void GSGenerator::addPages( KConfigDialog *dlg )
     dlg->addPage(w, GSSettings::self(), i18n("Ghostscript"), "okular-gv", i18n("Ghostscript Backend Configuration") );
 }
 
-bool GSGenerator::print( QPrinter& printer )
-{
-    bool result = false;
-
-    // Create tempfile to write to
-    KTemporaryFile tf;
-    tf.setSuffix( ".ps" );
-
-    // Get list of pages to print
-    QList<int> pageList = Okular::FilePrinter::pageList( printer,
-                                               spectre_document_get_n_pages( m_internalDocument ),
-                                               document()->currentPage() + 1,
-                                               document()->bookmarkedPageList() );
-
-    if ( !tf.open() )
-        return false;
-
-    SpectreExporter *exporter = spectre_exporter_new( m_internalDocument, SPECTRE_EXPORTER_FORMAT_PS );
-    SpectreStatus exportStatus = spectre_exporter_begin( exporter, tf.fileName().toAscii() );
-
-    int i = 0;
-    while ( i < pageList.count() && exportStatus == SPECTRE_STATUS_SUCCESS )
-    {
-        exportStatus = spectre_exporter_do_page( exporter, pageList.at( i ) - 1 );
-        i++;
-    }
-
-    SpectreStatus endStatus = SPECTRE_STATUS_EXPORTER_ERROR;
-    if (exportStatus == SPECTRE_STATUS_SUCCESS)
-        endStatus = spectre_exporter_end( exporter );
-
-    spectre_exporter_free( exporter );
-
-    const QString fileName = tf.fileName();
-    tf.close();
-
-    if ( exportStatus == SPECTRE_STATUS_SUCCESS && endStatus == SPECTRE_STATUS_SUCCESS )
-    {
-        tf.setAutoRemove( false );
-        int ret = Okular::FilePrinter::printFile( printer, fileName, document()->orientation(),
-                                                  Okular::FilePrinter::SystemDeletesFiles,
-                                                  Okular::FilePrinter::ApplicationSelectsPages,
-                                                  document()->bookmarkedPageRange() );
-        if ( ret >= 0 ) result = true;
-    }
-
-    return result;
-}
-
 Okular::ExportFormat::List GSGenerator::exportFormats() const
 {
     Okular::ExportFormat::List result;
index 95badba..45dd0fa 100644 (file)
@@ -39,9 +39,6 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface
 
         QVariant metaData(const QString &key, const QVariant &option) const;
 
-        // print document using already configured kprinter
-        bool print( QPrinter& /*printer*/ );
-
         // export as PDF
         Okular::ExportFormat::List exportFormats() const;
         bool exportTo( const QString &fileName, const Okular::ExportFormat &format );
index 1f89108..273e07d 100644 (file)
@@ -38,7 +38,7 @@
 #include <core/document.h>
 #include <core/page.h>
 #include <core/area.h>
-#include <core/fileprinter.h>
+#include <core/utils.h>
 
 #include <sys/stat.h>
 
@@ -2128,9 +2128,9 @@ bool XpsGenerator::exportTo( const QString &fileName, const Okular::ExportFormat
 
 bool XpsGenerator::print( QPrinter &printer )
 {
-    QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
-                                                         document()->currentPage() + 1,
-                                                         document()->bookmarkedPageList() );
+    QList<int> pageList = Okular::Utils::pageList( printer, document()->pages(),
+                                                   document()->currentPage() + 1,
+                                                   document()->bookmarkedPageList() );
 
     QPainter painter( &printer );
 
index 9464a81..52b717a 100644 (file)
@@ -80,7 +80,6 @@
 #include "ui/bookmarklist.h"
 #include "ui/findbar.h"
 #include "ui/sidebar.h"
-#include "ui/fileprinterpreview.h"
 #include "ui/guiutils.h"
 #include "conf/preferencesdialog.h"
 #include "settings.h"
@@ -90,7 +89,6 @@
 #include "core/document.h"
 #include "core/generator.h"
 #include "core/page.h"
-#include "core/fileprinter.h"
 
 #include <cstdio>
 #include <memory>
@@ -2340,7 +2338,7 @@ void Part::slotPrintPreview()
 
     QPrinter printer;
 
-    // Native printing supports QPrintPreviewDialog, Postscript needs to use FilePrinterPreview
+    // Native printing supports QPrintPreviewDialog
     if ( m_document->printingSupport() == Okular::Document::NativePrinting )
     {
         QPrintPreviewDialog previewdlg( &printer, widget() );
diff --git a/okular/ui/fileprinterpreview.cpp b/okular/ui/fileprinterpreview.cpp
deleted file mode 100644 (file)
index cd441e6..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by John Layt <john@layt.net>                       *
- *                                                                         *
- *   FilePrinterPreview based on KPrintPreview (originally LGPL)           *
- *   Copyright (c) 2007 Alex Merry <huntedhacker@tiscali.co.uk>            *
- *                                                                         *
- *   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.                                   *
- ***************************************************************************/
-
-#include "fileprinterpreview.h"
-
-#include <QFile>
-#include <QSize>
-#include <QtCore/QFile>
-#include <QtGui/QLabel>
-#include <QtGui/qevent.h>
-
-#include <kmimetypetrader.h>
-#include <kparts/part.h>
-#include <kpluginfactory.h>
-#include <kpluginloader.h>
-#include <kpushbutton.h>
-#include <kservice.h>
-#include <kdebug.h>
-
-using namespace Okular;
-
-// This code copied from KPrintPreview by Alex Merry, adapted to do PS files instead of PDF
-
-class Okular::FilePrinterPreviewPrivate
-{
-public:
-    FilePrinterPreviewPrivate( FilePrinterPreview *host, const QString & _filename )
-        : q(host)
-        , mainWidget(new QWidget(host))
-        , previewPart(0)
-        , failMessage(0)
-        , config(KSharedConfig::openConfig(QString::fromLatin1("okularrc")))
-
-    {
-        filename = _filename;
-    }
-
-    void getPart();
-    bool doPreview();
-    void fail();
-
-    FilePrinterPreview *q;
-
-    QWidget *mainWidget;
-
-    QString filename;
-
-    KParts::ReadOnlyPart *previewPart;
-    QWidget *failMessage;
-
-    KSharedConfig::Ptr config;
-};
-
-void FilePrinterPreviewPrivate::getPart()
-{
-    if (previewPart) {
-        kDebug(500) << "already got a part";
-        return;
-    }
-    kDebug(500) << "querying trader for application/ps service";
-
-    KPluginFactory *factory(0);
-    /* Explicitly look for the Okular/Ghostview part: no other PostScript
-       parts are available now; other parts which handles text are not
-       suitable here (PostScript source code) */
-    KService::List offers =
-        KMimeTypeTrader::self()->query("application/postscript", "KParts/ReadOnlyPart",
-                                       "[DesktopEntryName] == 'okularghostview'");
-
-    KService::List::ConstIterator it = offers.constBegin();
-    while (!factory && it != offers.constEnd()) {
-        KPluginLoader loader(**it);
-        factory = loader.factory();
-        if (!factory) {
-            kDebug(500) << "Loading failed:" << loader.errorString();
-        }
-        ++it;
-    }
-    if (factory) {
-        kDebug(500) << "Trying to create a part";
-        previewPart = factory->create<KParts::ReadOnlyPart>(q, (QVariantList() << "Print/Preview"));
-        if (!previewPart) {
-            kDebug(500) << "Part creation failed";
-        }
-    }
-}
-
-bool FilePrinterPreviewPrivate::doPreview()
-{
-    if (!QFile::exists(filename)) {
-        kWarning() << "Nothing was produced to be previewed";
-        return false;
-    }
-
-    getPart();
-    if (!previewPart) {
-        //TODO: error dialog
-        kWarning() << "Could not find a PS viewer for the preview dialog";
-        fail();
-        return false;
-    } else {
-        q->setMainWidget(previewPart->widget());
-        return previewPart->openUrl(filename);
-    }
-}
-
-void FilePrinterPreviewPrivate::fail()
-{
-    if (!failMessage) {
-        failMessage = new QLabel(i18n("Could not load print preview part"), q);
-    }
-    q->setMainWidget(failMessage);
-}
-
-
-
-
-FilePrinterPreview::FilePrinterPreview( const QString &filename, QWidget *parent )
-    : KDialog( parent )
-    , d( new FilePrinterPreviewPrivate( this, filename ) )
-{
-    kDebug(500) << "kdeprint: creating preview dialog";
-
-    // Set up the dialog
-    setCaption(i18n("Print Preview"));
-    setButtons(KDialog::Close);
-    button(KDialog::Close)->setAutoDefault(false);
-
-    restoreDialogSize(d->config->group("Print Preview"));
-}
-
-FilePrinterPreview::~FilePrinterPreview()
-{
-    KConfigGroup group(d->config->group("Print Preview"));
-    saveDialogSize(group);
-
-    delete d;
-}
-
-QSize FilePrinterPreview::sizeHint() const
-{
-    // return a more or less useful window size, if not saved already
-    return QSize(600, 500);
-}
-
-void FilePrinterPreview::showEvent(QShowEvent *event)
-{
-    if (!event->spontaneous()) {
-        // being shown for the first time
-        if (!d->doPreview()) {
-            event->accept();
-            return;
-        }
-    }
-    KDialog::showEvent(event);
-}
-
-#include "moc_fileprinterpreview.cpp"
diff --git a/okular/ui/fileprinterpreview.h b/okular/ui/fileprinterpreview.h
deleted file mode 100644 (file)
index 5ea5c60..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by John Layt <john@layt.net>                       *
- *                                                                         *
- *   FilePrinterPreview based on KPrintPreview (originally LGPL)           *
- *   Copyright (c) 2007 Alex Merry <huntedhacker@tiscali.co.uk>            *
- *                                                                         *
- *   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.                                   *
- ***************************************************************************/
-
-#ifndef FILEPRINTERPREVIEW_H
-#define FILEPRINTERPREVIEW_H
-
-#include <kdialog.h>
-
-namespace Okular {
-
-// This code copied from KPrintPreview by Alex Merry, adapted to do PS files instead of PDF
-
-class FilePrinterPreviewPrivate;
-
-class FilePrinterPreview : public KDialog
-{
-    Q_OBJECT
-
-public:
-    /**
-     * Create a Print Preview dialog for a given file.
-     *
-     * @param printer file to print preview
-     * @param parent  pointer to the parent widget for the dialog
-     */
-    explicit FilePrinterPreview( const QString &filename, QWidget *parent = 0 );
-    virtual ~FilePrinterPreview();
-
-    QSize sizeHint() const;
-
-protected:
-    void showEvent( QShowEvent *event );
-
-private:
-    FilePrinterPreviewPrivate * const d;
-};
-
-}
-
-#endif // FILEPRINTER_H