1 // Copyright 2016 PDFium Authors. All rights reserved. 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 ~CPDF_ContentMarkItem()16CPDF_ContentMarkItem::~CPDF_ContentMarkItem() {} 17 GetParam() const18const 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.Get(); 24 case kNone: 25 default: 26 return nullptr; 27 } 28 } 29 GetParam()30CPDF_Dictionary* CPDF_ContentMarkItem::GetParam() { 31 return const_cast<CPDF_Dictionary*>( 32 static_cast<const CPDF_ContentMarkItem*>(this)->GetParam()); 33 } 34 HasMCID() const35bool CPDF_ContentMarkItem::HasMCID() const { 36 const CPDF_Dictionary* pDict = GetParam(); 37 return pDict && pDict->KeyExist("MCID"); 38 } 39 SetDirectDict(RetainPtr<CPDF_Dictionary> pDict)40void CPDF_ContentMarkItem::SetDirectDict(RetainPtr<CPDF_Dictionary> pDict) { 41 m_ParamType = kDirectDict; 42 m_pDirectDict = std::move(pDict); 43 } 44 SetPropertiesHolder(CPDF_Dictionary * pHolder,const ByteString & property_name)45void CPDF_ContentMarkItem::SetPropertiesHolder( 46 CPDF_Dictionary* pHolder, 47 const ByteString& property_name) { 48 m_ParamType = kPropertiesDict; 49 m_pPropertiesHolder.Reset(pHolder); 50 m_PropertyName = property_name; 51 } 52