diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-07-11 20:55:02 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-11 20:55:02 +0000 |
commit | 10a7ddb596f0089ba12d0db29b5752a61919a208 (patch) | |
tree | 3a5470ac4240e50e12a22d40daf7aad866b62ac9 /core/fpdfapi/page | |
parent | 75625a8a8a84fffcfe09a09b57d77c99b5261f7d (diff) | |
download | pdfium-10a7ddb596f0089ba12d0db29b5752a61919a208.tar.xz |
Store property name for marked content with an indirect dict.
The name of the property is now stored in the CPDF_ContentMarkItem,
which will be needed to properly write back these content marks
after a change in the stream.
Bug: pdfium:1118
Change-Id: I1296f488b35ee0684efa33d17400ed22a88383a2
Reviewed-on: https://pdfium-review.googlesource.com/37370
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmark.cpp | 13 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmark.h | 8 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmarkitem.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmarkitem.h | 7 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 12 |
5 files changed, 30 insertions, 14 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp index 8b4609586d..29d1bba210 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -57,10 +57,12 @@ void CPDF_ContentMark::AddMarkWithDirectDict(ByteString name, m_pMarkData->AddMarkWithDirectDict(std::move(name), pDict); } -void CPDF_ContentMark::AddMarkWithPropertiesDict(ByteString name, - CPDF_Dictionary* pDict) { +void CPDF_ContentMark::AddMarkWithPropertiesDict( + ByteString name, + CPDF_Dictionary* pDict, + const ByteString& property_name) { EnsureMarkDataExists(); - m_pMarkData->AddMarkWithPropertiesDict(std::move(name), pDict); + m_pMarkData->AddMarkWithPropertiesDict(std::move(name), pDict, property_name); } void CPDF_ContentMark::EnsureMarkDataExists() { @@ -120,9 +122,10 @@ void CPDF_ContentMark::MarkData::AddMarkWithDirectDict(ByteString name, void CPDF_ContentMark::MarkData::AddMarkWithPropertiesDict( ByteString name, - CPDF_Dictionary* pDict) { + CPDF_Dictionary* pDict, + const ByteString& property_name) { auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(std::move(name)); - pItem->SetPropertiesDict(pDict); + pItem->SetPropertiesDict(pDict, property_name); m_Marks.push_back(pItem); } diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index b9b10b0a48..33180333af 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -31,7 +31,9 @@ class CPDF_ContentMark { void AddMark(ByteString name); void AddMarkWithDirectDict(ByteString name, CPDF_Dictionary* pDict); - void AddMarkWithPropertiesDict(ByteString name, CPDF_Dictionary* pDict); + void AddMarkWithPropertiesDict(ByteString name, + CPDF_Dictionary* pDict, + const ByteString& property_name); void DeleteLastMark(); private: @@ -48,7 +50,9 @@ class CPDF_ContentMark { int GetMarkedContentID() const; void AddMark(ByteString name); void AddMarkWithDirectDict(ByteString name, CPDF_Dictionary* pDict); - void AddMarkWithPropertiesDict(ByteString name, CPDF_Dictionary* pDict); + void AddMarkWithPropertiesDict(ByteString name, + CPDF_Dictionary* pDict, + const ByteString& property_name); void DeleteLastMark(); private: diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.cpp b/core/fpdfapi/page/cpdf_contentmarkitem.cpp index 2e715926d3..90a2930b23 100644 --- a/core/fpdfapi/page/cpdf_contentmarkitem.cpp +++ b/core/fpdfapi/page/cpdf_contentmarkitem.cpp @@ -50,7 +50,9 @@ void CPDF_ContentMarkItem::SetDirectDict( m_pDirectDict = std::move(pDict); } -void CPDF_ContentMarkItem::SetPropertiesDict(CPDF_Dictionary* pDict) { +void CPDF_ContentMarkItem::SetPropertiesDict(CPDF_Dictionary* pDict, + const ByteString& property_name) { m_ParamType = PropertiesDict; m_pPropertiesDict = pDict; + m_PropertyName = property_name; } diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h index 6d2310e261..435aef4b10 100644 --- a/core/fpdfapi/page/cpdf_contentmarkitem.h +++ b/core/fpdfapi/page/cpdf_contentmarkitem.h @@ -24,19 +24,22 @@ class CPDF_ContentMarkItem : public Retainable { explicit CPDF_ContentMarkItem(ByteString name); ~CPDF_ContentMarkItem() override; - ByteString GetName() const { return m_MarkName; } + const ByteString& GetName() const { return m_MarkName; } ParamType GetParamType() const { return m_ParamType; } const CPDF_Dictionary* GetParam() const; CPDF_Dictionary* GetParam(); + const ByteString& GetPropertyName() const { return m_PropertyName; } bool HasMCID() const; void SetDirectDict(std::unique_ptr<CPDF_Dictionary> pDict); - void SetPropertiesDict(CPDF_Dictionary* pDict); + void SetPropertiesDict(CPDF_Dictionary* pDict, + const ByteString& property_name); private: ByteString m_MarkName; ParamType m_ParamType = None; UnownedPtr<CPDF_Dictionary> m_pPropertiesDict; + ByteString m_PropertyName; std::unique_ptr<CPDF_Dictionary> m_pDirectDict; }; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index ae55390eb2..860f6d6b3b 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -608,18 +608,22 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { return; bool bIndirect = pProperty->IsName(); + ByteString property_name; if (bIndirect) { - pProperty = FindResourceObj("Properties", pProperty->GetString()); + property_name = pProperty->GetString(); + pProperty = FindResourceObj("Properties", property_name); if (!pProperty) return; } if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { std::unique_ptr<CPDF_ContentMark> new_marks = m_ContentMarksStack.top()->Clone(); - if (bIndirect) - new_marks->AddMarkWithPropertiesDict(std::move(tag), pDict); - else + if (bIndirect) { + new_marks->AddMarkWithPropertiesDict(std::move(tag), pDict, + property_name); + } else { new_marks->AddMarkWithDirectDict(std::move(tag), pDict); + } m_ContentMarksStack.push(std::move(new_marks)); } } |