void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code) { // Security if (err_code == FPDF_ERR_SECURITY) { FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY); return; } if (!pDoc) return; // Portfolios and Packages CPDF_Dictionary* pRootDict = pDoc->GetRoot(); if (pRootDict) { CFX_ByteString cbString; if (pRootDict->KeyExist("Collection")) { FPDF_UnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION); return; } if (pRootDict->KeyExist("Names")) { CPDF_Dictionary* pNameDict = pRootDict->GetDict("Names"); if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) { FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT); return; } if (pNameDict && pNameDict->KeyExist("JavaScript")) { CPDF_Dictionary* pJSDict = pNameDict->GetDict("JavaScript"); CPDF_Array* pArray = pJSDict ? pJSDict->GetArray("Names") : NULL; if (pArray) { int nCount = pArray->GetCount(); for (int i = 0; i < nCount; i++) { CFX_ByteString cbStr = pArray->GetString(i); if (cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0) { FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW); return; } } } } } } // SharedForm CPDF_Metadata metaData(pDoc); const CXML_Element* pElement = metaData.GetRoot(); if (pElement) CheckSharedForm(pElement, "workflowType"); // XFA Forms CPDF_InterForm* pInterForm = new CPDF_InterForm(pDoc, FALSE); if (pInterForm->HasXFAForm()) { FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM); } delete pInterForm; }
void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) { // Security if (err_code == FPDF_ERR_SECURITY) { FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY); return; } if (!pDoc) return; // Portfolios and Packages CPDF_Dictionary* pRootDict = pDoc->GetRoot(); if (pRootDict) { CFX_ByteString cbString; if (pRootDict->KeyExist("Collection")) { FPDF_UnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION); return; } if (pRootDict->KeyExist("Names")) { CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names"); if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) { FPDF_UnSupportError(FPDF_UNSP_DOC_ATTACHMENT); return; } if (pNameDict && pNameDict->KeyExist("JavaScript")) { CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript"); CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayFor("Names") : nullptr; if (pArray) { for (size_t i = 0; i < pArray->GetCount(); i++) { CFX_ByteString cbStr = pArray->GetStringAt(i); if (cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0) { FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW); return; } } } } } } // SharedForm CPDF_Metadata metaData(pDoc); const CXML_Element* pElement = metaData.GetRoot(); if (pElement) CheckSharedForm(pElement, "workflowType"); #ifndef PDF_ENABLE_XFA // XFA Forms CPDF_InterForm interform(pDoc); if (interform.HasXFAForm()) FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM); #endif // PDF_ENABLE_XFA }
FX_BOOL CheckSharedForm(CXML_Element * pElement, CFX_ByteString cbName) { int count = pElement->CountAttrs(); int i=0; for (i = 0; i < count; i++) { CFX_ByteString space, name; CFX_WideString value; pElement->GetAttrByIndex(i, space, name, value); if (space == FX_BSTRC("xmlns") && name == FX_BSTRC("adhocwf") && value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") { CXML_Element *pVersion = pElement->GetElement("adhocwf",cbName); if (!pVersion) continue; CFX_WideString wsContent = pVersion->GetContent(0); // == 1.1 int nType = wsContent.GetInteger(); switch(nType) { case 1: FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT); break; case 2: FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM); break; case 0: FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMAIL); break; } } } FX_DWORD nCount = pElement->CountChildren(); for(i=0; i<(int)nCount; i++) { CXML_Element::ChildType childType = pElement->GetChildType(i); if(childType == CXML_Element::Element) { CXML_Element * pChild = pElement->GetElement(i); if(CheckSharedForm(pChild, cbName)) return TRUE; } } return FALSE; }