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