Index: xfa/fwl/core/cfwl_edit.cpp |
diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp |
index 50f99fe090ca699a40af52a017f4c72f4aa23d2a..3ce1bcf2479b465254ee820bba0f3532d9ecb943 100644 |
--- a/xfa/fwl/core/cfwl_edit.cpp |
+++ b/xfa/fwl/core/cfwl_edit.cpp |
@@ -9,6 +9,18 @@ |
#include <memory> |
#include <vector> |
+namespace { |
+ |
+IFWL_Edit* ToEdit(IFWL_Widget* widget) { |
+ return static_cast<IFWL_Edit*>(widget); |
+} |
+ |
+const IFWL_Edit* ToEdit(const IFWL_Widget* widget) { |
+ return static_cast<const IFWL_Edit*>(widget); |
+} |
+ |
+} // namespace |
+ |
CFWL_Edit::CFWL_Edit(const IFWL_App* app) : CFWL_Widget(app) {} |
CFWL_Edit::~CFWL_Edit() {} |
@@ -24,24 +36,16 @@ void CFWL_Edit::Initialize() { |
CFWL_Widget::Initialize(); |
} |
-IFWL_Edit* CFWL_Edit::GetWidget() { |
- return static_cast<IFWL_Edit*>(m_pIface.get()); |
-} |
- |
-const IFWL_Edit* CFWL_Edit::GetWidget() const { |
- return static_cast<IFWL_Edit*>(m_pIface.get()); |
-} |
- |
FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->SetText(wsText); |
+ return ToEdit(GetWidget())->SetText(wsText); |
} |
int32_t CFWL_Edit::GetTextLength() const { |
if (!GetWidget()) |
return 0; |
- return GetWidget()->GetTextLength(); |
+ return ToEdit(GetWidget())->GetTextLength(); |
} |
FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText, |
@@ -49,75 +53,75 @@ FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText, |
int32_t nCount) const { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->GetText(wsText, nStart, nCount); |
+ return ToEdit(GetWidget())->GetText(wsText, nStart, nCount); |
} |
FWL_Error CFWL_Edit::ClearText() { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->ClearText(); |
+ return ToEdit(GetWidget())->ClearText(); |
} |
int32_t CFWL_Edit::GetCaretPos() const { |
if (!GetWidget()) |
return -1; |
- return GetWidget()->GetCaretPos(); |
+ return ToEdit(GetWidget())->GetCaretPos(); |
} |
int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
if (!GetWidget()) |
return -1; |
- return GetWidget()->SetCaretPos(nIndex, bBefore); |
+ return ToEdit(GetWidget())->SetCaretPos(nIndex, bBefore); |
} |
int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { |
if (!GetWidget()) |
return -1; |
- GetWidget()->AddSelRange(nStart, nCount); |
+ ToEdit(GetWidget())->AddSelRange(nStart, nCount); |
int32_t pos = 0; |
- int32_t sum = GetWidget()->GetTextLength(); |
+ int32_t sum = ToEdit(GetWidget())->GetTextLength(); |
if (nCount == -1) { |
pos = sum; |
} else { |
pos = nStart + nCount; |
} |
- return GetWidget()->SetCaretPos(pos); |
+ return ToEdit(GetWidget())->SetCaretPos(pos); |
} |
int32_t CFWL_Edit::CountSelRanges() { |
if (!GetWidget()) |
return 0; |
- return GetWidget()->CountSelRanges(); |
+ return ToEdit(GetWidget())->CountSelRanges(); |
} |
int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { |
if (!GetWidget()) |
return 0; |
- return GetWidget()->GetSelRange(nIndex, nStart); |
+ return ToEdit(GetWidget())->GetSelRange(nIndex, nStart); |
} |
FWL_Error CFWL_Edit::ClearSelections() { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->ClearSelections(); |
+ return ToEdit(GetWidget())->ClearSelections(); |
} |
int32_t CFWL_Edit::GetLimit() { |
if (!GetWidget()) |
return -1; |
- return GetWidget()->GetLimit(); |
+ return ToEdit(GetWidget())->GetLimit(); |
} |
FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->SetLimit(nLimit); |
+ return ToEdit(GetWidget())->SetLimit(nLimit); |
} |
FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->SetAliasChar(wAlias); |
+ return ToEdit(GetWidget())->SetAliasChar(wAlias); |
} |
FWL_Error CFWL_Edit::Insert(int32_t nStart, |
@@ -125,19 +129,19 @@ FWL_Error CFWL_Edit::Insert(int32_t nStart, |
int32_t nLen) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->Insert(nStart, lpText, nLen); |
+ return ToEdit(GetWidget())->Insert(nStart, lpText, nLen); |
} |
FWL_Error CFWL_Edit::DeleteSelections() { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->DeleteSelections(); |
+ return ToEdit(GetWidget())->DeleteSelections(); |
} |
FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->DeleteRange(nStart, nCount); |
+ return ToEdit(GetWidget())->DeleteRange(nStart, nCount); |
} |
FWL_Error CFWL_Edit::Replace(int32_t nStart, |
@@ -145,90 +149,89 @@ FWL_Error CFWL_Edit::Replace(int32_t nStart, |
const CFX_WideStringC& wsReplace) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->Replace(nStart, nLen, wsReplace); |
+ return ToEdit(GetWidget())->Replace(nStart, nLen, wsReplace); |
} |
FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->DoClipboard(iCmd); |
+ return ToEdit(GetWidget())->DoClipboard(iCmd); |
} |
FX_BOOL CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { |
- return GetWidget() && GetWidget()->Redo(pRecord); |
+ return GetWidget() && ToEdit(GetWidget())->Redo(pRecord); |
} |
FX_BOOL CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { |
- return GetWidget() && GetWidget()->Undo(pRecord); |
+ return GetWidget() && ToEdit(GetWidget())->Undo(pRecord); |
} |
FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->SetTabWidth(fTabWidth, bEquidistant); |
+ return ToEdit(GetWidget())->SetTabWidth(fTabWidth, bEquidistant); |
} |
FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { |
- if (iMin > iMax) { |
+ if (iMin > iMax) |
return FWL_Error::ParameterInvalid; |
- } |
- return GetWidget()->SetNumberRange(iMin, iMax); |
+ return ToEdit(GetWidget())->SetNumberRange(iMin, iMax); |
} |
FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->SetBackgroundColor(dwColor); |
+ return ToEdit(GetWidget())->SetBackgroundColor(dwColor); |
} |
FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
if (!GetWidget()) |
return FWL_Error::Indefinite; |
- return GetWidget()->SetFont(wsFont, fSize); |
+ return ToEdit(GetWidget())->SetFont(wsFont, fSize); |
} |
FX_BOOL CFWL_Edit::CanUndo() { |
- return GetWidget()->CanUndo(); |
+ return ToEdit(GetWidget())->CanUndo(); |
} |
FX_BOOL CFWL_Edit::CanRedo() { |
- return GetWidget()->CanRedo(); |
+ return ToEdit(GetWidget())->CanRedo(); |
} |
FX_BOOL CFWL_Edit::Undo() { |
- return GetWidget()->Undo(); |
+ return ToEdit(GetWidget())->Undo(); |
} |
FX_BOOL CFWL_Edit::Redo() { |
- return GetWidget()->Undo(); |
+ return ToEdit(GetWidget())->Undo(); |
} |
FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) { |
- return GetWidget()->Copy(wsCopy); |
+ return ToEdit(GetWidget())->Copy(wsCopy); |
} |
FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) { |
- return GetWidget()->Cut(wsCut); |
+ return ToEdit(GetWidget())->Cut(wsCut); |
} |
FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) { |
- return GetWidget()->Paste(wsPaste); |
+ return ToEdit(GetWidget())->Paste(wsPaste); |
} |
FX_BOOL CFWL_Edit::Delete() { |
- return GetWidget()->Delete(); |
+ return ToEdit(GetWidget())->Delete(); |
} |
void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
- return GetWidget()->SetScrollOffset(fScrollOffset); |
+ return ToEdit(GetWidget())->SetScrollOffset(fScrollOffset); |
} |
FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, |
std::vector<CFX_ByteString>& sSuggest) { |
- return GetWidget()->GetSuggestWords(pointf, sSuggest); |
+ return ToEdit(GetWidget())->GetSuggestWords(pointf, sSuggest); |
} |
FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, |
const CFX_ByteStringC& bsReplace) { |
- return GetWidget()->ReplaceSpellCheckWord(pointf, bsReplace); |
+ return ToEdit(GetWidget())->ReplaceSpellCheckWord(pointf, bsReplace); |
} |