diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fgas/layout/fgas_rtfbreak.cpp | 2 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_textbreak.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_lexer.cpp | 13 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_localevalue.cpp | 62 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 33 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.h | 3 |
6 files changed, 61 insertions, 54 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 68c04a7f64..68e8929c9a 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -507,7 +507,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, if (i == 0) pTC->m_iBidiLevel = 1; } - FX_BidiLine(chars, iBidiNum + 1, 0); + FX_BidiLine(&chars, iBidiNum + 1); } else { for (int32_t i = 0; i < iCount; ++i) { pTC = &chars[i]; diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index c42de45411..44545574e5 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -448,7 +448,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, if (i == 0) pTC->m_iBidiLevel = 1; } - FX_BidiLine(chars, iBidiNum + 1, 0); + FX_BidiLine(&chars, iBidiNum + 1); } if (bDone) { diff --git a/xfa/fxfa/fm2js/xfa_lexer.cpp b/xfa/fxfa/fm2js/xfa_lexer.cpp index 5d3f6f5890..7ccd4773fb 100644 --- a/xfa/fxfa/fm2js/xfa_lexer.cpp +++ b/xfa/fxfa/fm2js/xfa_lexer.cpp @@ -62,9 +62,9 @@ inline bool XFA_FMDChar::isAvalid(const wchar_t* p, bool flag) { inline bool XFA_FMDChar::string2number(const wchar_t* s, double* pValue, const wchar_t*& pEnd) { - if (s) { - *pValue = wcstod((wchar_t*)s, (wchar_t**)&pEnd); - } + if (s) + *pValue = wcstod(const_cast<wchar_t*>(s), const_cast<wchar_t**>(&pEnd)); + return 0; } @@ -404,12 +404,11 @@ uint32_t CXFA_FMLexer::Number(CXFA_FMToken* t, const wchar_t* p, const wchar_t*& pEnd) { double number = 0; - if (XFA_FMDChar::string2number(p, &number, pEnd)) { + if (XFA_FMDChar::string2number(p, &number, pEnd)) return 1; - } - if (pEnd && XFA_FMDChar::isAlpha(pEnd)) { + if (pEnd && XFA_FMDChar::isAlpha(pEnd)) return 1; - } + t->m_wstring = CFX_WideStringC(p, (pEnd - p)); return 0; } diff --git a/xfa/fxfa/parser/xfa_localevalue.cpp b/xfa/fxfa/parser/xfa_localevalue.cpp index b86ab90f19..0e7b8c9c2f 100644 --- a/xfa/fxfa/parser/xfa_localevalue.cpp +++ b/xfa/fxfa/parser/xfa_localevalue.cpp @@ -17,22 +17,6 @@ #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" -static const double fraction_scales[] = {0.1, - 0.01, - 0.001, - 0.0001, - 0.00001, - 0.000001, - 0.0000001, - 0.00000001, - 0.000000001, - 0.0000000001, - 0.00000000001, - 0.000000000001, - 0.0000000000001, - 0.00000000000001, - 0.000000000000001, - 0.0000000000000001}; CXFA_LocaleValue::CXFA_LocaleValue() { m_dwType = XFA_VT_NULL; m_bValid = true; @@ -248,10 +232,10 @@ float CXFA_LocaleValue::GetNum() const { if (cc < len && str[cc] == '.') { cc++; while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); + fraction += XFA_GetFractionalScale(scale) * (str[cc] - '0'); scale++; cc++; - if (scale == sizeof fraction_scales / sizeof(double) || + if (scale == XFA_GetMaxFractionalScale() || !FXSYS_isDecimalDigit(str[cc])) { break; } @@ -296,18 +280,18 @@ double CXFA_LocaleValue::GetDoubleNum() const { bool bNegative = false, bExpSign = false; const wchar_t* str = m_wsValue.c_str(); int len = m_wsValue.GetLength(); - while (FXSYS_iswspace(str[cc]) && cc < len) { + while (FXSYS_iswspace(str[cc]) && cc < len) cc++; - } - if (cc >= len) { + + if (cc >= len) return 0; - } if (str[0] == '+') { cc++; } else if (str[0] == '-') { bNegative = true; cc++; } + int32_t nIntegralLen = 0; while (cc < len) { if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc]) || @@ -324,15 +308,15 @@ double CXFA_LocaleValue::GetDoubleNum() const { if (cc < len && str[cc] == '.') { cc++; while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); + fraction += XFA_GetFractionalScale(scale) * (str[cc] - '0'); scale++; cc++; - if (scale == sizeof fraction_scales / sizeof(double) || + if (scale == XFA_GetMaxFractionalScale() || !FXSYS_isDecimalDigit(str[cc])) { break; } } - dwFractional = (uint32_t)(fraction * 4294967296.0); + dwFractional = static_cast<uint32_t>(fraction * 4294967296.0); } if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { cc++; @@ -345,23 +329,25 @@ double CXFA_LocaleValue::GetDoubleNum() const { } } while (cc < len) { - if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) { + if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) break; - } + nExponent = nExponent * 10 + str[cc] - '0'; cc++; } nExponent = bExpSign ? -nExponent : nExponent; } - double dValue = (dwFractional / 4294967296.0); + + double dValue = dwFractional / 4294967296.0; dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); - if (nExponent != 0) { - dValue *= FXSYS_pow(10, (float)nExponent); - } + if (nExponent != 0) + dValue *= FXSYS_pow(10, static_cast<float>(nExponent)); + return dValue; } return 0; } + CFX_Unitime CXFA_LocaleValue::GetDate() const { if (m_bValid && m_dwType == XFA_VT_DATE) { CFX_Unitime dt; @@ -370,6 +356,7 @@ CFX_Unitime CXFA_LocaleValue::GetDate() const { } return CFX_Unitime(); } + CFX_Unitime CXFA_LocaleValue::GetTime() const { if (m_bValid && m_dwType == XFA_VT_TIME) { CFX_Unitime dt(0); @@ -380,6 +367,7 @@ CFX_Unitime CXFA_LocaleValue::GetTime() const { } return CFX_Unitime(); } + CFX_Unitime CXFA_LocaleValue::GetDateTime() const { if (m_bValid && m_dwType == XFA_VT_DATETIME) { int32_t index = m_wsValue.Find('T'); @@ -393,39 +381,46 @@ CFX_Unitime CXFA_LocaleValue::GetDateTime() const { } return CFX_Unitime(); } + bool CXFA_LocaleValue::SetText(const CFX_WideString& wsText) { m_dwType = XFA_VT_TEXT; m_wsValue = wsText; return true; } + bool CXFA_LocaleValue::SetText(const CFX_WideString& wsText, const CFX_WideString& wsFormat, IFX_Locale* pLocale) { m_dwType = XFA_VT_TEXT; return m_bValid = ParsePatternValue(wsText, wsFormat, pLocale); } + bool CXFA_LocaleValue::SetNum(float fNum) { m_dwType = XFA_VT_FLOAT; - m_wsValue.Format(L"%.8g", (double)fNum); + m_wsValue.Format(L"%.8g", static_cast<double>(fNum)); return true; } + bool CXFA_LocaleValue::SetNum(const CFX_WideString& wsNum, const CFX_WideString& wsFormat, IFX_Locale* pLocale) { m_dwType = XFA_VT_FLOAT; return m_bValid = ParsePatternValue(wsNum, wsFormat, pLocale); } + bool CXFA_LocaleValue::SetDate(const CFX_Unitime& d) { m_dwType = XFA_VT_DATE; m_wsValue.Format(L"%04d-%02d-%02d", d.GetYear(), d.GetMonth(), d.GetDay()); return true; } + bool CXFA_LocaleValue::SetDate(const CFX_WideString& wsDate, const CFX_WideString& wsFormat, IFX_Locale* pLocale) { m_dwType = XFA_VT_DATE; return m_bValid = ParsePatternValue(wsDate, wsFormat, pLocale); } + bool CXFA_LocaleValue::SetTime(const CFX_Unitime& t) { m_dwType = XFA_VT_TIME; m_wsValue.Format(L"%02d:%02d:%02d", t.GetHour(), t.GetMinute(), @@ -437,12 +432,14 @@ bool CXFA_LocaleValue::SetTime(const CFX_Unitime& t) { } return true; } + bool CXFA_LocaleValue::SetTime(const CFX_WideString& wsTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale) { m_dwType = XFA_VT_TIME; return m_bValid = ParsePatternValue(wsTime, wsFormat, pLocale); } + bool CXFA_LocaleValue::SetDateTime(const CFX_Unitime& dt) { m_dwType = XFA_VT_DATETIME; m_wsValue.Format(L"%04d-%02d-%02dT%02d:%02d:%02d", dt.GetYear(), @@ -455,6 +452,7 @@ bool CXFA_LocaleValue::SetDateTime(const CFX_Unitime& dt) { } return true; } + bool CXFA_LocaleValue::SetDateTime(const CFX_WideString& wsDateTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale) { diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 101a6cf90e..5216d0cdd5 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -71,21 +71,19 @@ double WideStringToDouble(const CFX_WideString& wsStringVal) { if (cc < len && str[cc] == '.') { cc++; while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); + fraction += XFA_GetFractionalScale(scale) * (str[cc] - '0'); scale++; cc++; - if (cc == len) { + if (cc == len) break; - } - if (scale == sizeof(fraction_scales) / sizeof(double) || str[cc] == 'E' || + if (scale == XFA_GetMaxFractionalScale() || str[cc] == 'E' || str[cc] == 'e') { break; } - if (!FXSYS_isDecimalDigit(str[cc])) { + if (!FXSYS_isDecimalDigit(str[cc])) return 0; - } } - dwFractional = (uint32_t)(fraction * 4294967296.0); + dwFractional = static_cast<uint32_t>(fraction * 4294967296.0); } if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { cc++; @@ -98,24 +96,33 @@ double WideStringToDouble(const CFX_WideString& wsStringVal) { } } while (cc < len) { - if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) { + if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) return 0; - } + nExponent = nExponent * 10 + str[cc] - '0'; cc++; } nExponent = bExpSign ? -nExponent : nExponent; } - double dValue = (dwFractional / 4294967296.0); + + double dValue = dwFractional / 4294967296.0; dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); - if (nExponent != 0) { - dValue *= FXSYS_pow(10, (float)nExponent); - } + if (nExponent != 0) + dValue *= FXSYS_pow(10, static_cast<float>(nExponent)); + return dValue; } } // namespace +double XFA_GetFractionalScale(uint32_t idx) { + return fraction_scales[idx]; +} + +int XFA_GetMaxFractionalScale() { + return FX_ArraySize(fraction_scales); +} + CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { CXFA_Node* pNodeValue = pWidgetData->GetNode()->GetChild(0, XFA_Element::Value); diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h index 73f6101f3e..c40fdf1b18 100644 --- a/xfa/fxfa/parser/xfa_utils.h +++ b/xfa/fxfa/parser/xfa_utils.h @@ -17,6 +17,9 @@ class CXFA_LocaleValue; class CXFA_Node; class CXFA_WidgetData; +double XFA_GetFractionalScale(uint32_t idx); +int XFA_GetMaxFractionalScale(); + bool XFA_FDEExtension_ResolveNamespaceQualifier( CFDE_XMLElement* pNode, const CFX_WideStringC& wsQualifier, |