From eca45e00c04fea5fa6be10a17f61cbcec6cba131 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 21 Jun 2017 15:10:17 -0400 Subject: Fixed optional content not rendered when OCGs array is empty. At least one nonnull entry needs to be in OCGs for it to be considered present. See "OCGs" in table 4.49 in the PDF 1.7 spec. Bug: pdfium:491. Change-Id: I7eae65ba1fabff9cf1d5cea50d059a04814a3fec Reviewed-on: https://pdfium-review.googlesource.com/6751 Commit-Queue: Henrique Nakashima Reviewed-by: Lei Zhang Reviewed-by: dsinclair --- core/fpdfdoc/cpdf_occontext.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp index 66950c9406..7e746e0028 100644 --- a/core/fpdfdoc/cpdf_occontext.cpp +++ b/core/fpdfdoc/cpdf_occontext.cpp @@ -254,18 +254,25 @@ bool CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict) { return true; bool bState = (csP == "AllOn" || csP == "AllOff"); + // At least one entry of OCGs needs to be a valid dictionary for it to be + // considered present. See "OCGs" in table 4.49 in the PDF 1.7 spec. + bool bValidEntrySeen = false; for (size_t i = 0; i < pArray->GetCount(); i++) { bool bItem = true; CPDF_Dictionary* pItemDict = pArray->GetDictAt(i); - if (pItemDict) - bItem = GetOCGVisible(pItemDict); + if (!pItemDict) + continue; + + bValidEntrySeen = true; + bItem = GetOCGVisible(pItemDict); if ((csP == "AnyOn" && bItem) || (csP == "AnyOff" && !bItem)) return true; if ((csP == "AllOn" && !bItem) || (csP == "AllOff" && bItem)) return false; } - return bState; + + return !bValidEntrySeen || bState; } bool CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary* pOCGDict) { -- cgit v1.2.3