From a8c2b919f7adec510cbca49675ad4a0cd0d30fd9 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 22 Mar 2017 17:41:02 -0700 Subject: Remove dead CFX_Edit code and fix some typos. Change-Id: Ieaac36e06db3d1e2b857d999a7d3d9cd5c5a9506 Reviewed-on: https://pdfium-review.googlesource.com/3118 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfdoc/cpdf_variabletext.cpp | 12 ++--- fpdfsdk/formfiller/cffl_combobox.cpp | 24 ++++----- fpdfsdk/formfiller/cffl_textfield.cpp | 24 ++++----- fpdfsdk/fxedit/fxet_edit.cpp | 21 +++----- fpdfsdk/fxedit/fxet_edit.h | 1 - fpdfsdk/pdfwindow/PWL_EditCtrl.cpp | 96 +---------------------------------- fpdfsdk/pdfwindow/PWL_EditCtrl.h | 25 --------- 7 files changed, 37 insertions(+), 166 deletions(-) diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 4e46969dc4..ab5c5e8050 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -303,10 +303,10 @@ CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace& place, uint16_t word, int32_t charset, const CPVT_WordProps* pWordProps) { - int32_t nTotlaWords = GetTotalWords(); - if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) + int32_t nTotalWords = GetTotalWords(); + if (m_nLimitChar > 0 && nTotalWords >= m_nLimitChar) return place; - if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) + if (m_nCharArray > 0 && nTotalWords >= m_nCharArray) return place; CPVT_WordPlace newplace = place; @@ -321,10 +321,10 @@ CPVT_WordPlace CPDF_VariableText::InsertSection( const CPVT_WordPlace& place, const CPVT_SecProps* pSecProps, const CPVT_WordProps* pWordProps) { - int32_t nTotlaWords = GetTotalWords(); - if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) + int32_t nTotalWords = GetTotalWords(); + if (m_nLimitChar > 0 && nTotalWords >= m_nLimitChar) return place; - if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) + if (m_nCharArray > 0 && nTotalWords >= m_nCharArray) return place; if (!m_bMultiLine) return place; diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index c8438a3a28..7a6d497ad2 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -263,18 +263,18 @@ bool CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) { void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { ASSERT(m_pFormFillEnv); - if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { - CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; - pEdit->SetCharSet(FXFONT_GB2312_CHARSET); - pEdit->SetCodePage(936); - - pEdit->SetReadyToInput(); - CFX_WideString wsText = pEdit->GetText(); - int nCharacters = wsText.GetLength(); - CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); - unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); - m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, true); - } + if (pWnd->GetClassName() != PWL_CLASSNAME_EDIT) + return; + + CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; + pEdit->SetCharSet(FXFONT_GB2312_CHARSET); + pEdit->SetReadyToInput(); + + CFX_WideString wsText = pEdit->GetText(); + int nCharacters = wsText.GetLength(); + CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); + auto* pBuffer = reinterpret_cast(bsUTFText.c_str()); + m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, true); } CFX_WideString CFFL_ComboBox::GetSelectExportText() { diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index 91db0959db..19a87d04ae 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -271,16 +271,16 @@ bool CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) { void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) { ASSERT(m_pFormFillEnv); - if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { - CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; - pEdit->SetCharSet(FXFONT_GB2312_CHARSET); - pEdit->SetCodePage(936); - - pEdit->SetReadyToInput(); - CFX_WideString wsText = pEdit->GetText(); - int nCharacters = wsText.GetLength(); - CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); - unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); - m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, true); - } + if (pWnd->GetClassName() != PWL_CLASSNAME_EDIT) + return; + + CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; + pEdit->SetCharSet(FXFONT_GB2312_CHARSET); + pEdit->SetReadyToInput(); + + CFX_WideString wsText = pEdit->GetText(); + int nCharacters = wsText.GetLength(); + CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); + auto* pBuffer = reinterpret_cast(bsUTFText.c_str()); + m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, true); } diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 20f584e183..884232dc76 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -1074,10 +1074,6 @@ CFX_WideString CFX_Edit::GetSelText() const { return GetRangeText(m_SelState.ConvertToWordRange()); } -int32_t CFX_Edit::GetTotalWords() const { - return m_pVT->GetTotalWords(); -} - int32_t CFX_Edit::GetTotalLines() const { int32_t nLines = 1; @@ -1215,11 +1211,6 @@ void CFX_Edit::SetContentChanged() { CFX_FloatRect rcContent = m_pVT->GetContentRect(); if (rcContent.Width() != m_rcOldContent.Width() || rcContent.Height() != m_rcOldContent.Height()) { - if (!m_bNotifyFlag) { - m_bNotifyFlag = true; - m_pNotify->IOnContentChange(rcContent); - m_bNotifyFlag = false; - } m_rcOldContent = rcContent; } } @@ -1305,11 +1296,11 @@ void CFX_Edit::SetScrollInfo() { CFX_FloatRect rcContent = m_pVT->GetContentRect(); if (!m_bNotifyFlag) { + CFX_AutoRestorer restorer(&m_bNotifyFlag); m_bNotifyFlag = true; m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, rcContent.bottom, rcContent.top, rcPlate.Height() / 3, rcPlate.Height()); - m_bNotifyFlag = false; } } } @@ -1337,9 +1328,9 @@ void CFX_Edit::SetScrollPosY(float fy) { if (m_pNotify) { if (!m_bNotifyFlag) { + CFX_AutoRestorer restorer(&m_bNotifyFlag); m_bNotifyFlag = true; m_pNotify->IOnSetScrollPosY(fy); - m_bNotifyFlag = false; } } } @@ -1447,12 +1438,12 @@ void CFX_Edit::Refresh() { if (m_pNotify) { if (!m_bNotifyFlag) { + CFX_AutoRestorer restorer(&m_bNotifyFlag); m_bNotifyFlag = true; if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); } - m_bNotifyFlag = false; } } @@ -1516,10 +1507,10 @@ void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) { if (m_pNotify) { if (!m_bNotifyFlag) { + CFX_AutoRestorer restorer(&m_bNotifyFlag); m_bNotifyFlag = true; CFX_FloatRect rcRefresh = VTToEdit(rcWord); m_pNotify->IOnInvalidateRect(&rcRefresh); - m_bNotifyFlag = false; } } } else { @@ -1530,10 +1521,10 @@ void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) { if (m_pNotify) { if (!m_bNotifyFlag) { + CFX_AutoRestorer restorer(&m_bNotifyFlag); m_bNotifyFlag = true; CFX_FloatRect rcRefresh = VTToEdit(rcLine); m_pNotify->IOnInvalidateRect(&rcRefresh); - m_bNotifyFlag = false; } } @@ -1569,10 +1560,10 @@ void CFX_Edit::SetCaretInfo() { ptFoot.y = line.ptLine.y + line.fLineDescent; } + CFX_AutoRestorer restorer(&m_bNotifyFlag); m_bNotifyFlag = true; m_pNotify->IOnSetCaret(m_SelState.IsEmpty(), VTToEdit(ptHead), VTToEdit(ptFoot), m_wpCaret); - m_bNotifyFlag = false; } } } diff --git a/fpdfsdk/fxedit/fxet_edit.h b/fpdfsdk/fxedit/fxet_edit.h index 08a13a87bd..a279d1c1b6 100644 --- a/fpdfsdk/fxedit/fxet_edit.h +++ b/fpdfsdk/fxedit/fxet_edit.h @@ -396,7 +396,6 @@ class CFX_Edit { CFX_WideString GetRangeText(const CPVT_WordRange& range) const; int32_t GetHorzScale() const; float GetCharSpace() const; - int32_t GetTotalWords() const; void SetSel(int32_t nStartChar, int32_t nEndChar); void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; void SelectAll(); diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp index e7371fd0e7..19daae1413 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp @@ -21,8 +21,7 @@ CPWL_EditCtrl::CPWL_EditCtrl() : m_pEdit(new CFX_Edit), m_pEditCaret(nullptr), m_bMouseDown(false), - m_nCharSet(FXFONT_DEFAULT_CHARSET), - m_nCodePage(0) {} + m_nCharSet(FXFONT_DEFAULT_CHARSET) {} CPWL_EditCtrl::~CPWL_EditCtrl() {} @@ -314,10 +313,6 @@ bool CPWL_EditCtrl::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) { return true; } -CFX_FloatRect CPWL_EditCtrl::GetContentRect() const { - return m_pEdit->GetContentRect(); -} - void CPWL_EditCtrl::SetEditCaret(bool bVisible) { CFX_PointF ptHead; CFX_PointF ptFoot; @@ -378,26 +373,6 @@ void CPWL_EditCtrl::SelectAll() { m_pEdit->SelectAll(); } -void CPWL_EditCtrl::Paint() { - m_pEdit->Paint(); -} - -void CPWL_EditCtrl::EnableRefresh(bool bRefresh) { - m_pEdit->EnableRefresh(bRefresh); -} - -int32_t CPWL_EditCtrl::GetCaret() const { - return m_pEdit->GetCaret(); -} - -void CPWL_EditCtrl::SetCaret(int32_t nPos) { - m_pEdit->SetCaret(nPos); -} - -int32_t CPWL_EditCtrl::GetTotalWords() const { - return m_pEdit->GetTotalWords(); -} - void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) { m_pEdit->SetScrollPos(point); } @@ -406,49 +381,6 @@ CFX_PointF CPWL_EditCtrl::GetScrollPos() const { return m_pEdit->GetScrollPos(); } -CPDF_Font* CPWL_EditCtrl::GetCaretFont() const { - int32_t nFontIndex = 0; - - CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); - pIterator->SetAt(m_pEdit->GetCaret()); - CPVT_Word word; - CPVT_Section section; - if (pIterator->GetWord(word)) { - nFontIndex = word.nFontIndex; - } else if (HasFlag(PES_RICH)) { - if (pIterator->GetSection(section)) { - nFontIndex = section.WordProps.nFontIndex; - } - } - - if (IPVT_FontMap* pFontMap = GetFontMap()) - return pFontMap->GetPDFFont(nFontIndex); - - return nullptr; -} - -float CPWL_EditCtrl::GetCaretFontSize() const { - float fFontSize = GetFontSize(); - - CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); - pIterator->SetAt(m_pEdit->GetCaret()); - CPVT_Word word; - CPVT_Section section; - if (pIterator->GetWord(word)) { - fFontSize = word.fFontSize; - } else if (HasFlag(PES_RICH)) { - if (pIterator->GetSection(section)) { - fFontSize = section.WordProps.fFontSize; - } - } - - return fFontSize; -} - -void CPWL_EditCtrl::SetText(const CFX_WideString& wsText) { - m_pEdit->SetText(wsText); -} - void CPWL_EditCtrl::CopyText() {} void CPWL_EditCtrl::PasteText() {} @@ -457,11 +389,6 @@ void CPWL_EditCtrl::CutText() {} void CPWL_EditCtrl::ShowVScrollBar(bool bShow) {} -void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { - if (!IsReadOnly()) - m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); -} - void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { if (!IsReadOnly()) m_pEdit->InsertWord(word, nCharset); @@ -540,11 +467,6 @@ void CPWL_EditCtrl::IOnSetCaret(bool bVisible, OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t) nullptr); } -void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps, - const CPVT_WordProps& wordProps) {} - -void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) {} - void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { InvalidateRect(pRect); } @@ -553,22 +475,6 @@ int32_t CPWL_EditCtrl::GetCharSet() const { return m_nCharSet < 0 ? FXFONT_DEFAULT_CHARSET : m_nCharSet; } -void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect, - int32_t& nStartChar, - int32_t& nEndChar) const { - nStartChar = m_pEdit->WordPlaceToWordIndex( - m_pEdit->SearchWordPlace(CFX_PointF(rect.left, rect.top))); - nEndChar = m_pEdit->WordPlaceToWordIndex( - m_pEdit->SearchWordPlace(CFX_PointF(rect.right, rect.bottom))); -} - -CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar, - int32_t& nEndChar) const { - CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar); - CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar); - return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd)); -} - void CPWL_EditCtrl::SetReadyToInput() { if (m_bMouseDown) { ReleaseCapture(); diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.h b/fpdfsdk/pdfwindow/PWL_EditCtrl.h index 6977673eac..0f2487bc26 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.h +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.h @@ -33,37 +33,18 @@ class CPWL_EditCtrl : public CPWL_Wnd { CPWL_EditCtrl(); ~CPWL_EditCtrl() override; - CFX_FloatRect GetContentRect() const; - CFX_WideString GetText() const; void SetSel(int32_t nStartChar, int32_t nEndChar); void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; - void GetTextRange(const CFX_FloatRect& rect, - int32_t& nStartChar, - int32_t& nEndChar) const; - CFX_WideString GetText(int32_t& nStartChar, int32_t& nEndChar) const; void Clear(); void SelectAll(); - int32_t GetCaret() const; - void SetCaret(int32_t nPos); - int32_t GetTotalWords() const; - - void Paint(); - - void EnableRefresh(bool bRefresh); CFX_PointF GetScrollPos() const; void SetScrollPos(const CFX_PointF& point); void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } int32_t GetCharSet() const; - void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } - int32_t GetCodePage() const { return m_nCodePage; } - - CPDF_Font* GetCaretFont() const; - float GetCaretFontSize() const; - bool CanUndo() const; bool CanRedo() const; void Redo(); @@ -100,14 +81,9 @@ class CPWL_EditCtrl : public CPWL_Wnd { const CFX_PointF& ptHead, const CFX_PointF& ptFoot, const CPVT_WordPlace& place); - void IOnCaretChange(const CPVT_SecProps& secProps, - const CPVT_WordProps& wordProps); - void IOnContentChange(const CFX_FloatRect& rcContent); void IOnInvalidateRect(CFX_FloatRect* pRect); protected: - void InsertText(const CFX_WideString& wsText); - void SetText(const CFX_WideString& wsText); void CopyText(); void PasteText(); void CutText(); @@ -135,7 +111,6 @@ class CPWL_EditCtrl : public CPWL_Wnd { void CreateEditCaret(const PWL_CREATEPARAM& cp); int32_t m_nCharSet; - int32_t m_nCodePage; }; #endif // FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ -- cgit v1.2.3