summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_contentmark.cpp
diff options
context:
space:
mode:
authorJulian Lunger <jlunger@google.com>2017-12-27 10:18:50 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-09 23:41:53 +0000
commitecd063eccdb25cbb573d01fc512a3d40322761be (patch)
treec190a0305bb384efe82bc08de57fede4814017d6 /core/fpdfapi/page/cpdf_contentmark.cpp
parent81a1ac47e5d93980b59b1c34e8cf1bb22a89a936 (diff)
downloadpdfium-ecd063eccdb25cbb573d01fc512a3d40322761be.tar.xz
Expose marked content IDs for images and alt text.
- Adds two new public bits of API: - StructElement_GetMCID(STRUCTELEMENT) to return the marked content ID of the struct element. - IMAGEOBJ_METADATA.mcid to contain the marked content ID of the image. - Restores ContentMark::GetMCID, which was removed with other dead code in https://pdfium-review.googlesource.com/c/pdfium/+/19170. - Adds a couple calls to tests, including a simple new PDF to test the struct tree marked content ID. Bug:pdfium:957 Change-Id: I92856e43d741df989e53a575a08258da19a39f22 Reviewed-on: https://pdfium-review.googlesource.com/20632 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_contentmark.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index 1d70edeb51..c54ef55b1f 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -25,6 +25,11 @@ const CPDF_ContentMarkItem& CPDF_ContentMark::GetItem(size_t i) const {
return m_Ref.GetObject()->GetItem(i);
}
+int CPDF_ContentMark::GetMarkedContentID() const {
+ const MarkData* pData = m_Ref.GetObject();
+ return pData ? pData->GetMarkedContentID() : -1;
+}
+
void CPDF_ContentMark::AddMark(const ByteString& name,
CPDF_Dictionary* pDict,
bool bDirect) {
@@ -53,6 +58,15 @@ const CPDF_ContentMarkItem& CPDF_ContentMark::MarkData::GetItem(
return m_Marks[index];
}
+int CPDF_ContentMark::MarkData::GetMarkedContentID() const {
+ for (const auto& mark : m_Marks) {
+ const CPDF_Dictionary* pDict = mark.GetParam();
+ if (pDict && pDict->KeyExist("MCID"))
+ return pDict->GetIntegerFor("MCID");
+ }
+ return -1;
+}
+
void CPDF_ContentMark::MarkData::AddMark(const ByteString& name,
CPDF_Dictionary* pDict,
bool bDirect) {