Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2697)

Unified Diff: xfa/fde/cfde_txtedtengine.cpp

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Unused Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: xfa/fde/cfde_txtedtengine.cpp
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 1250043fc7d1437ba1124a23bcb95ea955f7f358..8104ec7aab6ae2768e0d579cd671bbad3d8ae150 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -206,7 +206,7 @@ int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, bool bBefore) {
m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical)
? m_rtCaret.top
: m_rtCaret.left;
- m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_CaretChanged();
m_nAnchorPos = -1;
return m_nCaret;
}
@@ -322,11 +322,11 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) {
AddSelRange(std::min(m_nAnchorPos, m_nCaret),
FXSYS_abs(m_nAnchorPos - m_nCaret));
- m_Param.pEventSink->On_SelChanged(this);
- }
- if (bSelChange) {
- m_Param.pEventSink->On_SelChanged(this);
+ m_Param.pEventSink->On_SelChanged();
}
+ if (bSelChange)
+ m_Param.pEventSink->On_SelChanged();
+
return m_nCaret;
}
@@ -405,19 +405,17 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
- if (!m_Param.pEventSink->On_Validate(this, wsText)) {
+ if (!m_Param.pEventSink->On_Validate(wsText))
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
}
if (IsSelect()) {
DeleteSelect();
}
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo))
m_Param.pEventSink->On_AddDoRecord(
- this,
new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength));
- m_ChangeInfo.wsPrevText = GetText(0);
+ m_ChangeInfo.wsPrevText = GetText(0, -1);
Inner_Insert(m_nCaret, lpBuffer, nLength);
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength);
@@ -430,7 +428,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
bBefore = false;
}
SetCaretPos(nStart, bBefore);
- m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
+ m_Param.pEventSink->On_TextChanged(m_ChangeInfo);
return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal;
}
@@ -466,14 +464,12 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) {
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
- if (!m_Param.pEventSink->On_Validate(this, wsText)) {
+ if (!m_Param.pEventSink->On_Validate(wsText))
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
}
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount);
m_Param.pEventSink->On_AddDoRecord(
- this,
new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange));
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
@@ -481,28 +477,24 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) {
Inner_DeleteRange(nStart, nCount);
SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0),
(bBackspace || nStart == 0));
- m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
+ m_Param.pEventSink->On_TextChanged(m_ChangeInfo);
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) {
- if (IsLocked()) {
+ if (IsLocked())
return FDE_TXTEDT_MODIFY_RET_F_Locked;
- }
- if (nCount == -1) {
+ if (nCount == -1)
nCount = GetTextBufLength();
- }
- if (nCount == 0) {
+ 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->On_Validate(this, wsText)) {
+ if (!m_Param.pEventSink->On_Validate(wsText))
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
}
DeleteRange_DoRecord(nStart, nCount);
- m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
+ m_Param.pEventSink->On_TextChanged(m_ChangeInfo);
SetCaretPos(nStart, true);
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
@@ -510,31 +502,28 @@ int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) {
int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
int32_t nLength,
const CFX_WideString& wsReplace) {
- if (IsLocked()) {
+ if (IsLocked())
return FDE_TXTEDT_MODIFY_RET_F_Locked;
- }
- if (nStart < 0 || (nStart + nLength > GetTextBufLength())) {
+ 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->On_Validate(this, wsText)) {
+ if (!m_Param.pEventSink->On_Validate(wsText))
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
- }
}
- if (IsSelect()) {
+ if (IsSelect())
ClearSelection();
- }
+
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace;
m_ChangeInfo.wsDelete = GetText(nStart, nLength);
- if (nLength > 0) {
+ if (nLength > 0)
Inner_DeleteRange(nStart, nLength);
- }
+
int32_t nTextLength = wsReplace.GetLength();
- if (nTextLength > 0) {
+ if (nTextLength > 0)
Inner_Insert(nStart, wsReplace.c_str(), nTextLength);
- }
+
m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength);
nStart += nTextLength;
FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1);
@@ -544,9 +533,9 @@ int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
bBefore = false;
}
SetCaretPos(nStart, bBefore);
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
- m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
- m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
+ m_Param.pEventSink->On_PageLoad(m_nCaretPage);
+ m_Param.pEventSink->On_TextChanged(m_ChangeInfo);
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
@@ -582,7 +571,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
lpSelRange->nStart = nStart;
lpSelRange->nCount = nCount;
m_SelRangePtrArr.Add(lpSelRange);
- m_Param.pEventSink->On_SelChanged(this);
+ m_Param.pEventSink->On_SelChanged();
return;
}
FDE_TXTEDTSELRANGE* lpTemp = nullptr;
@@ -592,7 +581,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
lpSelRange->nStart = nStart;
lpSelRange->nCount = nCount;
m_SelRangePtrArr.Add(lpSelRange);
- m_Param.pEventSink->On_SelChanged(this);
+ m_Param.pEventSink->On_SelChanged();
return;
}
int32_t nEnd = nStart + nCount - 1;
@@ -638,7 +627,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
m_SelRangePtrArr.RemoveAt(nRangeBgn);
}
}
- m_Param.pEventSink->On_SelChanged(this);
+ m_Param.pEventSink->On_SelChanged();
}
int32_t CFDE_TxtEdtEngine::CountSelRanges() const {
@@ -656,7 +645,7 @@ void CFDE_TxtEdtEngine::ClearSelection() {
delete m_SelRangePtrArr[i];
m_SelRangePtrArr.RemoveAll();
if (nCount && m_Param.pEventSink)
- m_Param.pEventSink->On_SelChanged(this);
+ m_Param.pEventSink->On_SelChanged();
}
bool CFDE_TxtEdtEngine::Redo(const IFDE_TxtEdtDoRecord* pDoRecord) {
@@ -829,7 +818,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
ASSERT(nLength > 0);
FDE_TXTEDTPARAGPOS ParagPos;
TextPos2ParagPos(nStart, ParagPos);
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
int32_t nParagCount = m_ParagPtrArray.GetSize();
int32_t i = 0;
for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++)
@@ -883,7 +872,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
nTotalLineCount += pParag->GetLineCount();
}
m_nLineCount += nTotalLineCount - nReserveLineCount;
- m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageLoad(m_nCaretPage);
UpdatePages();
}
@@ -893,7 +882,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
}
int32_t nEnd = nStart + nCount - 1;
ASSERT(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength());
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
FDE_TXTEDTPARAGPOS ParagPosBgn, ParagPosEnd;
TextPos2ParagPos(nStart, ParagPosBgn);
TextPos2ParagPos(nEnd, ParagPosEnd);
@@ -939,7 +928,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
if (m_nCaretPage >= nPageCount) {
m_nCaretPage = nPageCount - 1;
}
- m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageLoad(m_nCaretPage);
}
void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
@@ -953,9 +942,8 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount);
- m_Param.pEventSink->On_AddDoRecord(
- this, new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret,
- wsRange, bSel));
+ m_Param.pEventSink->On_AddDoRecord(new CFDE_TxtEdtDoRecord_DeleteRange(
+ this, nStart, m_nCaret, wsRange, bSel));
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
m_ChangeInfo.wsDelete = GetText(nStart, nCount);
@@ -1234,14 +1222,14 @@ int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
ASSERT(nIndex <= m_pTxtBuf->GetTextLength());
if (m_nCaretPage >= 0) {
IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
- m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageLoad(m_nCaretPage);
int32_t nPageCharStart = pPage->GetCharStart();
int32_t nPageCharCount = pPage->GetCharCount();
if (nIndex >= nPageCharStart && nIndex < nPageCharStart + nPageCharCount) {
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
return m_nCaretPage;
}
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
}
CFDE_TxtEdtParag* pParag = nullptr;
int32_t nLineCount = 0;
@@ -1551,7 +1539,7 @@ void CFDE_TxtEdtEngine::UpdateCaretRect(int32_t nIndex, bool bBefore) {
m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical)
? m_rtCaret.top
: m_rtCaret.left;
- m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_CaretChanged();
}
void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret,
@@ -1559,7 +1547,7 @@ void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret,
int32_t nCaret,
bool bBefore) {
IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
- m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageLoad(m_nCaretPage);
bool bCombText = !!(m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText);
int32_t nIndexInpage = nCaret - pPage->GetCharStart();
if (bBefore && bCombText && nIndexInpage > 0) {
@@ -1586,20 +1574,20 @@ void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret,
rtCaret.width = 1.0f;
}
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
}
void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) {
IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
- m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_PageLoad(m_nCaretPage);
m_nCaret = pPage->GetCharIndex(ptCaret, m_bBefore);
GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore);
if (!m_bBefore) {
m_nCaret++;
m_bBefore = true;
}
- m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage);
- m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
+ m_Param.pEventSink->On_CaretChanged();
+ m_Param.pEventSink->On_PageUnload(m_nCaretPage);
}
bool CFDE_TxtEdtEngine::IsSelect() {
@@ -1617,8 +1605,8 @@ void CFDE_TxtEdtEngine::DeleteSelect() {
DeleteRange_DoRecord(nSelStart, nSelCount, true);
}
ClearSelection();
- m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo);
- m_Param.pEventSink->On_SelChanged(this);
+ m_Param.pEventSink->On_TextChanged(m_ChangeInfo);
+ m_Param.pEventSink->On_SelChanged();
SetCaretPos(nSelStart, true);
return;
}

Powered by Google App Engine
This is Rietveld 408576698