| 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 "xfa/fxfa/parser/cxfa_occur.h" | 7 #include "xfa/fxfa/parser/cxfa_occur.h" |
| 8 | 8 |
| 9 #include "xfa/fxfa/parser/xfa_object.h" | 9 #include "xfa/fxfa/parser/xfa_object.h" |
| 10 | 10 |
| 11 CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {} | 11 CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {} |
| 12 | 12 |
| 13 int32_t CXFA_Occur::GetMax() { | 13 int32_t CXFA_Occur::GetMax() { |
| 14 int32_t iMax = 1; | 14 int32_t iMax = 1; |
| 15 if (m_pNode) { | 15 if (m_pNode) { |
| 16 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, TRUE)) | 16 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, true)) |
| 17 iMax = GetMin(); | 17 iMax = GetMin(); |
| 18 } | 18 } |
| 19 return iMax; | 19 return iMax; |
| 20 } | 20 } |
| 21 | 21 |
| 22 int32_t CXFA_Occur::GetMin() { | 22 int32_t CXFA_Occur::GetMin() { |
| 23 int32_t iMin = 1; | 23 int32_t iMin = 1; |
| 24 if (m_pNode) { | 24 if (m_pNode) { |
| 25 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, TRUE) || iMin < 0) | 25 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, true) || iMin < 0) |
| 26 iMin = 1; | 26 iMin = 1; |
| 27 } | 27 } |
| 28 return iMin; | 28 return iMin; |
| 29 } | 29 } |
| 30 | 30 |
| 31 FX_BOOL CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) { | 31 bool CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) { |
| 32 if (!m_pNode) | 32 if (!m_pNode) |
| 33 return FALSE; | 33 return false; |
| 34 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE) || iMin < 0) | 34 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false) || iMin < 0) |
| 35 iMin = 1; | 35 iMin = 1; |
| 36 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { | 36 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false)) { |
| 37 if (iMin == 0) | 37 if (iMin == 0) |
| 38 iMax = 1; | 38 iMax = 1; |
| 39 else | 39 else |
| 40 iMax = iMin; | 40 iMax = iMin; |
| 41 } | 41 } |
| 42 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, FALSE) || | 42 if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, false) || |
| 43 iInit < iMin) { | 43 iInit < iMin) { |
| 44 iInit = iMin; | 44 iInit = iMin; |
| 45 } | 45 } |
| 46 return TRUE; | 46 return true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void CXFA_Occur::SetMax(int32_t iMax) { | 49 void CXFA_Occur::SetMax(int32_t iMax) { |
| 50 iMax = (iMax != -1 && iMax < 1) ? 1 : iMax; | 50 iMax = (iMax != -1 && iMax < 1) ? 1 : iMax; |
| 51 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | 51 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, false); |
| 52 int32_t iMin = GetMin(); | 52 int32_t iMin = GetMin(); |
| 53 if (iMax != -1 && iMax < iMin) { | 53 if (iMax != -1 && iMax < iMin) { |
| 54 iMin = iMax; | 54 iMin = iMax; |
| 55 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE); | 55 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, false); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void CXFA_Occur::SetMin(int32_t iMin) { | 59 void CXFA_Occur::SetMin(int32_t iMin) { |
| 60 iMin = (iMin < 0) ? 1 : iMin; | 60 iMin = (iMin < 0) ? 1 : iMin; |
| 61 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE); | 61 m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, false); |
| 62 int32_t iMax = GetMax(); | 62 int32_t iMax = GetMax(); |
| 63 if (iMax > 0 && iMax < iMin) { | 63 if (iMax > 0 && iMax < iMin) { |
| 64 iMax = iMin; | 64 iMax = iMin; |
| 65 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | 65 m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, false); |
| 66 } | 66 } |
| 67 } | 67 } |
| OLD | NEW |