• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)13 CPDF_ContentMarkItem::CPDF_ContentMarkItem(ByteString name)
14     : m_MarkName(std::move(name)) {}
15 
16 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() = default;
17 
GetParam() const18 RetainPtr<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     default:
26       return nullptr;
27   }
28 }
29 
GetParam()30 RetainPtr<CPDF_Dictionary> CPDF_ContentMarkItem::GetParam() {
31   return pdfium::WrapRetain(
32       const_cast<CPDF_Dictionary*>(std::as_const(*this).GetParam().Get()));
33 }
34 
SetDirectDict(RetainPtr<CPDF_Dictionary> pDict)35 void CPDF_ContentMarkItem::SetDirectDict(RetainPtr<CPDF_Dictionary> pDict) {
36   m_ParamType = kDirectDict;
37   m_pDirectDict = std::move(pDict);
38 }
39 
SetPropertiesHolder(RetainPtr<CPDF_Dictionary> pHolder,const ByteString & property_name)40 void CPDF_ContentMarkItem::SetPropertiesHolder(
41     RetainPtr<CPDF_Dictionary> pHolder,
42     const ByteString& property_name) {
43   m_ParamType = kPropertiesDict;
44   m_pPropertiesHolder = std::move(pHolder);
45   m_PropertyName = property_name;
46 }
47