Bug fixing, report warnings only once

This commit is contained in:
Jakub Melka
2019-10-05 13:08:32 +02:00
parent 2d29bebe30
commit 76c5f5a11c
5 changed files with 26 additions and 16 deletions

View File

@@ -464,7 +464,7 @@ PDFImage PDFImage::createImage(const PDFDocument* document, const PDFStream* str
}
}
}
else if (imageFilterName == "CCITTFaxDecode")
else if (imageFilterName == "CCITTFaxDecode" || imageFilterName == "CCF")
{
throw PDFRendererException(RenderErrorType::NotImplemented, PDFTranslationContext::tr("Not implemented image filter 'CCITFaxDecode'."));
}

View File

@@ -200,7 +200,6 @@ PDFPageContentProcessor::PDFPageContentProcessor(const PDFPage* page,
m_textBeginEndState(0),
m_compatibilityBeginEndState(0),
m_drawingUncoloredTilingPatternState(0),
m_isWarningColorOperatorsInUncoloredTilingPatternReported(false),
m_patternBaseMatrix(pagePointToDevicePointMatrix),
m_pagePointToDevicePointMatrix(pagePointToDevicePointMatrix),
m_meshQualitySettings(meshQualitySettings)
@@ -1628,6 +1627,15 @@ void PDFPageContentProcessor::setRenderingIntentByName(QByteArray renderingInten
m_graphicState.setRenderingIntentName(renderingIntentName);
}
void PDFPageContentProcessor::reportRenderErrorOnce(RenderErrorType type, QString message)
{
if (!m_onceReportedErrors.count(message))
{
m_onceReportedErrors.insert(message);
reportRenderError(type, message);
}
}
void PDFPageContentProcessor::processApplyGraphicState(const PDFDictionary* graphicStateDictionary)
{
PDFDocumentDataLoaderDecorator loader(m_document);
@@ -1717,7 +1725,7 @@ void PDFPageContentProcessor::processApplyGraphicState(const PDFDictionary* grap
bool isNone = (softMaskObject.isName() && softMaskObject.getString() == "None");
if (!isNone)
{
reportRenderError(RenderErrorType::NotSupported, PDFTranslationContext::tr("Soft masks not supported."));
reportRenderErrorOnce(RenderErrorType::NotSupported, PDFTranslationContext::tr("Soft masks not supported."));
}
}
}
@@ -2679,11 +2687,7 @@ void PDFPageContentProcessor::paintXObjectImage(const PDFStream* stream)
void PDFPageContentProcessor::reportWarningAboutColorOperatorsInUTP()
{
if (!m_isWarningColorOperatorsInUncoloredTilingPatternReported)
{
m_isWarningColorOperatorsInUncoloredTilingPatternReported = true;
m_errorList.push_back(PDFRenderError(RenderErrorType::Warning, PDFTranslationContext::tr("Color operators are not allowed in uncolored tilling pattern.")));
}
reportRenderErrorOnce(RenderErrorType::Warning, PDFTranslationContext::tr("Color operators are not allowed in uncolored tilling pattern."));
}
void PDFPageContentProcessor::operatorPaintXObject(PDFPageContentProcessor::PDFOperandName name)

View File

@@ -168,6 +168,10 @@ public:
virtual void reportRenderError(RenderErrorType type, QString message) override;
/// Reports render error, but only once - if same error was already reported,
/// then no new error is reported.
void reportRenderErrorOnce(RenderErrorType type, QString message);
protected:
class PDFLineDashPattern
@@ -883,9 +887,6 @@ private:
/// Is drawing uncolored tiling pattern?
int m_drawingUncoloredTilingPatternState;
/// Is warning about uncolored tiling patterns reported?
bool m_isWarningColorOperatorsInUncoloredTilingPatternReported;
/// Actually realized physical font
PDFCachedItem<PDFRealizedFontPointer> m_realizedFont;
@@ -906,6 +907,9 @@ private:
/// Mesh quality settings
PDFMeshQualitySettings m_meshQualitySettings;
/// Set with rendering errors, which were reported (and should be reported once)
std::set<QString> m_onceReportedErrors;
};
} // namespace pdf

View File

@@ -199,14 +199,14 @@ void PDFPainter::performUpdateGraphicsState(const PDFPageContentProcessorState&
if (!PDFBlendModeInfo::isSupportedByQt(blendMode))
{
reportRenderError(RenderErrorType::NotSupported, PDFTranslationContext::tr("Blend mode '%1' not supported.").arg(PDFBlendModeInfo::getBlendModeName(blendMode)));
reportRenderErrorOnce(RenderErrorType::NotSupported, PDFTranslationContext::tr("Blend mode '%1' not supported.").arg(PDFBlendModeInfo::getBlendModeName(blendMode)));
}
m_painter->setCompositionMode(compositionMode);
}
else if (blendMode != BlendMode::Normal && blendMode != BlendMode::Compatible)
{
reportRenderError(RenderErrorType::NotSupported, PDFTranslationContext::tr("Blend mode '%1' is in transparency group, which is not supported.").arg(PDFBlendModeInfo::getBlendModeName(blendMode)));
reportRenderErrorOnce(RenderErrorType::NotSupported, PDFTranslationContext::tr("Blend mode '%1' is in transparency group, which is not supported.").arg(PDFBlendModeInfo::getBlendModeName(blendMode)));
}
}
@@ -366,7 +366,4 @@ bool PDFPainter::canSetBlendMode(BlendMode mode) const
return std::all_of(m_transparencyGroupDataStack.cbegin(), m_transparencyGroupDataStack.cend(), [](const PDFTransparencyGroupPainterData& group) { return group.blendMode == BlendMode::Normal || group.blendMode == BlendMode::Compatible; });
}
// TODO: Check all graphic state parameter dictionaries, warn about missing ones
// TODO: Recompile libraries in MSVC 2019
} // namespace pdf