summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-16 16:37:37 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-17 15:42:24 +0000
commite30e9cc05b62b046e5299ecc058957d93d2c68ea (patch)
tree28c192b5ecec3ca490082e0bfe435e895cf67dc4 /xfa
parentb3e7bfa6ed35651a22df314352883ccb44a7203d (diff)
downloadpdfium-e30e9cc05b62b046e5299ecc058957d93d2c68ea.tar.xz
Unify GetTextLength and GetTextBufLength in CFDE_TxtEdtEngine
The GetTextLength method just proxies to GetTextBufLength. This CL removes GetTextBufLength and puts the functionality into GetTextLength. Change-Id: If324fbeddd05cd63570b6942dc613e273a1fbce7 Reviewed-on: https://pdfium-review.googlesource.com/11272 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp24
-rw-r--r--xfa/fde/cfde_txtedtengine.h3
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp8
3 files changed, 17 insertions, 18 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index c02676fdf3..a3d743ca02 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -218,7 +218,7 @@ void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
CFX_WideString CFDE_TxtEdtEngine::GetText(int32_t nStart,
int32_t nCount) const {
- int32_t nTextBufLength = GetTextBufLength();
+ int32_t nTextBufLength = GetTextLength();
if (nCount == -1)
nCount = nTextBufLength - nStart;
@@ -231,7 +231,7 @@ void CFDE_TxtEdtEngine::ClearText() {
if (IsLocked())
return;
- int32_t len = GetTextBufLength();
+ int32_t len = GetTextLength();
if (len == 0)
return;
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
@@ -249,7 +249,7 @@ int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, bool bBefore) {
if (IsLocked())
return 0;
- ASSERT(nIndex >= 0 && nIndex <= GetTextBufLength());
+ ASSERT(nIndex >= 0 && nIndex <= GetTextLength());
if (!pdfium::IndexInBounds(m_PagePtrArray, m_nCaretPage))
return 0;
@@ -350,7 +350,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
wsTemp.ReleaseBuffer(nLength);
bool bPart = false;
if (m_nLimit > 0) {
- int32_t nTotalLength = GetTextBufLength();
+ int32_t nTotalLength = GetTextLength();
for (const auto& lpSelRange : m_SelRangePtrArr)
nTotalLength -= lpSelRange->nCount;
@@ -445,10 +445,10 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) {
}
nStart--;
} else {
- if (nStart == GetTextBufLength()) {
+ if (nStart == GetTextLength()) {
return FDE_TXTEDT_MODIFY_RET_F_Full;
}
- if ((nStart + 1 < GetTextBufLength()) &&
+ if ((nStart + 1 < GetTextLength()) &&
(m_pTxtBuf->GetCharByIndex(nStart) == L'\r') &&
(m_pTxtBuf->GetCharByIndex(nStart + 1) == L'\n')) {
nCount++;
@@ -611,7 +611,7 @@ int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
CFX_WideString CFDE_TxtEdtEngine::GetPreDeleteText(int32_t nIndex,
int32_t nLength) {
- CFX_WideString wsText = GetText(0, GetTextBufLength());
+ CFX_WideString wsText = GetText(0, GetTextLength());
wsText.Delete(nIndex, nLength);
return wsText;
}
@@ -619,7 +619,7 @@ CFX_WideString CFDE_TxtEdtEngine::GetPreDeleteText(int32_t nIndex,
CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex,
const wchar_t* lpText,
int32_t nLength) {
- CFX_WideString wsText = GetText(0, GetTextBufLength());
+ CFX_WideString wsText = GetText(0, GetTextLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
int32_t nSelCount = CountSelRanges();
@@ -645,7 +645,7 @@ CFX_WideString CFDE_TxtEdtEngine::GetPreReplaceText(int32_t nIndex,
int32_t nOriginLength,
const wchar_t* lpText,
int32_t nLength) {
- CFX_WideString wsText = GetText(0, GetTextBufLength());
+ CFX_WideString wsText = GetText(0, GetTextLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
int32_t nSelCount = CountSelRanges();
@@ -1164,10 +1164,10 @@ bool CFDE_TxtEdtEngine::MoveLineEnd() {
}
}
nIndex = nStart + nCount - 1;
- ASSERT(nIndex <= GetTextBufLength());
+ ASSERT(nIndex <= GetTextLength());
wchar_t wChar = m_pTxtBuf->GetCharByIndex(nIndex);
bool bBefore = false;
- if (nIndex <= GetTextBufLength()) {
+ if (nIndex <= GetTextLength()) {
if (wChar == L'\r') {
bBefore = true;
} else if (wChar == L'\n' && nIndex > nStart) {
@@ -1190,7 +1190,7 @@ bool CFDE_TxtEdtEngine::MoveHome() {
}
bool CFDE_TxtEdtEngine::MoveEnd() {
- UpdateCaretRect(GetTextBufLength(), true);
+ UpdateCaretRect(GetTextLength(), true);
return true;
}
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index c68227b243..19aed3fe7b 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -100,7 +100,7 @@ class CFDE_TxtEdtEngine {
CFDE_TxtEdtPage* GetPage(int32_t nIndex);
void SetText(const CFX_WideString& wsText);
- int32_t GetTextLength() const { return GetTextBufLength(); }
+ int32_t GetTextLength() const { return m_pTxtBuf->GetTextLength() - 1; }
CFX_WideString GetText(int32_t nStart, int32_t nCount) const;
void ClearText();
@@ -136,7 +136,6 @@ class CFDE_TxtEdtEngine {
return m_ParagPtrArray[nParagIndex].get();
}
CFDE_TxtEdtBuf* GetTextBuf() const { return m_pTxtBuf.get(); }
- int32_t GetTextBufLength() const { return m_pTxtBuf->GetTextLength() - 1; }
CFX_TxtBreak* GetTextBreak() const { return m_pTextBreak.get(); }
int32_t GetLineCount() const { return m_nLineCount; }
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index e00d2daa79..cbc652da76 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -92,9 +92,9 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) {
for (int32_t j = 0; j < nRtCount; j++) {
if (rectArr[j].Contains(ptF)) {
nCaret = m_nPageStart + pPiece->nStart + j;
- if (nCaret >= m_pEditEngine->GetTextBufLength()) {
+ if (nCaret >= m_pEditEngine->GetTextLength()) {
bBefore = true;
- return m_pEditEngine->GetTextBufLength();
+ return m_pEditEngine->GetTextLength();
}
wchar_t wChar = m_pEditEngine->GetTextBuf()->GetCharByIndex(nCaret);
if (wChar == L'\n' || wChar == L'\r') {
@@ -165,8 +165,8 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
bool bBefore;
int32_t nIndex = GetCharIndex(fPoint, bBefore);
- if (nIndex == m_pEditEngine->GetTextBufLength()) {
- nIndex = m_pEditEngine->GetTextBufLength() - 1;
+ if (nIndex == m_pEditEngine->GetTextLength()) {
+ nIndex = m_pEditEngine->GetTextLength() - 1;
}
if (nIndex < 0) {
return -1;