diff options
author | dan sinclair <dsinclair@chromium.org> | 2018-04-13 16:43:05 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-13 16:43:05 +0000 |
commit | e04b66cc759c2cf0ceafae47340fdf9588ca2e23 (patch) | |
tree | 5b7e8da1e61d1b6dc9550fb599722681e65572fc /fpdfsdk/cpdfsdk_helpers.cpp | |
parent | 996c93068bfc8b443c77b735bc6400285bc8a407 (diff) | |
download | pdfium-e04b66cc759c2cf0ceafae47340fdf9588ca2e23.tar.xz |
Move SharedForm check to CPDF_Metadata class
This CL moves code related to shared form detection into the
CPDF_Metadata class. This allows us to hide the usage of CXML inside
CPDF_Metadata.
Change-Id: I547471a2bcc119221565c415a58211c1500cbb3c
Reviewed-on: https://pdfium-review.googlesource.com/30370
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_helpers.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.cpp | 54 |
1 files changed, 9 insertions, 45 deletions
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index 19252f7c5b..16e7efc873 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp @@ -13,8 +13,6 @@ #include "core/fpdfdoc/cpdf_annot.h" #include "core/fpdfdoc/cpdf_interform.h" #include "core/fpdfdoc/cpdf_metadata.h" -#include "core/fxcrt/xml/cxml_content.h" -#include "core/fxcrt/xml/cxml_element.h" #include "public/fpdf_ext.h" namespace { @@ -37,45 +35,6 @@ bool RaiseUnSupportError(int nError) { return true; } -bool CheckSharedForm(const CXML_Element* pElement, ByteString cbName) { - size_t count = pElement->CountAttrs(); - for (size_t i = 0; i < count; ++i) { - ByteString space; - ByteString name; - WideString value; - pElement->GetAttrByIndex(i, &space, &name, &value); - if (space == "xmlns" && name == "adhocwf" && - value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") { - CXML_Element* pVersion = - pElement->GetElement("adhocwf", cbName.AsStringView(), 0); - if (!pVersion) - continue; - CXML_Content* pContent = ToContent(pVersion->GetChild(0)); - if (!pContent) - continue; - switch (pContent->m_Content.GetInteger()) { - case 1: - RaiseUnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT); - break; - case 2: - RaiseUnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM); - break; - case 0: - RaiseUnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMAIL); - break; - } - } - } - - size_t nCount = pElement->CountChildren(); - for (size_t i = 0; i < nCount; ++i) { - CXML_Element* pChild = ToElement(pElement->GetChild(i)); - if (pChild && CheckSharedForm(pChild, cbName)) - return true; - } - return false; -} - #ifdef PDF_ENABLE_XFA class FPDF_FileHandlerContext : public IFX_SeekableStream { public: @@ -300,10 +259,15 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) { } // SharedForm - CPDF_Metadata metaData(pDoc); - const CXML_Element* pElement = metaData.GetRoot(); - if (pElement) - CheckSharedForm(pElement, "workflowType"); + const CPDF_Dictionary* pRoot = pDoc->GetRoot(); + if (pRoot) { + CPDF_Stream* pStream = pRoot->GetStreamFor("Metadata"); + if (pStream) { + CPDF_Metadata metaData(pStream); + for (const auto& err : metaData.CheckForSharedForm()) + RaiseUnSupportError(static_cast<int>(err)); + } + } #ifndef PDF_ENABLE_XFA // XFA Forms |