diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-04-05 14:54:34 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-05 14:54:34 +0000 |
commit | 14f8897509d9db8739951a90488fb1634a497db5 (patch) | |
tree | d8f90d40f94afeecffd24090ac1dc3571c0c6587 /xfa/fwl | |
parent | 32942201a456ace47c052536cba594be03e9aa6c (diff) | |
download | pdfium-14f8897509d9db8739951a90488fb1634a497db5.tar.xz |
Remove spellchecking code from XFAchromium/3390
The existing code for spellchecking is non-functional and we are not
planning on fixing/finishing it, so removing it, since it currently is
marking everything as misspelt.
BUG=pdfium:1054
Change-Id: I23aaa13c09aed483376d7d06f47fdf31d890786b
Reviewed-on: https://pdfium-review.googlesource.com/29790
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fwl')
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 96 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.h | 6 | ||||
-rw-r--r-- | xfa/fwl/cfwl_event.h | 1 | ||||
-rw-r--r-- | xfa/fwl/cfwl_eventcheckword.cpp | 12 | ||||
-rw-r--r-- | xfa/fwl/cfwl_eventcheckword.h | 21 |
5 files changed, 0 insertions, 136 deletions
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 0067cab20a..733961eead 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -19,7 +19,6 @@ #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_caret.h" #include "xfa/fwl/cfwl_event.h" -#include "xfa/fwl/cfwl_eventcheckword.h" #include "xfa/fwl/cfwl_eventtextchanged.h" #include "xfa/fwl/cfwl_eventvalidate.h" #include "xfa/fwl/cfwl_messagekey.h" @@ -43,23 +42,6 @@ constexpr int kEditingModifier = FWL_KEYFLAG_Command; constexpr int kEditingModifier = FWL_KEYFLAG_Ctrl; #endif -bool FxEditIsLatinWord(wchar_t c) { - return c == 0x2D || (c <= 0x005A && c >= 0x0041) || - (c <= 0x007A && c >= 0x0061) || (c <= 0x02AF && c >= 0x00C0) || - c == 0x0027; -} - -void AddSquigglyPath(CXFA_GEPath* pPathData, - float fStartX, - float fEndX, - float fY, - float fStep) { - pPathData->MoveTo(CFX_PointF(fStartX, fY)); - int i = 1; - for (float fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) - pPathData->LineTo(CFX_PointF(fx, fY + (i & 1) * fStep)); -} - } // namespace CFWL_Edit::CFWL_Edit(const CFWL_App* app, @@ -162,80 +144,6 @@ FWL_WidgetHit CFWL_Edit::HitTest(const CFX_PointF& point) { return FWL_WidgetHit::Unknown; } -void CFWL_Edit::AddSpellCheckObj(CXFA_GEPath& PathData, - int32_t nStart, - int32_t nCount, - float fOffSetX, - float fOffSetY) { - float fStep = m_EdtEngine.GetFontSize() / 16.0f; - float font_ascent = m_EdtEngine.GetFontAscent(); - - std::vector<CFX_RectF> rects = - m_EdtEngine.GetCharacterRectsInRange(nStart, nCount); - for (const auto& rect : rects) { - float fY = rect.top + font_ascent + fOffSetY; - float fStartX = rect.left + fOffSetX; - float fEndX = fStartX + rect.Width(); - - AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); - } -} - -void CFWL_Edit::DrawSpellCheck(CXFA_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - pGraphics->SaveGraphState(); - if (pMatrix) - pGraphics->ConcatMatrix(pMatrix); - - CFWL_EventCheckWord checkWordEvent(this); - ByteString sLatinWord; - CXFA_GEPath pathSpell; - int32_t nStart = 0; - float fOffSetX = m_rtEngine.left - m_fScrollOffsetX; - float fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; - WideString wsSpell = GetText(); - int32_t nContentLen = wsSpell.GetLength(); - for (int i = 0; i < nContentLen; i++) { - if (FxEditIsLatinWord(wsSpell[i])) { - if (sLatinWord.IsEmpty()) - nStart = i; - sLatinWord += (char)wsSpell[i]; - continue; - } - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = true; - DispatchEvent(&checkWordEvent); - - if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { - AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, - fOffSetY); - } - sLatinWord.clear(); - } - - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = true; - DispatchEvent(&checkWordEvent); - - if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { - AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, - fOffSetY); - } - if (!pathSpell.IsEmpty()) { - CFX_RectF rtClip = m_rtEngine; - CFX_Matrix mt(1, 0, 0, 1, fOffSetX, fOffSetY); - if (pMatrix) { - rtClip = pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - pGraphics->SetClipRect(rtClip); - pGraphics->SetStrokeColor(CXFA_GEColor(0xFFFF0000)); - pGraphics->SetLineWidth(0); - pGraphics->StrokePath(&pathSpell, nullptr); - } - pGraphics->RestoreGraphState(); -} - void CFWL_Edit::DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) { if (!pGraphics) return; @@ -249,10 +157,6 @@ void CFWL_Edit::DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) { DrawTextBk(pGraphics, pTheme, &matrix); DrawContent(pGraphics, pTheme, &matrix); - if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && - !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { - DrawSpellCheck(pGraphics, &matrix); - } if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix); } diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index 9c667f5e14..894315de82 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h @@ -114,7 +114,6 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate { void DrawContent(CXFA_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix); - void DrawSpellCheck(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix); void UpdateEditEngine(); void UpdateEditParams(); @@ -134,11 +133,6 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate { bool ValidateNumberChar(wchar_t cNum); bool IsShowScrollBar(bool bVert); bool IsContentHeightOverflow(); - void AddSpellCheckObj(CXFA_GEPath& PathData, - int32_t nStart, - int32_t nCount, - float fOffSetX, - float fOffSetY); void SetCursorPosition(size_t position); void UpdateCursorRect(); diff --git a/xfa/fwl/cfwl_event.h b/xfa/fwl/cfwl_event.h index 01e3914b8b..787f8c2640 100644 --- a/xfa/fwl/cfwl_event.h +++ b/xfa/fwl/cfwl_event.h @@ -20,7 +20,6 @@ class CFWL_Event { public: enum class Type { CheckStateChanged, - CheckWord, Click, Close, EditChanged, diff --git a/xfa/fwl/cfwl_eventcheckword.cpp b/xfa/fwl/cfwl_eventcheckword.cpp deleted file mode 100644 index fb0ce6e77e..0000000000 --- a/xfa/fwl/cfwl_eventcheckword.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fwl/cfwl_eventcheckword.h" - -CFWL_EventCheckWord::CFWL_EventCheckWord(CFWL_Widget* pSrcTarget) - : CFWL_Event(CFWL_Event::Type::CheckWord, pSrcTarget) {} - -CFWL_EventCheckWord::~CFWL_EventCheckWord() {} diff --git a/xfa/fwl/cfwl_eventcheckword.h b/xfa/fwl/cfwl_eventcheckword.h deleted file mode 100644 index fafe3d3278..0000000000 --- a/xfa/fwl/cfwl_eventcheckword.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CFWL_EVENTCHECKWORD_H_ -#define XFA_FWL_CFWL_EVENTCHECKWORD_H_ - -#include "xfa/fwl/cfwl_event.h" - -class CFWL_EventCheckWord : public CFWL_Event { - public: - explicit CFWL_EventCheckWord(CFWL_Widget* pSrcTarget); - ~CFWL_EventCheckWord() override; - - ByteString bsWord; - bool bCheckWord; -}; - -#endif // XFA_FWL_CFWL_EVENTCHECKWORD_H_ |