Home | History | Annotate | Download | only in page
      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 
     13 CPDF_ContentMarkItem::CPDF_ContentMarkItem()
     14     : m_ParamType(None), m_pPropertiesDict(nullptr) {}
     15 
     16 CPDF_ContentMarkItem::CPDF_ContentMarkItem(const CPDF_ContentMarkItem& that)
     17     : m_MarkName(that.m_MarkName),
     18       m_ParamType(that.m_ParamType),
     19       m_pPropertiesDict(that.m_pPropertiesDict) {
     20   if (that.m_pDirectDict)
     21     m_pDirectDict = ToDictionary(that.m_pDirectDict->Clone());
     22 }
     23 
     24 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() {}
     25 
     26 CPDF_Dictionary* CPDF_ContentMarkItem::GetParam() const {
     27   switch (m_ParamType) {
     28     case PropertiesDict:
     29       return m_pPropertiesDict.Get();
     30     case DirectDict:
     31       return m_pDirectDict.get();
     32     case None:
     33     default:
     34       return nullptr;
     35   }
     36 }
     37 
     38 bool CPDF_ContentMarkItem::HasMCID() const {
     39   CPDF_Dictionary* pDict = GetParam();
     40   return pDict && pDict->KeyExist("MCID");
     41 }
     42 
     43 void CPDF_ContentMarkItem::SetDirectDict(
     44     std::unique_ptr<CPDF_Dictionary> pDict) {
     45   m_ParamType = DirectDict;
     46   m_pDirectDict = std::move(pDict);
     47 }
     48 
     49 void CPDF_ContentMarkItem::SetPropertiesDict(CPDF_Dictionary* pDict) {
     50   m_ParamType = PropertiesDict;
     51   m_pPropertiesDict = pDict;
     52 }
     53