Optional content - first part

This commit is contained in:
Jakub Melka
2019-06-23 18:35:32 +02:00
parent a429052002
commit 48f4a24923
9 changed files with 454 additions and 4 deletions

View File

@ -182,7 +182,8 @@ PDFPageContentProcessor::PDFPageContentProcessor(const PDFPage* page, const PDFD
m_fontDictionary(nullptr),
m_xobjectDictionary(nullptr),
m_extendedGraphicStateDictionary(nullptr),
m_textBeginEndState(0)
m_textBeginEndState(0),
m_compatibilityBeginEndState(0)
{
Q_ASSERT(page);
Q_ASSERT(document);
@ -790,6 +791,18 @@ void PDFPageContentProcessor::processCommand(const QByteArray& command)
break;
}
case Operator::CompatibilityBegin:
{
operatorCompatibilityBegin();
break;
}
case Operator::CompatibilityEnd:
{
operatorCompatibilityEnd();
break;
}
case Operator::Invalid:
{
m_errorList.append(PDFRenderError(RenderErrorType::Error, PDFTranslationContext::tr("Unknown operator '%1'.").arg(QString::fromLatin1(command))));
@ -1876,6 +1889,19 @@ void PDFPageContentProcessor::operatorPaintXObject(PDFPageContentProcessor::PDFO
}
}
void PDFPageContentProcessor::operatorCompatibilityBegin()
{
++m_compatibilityBeginEndState;
}
void PDFPageContentProcessor::operatorCompatibilityEnd()
{
if (--m_compatibilityBeginEndState < 0)
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Compatibility operator begin/end mismatch."));
}
}
void PDFPageContentProcessor::drawText(const TextSequence& textSequence)
{
if (textSequence.items.empty())