summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/cpdf_metadata.cpp77
-rw-r--r--core/fpdfdoc/cpdf_metadata.h33
2 files changed, 90 insertions, 20 deletions
diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
index efe3c29dbf..11fde82036 100644
--- a/core/fpdfdoc/cpdf_metadata.cpp
+++ b/core/fpdfdoc/cpdf_metadata.cpp
@@ -6,27 +6,76 @@
#include "core/fpdfdoc/cpdf_metadata.h"
-#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
+#include "core/fxcrt/xml/cxml_content.h"
#include "core/fxcrt/xml/cxml_element.h"
-CPDF_Metadata::CPDF_Metadata(const CPDF_Document* pDoc) {
- const CPDF_Dictionary* pRoot = pDoc->GetRoot();
- if (!pRoot)
- return;
+namespace {
- CPDF_Stream* pStream = pRoot->GetStreamFor("Metadata");
- if (!pStream)
- return;
+void CheckForSharedFormInternal(CXML_Element* element,
+ std::vector<UnsupportedFeature>* unsupported) {
+ size_t count = element->CountAttrs();
+ for (size_t i = 0; i < count; ++i) {
+ ByteString space;
+ ByteString name;
+ WideString value;
+ element->GetAttrByIndex(i, &space, &name, &value);
+ if (space != "xmlns" || name != "adhocwf" ||
+ value != L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") {
+ continue;
+ }
- auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
- pAcc->LoadAllDataFiltered();
- m_pXmlElement = CXML_Element::Parse(pAcc->GetData(), pAcc->GetSize());
+ CXML_Element* pVersion = element->GetElement("adhocwf", "workflowType", 0);
+ if (!pVersion)
+ continue;
+
+ CXML_Content* pContent = ToContent(pVersion->GetChild(0));
+ if (!pContent)
+ continue;
+
+ switch (pContent->m_Content.GetInteger()) {
+ case 0:
+ unsupported->push_back(UnsupportedFeature::kDocumentSharedFormEmail);
+ break;
+ case 1:
+ unsupported->push_back(UnsupportedFeature::kDocumentSharedFormAcrobat);
+ break;
+ case 2:
+ unsupported->push_back(
+ UnsupportedFeature::kDocumentSharedFormFilesystem);
+ break;
+ }
+ }
+
+ count = element->CountChildren();
+ for (size_t i = 0; i < count; ++i) {
+ CXML_Element* child = ToElement(element->GetChild(i));
+ if (!child)
+ continue;
+
+ CheckForSharedFormInternal(child, unsupported);
+ }
}
-CPDF_Metadata::~CPDF_Metadata() {}
+} // namespace
+
+CPDF_Metadata::CPDF_Metadata(const CPDF_Stream* pStream) : stream_(pStream) {
+ ASSERT(pStream);
+}
+
+CPDF_Metadata::~CPDF_Metadata() = default;
+
+std::vector<UnsupportedFeature> CPDF_Metadata::CheckForSharedForm() const {
+ auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(stream_.Get());
+ pAcc->LoadAllDataFiltered();
+
+ std::unique_ptr<CXML_Element> xml_root =
+ CXML_Element::Parse(pAcc->GetData(), pAcc->GetSize());
+ if (!xml_root)
+ return {};
-const CXML_Element* CPDF_Metadata::GetRoot() const {
- return m_pXmlElement.get();
+ std::vector<UnsupportedFeature> unsupported;
+ CheckForSharedFormInternal(xml_root.get(), &unsupported);
+ return unsupported;
}
diff --git a/core/fpdfdoc/cpdf_metadata.h b/core/fpdfdoc/cpdf_metadata.h
index fa958153fc..edf1938c4e 100644
--- a/core/fpdfdoc/cpdf_metadata.h
+++ b/core/fpdfdoc/cpdf_metadata.h
@@ -8,19 +8,40 @@
#define CORE_FPDFDOC_CPDF_METADATA_H_
#include <memory>
-
-class CPDF_Document;
-class CXML_Element;
+#include <vector>
+
+#include "core/fxcrt/unowned_ptr.h"
+
+class CPDF_Stream;
+
+enum class UnsupportedFeature : uint8_t {
+ kDocumentXFAForm = 1,
+ kDocumentPortableCollection = 2,
+ kDocumentAttachment = 3,
+ kDocumentSecurity = 4,
+ kDocumentSharedReview = 5,
+ kDocumentSharedFormAcrobat = 6,
+ kDocumentSharedFormFilesystem = 7,
+ kDocumentSharedFormEmail = 8,
+
+ kAnnotation3d = 11,
+ kAnnotationMovie = 12,
+ kAnnotationSound = 13,
+ kAnnotationScreenMedia = 14,
+ kAnnotationScreenRichMedia = 15,
+ kAnnotationAttachment = 16,
+ kAnnotationSignature = 17
+};
class CPDF_Metadata {
public:
- explicit CPDF_Metadata(const CPDF_Document* pDoc);
+ explicit CPDF_Metadata(const CPDF_Stream* pStream);
~CPDF_Metadata();
- const CXML_Element* GetRoot() const;
+ std::vector<UnsupportedFeature> CheckForSharedForm() const;
private:
- std::unique_ptr<CXML_Element> m_pXmlElement;
+ UnownedPtr<const CPDF_Stream> stream_;
};
#endif // CORE_FPDFDOC_CPDF_METADATA_H_