summaryrefslogtreecommitdiff
path: root/xfa/fde/cfde_txtedtengine.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-16 16:37:16 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-17 15:39:14 +0000
commitb3e7bfa6ed35651a22df314352883ccb44a7203d (patch)
tree7d5c4734bb8203f358890d09d2bafc49bc7fa67a /xfa/fde/cfde_txtedtengine.cpp
parent1748c4f6e42cda6ffa6bf32731d2fd525c060cf1 (diff)
downloadpdfium-b3e7bfa6ed35651a22df314352883ccb44a7203d.tar.xz
Cleanup visibilty and unused methods in xfa/fde
This CL fixes the visibility of some methods in xfa/fde along with removing unused methods. Unused params are also removed. Change-Id: Ic6e6d2ac8d07dc4bdabb3e0121831e4bf3fbb8ec Reviewed-on: https://pdfium-review.googlesource.com/11271 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/cfde_txtedtengine.cpp')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp102
1 files changed, 15 insertions, 87 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index e2cfaf653d..c02676fdf3 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -197,36 +197,6 @@ CFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) {
return m_PagePtrArray[nIndex].get();
}
-void CFDE_TxtEdtEngine::SetTextByStream(
- const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream) {
- ResetEngine();
- int32_t nIndex = 0;
- if (pStream && pStream->GetLength()) {
- int32_t nStreamLength = pStream->GetLength();
- bool bValid = true;
- if (m_nLimit > 0 && nStreamLength > m_nLimit) {
- bValid = false;
- }
- bool bPreIsCR = false;
- if (bValid) {
- int32_t nPos = pStream->GetBOMLength();
- pStream->Seek(CFX_SeekableStreamProxy::Pos::Begin, nPos);
- int32_t nPlateSize = std::min(nStreamLength, m_pTxtBuf->GetChunkSize());
- wchar_t* lpwstr = FX_Alloc(wchar_t, nPlateSize);
- bool bEos = false;
- while (!bEos) {
- int32_t nRead = pStream->ReadString(lpwstr, nPlateSize, &bEos);
- bPreIsCR = ReplaceParagEnd(lpwstr, nRead, bPreIsCR);
- m_pTxtBuf->Insert(nIndex, lpwstr, nRead);
- nIndex += nRead;
- }
- FX_Free(lpwstr);
- }
- }
- m_pTxtBuf->Insert(nIndex, &m_wLineEnd, 1);
- RebuildParagraphs();
-}
-
void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
ResetEngine();
int32_t nLength = wsText.GetLength();
@@ -258,7 +228,21 @@ CFX_WideString CFDE_TxtEdtEngine::GetText(int32_t nStart,
}
void CFDE_TxtEdtEngine::ClearText() {
- DeleteRange(0, GetTextBufLength());
+ if (IsLocked())
+ return;
+
+ int32_t len = GetTextBufLength();
+ if (len == 0)
+ return;
+ if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
+ CFX_WideString wsText = GetPreDeleteText(0, len);
+ if (!m_Param.pEventSink->OnValidate(wsText))
+ return;
+ }
+
+ DeleteRange_DoRecord(0, len, false);
+ m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
+ SetCaretPos(0, true);
}
int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, bool bBefore) {
@@ -488,62 +472,6 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) {
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
-int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, size_t nCount) {
- if (IsLocked())
- return FDE_TXTEDT_MODIFY_RET_F_Locked;
- if (nCount == 0)
- return FDE_TXTEDT_MODIFY_RET_S_Normal;
- if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
- if (!m_Param.pEventSink->OnValidate(wsText))
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
- DeleteRange_DoRecord(nStart, nCount, false);
- m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
- SetCaretPos(nStart, true);
- return FDE_TXTEDT_MODIFY_RET_S_Normal;
-}
-
-int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
- int32_t nLength,
- const CFX_WideString& wsReplace) {
- if (IsLocked())
- return FDE_TXTEDT_MODIFY_RET_F_Locked;
- if (nStart < 0 || (nStart + nLength > GetTextBufLength()))
- return FDE_TXTEDT_MODIFY_RET_F_Boundary;
- if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText = GetPreReplaceText(
- nStart, nLength, wsReplace.c_str(), wsReplace.GetLength());
- if (!m_Param.pEventSink->OnValidate(wsText))
- return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
- if (IsSelect())
- ClearSelection();
-
- UpdateChangeInfoDelete(FDE_TXTEDT_TEXTCHANGE_TYPE_Replace,
- GetText(nStart, nLength));
- if (nLength > 0)
- Inner_DeleteRange(nStart, nLength);
-
- int32_t nTextLength = wsReplace.GetLength();
- if (nTextLength > 0)
- Inner_Insert(nStart, wsReplace.c_str(), nTextLength);
-
- m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength);
- nStart += nTextLength;
- wchar_t wChar = m_pTxtBuf->GetCharByIndex(nStart - 1);
- bool bBefore = true;
- if (wChar != L'\n' && wChar != L'\r') {
- nStart--;
- bBefore = false;
- }
- SetCaretPos(nStart, bBefore);
- m_Param.pEventSink->OnPageUnload(m_nCaretPage);
- m_Param.pEventSink->OnPageLoad(m_nCaretPage);
- m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
- return FDE_TXTEDT_MODIFY_RET_S_Normal;
-}
-
void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) {
int32_t nRangeCount = pdfium::CollectionSize<int32_t>(m_SelRangePtrArr);
for (int32_t i = 0; i < nRangeCount; i++) {