OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/fpdf_page/cpdf_contentmarkitem.h" | 7 #include "core/fpdfapi/fpdf_page/cpdf_contentmarkitem.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
10 | 10 |
11 CPDF_ContentMarkItem::CPDF_ContentMarkItem() | 11 CPDF_ContentMarkItem::CPDF_ContentMarkItem() |
12 : m_ParamType(None), m_pParam(nullptr) {} | 12 : m_ParamType(None), m_pPropertiesDict(nullptr) {} |
13 | 13 |
14 CPDF_ContentMarkItem::CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src) { | 14 CPDF_ContentMarkItem::CPDF_ContentMarkItem(const CPDF_ContentMarkItem& that) |
15 m_MarkName = src.m_MarkName; | 15 : m_MarkName(that.m_MarkName), |
16 m_ParamType = src.m_ParamType; | 16 m_ParamType(that.m_ParamType), |
17 if (m_ParamType == DirectDict) { | 17 m_pPropertiesDict(that.m_pPropertiesDict) { |
18 m_pParam = ToDictionary(src.m_pParam->Clone()); | 18 if (that.m_pDirectDict) |
19 } else { | 19 m_pDirectDict.reset(that.m_pDirectDict->Clone()->AsDictionary()); |
20 m_pParam = src.m_pParam; | 20 } |
| 21 |
| 22 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() {} |
| 23 |
| 24 CPDF_Dictionary* CPDF_ContentMarkItem::GetParam() const { |
| 25 switch (m_ParamType) { |
| 26 case PropertiesDict: |
| 27 return m_pPropertiesDict; |
| 28 case DirectDict: |
| 29 return m_pDirectDict.get(); |
| 30 case None: |
| 31 default: |
| 32 return nullptr; |
21 } | 33 } |
22 } | 34 } |
23 | 35 |
24 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() { | 36 FX_BOOL CPDF_ContentMarkItem::HasMCID() const { |
25 if (m_ParamType == DirectDict && m_pParam) | 37 CPDF_Dictionary* pDict = GetParam(); |
26 m_pParam->Release(); | 38 return pDict && pDict->KeyExist("MCID"); |
27 } | 39 } |
28 | 40 |
29 FX_BOOL CPDF_ContentMarkItem::HasMCID() const { | 41 void CPDF_ContentMarkItem::SetDirectDict( |
30 if (m_pParam && | 42 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict) { |
31 (m_ParamType == DirectDict || m_ParamType == PropertiesDict)) { | 43 m_ParamType = DirectDict; |
32 return m_pParam->KeyExist("MCID"); | 44 m_pDirectDict = std::move(pDict); |
33 } | |
34 return FALSE; | |
35 } | 45 } |
| 46 |
| 47 void CPDF_ContentMarkItem::SetPropertiesDict(CPDF_Dictionary* pDict) { |
| 48 m_ParamType = PropertiesDict; |
| 49 m_pPropertiesDict = pDict; |
| 50 } |
OLD | NEW |