summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp2
-rw-r--r--xfa/fxfa/cxfa_pdffontmgr.cpp25
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp39
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp33
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_localevalue.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp13
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp14
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp43
10 files changed, 112 insertions, 97 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index ff20188a92..95faeb3606 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -279,7 +279,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
wsValidateStr = pValidateNode->GetContent();
}
- if (wsValidateStr.Find(L"preSubmit") == FX_STRNPOS)
+ if (!wsValidateStr.Contains(L"preSubmit"))
return XFA_EVENTERROR_Success;
}
diff --git a/xfa/fxfa/cxfa_pdffontmgr.cpp b/xfa/fxfa/cxfa_pdffontmgr.cpp
index af94ee8c82..5872078fdf 100644
--- a/xfa/fxfa/cxfa_pdffontmgr.cpp
+++ b/xfa/fxfa/cxfa_pdffontmgr.cpp
@@ -121,30 +121,29 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
CFX_ByteString bsDRName = bsDRFontName;
bsDRName.Remove('-');
FX_STRSIZE iPsLen = bsPsName.GetLength();
- FX_STRSIZE nIndex = bsDRName.Find(bsPsName);
- if (nIndex != FX_STRNPOS && !bStrictMatch)
+ auto nIndex = bsDRName.Find(bsPsName);
+ if (nIndex.has_value() && !bStrictMatch)
return true;
- if (nIndex != 0)
+ if (!nIndex.has_value() || nIndex.value() != 0)
return false;
int32_t iDifferLength = bsDRName.GetLength() - iPsLen;
if (iDifferLength > 1 || (bBold || bItalic)) {
- FX_STRSIZE iBoldIndex = bsDRName.Find("Bold");
- bool bBoldFont = iBoldIndex != FX_STRNPOS;
- if (bBold != bBoldFont)
+ auto iBoldIndex = bsDRName.Find("Bold");
+ if (bBold != iBoldIndex.has_value())
return false;
- if (bBoldFont) {
- iDifferLength =
- std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4);
+ if (iBoldIndex.has_value()) {
+ iDifferLength = std::min(iDifferLength - 4,
+ bsDRName.GetLength() - iBoldIndex.value() - 4);
}
bool bItalicFont = true;
- if (bsDRName.Find("Italic") != FX_STRNPOS) {
+ if (bsDRName.Contains("Italic")) {
iDifferLength -= 6;
- } else if (bsDRName.Find("It") != FX_STRNPOS) {
+ } else if (bsDRName.Contains("It")) {
iDifferLength -= 2;
- } else if (bsDRName.Find("Oblique") != FX_STRNPOS) {
+ } else if (bsDRName.Contains("Oblique")) {
iDifferLength -= 7;
} else {
bItalicFont = false;
@@ -158,7 +157,7 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
bsDRTailer == "Regular" || bsDRTailer == "Reg") {
return true;
}
- if (bBoldFont || bItalicFont)
+ if (iBoldIndex.has_value() || bItalicFont)
return false;
bool bMatch = false;
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 5912d26a99..a028538198 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -374,8 +374,9 @@ bool PatternStringType(const CFX_ByteStringC& szPattern,
return true;
}
if (L"date" == wsPattern.Left(4)) {
- FX_STRSIZE ret = wsPattern.Find(L"time");
- patternType = ret != 0 && ret != FX_STRNPOS ? XFA_VT_DATETIME : XFA_VT_DATE;
+ auto pos = wsPattern.Find(L"time");
+ patternType =
+ pos.has_value() && pos.value() != 0 ? XFA_VT_DATETIME : XFA_VT_DATE;
return true;
}
if (L"time" == wsPattern.Left(4)) {
@@ -1139,12 +1140,12 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
CXFA_Document* pDoc = pContext->GetDocument();
CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
CFX_ByteString szArgString = ValueToUTF8String(argOne.get());
- FX_STRSIZE pos = szArgString.Find('T', 0);
- szArgString = szArgString.Right(szArgString.GetLength() - (pos + 1));
- if (szArgString.IsEmpty()) {
+ auto pos = szArgString.Find('T', 0);
+ if (!pos.has_value() || pos.value() == szArgString.GetLength() - 1) {
args.GetReturnValue()->SetInteger(0);
return;
}
+ szArgString = szArgString.Right(szArgString.GetLength() - (pos.value() + 1));
CXFA_LocaleValue timeValue(
XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), pMgr);
@@ -3077,8 +3078,8 @@ void CXFA_FM2JSContext::At(CFXJSE_Value* pThis,
}
CFX_ByteString stringOne = ValueToUTF8String(argOne.get());
- FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC());
- args.GetReturnValue()->SetInteger(iPosition + 1);
+ auto pos = stringOne.Find(stringTwo.AsStringC());
+ args.GetReturnValue()->SetInteger(pos.has_value() ? pos.value() + 1 : 0);
}
// static
@@ -3689,13 +3690,18 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
if (!PatternStringType(szPattern.AsStringC(), patternType)) {
switch (patternType) {
case XFA_VT_DATETIME: {
- FX_STRSIZE iTChar = wsPattern.Find(L'T');
+ auto iTChar = wsPattern.Find(L'T');
+ if (!iTChar.has_value()) {
+ args.GetReturnValue()->SetString("");
+ return;
+ }
CFX_WideString wsDatePattern(L"date{");
- wsDatePattern += wsPattern.Left(iTChar) + L"} ";
+ wsDatePattern += wsPattern.Left(iTChar.value()) + L"} ";
CFX_WideString wsTimePattern(L"time{");
wsTimePattern +=
- wsPattern.Right(wsPattern.GetLength() - (iTChar + 1)) + L"}";
+ wsPattern.Right(wsPattern.GetLength() - (iTChar.value() + 1)) +
+ L"}";
wsPattern = wsDatePattern + wsTimePattern;
} break;
case XFA_VT_DATE: {
@@ -3878,11 +3884,16 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
switch (patternType) {
case XFA_VT_DATETIME: {
- FX_STRSIZE iTChar = wsPattern.Find(L'T');
- CFX_WideString wsDatePattern(L"date{" + wsPattern.Left(iTChar) + L"} ");
+ auto iTChar = wsPattern.Find(L'T');
+ if (!iTChar.has_value()) {
+ args.GetReturnValue()->SetString("");
+ return;
+ }
+ CFX_WideString wsDatePattern(L"date{" + wsPattern.Left(iTChar.value()) +
+ L"} ");
CFX_WideString wsTimePattern(
- L"time{" + wsPattern.Right(wsPattern.GetLength() - (iTChar + 1)) +
- L"}");
+ L"time{" +
+ wsPattern.Right(wsPattern.GetLength() - (iTChar.value() + 1)) + L"}");
wsPattern = wsDatePattern + wsTimePattern;
CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
pMgr);
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index b502bbdfa7..05586e12dd 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -226,14 +226,14 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
std::vector<CFX_WideString> wsSelTextArray;
FX_STRSIZE iStart = 0;
- FX_STRSIZE iEnd = wsRawValue.Find(L'\n', iStart);
- iEnd = (iEnd == FX_STRNPOS) ? wsRawValue.GetLength() : iEnd;
- while (iEnd != FX_STRNPOS && iEnd >= iStart) {
- wsSelTextArray.push_back(wsRawValue.Mid(iStart, iEnd - iStart));
- iStart = iEnd + 1;
+ auto iEnd = wsRawValue.Find(L'\n', iStart);
+ iEnd = !iEnd.has_value() ? wsRawValue.GetLength() : iEnd;
+ while (iEnd.has_value() && iEnd >= iStart) {
+ wsSelTextArray.push_back(
+ wsRawValue.Mid(iStart, iEnd.value() - iStart));
+ iStart = iEnd.value() + 1;
if (iStart >= wsRawValue.GetLength())
break;
-
iEnd = wsRawValue.Find(L'\n', iStart);
}
CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent);
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index f43deaf145..85d2758467 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -305,15 +305,17 @@ XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber(
wsTemplateURIPrefix) {
return XFA_VERSION_UNKNOWN;
}
- FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength);
- if (nDotPos == FX_STRNPOS)
+ auto nDotPos = wsTemplateNS.Find('.', nPrefixLength);
+ if (!nDotPos.has_value())
return XFA_VERSION_UNKNOWN;
int8_t iMajor = FXSYS_wtoi(
- wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength).c_str());
- int8_t iMinor = FXSYS_wtoi(
- wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2)
- .c_str());
+ wsTemplateNS.Mid(nPrefixLength, nDotPos.value() - nPrefixLength).c_str());
+ int8_t iMinor =
+ FXSYS_wtoi(wsTemplateNS
+ .Mid(nDotPos.value() + 1,
+ wsTemplateNS.GetLength() - nDotPos.value() - 2)
+ .c_str());
XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor);
if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX)
return XFA_VERSION_UNKNOWN;
@@ -367,20 +369,21 @@ void CXFA_Document::DoProtoMerge() {
CFX_WideStringC wsURI, wsID, wsSOM;
if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
!wsUseVal.IsEmpty()) {
- FX_STRSIZE uSharpPos = wsUseVal.Find('#');
- if (uSharpPos == FX_STRNPOS) {
+ auto uSharpPos = wsUseVal.Find('#');
+ if (!uSharpPos.has_value()) {
wsURI = wsUseVal.AsStringC();
} else {
- wsURI = CFX_WideStringC(wsUseVal.c_str(), uSharpPos);
+ wsURI = CFX_WideStringC(wsUseVal.c_str(), uSharpPos.value());
FX_STRSIZE uLen = wsUseVal.GetLength();
- if (uLen >= uSharpPos + 5 &&
- CFX_WideStringC(wsUseVal.c_str() + uSharpPos, 5) == L"#som(" &&
+ if (uLen >= uSharpPos.value() + 5 &&
+ CFX_WideStringC(wsUseVal.c_str() + uSharpPos.value(), 5) ==
+ L"#som(" &&
wsUseVal[uLen - 1] == ')') {
- wsSOM = CFX_WideStringC(wsUseVal.c_str() + uSharpPos + 5,
- uLen - 1 - uSharpPos - 5);
+ wsSOM = CFX_WideStringC(wsUseVal.c_str() + uSharpPos.value() + 5,
+ uLen - 1 - uSharpPos.value() - 5);
} else {
- wsID = CFX_WideStringC(wsUseVal.c_str() + uSharpPos + 1,
- uLen - uSharpPos - 1);
+ wsID = CFX_WideStringC(wsUseVal.c_str() + uSharpPos.value() + 1,
+ uLen - uSharpPos.value() - 1);
}
}
} else if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) &&
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index e643bc502f..b02efbb45d 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -148,11 +148,13 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
bool bTargetAllFind = true;
while (iSplitIndex != -1) {
CFX_WideString wsExpr;
- FX_STRSIZE iSplitNextIndex = 0;
+ pdfium::Optional<FX_STRSIZE> iSplitNextIndex = 0;
if (!bTargetAllFind) {
iSplitNextIndex = wsTargetAll.Find(' ', iSplitIndex);
- ASSERT(iSplitNextIndex != FX_STRNPOS);
- wsExpr = wsTargetAll.Mid(iSplitIndex, iSplitNextIndex - iSplitIndex);
+ if (!iSplitNextIndex.has_value())
+ return nullptr;
+ wsExpr =
+ wsTargetAll.Mid(iSplitIndex, iSplitNextIndex.value() - iSplitIndex);
} else {
wsExpr = wsTargetAll;
}
@@ -180,7 +182,7 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
if (iCount > 0 && rs.objects.front()->IsNode())
return rs.objects.front()->AsNode();
}
- iSplitIndex = iSplitNextIndex;
+ iSplitIndex = iSplitNextIndex.value();
}
return nullptr;
}
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index aa0f74b170..dd56e6d7a1 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -49,14 +49,14 @@ bool ValueSplitDateTime(const CFX_WideString& wsDateTime,
if (wsDateTime.IsEmpty())
return false;
- FX_STRSIZE nSplitIndex = wsDateTime.Find('T');
- if (nSplitIndex == FX_STRNPOS)
+ auto nSplitIndex = wsDateTime.Find('T');
+ if (!nSplitIndex.has_value())
nSplitIndex = wsDateTime.Find(' ');
- if (nSplitIndex == FX_STRNPOS)
+ if (!nSplitIndex.has_value())
return false;
- wsDate = wsDateTime.Left(nSplitIndex);
- wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1);
+ wsDate = wsDateTime.Left(nSplitIndex.value());
+ wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex.value() - 1);
return true;
}
@@ -444,7 +444,7 @@ bool CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate,
if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2)
return false;
- const bool bSymbol = wsDate.Find(0x2D) != FX_STRNPOS;
+ const bool bSymbol = wsDate.Contains(0x2D);
uint16_t wYear = 0;
uint16_t wMonth = 0;
uint16_t wDay = 0;
@@ -519,7 +519,7 @@ bool CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) {
const uint16_t wCountM = 2;
const uint16_t wCountS = 2;
const uint16_t wCountF = 3;
- const bool bSymbol = wsTime.Find(':') != FX_STRNPOS;
+ const bool bSymbol = wsTime.Contains(':');
uint16_t wHour = 0;
uint16_t wMinute = 0;
uint16_t wSecond = 0;
@@ -558,8 +558,8 @@ bool CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) {
wSecond = pTime[nIndex] - '0' + wSecond * 10;
nIndex++;
}
- FX_STRSIZE ret = wsTime.Find('.');
- if (ret && ret != FX_STRNPOS) {
+ auto pos = wsTime.Find('.');
+ if (pos.has_value() && pos.value() != 0) {
if (pTime[nIndex] != '.')
return false;
nIndex++;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 2b4bdd22c0..eea7fb2489 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -4045,16 +4045,17 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
if (!wsContent.IsEmpty()) {
FX_STRSIZE iStart = 0;
FX_STRSIZE iLength = wsContent.GetLength();
- FX_STRSIZE iEnd = wsContent.Find(L'\n', iStart);
- iEnd = (iEnd == FX_STRNPOS) ? iLength : iEnd;
- while (iEnd >= iStart) {
- wsSaveTextArray.push_back(wsContent.Mid(iStart, iEnd - iStart));
- iStart = iEnd + 1;
+ auto iEnd = wsContent.Find(L'\n', iStart);
+ iEnd = !iEnd.has_value() ? iLength : iEnd;
+ while (iEnd.value() >= iStart) {
+ wsSaveTextArray.push_back(
+ wsContent.Mid(iStart, iEnd.value() - iStart));
+ iStart = iEnd.value() + 1;
if (iStart >= iLength) {
break;
}
iEnd = wsContent.Find(L'\n', iStart);
- if (iEnd == FX_STRNPOS) {
+ if (!iEnd.has_value()) {
wsSaveTextArray.push_back(
wsContent.Mid(iStart, iLength - iStart));
}
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 39dc858b9e..ee2a2444fc 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -92,12 +92,12 @@ bool MatchNodeName(CFX_XMLNode* pNode,
bool GetAttributeLocalName(const CFX_WideStringC& wsAttributeName,
CFX_WideString& wsLocalAttrName) {
CFX_WideString wsAttrName(wsAttributeName);
- FX_STRSIZE iFind = wsAttrName.Find(L':', 0);
- if (iFind == FX_STRNPOS) {
+ auto pos = wsAttrName.Find(L':', 0);
+ if (!pos.has_value()) {
wsLocalAttrName = wsAttrName;
return false;
}
- wsLocalAttrName = wsAttrName.Right(wsAttrName.GetLength() - iFind - 1);
+ wsLocalAttrName = wsAttrName.Right(wsAttrName.GetLength() - pos.value() - 1);
return true;
}
@@ -133,17 +133,17 @@ bool FindAttributeWithNS(CFX_XMLElement* pElement,
CFX_WideString wsAttrNS;
for (auto it : pElement->GetAttributes()) {
- FX_STRSIZE iFind = it.first.Find(L':', 0);
+ auto pos = it.first.Find(L':', 0);
CFX_WideString wsNSPrefix;
- if (iFind == FX_STRNPOS) {
+ if (!pos.has_value()) {
if (wsLocalAttributeName != it.first)
continue;
} else {
if (wsLocalAttributeName !=
- it.first.Right(it.first.GetLength() - iFind - 1)) {
+ it.first.Right(it.first.GetLength() - pos.value() - 1)) {
continue;
}
- wsNSPrefix = it.first.Left(iFind);
+ wsNSPrefix = it.first.Left(pos.value());
}
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 5b9f62c93f..2da8820b67 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -42,18 +42,18 @@ bool SplitDateTime(const CFX_WideString& wsDateTime,
if (wsDateTime.IsEmpty())
return false;
- FX_STRSIZE nSplitIndex = wsDateTime.Find('T');
- if (nSplitIndex == FX_STRNPOS)
+ auto nSplitIndex = wsDateTime.Find('T');
+ if (!nSplitIndex.has_value())
nSplitIndex = wsDateTime.Find(' ');
- if (nSplitIndex == FX_STRNPOS)
+ if (!nSplitIndex.has_value())
return false;
- wsDate = wsDateTime.Left(nSplitIndex);
+ wsDate = wsDateTime.Left(nSplitIndex.value());
if (!wsDate.IsEmpty()) {
if (!std::any_of(wsDate.begin(), wsDate.end(), std::iswdigit))
return false;
}
- wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1);
+ wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex.value() - 1);
if (!wsTime.IsEmpty()) {
if (!std::any_of(wsTime.begin(), wsTime.end(), std::iswdigit))
return false;
@@ -849,15 +849,15 @@ std::vector<CFX_WideString> CXFA_WidgetData::GetSelectedItemsValue() {
if (!wsValue.IsEmpty()) {
FX_STRSIZE iStart = 0;
FX_STRSIZE iLength = wsValue.GetLength();
- FX_STRSIZE iEnd = wsValue.Find(L'\n', iStart);
- iEnd = (iEnd == FX_STRNPOS) ? iLength : iEnd;
+ auto iEnd = wsValue.Find(L'\n', iStart);
+ iEnd = (!iEnd.has_value()) ? iLength : iEnd;
while (iEnd >= iStart) {
- wsSelTextArray.push_back(wsValue.Mid(iStart, iEnd - iStart));
- iStart = iEnd + 1;
+ wsSelTextArray.push_back(wsValue.Mid(iStart, iEnd.value() - iStart));
+ iStart = iEnd.value() + 1;
if (iStart >= iLength)
break;
iEnd = wsValue.Find(L'\n', iStart);
- if (iEnd == FX_STRNPOS)
+ if (!iEnd.has_value())
wsSelTextArray.push_back(wsValue.Mid(iStart, iLength - iStart));
}
}
@@ -1315,15 +1315,16 @@ bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideString wsWideNarrowRatio;
if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) {
- FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':');
+ auto ptPos = wsWideNarrowRatio.Find(':');
float fRatio = 0;
- if (ptPos != FX_STRNPOS) {
+ if (!ptPos.has_value()) {
fRatio = (float)FXSYS_wtoi(wsWideNarrowRatio.c_str());
} else {
int32_t fA, fB;
- fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos).c_str());
+ fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos.value()).c_str());
fB = FXSYS_wtoi(
- wsWideNarrowRatio.Right(wsWideNarrowRatio.GetLength() - (ptPos + 1))
+ wsWideNarrowRatio
+ .Right(wsWideNarrowRatio.GetLength() - (ptPos.value() + 1))
.c_str());
if (fB)
fRatio = (float)fA / fB;
@@ -1742,9 +1743,8 @@ void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue,
wsOutput = wsValue;
wsOutput.TrimLeft('0');
- FX_STRSIZE dot_index = wsOutput.Find('.');
int32_t iFracDigits = 0;
- if (!wsOutput.IsEmpty() && dot_index != FX_STRNPOS &&
+ if (!wsOutput.IsEmpty() && wsOutput.Contains('.') &&
(!GetFracDigits(iFracDigits) || iFracDigits != -1)) {
wsOutput.TrimRight(L"0");
wsOutput.TrimRight(L".");
@@ -1768,13 +1768,12 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
wsSrcNum.Delete(0, 1);
}
int32_t len = wsSrcNum.GetLength();
- FX_STRSIZE dot_index = wsSrcNum.Find('.');
- if (dot_index == FX_STRNPOS)
- dot_index = len;
+ auto dot_index = wsSrcNum.Find('.');
+ dot_index = !dot_index.has_value() ? len : dot_index;
- int32_t cc = dot_index - 1;
+ int32_t cc = dot_index.value() - 1;
if (cc >= 0) {
- int nPos = dot_index % 3;
+ int nPos = dot_index.value() % 3;
wsOutput.clear();
for (int32_t i = 0; i < dot_index; i++) {
if (i % 3 == nPos && i != 0)
@@ -1784,7 +1783,7 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
}
if (dot_index < len) {
wsOutput += pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
- wsOutput += wsSrcNum.Right(len - dot_index - 1);
+ wsOutput += wsSrcNum.Right(len - dot_index.value() - 1);
}
if (bNeg) {
wsOutput =