diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-08-21 15:08:17 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-23 14:42:49 +0000 |
commit | 3bb0a34cc75abe49a59c6390353957bbb5c5ab38 (patch) | |
tree | 579b58399f24d3e12f39b4a0c9defcb1c56ad1bf | |
parent | 1d3696d091bd0485de55daedb000cef87fa35aae (diff) | |
download | pdfium-3bb0a34cc75abe49a59c6390353957bbb5c5ab38.tar.xz |
Convert the CFDE_TxtEdtEngine::Insert results into an enum class
This CL converts the return value to be an enum class and updates the
usages to use the names instead of values.
Change-Id: I8b6927551679ac4103775a04187daad2e0d6c569
Reviewed-on: https://pdfium-review.googlesource.com/11512
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | xfa/fde/cfde_txtedtengine.cpp | 19 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedtengine.h | 11 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 12 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.h | 2 |
4 files changed, 22 insertions, 22 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 72beac7718..469ec87cf7 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -22,13 +22,6 @@ namespace { const uint32_t kPageWidthMax = 0xffff; -enum FDE_TXTEDT_MODIFY_RET { - FDE_TXTEDT_MODIFY_RET_F_Locked = -5, - FDE_TXTEDT_MODIFY_RET_F_Invalidate = -4, - FDE_TXTEDT_MODIFY_RET_F_Full = -2, - FDE_TXTEDT_MODIFY_RET_S_Normal = 0, -}; - class InsertOperation : public IFDE_TxtEdtDoRecord { public: InsertOperation(CFDE_TxtEdtEngine* pEngine, @@ -304,9 +297,9 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_CaretMove eMoveCaret, bool bShift) { return m_nCaret; } -int32_t CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) { +FDE_EditResult CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) { if (IsLocked()) - return FDE_TXTEDT_MODIFY_RET_F_Locked; + return FDE_EditResult::kLocked; int32_t nLength = str.GetLength(); CFX_WideString wsTemp; @@ -322,7 +315,7 @@ int32_t CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) { int32_t nExpectLength = nTotalLength + nLength; if (nTotalLength == m_nLimit) - return FDE_TXTEDT_MODIFY_RET_F_Full; + return FDE_EditResult::kFull; if (nExpectLength > m_nLimit) nLength -= (nExpectLength - m_nLimit); @@ -353,12 +346,12 @@ int32_t CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) { } } if (nLength == 0) - return FDE_TXTEDT_MODIFY_RET_F_Full; + return FDE_EditResult::kFull; } if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength); if (!m_Param.pEventSink->OnValidate(wsText)) - return FDE_TXTEDT_MODIFY_RET_F_Invalidate; + return FDE_EditResult::kInvalidate; } if (IsSelect()) { DeleteSelect(); @@ -379,7 +372,7 @@ int32_t CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) { } SetCaretPos(nStart, bBefore); m_Param.pEventSink->OnTextChanged(prev); - return FDE_TXTEDT_MODIFY_RET_S_Normal; + return FDE_EditResult::kSuccess; } void CFDE_TxtEdtEngine::Delete(bool bBackspace) { diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h index 3edd4dc872..b708984ac4 100644 --- a/xfa/fde/cfde_txtedtengine.h +++ b/xfa/fde/cfde_txtedtengine.h @@ -49,6 +49,13 @@ enum class FDE_CaretMove { End, }; +enum class FDE_EditResult { + kLocked = -5, + kInvalidate = -4, + kFull = -2, + kSuccess = 0, +}; + struct FDE_TXTEDTPARAMS { FDE_TXTEDTPARAMS(); ~FDE_TXTEDTPARAMS(); @@ -93,7 +100,7 @@ class CFDE_TxtEdtEngine { int32_t SetCaretPos(int32_t nIndex, bool bBefore); int32_t MoveCaretPos(FDE_CaretMove eMoveCaret, bool bShift); - int32_t Insert(const CFX_WideString& str); + FDE_EditResult Insert(const CFX_WideString& str); void Delete(bool bBackspace); void SetLimit(int32_t nLimit) { m_nLimit = nLimit; } @@ -144,7 +151,7 @@ class CFDE_TxtEdtEngine { int32_t nCharIndex; }; - enum class LineEnding { + enum class LineEnding : uint8_t { kAuto, kCRLF, kCR, diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 127c258d04..6e56ab2485 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -351,8 +351,8 @@ bool CFWL_Edit::Cut(CFX_WideString& wsCut) { } bool CFWL_Edit::Paste(const CFX_WideString& wsPaste) { - int32_t iError = m_EdtEngine.Insert(wsPaste); - if (iError < 0) { + FDE_EditResult iError = m_EdtEngine.Insert(wsPaste); + if (iError != FDE_EditResult::kSuccess) { ProcessInsertError(iError); return false; } @@ -1188,11 +1188,11 @@ void CFWL_Edit::ClearRecord() { m_DoRecords.clear(); } -void CFWL_Edit::ProcessInsertError(int32_t iError) { +void CFWL_Edit::ProcessInsertError(FDE_EditResult iError) { // TODO(dsinclair): This should probably also send events for Validation // failure .... - if (iError != -2) + if (iError != FDE_EditResult::kFull) return; CFWL_Event textFullEvent(CFWL_Event::Type::TextFull, this); @@ -1432,7 +1432,7 @@ void CFWL_Edit::OnChar(CFWL_MessageKey* pMsg) { return; } - int32_t iError = 0; + FDE_EditResult iError = FDE_EditResult::kSuccess; wchar_t c = static_cast<wchar_t>(pMsg->m_dwKeyCode); switch (c) { case FWL_VKEY_Back: @@ -1475,7 +1475,7 @@ void CFWL_Edit::OnChar(CFWL_MessageKey* pMsg) { break; } } - if (iError < 0) + if (iError != FDE_EditResult::kSuccess) ProcessInsertError(iError); } diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index 23d6158ee6..c0583cd7af 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h @@ -139,7 +139,7 @@ class CFWL_Edit : public CFWL_Widget { bool IsShowScrollBar(bool bVert); bool IsContentHeightOverflow(); int32_t AddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord); - void ProcessInsertError(int32_t iError); + void ProcessInsertError(FDE_EditResult iError); void AddSpellCheckObj(CXFA_Path& PathData, int32_t nStart, int32_t nCount, |