diff options
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_contentmark.cpp | 40 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_contentmark.h | 24 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 16 |
3 files changed, 61 insertions, 19 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp index 06a6a50443..c36f407c36 100644 --- a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp @@ -6,8 +6,44 @@ #include "core/fpdfapi/fpdf_page/cpdf_contentmark.h" +CPDF_ContentMark::CPDF_ContentMark() {} + +CPDF_ContentMark::CPDF_ContentMark(const CPDF_ContentMark& that) + : m_Ref(that.m_Ref) {} + +CPDF_ContentMark::~CPDF_ContentMark() {} + +void CPDF_ContentMark::SetNull() { + m_Ref.SetNull(); +} + +int CPDF_ContentMark::CountItems() const { + return m_Ref.GetObject()->CountItems(); +} + +const CPDF_ContentMarkItem& CPDF_ContentMark::GetItem(int i) const { + return m_Ref.GetObject()->GetItem(i); +} + +int CPDF_ContentMark::GetMCID() const { + const CPDF_ContentMarkData* pData = m_Ref.GetObject(); + return pData ? pData->GetMCID() : -1; +} + +void CPDF_ContentMark::AddMark(const CFX_ByteString& name, + CPDF_Dictionary* pDict, + FX_BOOL bDirect) { + m_Ref.GetPrivateCopy()->AddMark(name, pDict, bDirect); +} + +void CPDF_ContentMark::DeleteLastMark() { + m_Ref.GetPrivateCopy()->DeleteLastMark(); + if (CountItems() == 0) + m_Ref.SetNull(); +} + bool CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const { - const CPDF_ContentMarkData* pData = GetObject(); + const CPDF_ContentMarkData* pData = m_Ref.GetObject(); if (!pData) return false; @@ -20,7 +56,7 @@ bool CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const { bool CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionary*& pDict) const { - const CPDF_ContentMarkData* pData = GetObject(); + const CPDF_ContentMarkData* pData = m_Ref.GetObject(); if (!pData) return false; diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.h b/core/fpdfapi/fpdf_page/cpdf_contentmark.h index 2f8c5cdbc7..2941c61ba9 100644 --- a/core/fpdfapi/fpdf_page/cpdf_contentmark.h +++ b/core/fpdfapi/fpdf_page/cpdf_contentmark.h @@ -11,15 +11,29 @@ #include "core/fxcrt/include/cfx_count_ref.h" #include "core/fxcrt/include/fx_basic.h" -class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData> { +class CPDF_ContentMark { public: - int GetMCID() const { - const CPDF_ContentMarkData* pData = GetObject(); - return pData ? pData->GetMCID() : -1; - } + CPDF_ContentMark(); + CPDF_ContentMark(const CPDF_ContentMark& that); + ~CPDF_ContentMark(); + + void SetNull(); + + int GetMCID() const; + int CountItems() const; + const CPDF_ContentMarkItem& GetItem(int i) const; bool HasMark(const CFX_ByteStringC& mark) const; bool LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionary*& pDict) const; + void AddMark(const CFX_ByteString& name, + CPDF_Dictionary* pDict, + FX_BOOL bDirect); + void DeleteLastMark(); + + operator bool() const { return !!m_Ref; } + + private: + CFX_CountRef<CPDF_ContentMarkData> m_Ref; }; #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_CONTENTMARK_H_ diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 5272a4464b..4712ea0725 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -583,7 +583,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { bDirect = FALSE; } if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { - m_CurContentMark.GetPrivateCopy()->AddMark(tag, pDict, bDirect); + m_CurContentMark.AddMark(tag, pDict, bDirect); } } @@ -658,8 +658,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } void CPDF_StreamContentParser::Handle_BeginMarkedContent() { - CFX_ByteString tag = GetString(0); - m_CurContentMark.GetPrivateCopy()->AddMark(tag, nullptr, FALSE); + m_CurContentMark.AddMark(GetString(0), nullptr, FALSE); } void CPDF_StreamContentParser::Handle_BeginText() { @@ -806,15 +805,8 @@ void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {} void CPDF_StreamContentParser::Handle_EndImage() {} void CPDF_StreamContentParser::Handle_EndMarkedContent() { - if (!m_CurContentMark) - return; - - int count = m_CurContentMark.GetObject()->CountItems(); - if (count == 1) { - m_CurContentMark.SetNull(); - return; - } - m_CurContentMark.GetPrivateCopy()->DeleteLastMark(); + if (m_CurContentMark) + m_CurContentMark.DeleteLastMark(); } void CPDF_StreamContentParser::Handle_EndText() { |