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_widgetdata.h" | 7 #include "xfa/fxfa/parser/cxfa_widgetdata.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fxbarcode/include/BC_Library.h" | 10 #include "xfa/fxbarcode/include/BC_Library.h" |
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 m_bIsNull = FALSE; | 1321 m_bIsNull = FALSE; |
1322 CFX_WideString wsNewText(wsValue); | 1322 CFX_WideString wsNewText(wsValue); |
1323 CFX_WideString wsPicture; | 1323 CFX_WideString wsPicture; |
1324 GetPictureContent(wsPicture, eValueType); | 1324 GetPictureContent(wsPicture, eValueType); |
1325 FX_BOOL bValidate = TRUE; | 1325 FX_BOOL bValidate = TRUE; |
1326 FX_BOOL bSyncData = FALSE; | 1326 FX_BOOL bSyncData = FALSE; |
1327 CXFA_Node* pNode = GetUIChild(); | 1327 CXFA_Node* pNode = GetUIChild(); |
1328 if (!pNode) | 1328 if (!pNode) |
1329 return TRUE; | 1329 return TRUE; |
1330 | 1330 |
1331 XFA_Element uiType = pNode->GetElementType(); | 1331 XFA_Element eType = pNode->GetElementType(); |
1332 if (!wsPicture.IsEmpty()) { | 1332 if (!wsPicture.IsEmpty()) { |
1333 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); | 1333 CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr(); |
1334 IFX_Locale* pLocale = GetLocal(); | 1334 IFX_Locale* pLocale = GetLocal(); |
1335 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); | 1335 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); |
1336 bValidate = | 1336 bValidate = |
1337 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); | 1337 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture); |
1338 if (bValidate) { | 1338 if (bValidate) { |
1339 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, | 1339 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText, |
1340 wsPicture, pLocale, pLocalMgr); | 1340 wsPicture, pLocale, pLocalMgr); |
1341 wsNewText = widgetValue.GetValue(); | 1341 wsNewText = widgetValue.GetValue(); |
1342 if (uiType == XFA_Element::NumericEdit) { | 1342 if (eType == XFA_Element::NumericEdit) { |
1343 int32_t iLeadDigits = 0; | 1343 int32_t iLeadDigits = 0; |
1344 int32_t iFracDigits = 0; | 1344 int32_t iFracDigits = 0; |
1345 GetLeadDigits(iLeadDigits); | 1345 GetLeadDigits(iLeadDigits); |
1346 GetFracDigits(iFracDigits); | 1346 GetFracDigits(iFracDigits); |
1347 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits); | 1347 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits); |
1348 } | 1348 } |
1349 bSyncData = TRUE; | 1349 bSyncData = TRUE; |
1350 } | 1350 } |
1351 } else { | 1351 } else { |
1352 if (uiType == XFA_Element::NumericEdit) { | 1352 if (eType == XFA_Element::NumericEdit) { |
1353 if (wsNewText != FX_WSTRC(L"0")) { | 1353 if (wsNewText != FX_WSTRC(L"0")) { |
1354 int32_t iLeadDigits = 0; | 1354 int32_t iLeadDigits = 0; |
1355 int32_t iFracDigits = 0; | 1355 int32_t iFracDigits = 0; |
1356 GetLeadDigits(iLeadDigits); | 1356 GetLeadDigits(iLeadDigits); |
1357 GetFracDigits(iFracDigits); | 1357 GetFracDigits(iFracDigits); |
1358 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits); | 1358 wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits); |
1359 } | 1359 } |
1360 bSyncData = TRUE; | 1360 bSyncData = TRUE; |
1361 } | 1361 } |
1362 } | 1362 } |
1363 if (uiType != XFA_Element::NumericEdit || bSyncData) | 1363 if (eType != XFA_Element::NumericEdit || bSyncData) |
1364 SyncValue(wsNewText, true); | 1364 SyncValue(wsNewText, true); |
1365 | 1365 |
1366 return bValidate; | 1366 return bValidate; |
1367 } | 1367 } |
1368 | 1368 |
1369 FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture, | 1369 FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture, |
1370 XFA_VALUEPICTURE ePicture) { | 1370 XFA_VALUEPICTURE ePicture) { |
1371 if (ePicture == XFA_VALUEPICTURE_Raw) | 1371 if (ePicture == XFA_VALUEPICTURE_Raw) |
1372 return FALSE; | 1372 return FALSE; |
1373 | 1373 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 | 1486 |
1487 if (eValueType == XFA_VALUEPICTURE_Display) | 1487 if (eValueType == XFA_VALUEPICTURE_Display) |
1488 GetItemLabel(wsValue.AsStringC(), wsValue); | 1488 GetItemLabel(wsValue.AsStringC(), wsValue); |
1489 | 1489 |
1490 CFX_WideString wsPicture; | 1490 CFX_WideString wsPicture; |
1491 GetPictureContent(wsPicture, eValueType); | 1491 GetPictureContent(wsPicture, eValueType); |
1492 CXFA_Node* pNode = GetUIChild(); | 1492 CXFA_Node* pNode = GetUIChild(); |
1493 if (!pNode) | 1493 if (!pNode) |
1494 return TRUE; | 1494 return TRUE; |
1495 | 1495 |
1496 XFA_Element uiType = GetUIChild()->GetElementType(); | 1496 switch (GetUIChild()->GetElementType()) { |
1497 switch (uiType) { | |
1498 case XFA_Element::ChoiceList: { | 1497 case XFA_Element::ChoiceList: { |
1499 if (eValueType == XFA_VALUEPICTURE_Display) { | 1498 if (eValueType == XFA_VALUEPICTURE_Display) { |
1500 int32_t iSelItemIndex = GetSelectedItem(0); | 1499 int32_t iSelItemIndex = GetSelectedItem(0); |
1501 if (iSelItemIndex >= 0) { | 1500 if (iSelItemIndex >= 0) { |
1502 GetChoiceListItem(wsValue, iSelItemIndex); | 1501 GetChoiceListItem(wsValue, iSelItemIndex); |
1503 wsPicture.clear(); | 1502 wsPicture.clear(); |
1504 } | 1503 } |
1505 } | 1504 } |
1506 } break; | 1505 } break; |
1507 case XFA_Element::NumericEdit: | 1506 case XFA_Element::NumericEdit: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 ASSERT(GetNode()); | 1590 ASSERT(GetNode()); |
1592 CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_Element::Value); | 1591 CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_Element::Value); |
1593 if (!pNodeValue) | 1592 if (!pNodeValue) |
1594 return FALSE; | 1593 return FALSE; |
1595 | 1594 |
1596 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); | 1595 CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); |
1597 if (!pValueChild) | 1596 if (!pValueChild) |
1598 return FALSE; | 1597 return FALSE; |
1599 | 1598 |
1600 int32_t iVTType = XFA_VT_NULL; | 1599 int32_t iVTType = XFA_VT_NULL; |
1601 XFA_Element eType = pValueChild->GetElementType(); | 1600 switch (pValueChild->GetElementType()) { |
1602 switch (eType) { | |
1603 case XFA_Element::Decimal: | 1601 case XFA_Element::Decimal: |
1604 iVTType = XFA_VT_DECIMAL; | 1602 iVTType = XFA_VT_DECIMAL; |
1605 break; | 1603 break; |
1606 case XFA_Element::Float: | 1604 case XFA_Element::Float: |
1607 iVTType = XFA_VT_FLOAT; | 1605 iVTType = XFA_VT_FLOAT; |
1608 break; | 1606 break; |
1609 case XFA_Element::Date: | 1607 case XFA_Element::Date: |
1610 iVTType = XFA_VT_DATE; | 1608 iVTType = XFA_VT_DATE; |
1611 break; | 1609 break; |
1612 case XFA_Element::Time: | 1610 case XFA_Element::Time: |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 } | 1777 } |
1780 } | 1778 } |
1781 } else if (wc == L'.') { | 1779 } else if (wc == L'.') { |
1782 iTread_ = 0; | 1780 iTread_ = 0; |
1783 iLead = -1; | 1781 iLead = -1; |
1784 } | 1782 } |
1785 wsRet += wc; | 1783 wsRet += wc; |
1786 } | 1784 } |
1787 return wsRet; | 1785 return wsRet; |
1788 } | 1786 } |
OLD | NEW |