summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-28 14:07:04 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-28 18:21:44 +0000
commite7a99de4f711302d57fe22682a9a8c3cfddb458c (patch)
tree7bb176d42e2a2181f014b41bd621d6b242ed20e7
parent106eecd27f346a0bc7f11f29a058a8fd16a77682 (diff)
downloadpdfium-e7a99de4f711302d57fe22682a9a8c3cfddb458c.tar.xz
Convert calls to Mid() to Left() or Right() if possible
The various string/byte classes support Mid(), Left(), and Right() for extracting substrings. Mid() can handle all possible cases, but Left() and Right() are useful for common cases and more explicit about what is going on. Calls like Mid(offset, length - offset) can be converted to Right(length - offset). Calls like Mid(0, length) can be converted to Left(length). If the substring being extracted does not extend all the way to one of the edges of the string, then Mid() still needs to be used. BUG=pdfium:828 Change-Id: I2ec46ad3d71aac0f7b513e103c69cbe8c854cf62 Reviewed-on: https://pdfium-review.googlesource.com/9510 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp6
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp4
-rw-r--r--core/fpdftext/cpdf_linkextract.cpp2
-rw-r--r--core/fpdftext/cpdf_textpage.cpp4
-rw-r--r--core/fpdftext/cpdf_textpagefind.cpp2
-rw-r--r--core/fxcrt/xml/cxml_parser.cpp4
-rw-r--r--core/fxge/cfx_fontmapper.cpp6
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp2
-rw-r--r--fpdfsdk/fpdfppo.cpp4
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp10
-rw-r--r--fxbarcode/cbc_ean13.cpp2
-rw-r--r--fxbarcode/cbc_ean8.cpp2
-rw-r--r--fxbarcode/cbc_upca.cpp2
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp7
-rw-r--r--fxbarcode/oned/BC_OnedEAN13Writer.cpp4
-rw-r--r--fxbarcode/oned/BC_OnedEAN8Writer.cpp2
-rw-r--r--fxbarcode/oned/BC_OnedUPCAWriter.cpp2
-rw-r--r--fxbarcode/qrcode/BC_QRCoderEncoder.cpp4
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.cpp2
-rw-r--r--xfa/fwl/cfwl_edit.cpp4
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp8
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp20
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_measurement.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp3
28 files changed, 60 insertions, 66 deletions
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 8c8520f0c4..56a4b13cb3 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -130,7 +130,7 @@ bool CPDF_SimpleFont::LoadCommon() {
}
if (m_pFontFile) {
if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+')
- m_BaseFont = m_BaseFont.Mid(8, m_BaseFont.GetLength() - 8);
+ m_BaseFont = m_BaseFont.Right(m_BaseFont.GetLength() - 8);
} else {
LoadSubstFont();
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 5f571aa8d6..288f9d57a8 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -620,7 +620,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
break;
}
auto word = m_pSyntax->GetWord();
- CFX_ByteString key(word.Mid(1, word.GetLength() - 1));
+ CFX_ByteString key(word.Right(word.GetLength() - 1));
auto pObj = m_pSyntax->ReadNextObject(false, false, 0);
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
@@ -1186,7 +1186,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
}
if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") {
CFX_ByteString defname = "Default";
- defname += name.Mid(7, name.GetLength() - 7);
+ defname += name.Right(name.GetLength() - 7);
CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
if (!pDefObj) {
if (name == "DeviceGray") {
@@ -1525,7 +1525,7 @@ uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData,
break;
case CPDF_StreamParser::Name: {
auto word = syntax.GetWord();
- AddNameParam(word.Mid(1, word.GetLength() - 1));
+ AddNameParam(word.Right(word.GetLength() - 1));
break;
}
default:
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 83c1f65587..956f91289b 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -66,7 +66,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
return false;
CPDF_Dictionary* pFontDict =
- pDRFontDict->GetDictFor(sFontName.Mid(1, sFontName.GetLength() - 1));
+ pDRFontDict->GetDictFor(sFontName.Right(sFontName.GetLength() - 1));
if (!pFontDict) {
pFontDict = pDoc->NewIndirect<CPDF_Dictionary>();
pFontDict->SetNewFor<CPDF_Name>("Type", "Font");
@@ -74,7 +74,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
pFontDict->SetNewFor<CPDF_Name>("BaseFont", "Helvetica");
pFontDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding");
pDRFontDict->SetNewFor<CPDF_Reference>(
- sFontName.Mid(1, sFontName.GetLength() - 1), pDoc,
+ sFontName.Right(sFontName.GetLength() - 1), pDoc,
pFontDict->GetObjNum());
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index 5179f732c9..e0bd4ae49f 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -154,7 +154,7 @@ void CPDF_LinkExtract::ParseLink() {
while (strBeCheck.GetLength() > 0) {
wchar_t ch = strBeCheck.GetAt(strBeCheck.GetLength() - 1);
if (ch == L')' || ch == L',' || ch == L'>' || ch == L'.') {
- strBeCheck = strBeCheck.Mid(0, strBeCheck.GetLength() - 1);
+ strBeCheck = strBeCheck.Left(strBeCheck.GetLength() - 1);
nCount--;
} else {
break;
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 1dc03db4ff..8f0e376dbc 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -441,8 +441,8 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (nCount == -1) {
nCount = pdfium::CollectionSize<int>(m_CharList) - start;
- return CFX_WideString(
- m_TextBuf.AsStringC().Mid(start, m_TextBuf.AsStringC().GetLength()));
+ CFX_WideStringC wsTextBuf = m_TextBuf.AsStringC();
+ return CFX_WideString(wsTextBuf.Right(wsTextBuf.GetLength() - start));
}
if (nCount <= 0 || m_CharList.empty())
return L"";
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index 058c293ac1..fe610abcd4 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -300,7 +300,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
continue;
}
if (pos > 0)
- m_csFindWhatArray.push_back(csWord.Mid(0, pos));
+ m_csFindWhatArray.push_back(csWord.Left(pos));
m_csFindWhatArray.push_back(curStr);
if (pos == csWord.GetLength() - 1) {
csWord.clear();
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index 0166ea8490..5ac1f82206 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -86,8 +86,8 @@ void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
if (iStart == -1) {
bsName = bsFullName;
} else {
- bsSpace = bsFullName.Mid(0, iStart);
- bsName = bsFullName.Mid(iStart + 1, bsFullName.GetLength() - (iStart + 1));
+ bsSpace = bsFullName.Left(iStart);
+ bsName = bsFullName.Right(bsFullName.GetLength() - (iStart + 1));
}
}
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 5c7b602fed..4c0073ab73 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -432,7 +432,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
CFX_ByteString SubstName = name;
SubstName.Remove(' ');
if (bTrueType && name[0] == '@')
- SubstName = name.Mid(1, name.GetLength() - 1);
+ SubstName = name.Right(name.GetLength() - 1);
PDF_GetStandardFontName(&SubstName);
if (SubstName == "Symbol" && !bTrueType) {
pSubstFont->m_Family = "Chrome Symbol";
@@ -453,7 +453,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
if (find >= 0) {
family = SubstName.Left(find);
PDF_GetStandardFontName(&family);
- style = SubstName.Mid(find + 1, SubstName.GetLength() - (find + 1));
+ style = SubstName.Right(SubstName.GetLength() - (find + 1));
bHasComma = true;
} else {
family = SubstName;
@@ -480,7 +480,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
if (!bHasComma) {
find = family.ReverseFind('-');
if (find >= 0) {
- style = family.Mid(find + 1, family.GetLength() - (find + 1));
+ style = family.Right(family.GetLength() - (find + 1));
family = family.Left(find);
bHasHyphen = true;
}
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index b195303800..577faf4b8f 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -221,7 +221,7 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString* sAlias) {
CFX_ByteString sFontName(syntax.GetWord());
CFX_ByteString sDecodedFontName = PDF_NameDecode(sFontName);
- *sAlias = sDecodedFontName.Mid(1, sDecodedFontName.GetLength() - 1);
+ *sAlias = sDecodedFontName.Right(sDecodedFontName.GetLength() - 1);
CPDF_Dictionary* pFontDict = nullptr;
if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictFor("AP")) {
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index d05fab9c0b..bc3d769574 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -91,7 +91,7 @@ bool ParserPageRangeString(CFX_ByteString rangstring,
nStringTo = rangstring.Find(',', nStringFrom);
if (nStringTo == -1)
nStringTo = nLength;
- cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom);
+ cbMidRange = rangstring.Right(nStringTo - nStringFrom);
int nMid = cbMidRange.Find('-');
if (nMid == -1) {
long lPageNum = atol(cbMidRange.c_str());
@@ -99,7 +99,7 @@ bool ParserPageRangeString(CFX_ByteString rangstring,
return false;
pageArray->push_back((uint16_t)lPageNum);
} else {
- int nStartPageNum = atol(cbMidRange.Mid(0, nMid).c_str());
+ int nStartPageNum = atol(cbMidRange.Left(nMid).c_str());
if (nStartPageNum == 0)
return false;
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index bf84b9cd91..06ed64c7cc 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -980,11 +980,10 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime,
}
}
- CFX_WideString wprefix = wstrValue.Mid(0, pEvent->SelStart());
+ CFX_WideString wprefix = wstrValue.Left(pEvent->SelStart());
CFX_WideString wpostfix;
if (pEvent->SelEnd() < wstrValue.GetLength())
- wpostfix = wstrValue.Mid(pEvent->SelEnd(),
- wstrValue.GetLength() - pEvent->SelEnd());
+ wpostfix = wstrValue.Right(wstrValue.GetLength() - pEvent->SelEnd());
val = wprefix + wstrChange + wpostfix;
return true;
}
@@ -1532,14 +1531,13 @@ bool CJS_PublicMethods::AFMergeChange(CJS_Runtime* pRuntime,
CFX_WideString prefix, postfix;
if (pEventHandler->SelStart() >= 0)
- prefix = swValue.Mid(0, pEventHandler->SelStart());
+ prefix = swValue.Left(pEventHandler->SelStart());
else
prefix = L"";
if (pEventHandler->SelEnd() >= 0 &&
pEventHandler->SelEnd() <= swValue.GetLength())
- postfix = swValue.Mid(pEventHandler->SelEnd(),
- swValue.GetLength() - pEventHandler->SelEnd());
+ postfix = swValue.Right(swValue.GetLength() - pEventHandler->SelEnd());
else
postfix = L"";
diff --git a/fxbarcode/cbc_ean13.cpp b/fxbarcode/cbc_ean13.cpp
index 1c57a877f2..ac08a9d53e 100644
--- a/fxbarcode/cbc_ean13.cpp
+++ b/fxbarcode/cbc_ean13.cpp
@@ -45,7 +45,7 @@ CFX_WideString CBC_EAN13::Preprocess(const CFX_WideStringC& contents) {
encodeContents = byteString.UTF8Decode();
}
if (length > 13)
- encodeContents = encodeContents.Mid(0, 13);
+ encodeContents = encodeContents.Left(13);
return encodeContents;
}
diff --git a/fxbarcode/cbc_ean8.cpp b/fxbarcode/cbc_ean8.cpp
index 3b4369e80f..ce2cf2ba79 100644
--- a/fxbarcode/cbc_ean8.cpp
+++ b/fxbarcode/cbc_ean8.cpp
@@ -43,7 +43,7 @@ CFX_WideString CBC_EAN8::Preprocess(const CFX_WideStringC& contents) {
encodeContents += wchar_t(checksum - 0 + '0');
}
if (length > 8)
- encodeContents = encodeContents.Mid(0, 8);
+ encodeContents = encodeContents.Left(8);
return encodeContents;
}
diff --git a/fxbarcode/cbc_upca.cpp b/fxbarcode/cbc_upca.cpp
index 6c2e08a9fb..85b5d549ab 100644
--- a/fxbarcode/cbc_upca.cpp
+++ b/fxbarcode/cbc_upca.cpp
@@ -44,7 +44,7 @@ CFX_WideString CBC_UPCA::Preprocess(const CFX_WideStringC& contents) {
encodeContents = byteString.UTF8Decode();
}
if (length > 12)
- encodeContents = encodeContents.Mid(0, 12);
+ encodeContents = encodeContents.Left(12);
return encodeContents;
}
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index ec527d29a8..6034173ee4 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -76,13 +76,12 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
return CFX_WideString();
context.setAllowRectangular(allowRectangular);
- if ((msg.Mid(0, 6) == MACRO_05_HEADER) &&
- (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) {
+ if ((msg.Left(6) == MACRO_05_HEADER) && (msg.Right(1) == MACRO_TRAILER)) {
context.writeCodeword(MACRO_05);
context.setSkipAtEnd(2);
context.m_pos += 6;
- } else if ((msg.Mid(0, 6) == MACRO_06_HEADER) &&
- (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) {
+ } else if ((msg.Left(6) == MACRO_06_HEADER) &&
+ (msg.Right(1) == MACRO_TRAILER)) {
context.writeCodeword(MACRO_06);
context.setSkipAtEnd(2);
context.m_pos += 6;
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 0e4bab9518..6f1d957a01 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -109,7 +109,7 @@ uint8_t* CBC_OnedEAN13Writer::EncodeImpl(const CFX_ByteString& contents,
return nullptr;
m_iDataLenth = 13;
- int32_t firstDigit = FXSYS_atoi(contents.Mid(0, 1).c_str());
+ int32_t firstDigit = FXSYS_atoi(contents.Left(1).c_str());
int32_t parities = FIRST_DIGIT_ENCODINGS[firstDigit];
outLength = m_codeWidth;
std::unique_ptr<uint8_t, FxFreeDeleter> result(
@@ -219,7 +219,7 @@ bool CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
- tempStr = str.Mid(0, 1);
+ tempStr = str.Left(1);
iLen = tempStr.GetLength();
strWidth = multiple * 7;
strWidth = (int32_t)(strWidth * m_outputHScale);
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index f891c08fc6..9a85f814a7 100644
--- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -159,7 +159,7 @@ bool CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
CFX_ByteString str = FX_UTF8Encode(contents);
int32_t iLength = str.GetLength();
std::vector<FXTEXT_CHARPOS> charpos(iLength);
- CFX_ByteString tempStr = str.Mid(0, 4);
+ CFX_ByteString tempStr = str.Left(4);
int32_t iLen = tempStr.GetLength();
int32_t strWidth = 7 * multiple * 4;
float blank = 0.0;
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 78ada1783a..13514eb53f 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -183,7 +183,7 @@ bool CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
- tempStr = str.Mid(0, 1);
+ tempStr = str.Left(1);
iLen = tempStr.GetLength();
strWidth = (float)multiple * 7;
strWidth = strWidth * m_outputHScale;
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index 955e2c7295..cad70b81c5 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -432,7 +432,7 @@ void SplitString(const CFX_ByteString& content,
index += 2;
}
if (index)
- result->push_back({CBC_QRCoderMode::sGBK, content.Mid(0, index)});
+ result->push_back({CBC_QRCoderMode::sGBK, content.Left(index)});
if (index >= content.GetLength())
return;
@@ -479,7 +479,7 @@ void SplitString(const CFX_ByteString& content,
}
flag = index;
if (index < content.GetLength())
- SplitString(content.Mid(index, content.GetLength() - index), result);
+ SplitString(content.Right(content.GetLength() - index), result);
}
CBC_QRCoderMode* ChooseMode(const CFX_ByteString& content,
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index 0abc86fbf3..f07cce8fd2 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -2242,7 +2242,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
}
if (!bAddNeg && bNeg) {
*wsOutput = pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) +
- (*wsOutput)[0] + wsOutput->Mid(1, wsOutput->GetLength() - 1);
+ (*wsOutput)[0] + wsOutput->Right(wsOutput->GetLength() - 1);
}
return true;
}
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 12786496d4..53fec0576e 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -1152,8 +1152,8 @@ bool CFWL_Edit::ValidateNumberChar(wchar_t cNum) {
return false;
int32_t nLen = wsText.GetLength();
- CFX_WideString l = wsText.Mid(0, caretPos);
- CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos);
+ CFX_WideString l = wsText.Left(caretPos);
+ CFX_WideString r = wsText.Right(nLen - caretPos);
CFX_WideString wsNew = l + cNum + r;
return wsNew.GetInteger() <= m_iMax;
}
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 1910e60e3e..84064efb45 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -1139,7 +1139,7 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
CFX_ByteString szArgString = ValueToUTF8String(argOne.get());
FX_STRSIZE pos = szArgString.Find('T', 0);
- szArgString = szArgString.Mid(pos + 1, szArgString.GetLength() - (pos + 1));
+ szArgString = szArgString.Right(szArgString.GetLength() - (pos + 1));
if (szArgString.IsEmpty()) {
args.GetReturnValue()->SetInteger(0);
return;
@@ -3694,8 +3694,7 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
CFX_WideString wsTimePattern(L"time{");
wsTimePattern +=
- wsPattern.Mid(iTChar + 1, wsPattern.GetLength() - (iTChar + 1)) +
- L"}";
+ wsPattern.Right(wsPattern.GetLength() - (iTChar + 1)) + L"}";
wsPattern = wsDatePattern + wsTimePattern;
} break;
case XFA_VT_DATE: {
@@ -3881,8 +3880,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
FX_STRSIZE iTChar = wsPattern.Find(L'T');
CFX_WideString wsDatePattern(L"date{" + wsPattern.Left(iTChar) + L"} ");
CFX_WideString wsTimePattern(
- L"time{" +
- wsPattern.Mid(iTChar + 1, wsPattern.GetLength() - (iTChar + 1)) +
+ L"time{" + wsPattern.Right(wsPattern.GetLength() - (iTChar + 1)) +
L"}");
wsPattern = wsDatePattern + wsTimePattern;
CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index b201863b25..a74239ff82 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -62,7 +62,7 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"function ";
if (m_wsName.GetAt(0) == L'!') {
CFX_WideString tempName =
- EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1);
javascript << tempName;
} else {
javascript << m_wsName;
@@ -75,7 +75,7 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
if (identifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- identifier.Mid(1, identifier.GetLength() - 1);
+ identifier.Right(identifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << identifier;
@@ -130,7 +130,7 @@ bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
tempName =
- EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1);
}
javascript << tempName;
javascript << L" = ";
@@ -154,7 +154,7 @@ bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
tempName =
- EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1, m_wsName.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1);
}
javascript << tempName;
javascript << L" = ";
@@ -461,7 +461,7 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CFX_WideString tempVariant;
if (m_wsVariant.GetAt(0) == L'!') {
tempVariant = EXCLAMATION_IN_IDENTIFIER +
- m_wsVariant.Mid(1, m_wsVariant.GetLength() - 1);
+ m_wsVariant.Right(m_wsVariant.GetLength() - 1);
javascript << tempVariant;
} else {
tempVariant = m_wsVariant;
@@ -516,7 +516,7 @@ bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CFX_WideString tempVariant;
if (m_wsVariant.GetAt(0) == L'!') {
tempVariant = EXCLAMATION_IN_IDENTIFIER +
- m_wsVariant.Mid(1, m_wsVariant.GetLength() - 1);
+ m_wsVariant.Right(m_wsVariant.GetLength() - 1);
javascript << tempVariant;
} else {
tempVariant = m_wsVariant;
@@ -583,7 +583,7 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -615,7 +615,7 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -640,7 +640,7 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
@@ -671,7 +671,7 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
if (m_wsIdentifier.GetAt(0) == L'!') {
CFX_WideString tempIdentifier =
EXCLAMATION_IN_IDENTIFIER +
- m_wsIdentifier.Mid(1, m_wsIdentifier.GetLength() - 1);
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
javascript << tempIdentifier;
} else {
javascript << m_wsIdentifier;
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 1a3a125032..32876e3b65 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -181,7 +181,7 @@ bool CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
tempStr = L"xfa.template";
} else if (tempStr[0] == L'!') {
tempStr =
- EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1, tempStr.GetLength() - 1);
+ EXCLAMATION_IN_IDENTIFIER + tempStr.Right(tempStr.GetLength() - 1);
}
javascript << tempStr;
return true;
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index e3565835c3..4d6886d7e1 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -162,7 +162,7 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
if (wsExpr.GetAt(0) == '#') {
CXFA_Node* pNode = pDocument->GetNodeByID(
ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)),
- wsExpr.Mid(1, wsExpr.GetLength() - 1).AsStringC());
+ wsExpr.Right(wsExpr.GetLength() - 1).AsStringC());
if (pNode)
return pNode;
} else if (bNewExprStyle) {
diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp
index 50076583bb..66b715ec38 100644
--- a/xfa/fxfa/parser/cxfa_measurement.cpp
+++ b/xfa/fxfa/parser/cxfa_measurement.cpp
@@ -40,8 +40,8 @@ void CXFA_Measurement::SetString(const CFX_WideStringC& wsMeasure) {
int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0;
float fValue = FXSYS_wcstof(wsMeasure.unterminated_c_str() + iOffset,
wsMeasure.GetLength() - iOffset, &iUsedLen);
- XFA_UNIT eUnit = GetUnitFromString(wsMeasure.Mid(
- iOffset + iUsedLen, wsMeasure.GetLength() - (iOffset + iUsedLen)));
+ XFA_UNIT eUnit = GetUnitFromString(
+ wsMeasure.Right(wsMeasure.GetLength() - (iOffset + iUsedLen)));
Set(fValue, eUnit);
}
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1265988902..261fee1971 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -77,7 +77,7 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) {
CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' ||
- wsInstName.Mid(1, wsInstName.GetLength() - 1) != wsName) {
+ wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
return iCount;
}
dwNameHash = pNode->GetNameHash();
@@ -198,7 +198,7 @@ CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) {
CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' ||
- wsInstName.Mid(1, wsInstName.GetLength() - 1) != wsName) {
+ wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
return nullptr;
}
dwNameHash = pNode->GetNameHash();
@@ -2737,7 +2737,7 @@ void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue,
if (pNode->GetElementType() == XFA_Element::InstanceManager) {
CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' &&
- wsInstMgrName.Mid(1, wsInstMgrName.GetLength() - 1) == wsName) {
+ wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
}
break;
@@ -3165,7 +3165,7 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
CFX_WideString wsInstanceName = CFX_WideString(
wsInstManagerName.IsEmpty()
? wsInstManagerName
- : wsInstManagerName.Mid(1, wsInstManagerName.GetLength() - 1));
+ : wsInstManagerName.Right(wsInstManagerName.GetLength() - 1));
uint32_t dInstanceNameHash =
FX_HashCode_GetW(wsInstanceName.AsStringC(), false);
CXFA_Node* pPrevSibling =
@@ -4665,7 +4665,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' &&
- wsInstName.Mid(1, wsInstName.GetLength() - 1) == wsName) {
+ wsInstName.Right(wsInstName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
}
break;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 1920e9f3fd..5efc0ea481 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1324,8 +1324,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
int32_t fA, fB;
fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos).c_str());
fB = FXSYS_wtoi(
- wsWideNarrowRatio
- .Mid(ptPos + 1, wsWideNarrowRatio.GetLength() - (ptPos + 1))
+ wsWideNarrowRatio.Right(wsWideNarrowRatio.GetLength() - (ptPos + 1))
.c_str());
if (fB)
fRatio = (float)fA / fB;