1 // Copyright 2016 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fpdfapi/page/cpdf_contentmarkitem.h" 8 9 #include <utility> 10 11 #include "core/fpdfapi/parser/cpdf_dictionary.h" 12 CPDF_ContentMarkItem(ByteString name)13CPDF_ContentMarkItem::CPDF_ContentMarkItem(ByteString name) 14 : m_MarkName(std::move(name)) {} 15 16 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() = default; 17 GetParam() const18RetainPtr<const CPDF_Dictionary> CPDF_ContentMarkItem::GetParam() const { 19 switch (m_ParamType) { 20 case kPropertiesDict: 21 return m_pPropertiesHolder->GetDictFor(m_PropertyName); 22 case kDirectDict: 23 return m_pDirectDict; 24 case kNone: 25 return nullptr; 26 } 27 } 28 GetParam()29RetainPtr<CPDF_Dictionary> CPDF_ContentMarkItem::GetParam() { 30 return pdfium::WrapRetain( 31 const_cast<CPDF_Dictionary*>(std::as_const(*this).GetParam().Get())); 32 } 33 SetDirectDict(RetainPtr<CPDF_Dictionary> pDict)34void CPDF_ContentMarkItem::SetDirectDict(RetainPtr<CPDF_Dictionary> pDict) { 35 m_ParamType = kDirectDict; 36 m_pDirectDict = std::move(pDict); 37 } 38 SetPropertiesHolder(RetainPtr<CPDF_Dictionary> pHolder,const ByteString & property_name)39void CPDF_ContentMarkItem::SetPropertiesHolder( 40 RetainPtr<CPDF_Dictionary> pHolder, 41 const ByteString& property_name) { 42 m_ParamType = kPropertiesDict; 43 m_pPropertiesHolder = std::move(pHolder); 44 m_PropertyName = property_name; 45 } 46