mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Exception refactoring
This commit is contained in:
@ -83,7 +83,8 @@ HEADERS += \
|
|||||||
sources/pdfrenderingerrorswidget.h \
|
sources/pdfrenderingerrorswidget.h \
|
||||||
sources/pdffunction.h \
|
sources/pdffunction.h \
|
||||||
sources/pdfnametounicode.h \
|
sources/pdfnametounicode.h \
|
||||||
sources/pdffont.h
|
sources/pdffont.h \
|
||||||
|
sources/pdfexception.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
sources/pdfrenderingerrorswidget.ui
|
sources/pdfrenderingerrorswidget.ui
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "pdfcatalog.h"
|
#include "pdfcatalog.h"
|
||||||
#include "pdfparser.h"
|
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
#include "pdfnumbertreeloader.h"
|
#include "pdfnumbertreeloader.h"
|
||||||
|
|
||||||
namespace pdf
|
namespace pdf
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "pdfcolorspaces.h"
|
#include "pdfcolorspaces.h"
|
||||||
#include "pdfobject.h"
|
#include "pdfobject.h"
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
#include "pdfparser.h"
|
#include "pdfexception.h"
|
||||||
|
|
||||||
namespace pdf
|
namespace pdf
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
#include "pdfparser.h"
|
|
||||||
#include "pdfencoding.h"
|
#include "pdfencoding.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
#include "pdfstreamfilters.h"
|
#include "pdfstreamfilters.h"
|
||||||
#include "pdfconstants.h"
|
#include "pdfconstants.h"
|
||||||
|
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "pdfdocumentreader.h"
|
#include "pdfdocumentreader.h"
|
||||||
#include "pdfparser.h"
|
|
||||||
#include "pdfconstants.h"
|
#include "pdfconstants.h"
|
||||||
#include "pdfxreftable.h"
|
#include "pdfxreftable.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
#include "pdfparser.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
79
PdfForQtLib/sources/pdfexception.h
Normal file
79
PdfForQtLib/sources/pdfexception.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (C) 2019 Jakub Melka
|
||||||
|
//
|
||||||
|
// This file is part of PdfForQt.
|
||||||
|
//
|
||||||
|
// PdfForQt is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// PdfForQt is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef PDFEXCEPTION_H
|
||||||
|
#define PDFEXCEPTION_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
|
||||||
|
class PDFParserException : public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PDFParserException(const QString& message) :
|
||||||
|
m_message(message)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns error message
|
||||||
|
const QString& getMessage() const { return m_message; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_message;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum RenderErrorType
|
||||||
|
{
|
||||||
|
Error,
|
||||||
|
NotImplemented
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PDFRenderError
|
||||||
|
{
|
||||||
|
explicit PDFRenderError() = default;
|
||||||
|
explicit PDFRenderError(RenderErrorType type, QString message) :
|
||||||
|
type(type),
|
||||||
|
message(std::move(message))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderErrorType type = RenderErrorType::Error;
|
||||||
|
QString message;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PDFRendererException : public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit PDFRendererException(RenderErrorType type, QString message) :
|
||||||
|
m_error(type, std::move(message))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const PDFRenderError& getError() const { return m_error; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
PDFRenderError m_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdf
|
||||||
|
|
||||||
|
#endif // PDFEXCEPTION_H
|
@ -19,6 +19,7 @@
|
|||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
#include "pdfparser.h"
|
#include "pdfparser.h"
|
||||||
#include "pdfnametounicode.h"
|
#include "pdfnametounicode.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include <freetype/freetype.h>
|
#include <freetype/freetype.h>
|
||||||
@ -562,7 +563,6 @@ PDFRealizedFontPointer PDFRealizedFont::createRealizedFont(PDFFontPointer font,
|
|||||||
|
|
||||||
if (impl->m_systemFontData.isEmpty())
|
if (impl->m_systemFontData.isEmpty())
|
||||||
{
|
{
|
||||||
// TODO: Upravit vyjimky do separatniho souboru
|
|
||||||
throw PDFParserException(PDFTranslationContext::tr("Can't load system font '%1'.").arg(QString::fromLatin1(descriptor->fontName)));
|
throw PDFParserException(PDFTranslationContext::tr("Can't load system font '%1'.").arg(QString::fromLatin1(descriptor->fontName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "pdfflatarray.h"
|
#include "pdfflatarray.h"
|
||||||
#include "pdfparser.h"
|
#include "pdfparser.h"
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "pdfpage.h"
|
#include "pdfpage.h"
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
#include "pdfparser.h"
|
#include "pdfexception.h"
|
||||||
|
|
||||||
namespace pdf
|
namespace pdf
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "pdfpagecontentprocessor.h"
|
#include "pdfpagecontentprocessor.h"
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
|
||||||
namespace pdf
|
namespace pdf
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#define PDFPAGECONTENTPROCESSOR_H
|
#define PDFPAGECONTENTPROCESSOR_H
|
||||||
|
|
||||||
#include "pdfrenderer.h"
|
#include "pdfrenderer.h"
|
||||||
#include "pdfparser.h"
|
|
||||||
#include "pdfcolorspaces.h"
|
#include "pdfcolorspaces.h"
|
||||||
|
#include "pdfparser.h"
|
||||||
#include "pdffont.h"
|
#include "pdffont.h"
|
||||||
#include "pdfutils.h"
|
#include "pdfutils.h"
|
||||||
|
|
||||||
@ -36,21 +36,6 @@ namespace pdf
|
|||||||
{
|
{
|
||||||
static constexpr const char* PDF_RESOURCE_EXTGSTATE = "ExtGState";
|
static constexpr const char* PDF_RESOURCE_EXTGSTATE = "ExtGState";
|
||||||
|
|
||||||
class PDFRendererException : public std::exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit PDFRendererException(RenderErrorType type, QString message) :
|
|
||||||
m_error(type, std::move(message))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const PDFRenderError& getError() const { return m_error; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
PDFRenderError m_error;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Process the contents of the page.
|
/// Process the contents of the page.
|
||||||
class PDFPageContentProcessor
|
class PDFPageContentProcessor
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "pdfparser.h"
|
#include "pdfparser.h"
|
||||||
#include "pdfconstants.h"
|
#include "pdfconstants.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
@ -76,22 +76,6 @@ constexpr const char* PDF_REFERENCE_COMMAND = "R";
|
|||||||
constexpr const char* PDF_STREAM_START_COMMAND = "stream";
|
constexpr const char* PDF_STREAM_START_COMMAND = "stream";
|
||||||
constexpr const char* PDF_STREAM_END_COMMAND = "endstream";
|
constexpr const char* PDF_STREAM_END_COMMAND = "endstream";
|
||||||
|
|
||||||
class PDFParserException : public std::exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PDFParserException(const QString& message) :
|
|
||||||
m_message(message)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns error message
|
|
||||||
const QString& getMessage() const { return m_message; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_message;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PDFFORQTLIBSHARED_EXPORT PDFLexicalAnalyzer
|
class PDFFORQTLIBSHARED_EXPORT PDFLexicalAnalyzer
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define PDFRENDERER_H
|
#define PDFRENDERER_H
|
||||||
|
|
||||||
#include "pdfpage.h"
|
#include "pdfpage.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
@ -26,26 +27,6 @@ namespace pdf
|
|||||||
{
|
{
|
||||||
class PDFFontCache;
|
class PDFFontCache;
|
||||||
|
|
||||||
enum RenderErrorType
|
|
||||||
{
|
|
||||||
Error,
|
|
||||||
NotImplemented
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PDFRenderError
|
|
||||||
{
|
|
||||||
explicit PDFRenderError() = default;
|
|
||||||
explicit PDFRenderError(RenderErrorType type, QString message) :
|
|
||||||
type(type),
|
|
||||||
message(std::move(message))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderErrorType type = RenderErrorType::Error;
|
|
||||||
QString message;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Renders the PDF page on the painter, or onto an image.
|
/// Renders the PDF page on the painter, or onto an image.
|
||||||
class PDFRenderer
|
class PDFRenderer
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "pdfstreamfilters.h"
|
#include "pdfstreamfilters.h"
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
#include "pdfparser.h"
|
#include "pdfparser.h"
|
||||||
|
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "pdfxreftable.h"
|
#include "pdfxreftable.h"
|
||||||
#include "pdfconstants.h"
|
#include "pdfconstants.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
#include "pdfparser.h"
|
#include "pdfparser.h"
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "pdfstreamfilters.h"
|
#include "pdfstreamfilters.h"
|
||||||
#include "pdffunction.h"
|
#include "pdffunction.h"
|
||||||
#include "pdfdocument.h"
|
#include "pdfdocument.h"
|
||||||
|
#include "pdfexception.h"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user