| 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_data.h" | 7 #include "xfa/fxfa/parser/cxfa_data.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" |
| 9 #include "xfa/fxfa/parser/xfa_object.h" | 10 #include "xfa/fxfa/parser/xfa_object.h" |
| 10 | 11 |
| 11 // Static. | 12 // Static. |
| 12 FX_ARGB CXFA_Data::ToColor(const CFX_WideStringC& wsValue) { | 13 FX_ARGB CXFA_Data::ToColor(const CFX_WideStringC& wsValue) { |
| 13 uint8_t r = 0, g = 0, b = 0; | 14 uint8_t r = 0, g = 0, b = 0; |
| 14 if (wsValue.GetLength() == 0) | 15 if (wsValue.GetLength() == 0) |
| 15 return 0xff000000; | 16 return 0xff000000; |
| 16 | 17 |
| 17 int cc = 0; | 18 int cc = 0; |
| 18 const FX_WCHAR* str = wsValue.c_str(); | 19 const FX_WCHAR* str = wsValue.c_str(); |
| 19 int len = wsValue.GetLength(); | 20 int len = wsValue.GetLength(); |
| 20 while (XFA_IsSpace(str[cc]) && cc < len) | 21 while (FXSYS_iswspace(str[cc]) && cc < len) |
| 21 cc++; | 22 cc++; |
| 22 | 23 |
| 23 if (cc >= len) | 24 if (cc >= len) |
| 24 return 0xff000000; | 25 return 0xff000000; |
| 25 | 26 |
| 26 while (cc < len) { | 27 while (cc < len) { |
| 27 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) | 28 if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc])) |
| 28 break; | 29 break; |
| 29 | 30 |
| 30 r = r * 10 + str[cc] - '0'; | 31 r = r * 10 + str[cc] - '0'; |
| 31 cc++; | 32 cc++; |
| 32 } | 33 } |
| 33 if (cc < len && str[cc] == ',') { | 34 if (cc < len && str[cc] == ',') { |
| 34 cc++; | 35 cc++; |
| 35 while (XFA_IsSpace(str[cc]) && cc < len) | 36 while (FXSYS_iswspace(str[cc]) && cc < len) |
| 36 cc++; | 37 cc++; |
| 37 | 38 |
| 38 while (cc < len) { | 39 while (cc < len) { |
| 39 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) | 40 if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc])) |
| 40 break; | 41 break; |
| 41 | 42 |
| 42 g = g * 10 + str[cc] - '0'; | 43 g = g * 10 + str[cc] - '0'; |
| 43 cc++; | 44 cc++; |
| 44 } | 45 } |
| 45 if (cc < len && str[cc] == ',') { | 46 if (cc < len && str[cc] == ',') { |
| 46 cc++; | 47 cc++; |
| 47 while (XFA_IsSpace(str[cc]) && cc < len) | 48 while (FXSYS_iswspace(str[cc]) && cc < len) |
| 48 cc++; | 49 cc++; |
| 49 | 50 |
| 50 while (cc < len) { | 51 while (cc < len) { |
| 51 if (str[cc] == ',' || !XFA_IsDigit(str[cc])) | 52 if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc])) |
| 52 break; | 53 break; |
| 53 | 54 |
| 54 b = b * 10 + str[cc] - '0'; | 55 b = b * 10 + str[cc] - '0'; |
| 55 cc++; | 56 cc++; |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 return (0xff << 24) | (r << 16) | (g << 8) | b; | 60 return (0xff << 24) | (r << 16) | (g << 8) | b; |
| 60 } | 61 } |
| 61 | 62 |
| 62 XFA_Element CXFA_Data::GetElementType() const { | 63 XFA_Element CXFA_Data::GetElementType() const { |
| 63 return m_pNode ? m_pNode->GetElementType() : XFA_Element::Unknown; | 64 return m_pNode ? m_pNode->GetElementType() : XFA_Element::Unknown; |
| 64 } | 65 } |
| 65 | 66 |
| 66 FX_BOOL CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr, | 67 FX_BOOL CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr, |
| 67 FX_FLOAT& fValue, | 68 FX_FLOAT& fValue, |
| 68 FX_BOOL bUseDefault) const { | 69 FX_BOOL bUseDefault) const { |
| 69 CXFA_Measurement ms; | 70 CXFA_Measurement ms; |
| 70 if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) { | 71 if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) { |
| 71 fValue = ms.ToUnit(XFA_UNIT_Pt); | 72 fValue = ms.ToUnit(XFA_UNIT_Pt); |
| 72 return TRUE; | 73 return TRUE; |
| 73 } | 74 } |
| 74 return FALSE; | 75 return FALSE; |
| 75 } | 76 } |
| 76 | 77 |
| 77 FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) { | 78 FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) { |
| 78 CXFA_Measurement ms(fValue, XFA_UNIT_Pt); | 79 CXFA_Measurement ms(fValue, XFA_UNIT_Pt); |
| 79 return m_pNode->SetMeasure(eAttr, ms); | 80 return m_pNode->SetMeasure(eAttr, ms); |
| 80 } | 81 } |
| OLD | NEW |