mirror of
https://invent.kde.org/graphics/okular
synced 2024-06-30 22:54:24 +00:00
Act on core/ TODOs that are not binary compatible
I'm going to need to break binary compatibility to add a new feature so may as well cleanup all the TODOs regarding that Changes: * Moving a few destructors to the header * Removing a few unnecessary & in params * Adding a few necessary & in params * Making print return an enum instead of a bool and then having another function that returns the enum * Make Generator::requestFontData be a virtual * Remove unused enum * Remove a few filePrinter unneeded functions * Remove unused TextDocumentGenerator::addMetaData signal
This commit is contained in:
parent
8681bc0223
commit
a2576dc746
|
@ -38,7 +38,6 @@ NormalizedPoint::NormalizedPoint(int iX, int iY, int xScale, int yScale)
|
|||
|
||||
NormalizedPoint &NormalizedPoint::operator=(const NormalizedPoint &p) = default;
|
||||
NormalizedPoint::NormalizedPoint(const NormalizedPoint &) = default;
|
||||
NormalizedPoint::~NormalizedPoint() = default;
|
||||
|
||||
void NormalizedPoint::transform(const QTransform &matrix)
|
||||
{
|
||||
|
@ -132,7 +131,7 @@ NormalizedRect::NormalizedRect(double l, double t, double r, double b)
|
|||
{
|
||||
}
|
||||
|
||||
NormalizedRect::NormalizedRect(const QRect &r, double xScale, double yScale) // clazy:exclude=function-args-by-value TODO when BIC changes are allowed
|
||||
NormalizedRect::NormalizedRect(const QRect r, double xScale, double yScale)
|
||||
: left((double)r.left() / xScale)
|
||||
, top((double)r.top() / yScale)
|
||||
, right((double)r.right() / xScale)
|
||||
|
@ -212,8 +211,6 @@ NormalizedRect NormalizedRect::operator&(const NormalizedRect &r) const
|
|||
|
||||
NormalizedRect &NormalizedRect::operator=(const NormalizedRect &r) = default;
|
||||
|
||||
NormalizedRect::~NormalizedRect() = default;
|
||||
|
||||
bool NormalizedRect::operator==(const NormalizedRect &r) const
|
||||
{
|
||||
return (isNull() && r.isNull()) || (fabs(left - r.left) < 1e-4 && fabs(right - r.right) < 1e-4 && fabs(top - r.top) < 1e-4 && fabs(bottom - r.bottom) < 1e-4);
|
||||
|
|
|
@ -138,8 +138,7 @@ public:
|
|||
NormalizedPoint &operator=(const NormalizedPoint &);
|
||||
|
||||
NormalizedPoint(const NormalizedPoint &);
|
||||
// TODO next ABI break, move the = default to here
|
||||
~NormalizedPoint(); // NOLINT(performance-trivially-destructible)
|
||||
~NormalizedPoint() = default;
|
||||
|
||||
/**
|
||||
* Transforms the normalized point with the operations defined by @p matrix.
|
||||
|
@ -223,7 +222,7 @@ public:
|
|||
* You can use e. g. QRect::normalize() to ensure this.
|
||||
* At negative width or height the behaviour of some operations is undefined.
|
||||
*/
|
||||
NormalizedRect(const QRect &rectangle, double xScale, double yScale);
|
||||
NormalizedRect(const QRect rectangle, double xScale, double yScale);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -235,8 +234,7 @@ public:
|
|||
*/
|
||||
NormalizedRect &operator=(const NormalizedRect &other);
|
||||
|
||||
// TODO next ABI break, move the = default to here
|
||||
~NormalizedRect(); // NOLINT(performance-trivially-destructible)
|
||||
~NormalizedRect() = default;
|
||||
|
||||
/**
|
||||
* Build a normalized rect from a QRectF, which already has normalized coordinates.
|
||||
|
|
|
@ -4256,42 +4256,37 @@ bool Document::supportsPrintToFile() const
|
|||
return d->m_generator ? d->m_generator->hasFeature(Generator::PrintToFile) : false;
|
||||
}
|
||||
|
||||
bool Document::print(QPrinter &printer)
|
||||
Document::PrintError Document::print(QPrinter &printer)
|
||||
{
|
||||
return d->m_generator ? d->m_generator->print(printer) : false;
|
||||
return d->m_generator ? d->m_generator->print(printer) : Document::UnknownPrintError;
|
||||
}
|
||||
|
||||
QString Document::printError() const
|
||||
QString Document::printErrorString(PrintError error)
|
||||
{
|
||||
Okular::Generator::PrintError err = Generator::UnknownPrintError;
|
||||
if (d->m_generator) {
|
||||
QMetaObject::invokeMethod(d->m_generator, "printError", Qt::DirectConnection, Q_RETURN_ARG(Okular::Generator::PrintError, err));
|
||||
}
|
||||
Q_ASSERT(err != Generator::NoPrintError);
|
||||
switch (err) {
|
||||
case Generator::TemporaryFileOpenPrintError:
|
||||
switch (error) {
|
||||
case TemporaryFileOpenPrintError:
|
||||
return i18n("Could not open a temporary file");
|
||||
case Generator::FileConversionPrintError:
|
||||
case FileConversionPrintError:
|
||||
return i18n("Print conversion failed");
|
||||
case Generator::PrintingProcessCrashPrintError:
|
||||
case PrintingProcessCrashPrintError:
|
||||
return i18n("Printing process crashed");
|
||||
case Generator::PrintingProcessStartPrintError:
|
||||
case PrintingProcessStartPrintError:
|
||||
return i18n("Printing process could not start");
|
||||
case Generator::PrintToFilePrintError:
|
||||
case PrintToFilePrintError:
|
||||
return i18n("Printing to file failed");
|
||||
case Generator::InvalidPrinterStatePrintError:
|
||||
case InvalidPrinterStatePrintError:
|
||||
return i18n("Printer was in invalid state");
|
||||
case Generator::UnableToFindFilePrintError:
|
||||
case UnableToFindFilePrintError:
|
||||
return i18n("Unable to find file to print");
|
||||
case Generator::NoFileToPrintError:
|
||||
case NoFileToPrintError:
|
||||
return i18n("There was no file to print");
|
||||
case Generator::NoBinaryToPrintError:
|
||||
case NoBinaryToPrintError:
|
||||
return i18n("Could not find a suitable binary for printing. Make sure CUPS lpr binary is available");
|
||||
case Generator::InvalidPageSizePrintError:
|
||||
case InvalidPageSizePrintError:
|
||||
return i18n("The page print size is invalid");
|
||||
case Generator::NoPrintError:
|
||||
case NoPrintError:
|
||||
return QString();
|
||||
case Generator::UnknownPrintError:
|
||||
case UnknownPrintError:
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@ -4633,16 +4628,11 @@ void Document::unregisterView(View *view)
|
|||
|
||||
QByteArray Document::fontData(const FontInfo &font) const
|
||||
{
|
||||
QByteArray result;
|
||||
|
||||
if (d->m_generator) {
|
||||
// clang-format off
|
||||
// Otherwise the Q_ARG(QByteArray* gets broken
|
||||
QMetaObject::invokeMethod(d->m_generator, "requestFontData", Qt::DirectConnection, Q_ARG(Okular::FontInfo, font), Q_ARG(QByteArray*, &result));
|
||||
// clang-format on
|
||||
return d->m_generator->requestFontData(font);
|
||||
}
|
||||
|
||||
return result;
|
||||
return {};
|
||||
}
|
||||
|
||||
ArchiveData *DocumentPrivate::unpackDocumentArchive(const QString &archivePath)
|
||||
|
|
|
@ -627,12 +627,10 @@ public:
|
|||
/**
|
||||
* Describes how search ended
|
||||
*/
|
||||
// TODO remove EndOfDocumentReached when we break API
|
||||
enum SearchStatus {
|
||||
MatchFound, ///< Any match was found
|
||||
NoMatchFound, ///< No match was found
|
||||
SearchCancelled, ///< The search was cancelled
|
||||
EndOfDocumentReached ///< This is not ever emitted since 1.3. The end of document was reached without any match @since 0.20 (KDE 4.14)
|
||||
MatchFound, ///< Any match was found
|
||||
NoMatchFound, ///< No match was found
|
||||
SearchCancelled ///< The search was cancelled
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -744,16 +742,29 @@ public:
|
|||
*/
|
||||
bool supportsPrintToFile() const;
|
||||
|
||||
/// @since 22.04
|
||||
enum PrintError {
|
||||
NoPrintError, ///< Printing succeeded
|
||||
UnknownPrintError,
|
||||
TemporaryFileOpenPrintError,
|
||||
FileConversionPrintError,
|
||||
PrintingProcessCrashPrintError,
|
||||
PrintingProcessStartPrintError,
|
||||
PrintToFilePrintError,
|
||||
InvalidPrinterStatePrintError,
|
||||
UnableToFindFilePrintError,
|
||||
NoFileToPrintError,
|
||||
NoBinaryToPrintError,
|
||||
InvalidPageSizePrintError
|
||||
};
|
||||
|
||||
/**
|
||||
* Prints the document to the given @p printer.
|
||||
*/
|
||||
bool print(QPrinter &printer);
|
||||
Document::PrintError print(QPrinter &printer);
|
||||
|
||||
/**
|
||||
* Returns the last print error in case print() failed
|
||||
* @since 0.11 (KDE 4.5)
|
||||
*/
|
||||
QString printError() const;
|
||||
/// @since 22.04
|
||||
static QString printErrorString(PrintError error);
|
||||
|
||||
/**
|
||||
* Returns a custom printer configuration page or 0 if no
|
||||
|
|
|
@ -27,57 +27,46 @@
|
|||
|
||||
using namespace Okular;
|
||||
|
||||
int FilePrinter::printFile(QPrinter &printer,
|
||||
const QString file, // NOLINT(performance-unnecessary-value-param) clazy:exclude=function-args-by-ref TODO when BIC changes are allowed
|
||||
QPrinter::Orientation documentOrientation,
|
||||
FileDeletePolicy fileDeletePolicy,
|
||||
PageSelectPolicy pageSelectPolicy,
|
||||
const QString &pageRange)
|
||||
{
|
||||
return printFile(printer, file, documentOrientation, fileDeletePolicy, pageSelectPolicy, pageRange, ScaleMode::FitToPrintArea);
|
||||
}
|
||||
|
||||
int FilePrinter::printFile(QPrinter &printer,
|
||||
const QString file, // NOLINT(performance-unnecessary-value-param) clazy:exclude=function-args-by-ref TODO when BIC changes are allowed
|
||||
QPrinter::Orientation documentOrientation,
|
||||
FileDeletePolicy fileDeletePolicy,
|
||||
PageSelectPolicy pageSelectPolicy,
|
||||
const QString &pageRange,
|
||||
ScaleMode scaleMode)
|
||||
Document::PrintError
|
||||
FilePrinter::printFile(QPrinter &printer, const QString &file, QPrinter::Orientation documentOrientation, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, ScaleMode scaleMode)
|
||||
{
|
||||
FilePrinter fp;
|
||||
return fp.doPrintFiles(printer, QStringList(file), fileDeletePolicy, pageSelectPolicy, pageRange, documentOrientation, scaleMode);
|
||||
}
|
||||
|
||||
int FilePrinter::doPrintFiles(QPrinter &printer,
|
||||
const QStringList fileList, // NOLINT(performance-unnecessary-value-param) clazy:exclude=function-args-by-ref TODO when BIC changes are allowed
|
||||
FileDeletePolicy fileDeletePolicy,
|
||||
PageSelectPolicy pageSelectPolicy,
|
||||
const QString &pageRange,
|
||||
QPrinter::Orientation documentOrientation)
|
||||
static Document::PrintError doKProcessExecute(const QString &exe, const QStringList &argList)
|
||||
{
|
||||
return doPrintFiles(printer, fileList, fileDeletePolicy, pageSelectPolicy, pageRange, documentOrientation, ScaleMode::FitToPrintArea);
|
||||
const int ret = KProcess::execute(exe, argList);
|
||||
if (ret == -1)
|
||||
return Document::PrintingProcessCrashPrintError;
|
||||
if (ret == -2)
|
||||
return Document::PrintingProcessStartPrintError;
|
||||
if (ret < 0)
|
||||
return Document::UnknownPrintError;
|
||||
|
||||
return Document::NoPrintError;
|
||||
}
|
||||
|
||||
int FilePrinter::doPrintFiles(QPrinter &printer, QStringList fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPrinter::Orientation documentOrientation, ScaleMode scaleMode)
|
||||
Document::PrintError
|
||||
FilePrinter::doPrintFiles(QPrinter &printer, const QStringList &fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPrinter::Orientation documentOrientation, ScaleMode scaleMode)
|
||||
{
|
||||
if (fileList.size() < 1) {
|
||||
return -8;
|
||||
return Document::NoFileToPrintError;
|
||||
}
|
||||
|
||||
for (QStringList::ConstIterator it = fileList.constBegin(); it != fileList.constEnd(); ++it) {
|
||||
if (!QFile::exists(*it)) {
|
||||
return -7;
|
||||
return Document::UnableToFindFilePrintError;
|
||||
}
|
||||
}
|
||||
|
||||
if (printer.printerState() == QPrinter::Aborted || printer.printerState() == QPrinter::Error) {
|
||||
return -6;
|
||||
return Document::InvalidPrinterStatePrintError;
|
||||
}
|
||||
|
||||
QString exe;
|
||||
QStringList argList;
|
||||
int ret;
|
||||
Document::PrintError ret;
|
||||
|
||||
// Print to File if a filename set, assumes there must be only 1 file
|
||||
if (!printer.outputFileName().isEmpty()) {
|
||||
|
@ -94,30 +83,30 @@ int FilePrinter::doPrintFiles(QPrinter &printer, QStringList fileList, FileDelet
|
|||
bool res = QFile::rename(fileList[0], printer.outputFileName());
|
||||
if (res) {
|
||||
doDeleteFile = false;
|
||||
ret = 0;
|
||||
ret = Document::NoPrintError;
|
||||
} else {
|
||||
ret = -5;
|
||||
ret = Document::PrintToFilePrintError;
|
||||
}
|
||||
} else {
|
||||
bool res = QFile::copy(fileList[0], printer.outputFileName());
|
||||
if (res) {
|
||||
ret = 0;
|
||||
ret = Document::NoPrintError;
|
||||
} else {
|
||||
ret = -5;
|
||||
ret = Document::PrintToFilePrintError;
|
||||
}
|
||||
}
|
||||
} else if (inputFileInfo.suffix() == QLatin1String("ps") && printer.outputFormat() == QPrinter::PdfFormat && ps2pdfAvailable()) {
|
||||
exe = QStringLiteral("ps2pdf");
|
||||
argList << fileList[0] << printer.outputFileName();
|
||||
qCDebug(OkularCoreDebug) << "Executing" << exe << "with arguments" << argList;
|
||||
ret = KProcess::execute(exe, argList);
|
||||
ret = doKProcessExecute(exe, argList);
|
||||
} else if (inputFileInfo.suffix() == QLatin1String("pdf") && printer.outputFormat() == QPrinter::NativeFormat && pdf2psAvailable()) {
|
||||
exe = QStringLiteral("pdf2ps");
|
||||
argList << fileList[0] << printer.outputFileName();
|
||||
qCDebug(OkularCoreDebug) << "Executing" << exe << "with arguments" << argList;
|
||||
ret = KProcess::execute(exe, argList);
|
||||
ret = doKProcessExecute(exe, argList);
|
||||
} else {
|
||||
ret = -5;
|
||||
ret = Document::PrintToFilePrintError;
|
||||
}
|
||||
|
||||
if (doDeleteFile) {
|
||||
|
@ -139,14 +128,14 @@ int FilePrinter::doPrintFiles(QPrinter &printer, QStringList fileList, FileDelet
|
|||
} else if (!QStandardPaths::findExecutable(QStringLiteral("lp")).isEmpty()) {
|
||||
exe = QStringLiteral("lp");
|
||||
} else {
|
||||
return -9;
|
||||
return Document::NoBinaryToPrintError;
|
||||
}
|
||||
|
||||
bool useCupsOptions = cupsAvailable();
|
||||
argList = printArguments(printer, fileDeletePolicy, pageSelectPolicy, useCupsOptions, pageRange, exe, documentOrientation, scaleMode) << fileList;
|
||||
qCDebug(OkularCoreDebug) << "Executing" << exe << "with arguments" << argList;
|
||||
|
||||
ret = KProcess::execute(exe, argList);
|
||||
ret = doKProcessExecute(exe, argList);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -293,47 +282,6 @@ QSize FilePrinter::psPaperSize(QPrinter &printer)
|
|||
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)
|
||||
{
|
||||
return printArguments(printer, fileDeletePolicy, pageSelectPolicy, useCupsOptions, pageRange, version, documentOrientation, ScaleMode::FitToPrintArea);
|
||||
}
|
||||
|
||||
QStringList FilePrinter::printArguments(QPrinter &printer,
|
||||
FileDeletePolicy fileDeletePolicy,
|
||||
PageSelectPolicy pageSelectPolicy,
|
||||
|
@ -456,11 +404,6 @@ QStringList FilePrinter::pages(QPrinter &printer, PageSelectPolicy pageSelectPol
|
|||
return QStringList(); // AllPages
|
||||
}
|
||||
|
||||
QStringList FilePrinter::cupsOptions(QPrinter &printer, QPrinter::Orientation documentOrientation)
|
||||
{
|
||||
return cupsOptions(printer, documentOrientation, ScaleMode::FitToPrintArea);
|
||||
}
|
||||
|
||||
QStringList FilePrinter::cupsOptions(QPrinter &printer, QPrinter::Orientation documentOrientation, ScaleMode scaleMode)
|
||||
{
|
||||
QStringList optionList;
|
||||
|
@ -668,11 +611,6 @@ QStringList FilePrinter::optionCollateCopies(QPrinter &printer)
|
|||
return QStringList(QStringLiteral("-o")) << QStringLiteral("Collate=False");
|
||||
}
|
||||
|
||||
QStringList FilePrinter::optionPageMargins(QPrinter &printer)
|
||||
{
|
||||
return optionPageMargins(printer, ScaleMode::FitToPrintArea);
|
||||
}
|
||||
|
||||
QStringList FilePrinter::optionPageMargins(QPrinter &printer, ScaleMode scaleMode)
|
||||
{
|
||||
if (printer.printEngine()->property(QPrintEngine::PPK_PageMargins).isNull()) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <QPrinter>
|
||||
#include <QString>
|
||||
|
||||
#include "generator.h"
|
||||
#include "document.h"
|
||||
#include "okularcore_export.h"
|
||||
|
||||
class QSize;
|
||||
|
@ -82,23 +82,13 @@ public:
|
|||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
// TODO make file const QString & when a BIC change happens somehwere else
|
||||
static int printFile(QPrinter &printer, const QString file, QPrinter::Orientation documentOrientation, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, ScaleMode scaleMode);
|
||||
|
||||
/** Print a file using the settings in QPrinter
|
||||
*
|
||||
* Same as 'printFile()' with 7 parameters, but always using a 'scaleMode' of
|
||||
* 'FitToPrintArea'.
|
||||
*
|
||||
* @since 0.14 (KDE 4.8)
|
||||
*/
|
||||
// TODO merge with function above when a BIC change happens somehwere else
|
||||
static int printFile(QPrinter &printer,
|
||||
const QString file,
|
||||
QPrinter::Orientation documentOrientation,
|
||||
FileDeletePolicy fileDeletePolicy = FilePrinter::ApplicationDeletesFiles,
|
||||
PageSelectPolicy pageSelectPolicy = FilePrinter::ApplicationSelectsPages,
|
||||
const QString &pageRange = QString());
|
||||
static Document::PrintError printFile(QPrinter &printer,
|
||||
const QString &file,
|
||||
QPrinter::Orientation documentOrientation,
|
||||
FileDeletePolicy fileDeletePolicy = FilePrinter::ApplicationDeletesFiles,
|
||||
PageSelectPolicy pageSelectPolicy = FilePrinter::ApplicationSelectsPages,
|
||||
const QString &pageRange = QString(),
|
||||
ScaleMode scaleMode = ScaleMode::FitToPrintArea);
|
||||
|
||||
/** Return the list of pages selected by the user in the Print Dialog
|
||||
*
|
||||
|
@ -159,24 +149,13 @@ public:
|
|||
*/
|
||||
static QSize psPaperSize(QPrinter &printer);
|
||||
|
||||
/**
|
||||
* Convert the code returned by printFile* to PrintError
|
||||
* @since 0.11 (KDE 4.5)
|
||||
*/
|
||||
static Generator::PrintError printError(int c);
|
||||
|
||||
protected:
|
||||
bool detectCupsService();
|
||||
bool detectCupsConfig();
|
||||
|
||||
// TODO make fileList const QStringList & when a BIC change happens somehwere else
|
||||
int doPrintFiles(QPrinter &printer, const QStringList fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPrinter::Orientation documentOrientation);
|
||||
// TODO merge with function above when a BIC change happens somehwere else
|
||||
/// @since 1.8
|
||||
int doPrintFiles(QPrinter &printer, const QStringList fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPrinter::Orientation documentOrientation, ScaleMode scaleMode);
|
||||
Document::PrintError
|
||||
doPrintFiles(QPrinter &printer, const QStringList &fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPrinter::Orientation documentOrientation, ScaleMode scaleMode);
|
||||
|
||||
QStringList printArguments(QPrinter &printer, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, bool useCupsOptions, const QString &pageRange, const QString &version, QPrinter::Orientation documentOrientation);
|
||||
// TODO merge with function above when a BIC change happens somehwere else
|
||||
/// @since 1.8
|
||||
QStringList printArguments(QPrinter &printer,
|
||||
FileDeletePolicy fileDeletePolicy,
|
||||
|
@ -193,8 +172,6 @@ protected:
|
|||
QStringList deleteFile(QPrinter &printer, FileDeletePolicy fileDeletePolicy, const QString &version);
|
||||
QStringList pages(QPrinter &printer, PageSelectPolicy pageSelectPolicy, const QString &pageRange, bool useCupsOptions, const QString &version);
|
||||
|
||||
QStringList cupsOptions(QPrinter &printer, QPrinter::Orientation documentOrientation);
|
||||
// TODO merge with function above when a BIC change happens somehwere else
|
||||
/// @since 1.8
|
||||
QStringList cupsOptions(QPrinter &printer, QPrinter::Orientation documentOrientation, ScaleMode scaleMode);
|
||||
QStringList optionMedia(QPrinter &printer);
|
||||
|
@ -204,8 +181,6 @@ protected:
|
|||
QStringList optionDoubleSidedPrinting(QPrinter &printer);
|
||||
QStringList optionPageOrder(QPrinter &printer);
|
||||
QStringList optionCollateCopies(QPrinter &printer);
|
||||
QStringList optionPageMargins(QPrinter &printer);
|
||||
// TODO merge with function above when a BIC change happens somehwere else
|
||||
/// @since 1.8
|
||||
QStringList optionPageMargins(QPrinter &printer, ScaleMode scaleMode);
|
||||
QStringList optionCupsProperties(QPrinter &printer);
|
||||
|
|
|
@ -377,14 +377,9 @@ void Generator::pageSizeChanged(const PageSize &, const PageSize &)
|
|||
{
|
||||
}
|
||||
|
||||
bool Generator::print(QPrinter &)
|
||||
Document::PrintError Generator::print(QPrinter &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Generator::PrintError Generator::printError() const
|
||||
{
|
||||
return UnknownPrintError;
|
||||
return Document::UnknownPrintError;
|
||||
}
|
||||
|
||||
void Generator::opaqueAction(const BackendOpaqueAction * /*action*/)
|
||||
|
@ -511,11 +506,12 @@ void Generator::updatePageBoundingBox(int page, const NormalizedRect &boundingBo
|
|||
d->m_document->setPageBoundingBox(page, boundingBox);
|
||||
}
|
||||
|
||||
void Generator::requestFontData(const Okular::FontInfo & /*font*/, QByteArray * /*data*/)
|
||||
QByteArray Generator::requestFontData(const Okular::FontInfo & /*font*/)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void Generator::setDPI(const QSizeF &dpi) // clazy:exclude=function-args-by-value TODO remove the & when we do a BIC change elsewhere
|
||||
void Generator::setDPI(const QSizeF dpi)
|
||||
{
|
||||
Q_D(Generator);
|
||||
d->m_dpi = dpi;
|
||||
|
|
|
@ -399,26 +399,7 @@ public:
|
|||
/**
|
||||
* This method is called to print the document to the given @p printer.
|
||||
*/
|
||||
virtual bool print(QPrinter &printer);
|
||||
|
||||
/**
|
||||
* Possible print errors
|
||||
* @since 0.11 (KDE 4.5)
|
||||
*/
|
||||
enum PrintError {
|
||||
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)
|
||||
};
|
||||
virtual Document::PrintError print(QPrinter &printer);
|
||||
|
||||
/**
|
||||
* This method returns the meta data of the given @p key with the given @p option
|
||||
|
@ -452,9 +433,10 @@ public:
|
|||
/**
|
||||
* Update DPI of the generator
|
||||
*
|
||||
* @since 0.19 (KDE 4.13)
|
||||
* @since 0.19 (old signature)
|
||||
* @since 22.04 (new signature)
|
||||
*/
|
||||
void setDPI(const QSizeF &dpi); // TODO remove the & when we do a BIC change elsewhere
|
||||
void setDPI(const QSizeF dpi);
|
||||
|
||||
/**
|
||||
* Returns the 'layers model' object of the document or NULL if
|
||||
|
@ -591,15 +573,15 @@ protected:
|
|||
*/
|
||||
QSizeF dpi() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* Gets the font data for the given font
|
||||
*
|
||||
* @since 0.8 (KDE 4.1)
|
||||
* @since 0.8 (old signature)
|
||||
* @since 22.04 (new signature)
|
||||
*/
|
||||
// TODO Make it return a QByteArray and be virtual when a BIC change happens somewhere else
|
||||
void requestFontData(const Okular::FontInfo &font, QByteArray *data);
|
||||
virtual QByteArray requestFontData(const Okular::FontInfo &font);
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* This method can be called to trigger a partial pixmap update for the given request
|
||||
* Make sure you call it in a way it's executed in the main thread.
|
||||
|
@ -608,13 +590,6 @@ protected Q_SLOTS:
|
|||
void signalPartialPixmapRequest(Okular::PixmapRequest *request, const QImage &image);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns the last print error in case print() failed
|
||||
* @since 0.11 (KDE 4.5)
|
||||
*/
|
||||
// TODO Make print() return a PrintError instead of bool and remove this function when a BIC change happens somewhere else
|
||||
Q_INVOKABLE Okular::Generator::PrintError printError() const;
|
||||
|
||||
/// @cond PRIVATE
|
||||
Generator(GeneratorPrivate &dd, QObject *parent, const QVariantList &args);
|
||||
Q_DECLARE_PRIVATE(Generator)
|
||||
|
@ -813,7 +788,6 @@ private:
|
|||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(Okular::Generator::PrintError)
|
||||
Q_DECLARE_METATYPE(Okular::PixmapRequest *)
|
||||
|
||||
#define OkularGeneratorInterface_iid "org.kde.okular.Generator"
|
||||
|
|
|
@ -83,7 +83,7 @@ QString Movie::url() const
|
|||
return d->m_url;
|
||||
}
|
||||
|
||||
void Movie::setSize(const QSize &aspect) // clazy:exclude=function-args-by-value TODO remove the & when we do a BIC change elsewhere
|
||||
void Movie::setSize(const QSize aspect)
|
||||
{
|
||||
d->m_aspect = aspect;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
/**
|
||||
* Sets the size for the movie.
|
||||
*/
|
||||
void setSize(const QSize &aspect); // TODO remove the & when we do a BIC change elsewhere
|
||||
void setSize(const QSize aspect);
|
||||
|
||||
/**
|
||||
* Returns the size of the movie.
|
||||
|
|
|
@ -154,11 +154,6 @@ void TextDocumentGeneratorPrivate::addTitle(int level, const QString &title, con
|
|||
mTitlePositions.append(position);
|
||||
}
|
||||
|
||||
void TextDocumentGeneratorPrivate::addMetaData(const QString &key, const QString &value, const QString &title)
|
||||
{
|
||||
mDocumentInfo.set(key, value, title);
|
||||
}
|
||||
|
||||
void TextDocumentGeneratorPrivate::addMetaData(DocumentInfo::Key key, const QString &value)
|
||||
{
|
||||
mDocumentInfo.set(key, value);
|
||||
|
@ -263,8 +258,7 @@ void TextDocumentGeneratorPrivate::initializeGenerator()
|
|||
QObject::connect(mConverter, &TextDocumentConverter::addAction, q, [this](Action *a, int cb, int ce) { addAction(a, cb, ce); });
|
||||
QObject::connect(mConverter, &TextDocumentConverter::addAnnotation, q, [this](Annotation *a, int cb, int ce) { addAnnotation(a, cb, ce); });
|
||||
QObject::connect(mConverter, &TextDocumentConverter::addTitle, q, [this](int l, const QString &t, const QTextBlock &b) { addTitle(l, t, b); });
|
||||
QObject::connect(mConverter, QOverload<const QString &, const QString &, const QString &>::of(&TextDocumentConverter::addMetaData), q, [this](const QString &k, const QString &v, const QString &t) { addMetaData(k, v, t); });
|
||||
QObject::connect(mConverter, QOverload<DocumentInfo::Key, const QString &>::of(&TextDocumentConverter::addMetaData), q, [this](DocumentInfo::Key k, const QString &v) { addMetaData(k, v); });
|
||||
QObject::connect(mConverter, &TextDocumentConverter::addMetaData, q, [this](DocumentInfo::Key k, const QString &v) { addMetaData(k, v); });
|
||||
|
||||
QObject::connect(mConverter, &TextDocumentConverter::error, q, &Generator::error);
|
||||
QObject::connect(mConverter, &TextDocumentConverter::warning, q, &Generator::warning);
|
||||
|
@ -428,15 +422,15 @@ Okular::TextPage *TextDocumentGenerator::textPage(Okular::TextRequest *request)
|
|||
return d->createTextPage(request->page()->number());
|
||||
}
|
||||
|
||||
bool TextDocumentGenerator::print(QPrinter &printer)
|
||||
Document::PrintError TextDocumentGenerator::print(QPrinter &printer)
|
||||
{
|
||||
Q_D(TextDocumentGenerator);
|
||||
if (!d->mDocument)
|
||||
return false;
|
||||
return Document::UnknownPrintError;
|
||||
|
||||
d->mDocument->print(&printer);
|
||||
|
||||
return true;
|
||||
return Document::NoPrintError;
|
||||
}
|
||||
|
||||
Okular::DocumentInfo TextDocumentGenerator::generateDocumentInfo(const QSet<DocumentInfo::Key> & /*keys*/) const
|
||||
|
|
|
@ -76,18 +76,12 @@ Q_SIGNALS:
|
|||
*/
|
||||
void addTitle(int level, const QString &title, const QTextBlock &position);
|
||||
|
||||
/**
|
||||
* Adds a set of meta data to the generator.
|
||||
*/
|
||||
void addMetaData(const QString &key, const QString &value, const QString &title); // clazy:exclude=overloaded-signal
|
||||
|
||||
// TODO When we can do a BIC change rename one of the two addMetaData functions (or see if we can kill one)
|
||||
/**
|
||||
* Adds a set of meta data to the generator.
|
||||
*
|
||||
* @since 0.7 (KDE 4.1)
|
||||
*/
|
||||
void addMetaData(DocumentInfo::Key key, const QString &value); // clazy:exclude=overloaded-signal
|
||||
void addMetaData(DocumentInfo::Key key, const QString &value);
|
||||
|
||||
/**
|
||||
* This signal should be emitted whenever an error occurred in the converter.
|
||||
|
@ -182,7 +176,7 @@ public:
|
|||
void generatePixmap(Okular::PixmapRequest *request) override;
|
||||
|
||||
// [INHERITED] print document using already configured QPrinter
|
||||
bool print(QPrinter &printer) override;
|
||||
Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
// [INHERITED] text exporting
|
||||
Okular::ExportFormat::List exportFormats() const override;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace Okular;
|
||||
|
||||
QRect Utils::rotateRect(const QRect &source, int width, int height, int orientation) // clazy:exclude=function-args-by-value TODO remove the & when we do a BIC change elsewhere
|
||||
QRect Utils::rotateRect(const QRect source, int width, int height, int orientation)
|
||||
{
|
||||
QRect ret;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
* Rotate the rect \p source in the area \p width x \p height with the
|
||||
* specified \p orientation .
|
||||
*/
|
||||
static QRect rotateRect(const QRect &source, int width, int height, int orientation); // TODO remove the & when we do a BIC change elsewhere
|
||||
static QRect rotateRect(const QRect source, int width, int height, int orientation);
|
||||
|
||||
/**
|
||||
* Return the real DPI of the display containing given widget
|
||||
|
|
|
@ -62,7 +62,7 @@ QImage ComicBookGenerator::image(Okular::PixmapRequest *request)
|
|||
return image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
bool ComicBookGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError ComicBookGenerator::print(QPrinter &printer)
|
||||
{
|
||||
QPainter p(&printer);
|
||||
|
||||
|
@ -81,7 +81,7 @@ bool ComicBookGenerator::print(QPrinter &printer)
|
|||
p.drawImage(0, 0, image);
|
||||
}
|
||||
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
#include "generator_comicbook.moc"
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
bool loadDocument(const QString &fileName, QVector<Okular::Page *> &pagesVector) override;
|
||||
|
||||
// [INHERITED] print document using already configured kprinter
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
protected:
|
||||
bool doCloseDocument() override;
|
||||
|
|
|
@ -155,14 +155,12 @@ const Okular::DocumentSynopsis *DjVuGenerator::generateDocumentSynopsis()
|
|||
return m_docSyn;
|
||||
}
|
||||
|
||||
bool DjVuGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError DjVuGenerator::print(QPrinter &printer)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
// Create tempfile to write to
|
||||
QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
|
||||
if (!tf.open())
|
||||
return false;
|
||||
return Okular::Document::TemporaryFileOpenPrintError;
|
||||
const QString fileName = tf.fileName();
|
||||
|
||||
QMutexLocker locker(userMutex());
|
||||
|
@ -171,11 +169,10 @@ bool DjVuGenerator::print(QPrinter &printer)
|
|||
if (m_djvu->exportAsPostScript(&tf, pageList)) {
|
||||
tf.setAutoRemove(false);
|
||||
tf.close();
|
||||
int ret = Okular::FilePrinter::printFile(printer, fileName, document()->orientation(), Okular::FilePrinter::SystemDeletesFiles, Okular::FilePrinter::ApplicationSelectsPages, document()->bookmarkedPageRange());
|
||||
result = (ret >= 0);
|
||||
return Okular::FilePrinter::printFile(printer, fileName, document()->orientation(), Okular::FilePrinter::SystemDeletesFiles, Okular::FilePrinter::ApplicationSelectsPages, document()->bookmarkedPageRange());
|
||||
}
|
||||
|
||||
return result;
|
||||
return Okular::Document::UnknownPrintError;
|
||||
}
|
||||
|
||||
QVariant DjVuGenerator::metaData(const QString &key, const QVariant &option) const
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
const Okular::DocumentSynopsis *generateDocumentSynopsis() override;
|
||||
|
||||
// printing
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
QVariant metaData(const QString &key, const QVariant &option) const override;
|
||||
|
||||
|
|
|
@ -455,12 +455,12 @@ void DviGenerator::loadPages(QVector<Okular::Page *> &pagesVector)
|
|||
pagesVector[i]->setSourceReferences(refRects.at(i));
|
||||
}
|
||||
|
||||
bool DviGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError DviGenerator::print(QPrinter &printer)
|
||||
{
|
||||
// Create tempfile to write to
|
||||
QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
|
||||
if (!tf.open())
|
||||
return false;
|
||||
return Okular::Document::TemporaryFileOpenPrintError;
|
||||
|
||||
const QList<int> pageList = Okular::FilePrinter::pageList(printer, static_cast<quint16>(m_dviRenderer->totalPages()), document()->currentPage() + 1, document()->bookmarkedPageList());
|
||||
QString pages;
|
||||
|
@ -479,7 +479,7 @@ bool DviGenerator::print(QPrinter &printer)
|
|||
tf.close();
|
||||
|
||||
// Error messages are handled by the generator - ugly, but it works.
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
QVariant DviGenerator::metaData(const QString &key, const QVariant &option) const
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
// list of fonts
|
||||
Okular::FontInfo::List fontsForPage(int page) override;
|
||||
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
QVariant metaData(const QString &key, const QVariant &option) const override;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ Okular::DocumentInfo FaxGenerator::generateDocumentInfo(const QSet<Okular::Docum
|
|||
return docInfo;
|
||||
}
|
||||
|
||||
bool FaxGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError FaxGenerator::print(QPrinter &printer)
|
||||
{
|
||||
QPainter p(&printer);
|
||||
|
||||
|
@ -94,7 +94,7 @@ bool FaxGenerator::print(QPrinter &printer)
|
|||
|
||||
p.drawImage(0, 0, image);
|
||||
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
#include "generator_fax.moc"
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
Okular::DocumentInfo generateDocumentInfo(const QSet<Okular::DocumentInfo::Key> &keys) const override;
|
||||
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
protected:
|
||||
bool doCloseDocument() override;
|
||||
|
|
|
@ -138,7 +138,7 @@ QImage KIMGIOGenerator::image(Okular::PixmapRequest *request)
|
|||
}
|
||||
}
|
||||
|
||||
bool KIMGIOGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError KIMGIOGenerator::print(QPrinter &printer)
|
||||
{
|
||||
QPainter p(&printer);
|
||||
|
||||
|
@ -150,7 +150,7 @@ bool KIMGIOGenerator::print(QPrinter &printer)
|
|||
|
||||
p.drawImage(0, 0, image);
|
||||
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
Okular::DocumentInfo KIMGIOGenerator::generateDocumentInfo(const QSet<Okular::DocumentInfo::Key> &keys) const
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
SwapBackingFileResult swapBackingFile(QString const &newFileName, QVector<Okular::Page *> &newPagesVector) override;
|
||||
|
||||
// [INHERITED] print document using already configured kprinter
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
// [INHERITED] document information
|
||||
Okular::DocumentInfo generateDocumentInfo(const QSet<Okular::DocumentInfo::Key> &keys) const override;
|
||||
|
|
|
@ -175,13 +175,4 @@ bool PluckerGenerator::exportTo(const QString &fileName, const Okular::ExportFor
|
|||
return false;
|
||||
}
|
||||
|
||||
bool PluckerGenerator::print(QPrinter &)
|
||||
{
|
||||
/*
|
||||
for ( int i = 0; i < mPages.count(); ++i )
|
||||
mPages[ i ]->print( &printer );
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "generator_plucker.moc"
|
||||
|
|
|
@ -38,9 +38,6 @@ public:
|
|||
Okular::ExportFormat::List exportFormats() const override;
|
||||
bool exportTo(const QString &fileName, const Okular::ExportFormat &format) override;
|
||||
|
||||
// [INHERITED] print document using already configured kprinter
|
||||
bool print(QPrinter &printer) override;
|
||||
|
||||
protected:
|
||||
bool doCloseDocument() override;
|
||||
|
||||
|
|
|
@ -1259,14 +1259,14 @@ Okular::TextPage *PDFGenerator::textPage(Okular::TextRequest *request)
|
|||
return tp;
|
||||
}
|
||||
|
||||
void PDFGenerator::requestFontData(const Okular::FontInfo &font, QByteArray *data)
|
||||
QByteArray PDFGenerator::requestFontData(const Okular::FontInfo &font)
|
||||
{
|
||||
Poppler::FontInfo fi = font.nativeId().value<Poppler::FontInfo>();
|
||||
*data = pdfdoc->fontData(fi);
|
||||
return pdfdoc->fontData(fi);
|
||||
}
|
||||
|
||||
#define DUMMY_QPRINTER_COPY
|
||||
bool PDFGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError PDFGenerator::print(QPrinter &printer)
|
||||
{
|
||||
bool printAnnots = true;
|
||||
bool forceRasterize = false;
|
||||
|
@ -1332,7 +1332,7 @@ bool PDFGenerator::print(QPrinter &printer)
|
|||
userMutex()->unlock();
|
||||
}
|
||||
painter.end();
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
#ifdef DUMMY_QPRINTER_COPY
|
||||
|
@ -1350,15 +1350,13 @@ bool PDFGenerator::print(QPrinter &printer)
|
|||
#endif
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
lastPrintError = InvalidPageSizePrintError;
|
||||
return false;
|
||||
return Okular::Document::InvalidPageSizePrintError;
|
||||
}
|
||||
|
||||
// Create the tempfile to send to FilePrinter, which will manage the deletion
|
||||
QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
|
||||
if (!tf.open()) {
|
||||
lastPrintError = TemporaryFileOpenPrintError;
|
||||
return false;
|
||||
return Okular::Document::TemporaryFileOpenPrintError;
|
||||
}
|
||||
QString tempfilename = tf.fileName();
|
||||
|
||||
|
@ -1400,21 +1398,15 @@ bool PDFGenerator::print(QPrinter &printer)
|
|||
|
||||
const Okular::FilePrinter::ScaleMode filePrinterScaleMode = (scaleMode == PDFOptionsPage::None) ? Okular::FilePrinter::ScaleMode::NoScaling : Okular::FilePrinter::ScaleMode::FitToPrintArea;
|
||||
|
||||
int ret =
|
||||
Okular::FilePrinter::printFile(printer, tempfilename, document()->orientation(), Okular::FilePrinter::SystemDeletesFiles, Okular::FilePrinter::ApplicationSelectsPages, document()->bookmarkedPageRange(), filePrinterScaleMode);
|
||||
|
||||
lastPrintError = Okular::FilePrinter::printError(ret);
|
||||
|
||||
return (lastPrintError == NoPrintError);
|
||||
return Okular::FilePrinter::printFile(printer, tempfilename, document()->orientation(), Okular::FilePrinter::SystemDeletesFiles, Okular::FilePrinter::ApplicationSelectsPages, document()->bookmarkedPageRange(), filePrinterScaleMode);
|
||||
} else {
|
||||
lastPrintError = FileConversionPrintError;
|
||||
delete psConverter;
|
||||
userMutex()->unlock();
|
||||
|
||||
tf.close();
|
||||
|
||||
return Okular::Document::FileConversionPrintError;
|
||||
}
|
||||
|
||||
tf.close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) const
|
||||
|
@ -1820,11 +1812,6 @@ QLinkedList<Okular::FormField *> PDFGenerator::getFormFields(Poppler::Page *popp
|
|||
return okularFormFields;
|
||||
}
|
||||
|
||||
PDFGenerator::PrintError PDFGenerator::printError() const
|
||||
{
|
||||
return lastPrintError;
|
||||
}
|
||||
|
||||
Okular::PrintOptionsWidget *PDFGenerator::printConfigurationWidget() const
|
||||
{
|
||||
if (!pdfOptionsPage) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
QImage image(Okular::PixmapRequest *request) override;
|
||||
|
||||
// [INHERITED] print page using an already configured kprinter
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
// [INHERITED] reply to some metadata requests
|
||||
QVariant metaData(const QString &key, const QVariant &option) const override;
|
||||
|
@ -105,14 +105,12 @@ public:
|
|||
|
||||
Okular::CertificateStore *certificateStore() const override;
|
||||
|
||||
QByteArray requestFontData(const Okular::FontInfo &font) override;
|
||||
|
||||
protected:
|
||||
SwapBackingFileResult swapBackingFile(QString const &newFileName, QVector<Okular::Page *> &newPagesVector) override;
|
||||
bool doCloseDocument() override;
|
||||
Okular::TextPage *textPage(Okular::TextRequest *request) override;
|
||||
Q_INVOKABLE Okular::Generator::PrintError printError() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void requestFontData(const Okular::FontInfo &font, QByteArray *data);
|
||||
|
||||
private:
|
||||
Okular::Document::OpenResult init(QVector<Okular::Page *> &pagesVector, const QString &password);
|
||||
|
@ -154,8 +152,6 @@ private:
|
|||
QBitArray rectsGenerated;
|
||||
|
||||
QPointer<PDFOptionsPage> pdfOptionsPage;
|
||||
|
||||
PrintError lastPrintError;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -81,10 +81,8 @@ void GSGenerator::addPages(KConfigDialog *dlg)
|
|||
dlg->addPage(w, GSSettings::self(), i18n("Ghostscript"), QStringLiteral("okular-gv"), i18n("Ghostscript Backend Configuration"));
|
||||
}
|
||||
|
||||
bool GSGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError GSGenerator::print(QPrinter &printer)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
// Create tempfile to write to
|
||||
QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
|
||||
|
||||
|
@ -99,7 +97,7 @@ bool GSGenerator::print(QPrinter &printer)
|
|||
}
|
||||
|
||||
if (!tf.open())
|
||||
return false;
|
||||
return Okular::Document::TemporaryFileOpenPrintError;
|
||||
|
||||
SpectreExporter *exporter = spectre_exporter_new(m_internalDocument, exportFormat);
|
||||
SpectreStatus exportStatus = spectre_exporter_begin(exporter, tf.fileName().toLatin1().constData());
|
||||
|
@ -121,12 +119,10 @@ bool GSGenerator::print(QPrinter &printer)
|
|||
|
||||
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 Okular::FilePrinter::printFile(printer, fileName, document()->orientation(), Okular::FilePrinter::SystemDeletesFiles, Okular::FilePrinter::ApplicationSelectsPages, document()->bookmarkedPageRange());
|
||||
}
|
||||
|
||||
return result;
|
||||
return Okular::Document::UnknownPrintError;
|
||||
}
|
||||
|
||||
bool GSGenerator::loadDocument(const QString &fileName, QVector<Okular::Page *> &pagesVector)
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
QVariant metaData(const QString &key, const QVariant &option) const override;
|
||||
|
||||
// print document using already configured kprinter
|
||||
bool print(QPrinter & /*printer*/) override;
|
||||
Okular::Document::PrintError print(QPrinter & /*printer*/) override;
|
||||
QString fileName() const;
|
||||
|
||||
bool reparseConfig() override;
|
||||
|
|
|
@ -345,7 +345,7 @@ void TIFFGenerator::loadPages(QVector<Okular::Page *> &pagesVector)
|
|||
pagesVector.resize(realdirs);
|
||||
}
|
||||
|
||||
bool TIFFGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError TIFFGenerator::print(QPrinter &printer)
|
||||
{
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
|
@ -389,7 +389,7 @@ bool TIFFGenerator::print(QPrinter &printer)
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
int TIFFGenerator::mapPage(int page) const
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
Okular::DocumentInfo generateDocumentInfo(const QSet<Okular::DocumentInfo::Key> &keys) const override;
|
||||
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
protected:
|
||||
bool doCloseDocument() override;
|
||||
|
|
|
@ -2095,7 +2095,7 @@ bool XpsGenerator::exportTo(const QString &fileName, const Okular::ExportFormat
|
|||
return false;
|
||||
}
|
||||
|
||||
bool XpsGenerator::print(QPrinter &printer)
|
||||
Okular::Document::PrintError XpsGenerator::print(QPrinter &printer)
|
||||
{
|
||||
QList<int> pageList = Okular::FilePrinter::pageList(printer, document()->pages(), document()->currentPage() + 1, document()->bookmarkedPageList());
|
||||
|
||||
|
@ -2110,7 +2110,7 @@ bool XpsGenerator::print(QPrinter &printer)
|
|||
pageToRender->renderToPainter(&painter);
|
||||
}
|
||||
|
||||
return true;
|
||||
return Okular::Document::NoPrintError;
|
||||
}
|
||||
|
||||
const XpsRenderNode *XpsRenderNode::findChild(const QString &name) const
|
||||
|
|
|
@ -312,7 +312,7 @@ public:
|
|||
Okular::ExportFormat::List exportFormats() const override;
|
||||
bool exportTo(const QString &fileName, const Okular::ExportFormat &format) override;
|
||||
|
||||
bool print(QPrinter &printer) override;
|
||||
Okular::Document::PrintError print(QPrinter &printer) override;
|
||||
|
||||
protected:
|
||||
bool doCloseDocument() override;
|
||||
|
|
|
@ -3400,8 +3400,9 @@ bool Part::doPrint(QPrinter &printer)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!m_document->print(printer)) {
|
||||
const QString error = m_document->printError();
|
||||
const Document::PrintError printError = m_document->print(printer);
|
||||
if (printError != Document::NoPrintError) {
|
||||
const QString error = Okular::Document::printErrorString(printError);
|
||||
if (error.isEmpty()) {
|
||||
KMessageBox::error(widget(), i18n("Could not print the document. Unknown error. Please report to bugs.kde.org"));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user