From 8da140e8747920057a2f2bbcf5c78e40bb198733 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 7 Apr 2016 12:39:44 -0700 Subject: Remove all PWL_Note classes The PWL_Note clasess are never instantiated, remove them and their implementation. PWL_Note was the only caller to enable spellcheck so this allows us to remove IPWL_SpellCheck and the conditionals for PES_SPELLCHECK. BUG=pdfium:468 Review URL: https://codereview.chromium.org/1869533003 --- BUILD.gn | 2 - fpdfsdk/pdfwindow/PWL_Edit.cpp | 52 +-- fpdfsdk/pdfwindow/PWL_Edit.h | 18 +- fpdfsdk/pdfwindow/PWL_Note.cpp | 859 ---------------------------------------- fpdfsdk/pdfwindow/PWL_Note.h | 258 ------------ fpdfsdk/pdfwindow/PWL_Utils.cpp | 313 --------------- fpdfsdk/pdfwindow/PWL_Utils.h | 14 - fpdfsdk/pdfwindow/PWL_Wnd.h | 12 - pdfium.gyp | 2 - 9 files changed, 4 insertions(+), 1526 deletions(-) delete mode 100644 fpdfsdk/pdfwindow/PWL_Note.cpp delete mode 100644 fpdfsdk/pdfwindow/PWL_Note.h diff --git a/BUILD.gn b/BUILD.gn index 62bbcdb7a8..380eee9fdd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -767,8 +767,6 @@ static_library("pdfwindow") { "fpdfsdk/pdfwindow/PWL_ListBox.h", "fpdfsdk/pdfwindow/PWL_ListCtrl.cpp", "fpdfsdk/pdfwindow/PWL_ListCtrl.h", - "fpdfsdk/pdfwindow/PWL_Note.cpp", - "fpdfsdk/pdfwindow/PWL_Note.h", "fpdfsdk/pdfwindow/PWL_ScrollBar.cpp", "fpdfsdk/pdfwindow/PWL_ScrollBar.h", "fpdfsdk/pdfwindow/PWL_Signature.cpp", diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index e193d0f469..e836594378 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -23,9 +23,7 @@ #include "third_party/base/stl_util.h" CPWL_Edit::CPWL_Edit() - : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) { - m_pFormFiller = NULL; -} + : m_pFillerNotify(nullptr), m_bFocus(FALSE), m_pFormFiller(nullptr) {} CPWL_Edit::~CPWL_Edit() { ASSERT(m_bFocus == FALSE); @@ -247,10 +245,6 @@ void CPWL_Edit::SetParamByFlag() { GetClientRect(), 1.0f)); // +1 for caret beside border } } - - if (HasFlag(PES_SPELLCHECK)) { - m_pSpellCheck = GetCreationParam().pSpellCheck; - } } void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { @@ -356,16 +350,6 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC() << sEditAfter.AsByteStringC() << "ET\n"; - if (HasFlag(PES_SPELLCHECK)) { - CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( - m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); - if (sSpellCheck.GetLength() > 0) - sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), - FALSE) - .AsByteStringC() - << sSpellCheck.AsByteStringC(); - } - if (sText.GetLength() > 0) { CFX_FloatRect rcClient = GetClientRect(); sAppStream << "q\n/Tx BMC\n"; @@ -467,12 +451,6 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); - - if (HasFlag(PES_SPELLCHECK)) { - CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, - CFX_FloatPoint(0.0f, 0.0f), pRange, - GetCreationParam().pSpellCheck); - } } FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) { @@ -536,27 +514,6 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { std::vector sSuggestWords; CFX_FloatPoint ptPopup = point; - if (!IsReadOnly()) { - if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { - if (m_pSpellCheck) { - CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); - if (!m_pSpellCheck->CheckWord(sLatin)) { - m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); - - int32_t nSuggest = pdfium::CollectionSize(sSuggestWords); - for (int32_t nWord = 0; nWord < nSuggest; nWord++) { - pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord, - sSuggestWords[nWord].UTF8Decode()); - } - if (nSuggest > 0) - pSH->AppendMenuItem(hPopup, 0, L""); - - ptPopup = GetWordRightBottomPoint(wrLatin.EndPos); - } - } - } - } - IPWL_Provider* pProvider = GetProvider(); if (HasFlag(PES_UNDO)) { @@ -864,13 +821,6 @@ FX_BOOL CPWL_Edit::IsVScrollBarVisible() const { return FALSE; } -void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) { - if (bEnabled) - AddFlag(PES_SPELLCHECK); - else - RemoveFlag(PES_SPELLCHECK); -} - FX_BOOL CPWL_Edit::OnKeyDown(uint16_t nChar, uint32_t nFlag) { if (m_bMouseDown) return TRUE; diff --git a/fpdfsdk/pdfwindow/PWL_Edit.h b/fpdfsdk/pdfwindow/PWL_Edit.h index 2cdc4d149d..29747dd2ae 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/pdfwindow/PWL_Edit.h @@ -12,8 +12,6 @@ #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" -class IPWL_SpellCheck; - class IPWL_Filler_Notify { public: virtual ~IPWL_Filler_Notify() {} @@ -81,8 +79,6 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); - void EnableSpellCheck(FX_BOOL bEnabled); - FX_BOOL CanSelectAll() const; FX_BOOL CanClear() const; FX_BOOL CanCopy() const; @@ -117,6 +113,9 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { void GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, const CFX_FloatPoint& ptOffset); + FX_BOOL IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag); + void AttachFFLData(void* pData) { m_pFormFiller = pData; } + protected: // IFX_Edit_OprNotify void OnInsertWord(const CPVT_WordPlace& place, @@ -152,20 +151,9 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { CPVT_WordRange GetSameWordsRange(const CPVT_WordPlace& place, FX_BOOL bLatin, FX_BOOL bArabic) const; - - public: - FX_BOOL IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag); - - private: IPWL_Filler_Notify* m_pFillerNotify; - IPWL_SpellCheck* m_pSpellCheck; FX_BOOL m_bFocus; CFX_FloatRect m_rcOldWindow; - - public: - void AttachFFLData(void* pData) { m_pFormFiller = pData; } - - private: void* m_pFormFiller; }; diff --git a/fpdfsdk/pdfwindow/PWL_Note.cpp b/fpdfsdk/pdfwindow/PWL_Note.cpp deleted file mode 100644 index 964948ee53..0000000000 --- a/fpdfsdk/pdfwindow/PWL_Note.cpp +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2014 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 "fpdfsdk/pdfwindow/PWL_Note.h" - -#include "core/fxge/include/fx_ge.h" -#include "fpdfsdk/pdfwindow/PWL_Button.h" -#include "fpdfsdk/pdfwindow/PWL_Caret.h" -#include "fpdfsdk/pdfwindow/PWL_Edit.h" -#include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" -#include "fpdfsdk/pdfwindow/PWL_Label.h" -#include "fpdfsdk/pdfwindow/PWL_ListCtrl.h" -#include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" -#include "fpdfsdk/pdfwindow/PWL_Utils.h" -#include "fpdfsdk/pdfwindow/PWL_Wnd.h" - -#define POPUP_ITEM_HEAD_BOTTOM 3.0f -#define POPUP_ITEM_BOTTOMWIDTH 1.0f -#define POPUP_ITEM_SIDEMARGIN 3.0f -#define POPUP_ITEM_SPACE 4.0f -#define POPUP_ITEM_TEXT_INDENT 2.0f -#define POPUP_ITEM_BORDERCOLOR \ - CPWL_Color(COLORTYPE_RGB, 80 / 255.0f, 80 / 255.0f, 80 / 255.0f) - -#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) -#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) -#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) -#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) - -CPWL_Note_Options::CPWL_Note_Options() : m_pText(NULL) {} - -CPWL_Note_Options::~CPWL_Note_Options() {} - -void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) { - CPWL_Wnd::SetTextColor(color); - - if (m_pText) - m_pText->SetTextColor(color); -} - -void CPWL_Note_Options::RePosChildWnd() { - if (IsValid()) { - CFX_FloatRect rcClient = GetClientRect(); - - if (rcClient.Width() > 15.0f) { - rcClient.right -= 15.0f; - m_pText->Move(rcClient, TRUE, FALSE); - m_pText->SetVisible(TRUE); - } else { - m_pText->Move(CFX_FloatRect(0, 0, 0, 0), TRUE, FALSE); - m_pText->SetVisible(FALSE); - } - } -} - -void CPWL_Note_Options::CreateChildWnd(const PWL_CREATEPARAM& cp) { - m_pText = new CPWL_Label; - PWL_CREATEPARAM tcp = cp; - tcp.pParentWnd = this; - tcp.dwFlags = PWS_CHILD | PWS_VISIBLE; - m_pText->Create(tcp); -} - -void CPWL_Note_Options::SetText(const CFX_WideString& sText) { - m_pText->SetText(sText.c_str()); -} - -void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) { - CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); - - CFX_FloatRect rcClient = GetClientRect(); - rcClient.left = rcClient.right - 15.0f; - - CFX_FloatPoint ptCenter = - CFX_FloatPoint((rcClient.left + rcClient.right) * 0.5f, - (rcClient.top + rcClient.bottom) * 0.5f); - - CFX_FloatPoint pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f); - CFX_FloatPoint pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f); - CFX_FloatPoint pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f); - - CFX_PathData path; - - path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); - path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); - path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); - path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); - - pDevice->DrawPath( - &path, pUser2Device, NULL, - CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), 0, - FXFILL_ALTERNATE); -} - -CFX_FloatRect CPWL_Note_Options::GetContentRect() const { - CFX_FloatRect rcText = m_pText->GetContentRect(); - rcText.right += 15.0f; - return rcText; -} - -CPWL_Note_Edit::CPWL_Note_Edit() - : m_bEnableNotify(TRUE), - m_fOldItemHeight(0.0f), - m_bSizeChanged(FALSE), - m_fOldMin(0.0f), - m_fOldMax(0.0f) {} - -CPWL_Note_Edit::~CPWL_Note_Edit() {} - -void CPWL_Note_Edit::RePosChildWnd() { - m_bEnableNotify = FALSE; - CPWL_Edit::RePosChildWnd(); - m_bEnableNotify = TRUE; - - m_fOldItemHeight = GetContentRect().Height(); -} - -void CPWL_Note_Edit::SetText(const FX_WCHAR* csText) { - m_bEnableNotify = FALSE; - CPWL_Edit::SetText(csText); - m_bEnableNotify = TRUE; - m_fOldItemHeight = GetContentRect().Height(); -} - -void CPWL_Note_Edit::OnSetFocus() { - m_bEnableNotify = FALSE; - CPWL_Edit::OnSetFocus(); - m_bEnableNotify = TRUE; - - EnableSpellCheck(TRUE); -} - -void CPWL_Note_Edit::OnKillFocus() { - EnableSpellCheck(FALSE); - CPWL_Edit::OnKillFocus(); -} - -void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam, - intptr_t lParam) { - if (m_bEnableNotify) { - if (wParam == SBT_VSCROLL) { - switch (msg) { - case PNM_SETSCROLLINFO: - if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { - if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) || - !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) { - m_bSizeChanged = TRUE; - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); - } - - m_fOldMax = pInfo->fContentMax; - m_fOldMin = pInfo->fContentMin; - return; - } - } - } - } - } - - CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam); - - if (m_bEnableNotify) { - switch (msg) { - case PNM_SETCARETINFO: - if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { - PWL_CARET_INFO newInfo = *pInfo; - newInfo.bVisible = TRUE; - newInfo.ptHead = ChildToParent(pInfo->ptHead); - newInfo.ptFoot = ChildToParent(pInfo->ptFoot); - - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0); - } - } - break; - } - } -} - -FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) { - if (fLimitWidth > 0) { - if (!m_bSizeChanged) - return m_fOldItemHeight; - - m_bSizeChanged = FALSE; - - EnableNotify(FALSE); - EnableRefresh(FALSE); - m_pEdit->EnableNotify(FALSE); - - Move(CFX_FloatRect(0, 0, fLimitWidth, 0), TRUE, FALSE); - FX_FLOAT fRet = GetContentRect().Height(); - - m_pEdit->EnableNotify(TRUE); - EnableNotify(TRUE); - EnableRefresh(TRUE); - - return fRet; - } - - return 0; -} - -FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin() { - return POPUP_ITEM_TEXT_INDENT; -} - -FX_FLOAT CPWL_Note_Edit::GetItemRightMargin() { - return POPUP_ITEM_TEXT_INDENT; -} - -CPWL_Note_LBBox::CPWL_Note_LBBox() {} - -CPWL_Note_LBBox::~CPWL_Note_LBBox() {} - -void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) { - CFX_FloatRect rcClient = GetClientRect(); - - CFX_GraphStateData gsd; - gsd.m_LineWidth = 1.0f; - - CFX_PathData pathCross; - - pathCross.SetPointCount(4); - pathCross.SetPoint(0, rcClient.left, rcClient.top, FXPT_MOVETO); - pathCross.SetPoint(1, rcClient.right, rcClient.bottom, FXPT_LINETO); - pathCross.SetPoint(2, rcClient.left, - rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO); - pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f, - rcClient.bottom, FXPT_LINETO); - - pDevice->DrawPath( - &pathCross, pUser2Device, &gsd, 0, - CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), - FXFILL_ALTERNATE); -} - -CPWL_Note_RBBox::CPWL_Note_RBBox() {} - -CPWL_Note_RBBox::~CPWL_Note_RBBox() {} - -void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) { - CFX_FloatRect rcClient = GetClientRect(); - - CFX_GraphStateData gsd; - gsd.m_LineWidth = 1.0f; - - CFX_PathData pathCross; - - pathCross.SetPointCount(4); - pathCross.SetPoint(0, rcClient.right, rcClient.top, FXPT_MOVETO); - pathCross.SetPoint(1, rcClient.left, rcClient.bottom, FXPT_LINETO); - pathCross.SetPoint(2, rcClient.right, - rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO); - pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f, - rcClient.bottom, FXPT_LINETO); - - pDevice->DrawPath( - &pathCross, pUser2Device, &gsd, 0, - CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), - FXFILL_ALTERNATE); -} - -CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0) {} - -CPWL_Note_Icon::~CPWL_Note_Icon() {} - -void CPWL_Note_Icon::SetIconType(int32_t nType) { - m_nType = nType; -} - -void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) { - CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(), - GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR, - GetTransparency()); -} - -CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE) {} - -CPWL_Note_CloseBox::~CPWL_Note_CloseBox() {} - -void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) { - CPWL_Button::DrawThisAppearance(pDevice, pUser2Device); - - CFX_FloatRect rcClient = GetClientRect(); - rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f); - - CFX_GraphStateData gsd; - gsd.m_LineWidth = 1.0f; - - CFX_PathData pathCross; - - if (m_bMouseDown) { - rcClient.left += 0.5f; - rcClient.right += 0.5f; - rcClient.top -= 0.5f; - rcClient.bottom -= 0.5f; - } - - pathCross.SetPointCount(4); - pathCross.SetPoint(0, rcClient.left, rcClient.bottom, FXPT_MOVETO); - pathCross.SetPoint(1, rcClient.right, rcClient.top, FXPT_LINETO); - pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO); - pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO); - - pDevice->DrawPath( - &pathCross, pUser2Device, &gsd, 0, - CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), - FXFILL_ALTERNATE); -} - -FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CFX_FloatPoint& point, - uint32_t nFlag) { - SetBorderStyle(PBS_INSET); - InvalidateRect(NULL); - - m_bMouseDown = TRUE; - - return CPWL_Button::OnLButtonDown(point, nFlag); -} - -FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CFX_FloatPoint& point, - uint32_t nFlag) { - m_bMouseDown = FALSE; - - SetBorderStyle(PBS_BEVELED); - InvalidateRect(NULL); - - return CPWL_Button::OnLButtonUp(point, nFlag); -} - -CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) {} - -CPWL_Note_Contents::~CPWL_Note_Contents() {} - -CFX_ByteString CPWL_Note_Contents::GetClassName() const { - return "CPWL_Note_Contents"; -} - -void CPWL_Note_Contents::CreateChildWnd(const PWL_CREATEPARAM& cp) { - m_pEdit = new CPWL_Note_Edit; - PWL_CREATEPARAM ecp = cp; - ecp.pParentWnd = this; - ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_MULTILINE | PES_AUTORETURN | - PES_TEXTOVERFLOW | PES_UNDO | PES_SPELLCHECK; - - m_pEdit->EnableNotify(FALSE); - m_pEdit->Create(ecp); - m_pEdit->EnableNotify(TRUE); -} - -void CPWL_Note_Contents::SetText(const CFX_WideString& sText) { - if (m_pEdit) { - m_pEdit->EnableNotify(FALSE); - m_pEdit->SetText(sText.c_str()); - m_pEdit->EnableNotify(TRUE); - OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0); - } -} - -CFX_WideString CPWL_Note_Contents::GetText() const { - if (m_pEdit) - return m_pEdit->GetText(); - - return L""; -} - -int32_t CPWL_Note_Contents::CountSubItems() const { - return m_aChildren.GetSize() - 1; -} - -IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const { - int32_t nIndex = index + 1; - - if (nIndex > 0 && nIndex < m_aChildren.GetSize()) { - if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) { - ASSERT(pChild->GetClassName() == "CPWL_NoteItem"); - CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild; - return pItem; - } - } - return NULL; -} - -IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CFX_FloatPoint& point) { - CFX_FloatPoint pt = ParentToChild(point); - - for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { - if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { - if (pChild->GetClassName() == "CPWL_NoteItem") { - CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; - if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt)) - return pRet; - } - } - } - return NULL; -} - -void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam, - intptr_t lParam) { - switch (msg) { - case PNM_NOTEEDITCHANGED: { - int32_t nIndex = GetItemIndex(pWnd); - if (nIndex < 0) - nIndex = 0; - - m_pEdit->EnableNotify(FALSE); - ResetContent(nIndex); - m_pEdit->EnableNotify(TRUE); - - for (int32_t i = nIndex + 1, sz = m_aChildren.GetSize(); i < sz; i++) { - if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) - pChild->OnNotify(this, PNM_NOTERESET, 0, 0); - } - - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); - } - } - return; - case PNM_SCROLLWINDOW: - SetScrollPos(CFX_FloatPoint(0.0f, *(FX_FLOAT*)lParam)); - ResetFace(); - InvalidateRect(NULL); - return; - case PNM_SETCARETINFO: - if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { - PWL_CARET_INFO newInfo = *pInfo; - newInfo.bVisible = TRUE; - newInfo.ptHead = ChildToParent(pInfo->ptHead); - newInfo.ptFoot = ChildToParent(pInfo->ptFoot); - - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0); - } - } - return; - case PNM_NOTERESET: { - m_pEdit->EnableNotify(FALSE); - ResetContent(0); - m_pEdit->EnableNotify(TRUE); - - for (int32_t i = 1, sz = m_aChildren.GetSize(); i < sz; i++) { - if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) - pChild->OnNotify(this, PNM_NOTERESET, 0, 0); - } - - m_pEdit->EnableNotify(FALSE); - ResetContent(0); - m_pEdit->EnableNotify(TRUE); - } - return; - } - - CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); -} - -FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CFX_FloatPoint& point, - uint32_t nFlag) { - if (CPWL_Wnd::OnLButtonDown(point, nFlag)) - return TRUE; - - if (!m_pEdit->IsFocused()) { - m_pEdit->SetFocus(); - } - - return TRUE; -} - -void CPWL_Note_Contents::SetEditFocus(FX_BOOL bLast) { - if (!m_pEdit->IsFocused()) { - m_pEdit->SetFocus(); - m_pEdit->SetCaret(bLast ? m_pEdit->GetTotalWords() : 0); - } -} - -CPWL_Edit* CPWL_Note_Contents::GetEdit() const { - return m_pEdit; -} - -void CPWL_Note_Contents::EnableModify(FX_BOOL bEnabled) { - if (!bEnabled) - m_pEdit->AddFlag(PWS_READONLY); - else - m_pEdit->RemoveFlag(PWS_READONLY); - - for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { - if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { - if (pChild->GetClassName() == "CPWL_NoteItem") { - CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; - pNoteItem->EnableModify(bEnabled); - } - } - } -} - -void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled) { - if (!bEnabled) - m_pEdit->AddFlag(PES_NOREAD); - else - m_pEdit->RemoveFlag(PES_NOREAD); - - for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { - if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { - if (pChild->GetClassName() == "CPWL_NoteItem") { - CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; - pNoteItem->EnableRead(bEnabled); - } - } - } -} - -CPWL_NoteItem::CPWL_NoteItem() - : m_pSubject(NULL), - m_pDateTime(NULL), - m_pContents(NULL), - m_pPrivateData(NULL), - m_sAuthor(L""), - m_fOldItemHeight(0.0f), - m_bSizeChanged(FALSE), - m_bAllowModify(TRUE) {} - -CPWL_NoteItem::~CPWL_NoteItem() {} - -CFX_ByteString CPWL_NoteItem::GetClassName() const { - return "CPWL_NoteItem"; -} - -void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM& cp) { - CPWL_Color sTextColor; - - if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor())) - sTextColor = PWL_DEFAULT_WHITECOLOR; - else - sTextColor = PWL_DEFAULT_BLACKCOLOR; - - m_pSubject = new CPWL_Label; - PWL_CREATEPARAM scp = cp; - scp.pParentWnd = this; - scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP; - scp.sTextColor = sTextColor; - m_pSubject->Create(scp); - - m_pDateTime = new CPWL_Label; - PWL_CREATEPARAM dcp = cp; - dcp.pParentWnd = this; - dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP; - dcp.sTextColor = sTextColor; - m_pDateTime->Create(dcp); - - m_pContents = new CPWL_Note_Contents; - PWL_CREATEPARAM ccp = cp; - ccp.pParentWnd = this; - ccp.sBackgroundColor = - CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f); - ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND; - m_pContents->Create(ccp); - m_pContents->SetItemSpace(POPUP_ITEM_SPACE); - m_pContents->SetTopSpace(POPUP_ITEM_SPACE); - m_pContents->SetBottomSpace(POPUP_ITEM_SPACE); -} - -void CPWL_NoteItem::RePosChildWnd() { - if (IsValid()) { - CFX_FloatRect rcClient = GetClientRect(); - - CFX_FloatRect rcSubject = rcClient; - rcSubject.left += POPUP_ITEM_TEXT_INDENT; - rcSubject.top = rcClient.top; - rcSubject.right = - PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f, - rcClient.right); - rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height(); - rcSubject.Normalize(); - m_pSubject->Move(rcSubject, TRUE, FALSE); - m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject)); - - CFX_FloatRect rcDate = rcClient; - rcDate.right -= POPUP_ITEM_TEXT_INDENT; - rcDate.left = - PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f, - rcSubject.right); - rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height(); - rcDate.Normalize(); - m_pDateTime->Move(rcDate, TRUE, FALSE); - m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate)); - - CFX_FloatRect rcContents = rcClient; - rcContents.left += 1.0f; - rcContents.right -= 1.0f; - rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM; - rcContents.bottom += POPUP_ITEM_BOTTOMWIDTH; - rcContents.Normalize(); - m_pContents->Move(rcContents, TRUE, FALSE); - m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents)); - } - - SetClipRect(CPWL_Utils::InflateRect(GetWindowRect(), 1.0f)); -} - -void CPWL_NoteItem::SetPrivateData(void* pData) { - m_pPrivateData = pData; -} - -void CPWL_NoteItem::SetBkColor(const CPWL_Color& color) { - CPWL_Color sBK = color; - SetBackgroundColor(sBK); - - CPWL_Color sTextColor; - - if (CPWL_Utils::IsBlackOrWhite(sBK)) - sTextColor = PWL_DEFAULT_WHITECOLOR; - else - sTextColor = PWL_DEFAULT_BLACKCOLOR; - - SetTextColor(sTextColor); - if (m_pSubject) - m_pSubject->SetTextColor(sTextColor); - if (m_pDateTime) - m_pDateTime->SetTextColor(sTextColor); - - InvalidateRect(nullptr); -} - -void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) { - if (m_pSubject) - m_pSubject->SetText(sName.c_str()); -} - -void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) { - m_dtNote = time; - - CFX_WideString swTime; - swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth, - time.wDay, time.wHour, time.wMinute, time.wSecond); - if (m_pDateTime) { - m_pDateTime->SetText(swTime.c_str()); - } - - RePosChildWnd(); -} - -void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) { - if (m_pContents) { - m_pContents->SetText(sContents); - } -} - -CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const { - if (CPWL_Wnd* pParent = GetParentWindow()) { - if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) { - ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); - return (CPWL_NoteItem*)pGrand; - } - } - - return NULL; -} - -IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const { - return GetParentNoteItem(); -} - -CPWL_Edit* CPWL_NoteItem::GetEdit() const { - if (m_pContents) - return m_pContents->GetEdit(); - return NULL; -} - -void* CPWL_NoteItem::GetPrivateData() const { - return m_pPrivateData; -} - -CFX_WideString CPWL_NoteItem::GetAuthorName() const { - return m_sAuthor; -} - -CPWL_Color CPWL_NoteItem::GetBkColor() const { - return GetBackgroundColor(); -} - -CFX_WideString CPWL_NoteItem::GetContents() const { - if (m_pContents) - return m_pContents->GetText(); - - return L""; -} - -FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const { - return m_dtNote; -} - -CFX_WideString CPWL_NoteItem::GetSubjectName() const { - if (m_pSubject) - return m_pSubject->GetText(); - - return L""; -} - -int32_t CPWL_NoteItem::CountSubItems() const { - if (m_pContents) - return m_pContents->CountSubItems(); - - return 0; -} - -IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const { - if (m_pContents) - return m_pContents->GetSubItems(index); - - return NULL; -} - -IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CFX_FloatPoint& point) { - CFX_FloatPoint pt = ParentToChild(point); - - if (WndHitTest(pt)) { - if (m_pContents) { - if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt)) - return pNoteItem; - } - - return this; - } - - return NULL; -} - -IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const { - if (const CPWL_Wnd* pWnd = GetFocused()) { - if (pWnd->GetClassName() == "CPWL_Edit") { - if (CPWL_Wnd* pParent = pWnd->GetParentWindow()) { - ASSERT(pParent->GetClassName() == "CPWL_Note_Contents"); - - if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) { - ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); - return (CPWL_NoteItem*)pGrand; - } - } - } - } - - return NULL; -} - -FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) { - if (fLimitWidth > 0) { - if (!m_bSizeChanged) - return m_fOldItemHeight; - - m_bSizeChanged = FALSE; - - FX_FLOAT fRet = m_pDateTime->GetContentRect().Height(); - FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); - if (fLimitWidth > fBorderWidth * 2) - fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2); - fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2; - - return m_fOldItemHeight = fRet; - } - - return 0; -} - -FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() { - return POPUP_ITEM_SIDEMARGIN; -} - -FX_FLOAT CPWL_NoteItem::GetItemRightMargin() { - return POPUP_ITEM_SIDEMARGIN; -} - -FX_BOOL CPWL_NoteItem::OnLButtonDown(const CFX_FloatPoint& point, - uint32_t nFlag) { - if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { - SetNoteFocus(FALSE); - } - - CPWL_Wnd::OnLButtonDown(point, nFlag); - - return TRUE; -} - -FX_BOOL CPWL_NoteItem::OnRButtonUp(const CFX_FloatPoint& point, - uint32_t nFlag) { - if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { - SetNoteFocus(FALSE); - PopupNoteItemMenu(point); - - return TRUE; - } - - return CPWL_Wnd::OnRButtonUp(point, nFlag); -} - -void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam, - intptr_t lParam) { - switch (msg) { - case PNM_NOTEEDITCHANGED: - m_bSizeChanged = TRUE; - - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); - } - return; - case PNM_SETCARETINFO: - if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { - PWL_CARET_INFO newInfo = *pInfo; - newInfo.bVisible = TRUE; - newInfo.ptHead = ChildToParent(pInfo->ptHead); - newInfo.ptFoot = ChildToParent(pInfo->ptFoot); - - if (CPWL_Wnd* pParent = GetParentWindow()) { - pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0); - } - } - return; - case PNM_NOTERESET: - m_bSizeChanged = TRUE; - m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); - - return; - } - - CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); -} - -void CPWL_NoteItem::PopupNoteItemMenu(const CFX_FloatPoint& point) { -} - -void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) { - m_pContents->SetEditFocus(bLast); -} - -void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) { - m_pContents->EnableModify(bEnabled); - m_bAllowModify = bEnabled; -} - -void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) { - m_pContents->EnableRead(bEnabled); -} diff --git a/fpdfsdk/pdfwindow/PWL_Note.h b/fpdfsdk/pdfwindow/PWL_Note.h deleted file mode 100644 index e741f0f872..0000000000 --- a/fpdfsdk/pdfwindow/PWL_Note.h +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2014 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 FPDFSDK_PDFWINDOW_PWL_NOTE_H_ -#define FPDFSDK_PDFWINDOW_PWL_NOTE_H_ - -#include "fpdfsdk/pdfwindow/PWL_Button.h" -#include "fpdfsdk/pdfwindow/PWL_Edit.h" -#include "fpdfsdk/pdfwindow/PWL_ListCtrl.h" -#include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" -#include "fpdfsdk/pdfwindow/PWL_Wnd.h" - -class CPWL_Label; -class CPWL_Note; -class CPWL_NoteItem; -class CPWL_Note_CloseBox; -class CPWL_Note_Contents; -class CPWL_Note_Edit; -class CPWL_Note_Icon; -class CPWL_Note_LBBox; -class CPWL_Note_Options; -class CPWL_Note_RBBox; -class IPWL_NoteHandler; -class IPWL_NoteItem; -class IPopup_Note; - -class IPWL_NoteHandler { - public: - virtual ~IPWL_NoteHandler() {} - virtual void OnNoteColorChanged(const CPWL_Color& color) = 0; -}; - -class IPWL_NoteItem { - public: - virtual ~IPWL_NoteItem() {} - virtual void SetPrivateData(void* pData) = 0; - virtual void SetBkColor(const CPWL_Color& color) = 0; - virtual void SetSubjectName(const CFX_WideString& sName) = 0; - virtual void SetDateTime(FX_SYSTEMTIME time) = 0; - virtual void SetContents(const CFX_WideString& sContents) = 0; - - virtual int32_t CountSubItems() const = 0; - virtual IPWL_NoteItem* GetSubItems(int32_t index) const = 0; - virtual void SetFocus() = 0; - - virtual IPWL_NoteItem* GetParentItem() const = 0; - virtual void* GetPrivateData() const = 0; - virtual CFX_WideString GetAuthorName() const = 0; - virtual CPWL_Color GetBkColor() const = 0; - virtual CFX_WideString GetContents() const = 0; - virtual FX_SYSTEMTIME GetDateTime() const = 0; - virtual CFX_WideString GetSubjectName() const = 0; - - virtual CPWL_Edit* GetEdit() const = 0; -}; - -class CPWL_Note_Icon : public CPWL_Wnd { - public: - CPWL_Note_Icon(); - ~CPWL_Note_Icon() override; - - void SetIconType(int32_t nType); - - protected: - // CPWL_Wnd - void DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) override; - - private: - int32_t m_nType; -}; - -class CPWL_Note_CloseBox : public CPWL_Button { - public: - CPWL_Note_CloseBox(); - ~CPWL_Note_CloseBox() override; - - protected: - // CPWL_Button - void DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) override; - FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; - FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override; - - private: - FX_BOOL m_bMouseDown; -}; - -class CPWL_Note_LBBox : public CPWL_Wnd { - public: - CPWL_Note_LBBox(); - ~CPWL_Note_LBBox() override; - - protected: - // CPWL_Wnd - void DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) override; -}; - -class CPWL_Note_RBBox : public CPWL_Wnd { - public: - CPWL_Note_RBBox(); - ~CPWL_Note_RBBox() override; - - protected: - // CPWL_Wnd - void DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) override; -}; - -class CPWL_Note_Edit : public CPWL_Edit { - public: - CPWL_Note_Edit(); - ~CPWL_Note_Edit() override; - - void EnableNotify(FX_BOOL bEnable) { m_bEnableNotify = bEnable; } - - // CPWL_Edit - FX_FLOAT GetItemLeftMargin() override; - FX_FLOAT GetItemRightMargin() override; - FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) override; - void SetText(const FX_WCHAR* csText) override; - void OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam = 0, - intptr_t lParam = 0) override; - void RePosChildWnd() override; - void OnSetFocus() override; - void OnKillFocus() override; - - private: - FX_BOOL m_bEnableNotify; - FX_FLOAT m_fOldItemHeight; - FX_BOOL m_bSizeChanged; - FX_FLOAT m_fOldMin; - FX_FLOAT m_fOldMax; -}; - -class CPWL_Note_Options : public CPWL_Wnd { - public: - CPWL_Note_Options(); - ~CPWL_Note_Options() override; - - CFX_FloatRect GetContentRect() const; - void SetText(const CFX_WideString& sText); - - // CPWL_Wnd - void RePosChildWnd() override; - void CreateChildWnd(const PWL_CREATEPARAM& cp) override; - void DrawThisAppearance(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device) override; - void SetTextColor(const CPWL_Color& color) override; - - private: - CPWL_Label* m_pText; -}; - -class CPWL_Note_Contents : public CPWL_ListCtrl { - public: - CPWL_Note_Contents(); - ~CPWL_Note_Contents() override; - - void SetEditFocus(FX_BOOL bLast); - CPWL_Edit* GetEdit() const; - - void SetText(const CFX_WideString& sText); - CFX_WideString GetText() const; - - int32_t CountSubItems() const; - IPWL_NoteItem* GetSubItems(int32_t index) const; - - virtual IPWL_NoteItem* GetHitNoteItem(const CFX_FloatPoint& point); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - - // CPWL_ListCtrl - CFX_ByteString GetClassName() const override; - void OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam = 0, - intptr_t lParam = 0) override; - FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; - void CreateChildWnd(const PWL_CREATEPARAM& cp) override; - - private: - CPWL_Note_Edit* m_pEdit; -}; - -class CPWL_NoteItem : public CPWL_Wnd, public IPWL_NoteItem { - public: - CPWL_NoteItem(); - ~CPWL_NoteItem() override; - - virtual IPWL_NoteItem* GetHitNoteItem(const CFX_FloatPoint& point); - virtual IPWL_NoteItem* GetFocusedNoteItem() const; - - virtual FX_BOOL IsTopItem() const { return FALSE; } - - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - - // IPWL_NoteItem - void SetPrivateData(void* pData) override; - void SetBkColor(const CPWL_Color& color) override; - void SetSubjectName(const CFX_WideString& sName) override; - void SetDateTime(FX_SYSTEMTIME time) override; - void SetContents(const CFX_WideString& sContents) override; - int32_t CountSubItems() const override; - IPWL_NoteItem* GetSubItems(int32_t index) const override; - void SetFocus() override { SetNoteFocus(FALSE); } - IPWL_NoteItem* GetParentItem() const override; - void* GetPrivateData() const override; - CFX_WideString GetAuthorName() const override; - CPWL_Color GetBkColor() const override; - CFX_WideString GetContents() const override; - FX_SYSTEMTIME GetDateTime() const override; - CFX_WideString GetSubjectName() const override; - CPWL_Edit* GetEdit() const override; - - protected: - // CPWL_Wnd - FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; - FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override; - CFX_ByteString GetClassName() const override; - void RePosChildWnd() override; - void CreateChildWnd(const PWL_CREATEPARAM& cp) override; - void OnNotify(CPWL_Wnd* pWnd, - uint32_t msg, - intptr_t wParam = 0, - intptr_t lParam = 0) override; - FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) override; - FX_FLOAT GetItemLeftMargin() override; - FX_FLOAT GetItemRightMargin() override; - - CPWL_NoteItem* GetParentNoteItem() const; - - void SetNoteFocus(FX_BOOL bLast); - void PopupNoteItemMenu(const CFX_FloatPoint& point); - - protected: - CPWL_Label* m_pSubject; - CPWL_Label* m_pDateTime; - CPWL_Note_Contents* m_pContents; - - private: - void* m_pPrivateData; - FX_SYSTEMTIME m_dtNote; - CFX_WideString m_sAuthor; - - FX_FLOAT m_fOldItemHeight; - FX_BOOL m_bSizeChanged; - FX_BOOL m_bAllowModify; -}; - -#endif // FPDFSDK_PDFWINDOW_PWL_NOTE_H_ diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index fe0075c2b0..92787b9e6c 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -430,152 +430,6 @@ CFX_ByteString CPWL_Utils::GetEditSelAppStream(IFX_Edit* pEdit, return IFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange); } -static CFX_ByteString GetSquigglyAppearanceStream(FX_FLOAT fStartX, - FX_FLOAT fEndX, - FX_FLOAT fY, - FX_FLOAT fStep) { - CFX_ByteTextBuf sRet; - - sRet << "0 w\n" << fStartX << " " << fY << " m\n"; - - FX_FLOAT fx; - int32_t i; - - for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) { - sRet << fx << " " << fY + (i & 1) * fStep << " l\n"; - } - - sRet << "S\n"; - - return sRet.GetByteString(); -} - -static CFX_ByteString GetWordSpellCheckAppearanceStream( - IFX_Edit_Iterator* pIterator, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange& wrWord) { - CFX_ByteTextBuf sRet; - - FX_FLOAT fStartX = 0.0f; - FX_FLOAT fEndX = 0.0f; - FX_FLOAT fY = 0.0f; - FX_FLOAT fStep = 0.0f; - - FX_BOOL bBreak = FALSE; - - if (pIterator) { - pIterator->SetAt(wrWord.BeginPos); - - do { - CPVT_WordPlace place = pIterator->GetAt(); - - CPVT_Line line; - if (pIterator->GetLine(line)) { - fY = line.ptLine.y; - fStep = (line.fLineAscent - line.fLineDescent) / 16.0f; - } - - if (place.LineCmp(wrWord.BeginPos) == 0) { - pIterator->SetAt(wrWord.BeginPos); - CPVT_Word word; - if (pIterator->GetWord(word)) { - fStartX = word.ptWord.x; - } - } else { - fStartX = line.ptLine.x; - } - - if (place.LineCmp(wrWord.EndPos) == 0) { - pIterator->SetAt(wrWord.EndPos); - CPVT_Word word; - if (pIterator->GetWord(word)) { - fEndX = word.ptWord.x + word.fWidth; - } - - bBreak = TRUE; - } else { - fEndX = line.ptLine.x + line.fLineWidth; - } - - sRet << GetSquigglyAppearanceStream( - fStartX + ptOffset.x, fEndX + ptOffset.x, fY + ptOffset.y, fStep); - - if (bBreak) - break; - } while (pIterator->NextLine()); - } - - return sRet.GetByteString(); -} - -CFX_ByteString CPWL_Utils::GetSpellCheckAppStream( - IFX_Edit* pEdit, - IPWL_SpellCheck* pSpellCheck, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange) { - CFX_ByteTextBuf sRet; - - if (pRange && pRange->IsExist()) { - if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { - pIterator->SetAt(pRange->BeginPos); - - FX_BOOL bLatinWord = FALSE; - CPVT_WordPlace wpWordStart; - CFX_ByteString sWord; - - CPVT_WordPlace oldplace; - while (pIterator->NextWord()) { - CPVT_WordPlace place = pIterator->GetAt(); - if (pRange && place.WordCmp(pRange->EndPos) > 0) - break; - - CPVT_Word word; - if (pIterator->GetWord(word)) { - if (FX_EDIT_ISLATINWORD(word.Word)) { - if (!bLatinWord) { - wpWordStart = place; - bLatinWord = TRUE; - } - - sWord += (char)word.Word; - oldplace = place; - } else { - if (bLatinWord) { - if (!pSpellCheck->CheckWord(sWord)) { - sRet << GetWordSpellCheckAppearanceStream( - pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace)); - pIterator->SetAt(place); - } - bLatinWord = FALSE; - } - - sWord.Empty(); - } - } else { - if (bLatinWord) { - if (!pSpellCheck->CheckWord(sWord)) - sRet << GetWordSpellCheckAppearanceStream( - pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace)); - bLatinWord = FALSE; - sWord.Empty(); - } - } - } - - if (bLatinWord) { - if (!pSpellCheck->CheckWord(sWord)) - sRet << GetWordSpellCheckAppearanceStream( - pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace)); - - bLatinWord = FALSE; - sWord.Empty(); - } - } - } - - return sRet.GetByteString(); -} - CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox, IPVT_FontMap* pFontMap, const CFX_WideString& sText, @@ -1608,173 +1462,6 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, } } -static void AddSquigglyPath(CFX_PathData& PathData, - FX_FLOAT fStartX, - FX_FLOAT fEndX, - FX_FLOAT fY, - FX_FLOAT fStep) { - PathData.AddPointCount(1); - PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO); - - FX_FLOAT fx; - int32_t i; - - for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) { - PathData.AddPointCount(1); - PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i & 1) * fStep, - FXPT_LINETO); - } -} - -static void AddSpellCheckObj(CFX_PathData& PathData, - IFX_Edit* pEdit, - const CPVT_WordRange& wrWord) { - FX_FLOAT fStartX = 0.0f; - FX_FLOAT fEndX = 0.0f; - FX_FLOAT fY = 0.0f; - FX_FLOAT fStep = 0.0f; - - FX_BOOL bBreak = FALSE; - - if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { - pIterator->SetAt(wrWord.BeginPos); - - do { - CPVT_WordPlace place = pIterator->GetAt(); - - CPVT_Line line; - if (pIterator->GetLine(line)) { - fY = line.ptLine.y; - fStep = (line.fLineAscent - line.fLineDescent) / 16.0f; - } - - if (place.LineCmp(wrWord.BeginPos) == 0) { - pIterator->SetAt(wrWord.BeginPos); - CPVT_Word word; - if (pIterator->GetWord(word)) { - fStartX = word.ptWord.x; - } - } else { - fStartX = line.ptLine.x; - } - - if (place.LineCmp(wrWord.EndPos) == 0) { - pIterator->SetAt(wrWord.EndPos); - CPVT_Word word; - if (pIterator->GetWord(word)) { - fEndX = word.ptWord.x + word.fWidth; - } - - bBreak = TRUE; - } else { - fEndX = line.ptLine.x + line.fLineWidth; - } - - AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep); - - if (bBreak) - break; - } while (pIterator->NextLine()); - } -} - -void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - IFX_Edit* pEdit, - const CFX_FloatRect& rcClip, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - IPWL_SpellCheck* pSpellCheck) { - const FX_COLORREF crSpell = ArgbEncode(255, 255, 0, 0); - - // for spellcheck - FX_BOOL bLatinWord = FALSE; - CPVT_WordPlace wpWordStart; - CFX_ByteString sLatinWord; - - CFX_PathData pathSpell; - - pDevice->SaveState(); - - if (!rcClip.IsEmpty()) { - CFX_FloatRect rcTemp = rcClip; - pUser2Device->TransformRect(rcTemp); - pDevice->SetClip_Rect(rcTemp.ToFxRect()); - } - - if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { - if (pEdit->GetFontMap()) { - if (pRange) - pIterator->SetAt(pRange->BeginPos); - else - pIterator->SetAt(0); - - CPVT_WordPlace oldplace; - - while (pIterator->NextWord()) { - CPVT_WordPlace place = pIterator->GetAt(); - if (pRange && place.WordCmp(pRange->EndPos) > 0) - break; - - CPVT_Word word; - if (pIterator->GetWord(word)) { - if (FX_EDIT_ISLATINWORD(word.Word)) { - if (!bLatinWord) { - wpWordStart = place; - bLatinWord = TRUE; - } - - sLatinWord += (char)word.Word; - } else { - if (bLatinWord) { - if (!sLatinWord.IsEmpty()) { - if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) { - AddSpellCheckObj(pathSpell, pEdit, - CPVT_WordRange(wpWordStart, oldplace)); - pIterator->SetAt(place); - } - } - bLatinWord = FALSE; - } - - sLatinWord.Empty(); - } - - oldplace = place; - } else { - if (bLatinWord) { - if (!sLatinWord.IsEmpty()) { - if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) { - AddSpellCheckObj(pathSpell, pEdit, - CPVT_WordRange(wpWordStart, oldplace)); - pIterator->SetAt(place); - } - } - bLatinWord = FALSE; - } - - sLatinWord.Empty(); - } - } - - if (!sLatinWord.IsEmpty()) { - if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) { - AddSpellCheckObj(pathSpell, pEdit, - CPVT_WordRange(wpWordStart, oldplace)); - } - } - } - } - - CFX_GraphStateData gsd; - gsd.m_LineWidth = 0; - if (pathSpell.GetPointCount() > 0) - pDevice->DrawPath(&pathSpell, pUser2Device, &gsd, 0, crSpell, - FXFILL_ALTERNATE); - - pDevice->RestoreState(); -} - FX_BOOL CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) { switch (color.nColorType) { case COLORTYPE_TRANSPARENT: diff --git a/fpdfsdk/pdfwindow/PWL_Utils.h b/fpdfsdk/pdfwindow/PWL_Utils.h index 76c3c478b7..cdef768cfa 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.h +++ b/fpdfsdk/pdfwindow/PWL_Utils.h @@ -100,8 +100,6 @@ class CPWL_PathData { PWL_PATHDATA_TYPE type; }; -class IPWL_SpellCheck; - class CPWL_Utils { public: static CFX_FloatRect InflateRect(const CFX_FloatRect& rcRect, FX_FLOAT fSize); @@ -177,11 +175,6 @@ class CPWL_Utils { IFX_Edit* pEdit, const CFX_FloatPoint& ptOffset, const CPVT_WordRange* pRange = NULL); - static CFX_ByteString GetSpellCheckAppStream( - IFX_Edit* pEdit, - IPWL_SpellCheck* pSpellCheck, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange = NULL); static CFX_ByteString GetTextAppStream(const CFX_FloatRect& rcBBox, IPVT_FontMap* pFontMap, const CFX_WideString& sText, @@ -235,13 +228,6 @@ class CPWL_Utils { int32_t nTransparancy, int32_t nStartGray, int32_t nEndGray); - static void DrawEditSpellCheck(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - IFX_Edit* pEdit, - const CFX_FloatRect& rcClip, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - IPWL_SpellCheck* pSpellCheck); public: static void ConvertCMYK2RGB(FX_FLOAT dC, diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index 7cad1cc664..b9448c4362 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h @@ -21,7 +21,6 @@ class CPWL_Wnd; class IPVT_FontMap; class IFX_SystemHandler; class IPWL_Provider; -class IPWL_SpellCheck; // window styles #define PWS_CHILD 0x80000000L @@ -65,7 +64,6 @@ class IPWL_SpellCheck; #define PRES_MULTILINE 0x0001L #define PRES_AUTORETURN 0x0002L #define PRES_AUTOSCROLL 0x0004L -#define PRES_SPELLCHECK 0x0008L #define PRES_UNDO 0x0100L #define PRES_MULTIPAGES 0x0200L #define PRES_TEXTOVERFLOW 0x0400L @@ -168,14 +166,6 @@ inline bool operator!=(const CPWL_Color& c1, const CPWL_Color& c2) { #define PWL_CBBUTTON_TRIANGLE_HALFLEN 3.0f #define PWL_INVALIDATE_INFLATE 2 -class IPWL_SpellCheck { - public: - virtual ~IPWL_SpellCheck() {} - virtual FX_BOOL CheckWord(const FX_CHAR* sWord) = 0; - virtual void SuggestWords(const FX_CHAR* sWord, - std::vector& sSuggest) = 0; -}; - class IPWL_Provider { public: virtual ~IPWL_Provider() {} @@ -213,7 +203,6 @@ struct PWL_CREATEPARAM { dwFlags(0), sBackgroundColor(), hAttachedWnd(NULL), - pSpellCheck(NULL), nBorderStyle(PBS_SOLID), dwBorderWidth(1), sBorderColor(), @@ -236,7 +225,6 @@ struct PWL_CREATEPARAM { uint32_t dwFlags; // optional CPWL_Color sBackgroundColor; // optional FX_HWND hAttachedWnd; // required for no-reader framework - IPWL_SpellCheck* pSpellCheck; // required for spellchecking int32_t nBorderStyle; // optional int32_t dwBorderWidth; // optional CPWL_Color sBorderColor; // optional diff --git a/pdfium.gyp b/pdfium.gyp index 1d2fa0d6e7..02a6f1eacb 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -796,8 +796,6 @@ 'fpdfsdk/pdfwindow/PWL_ListBox.h', 'fpdfsdk/pdfwindow/PWL_ListCtrl.cpp', 'fpdfsdk/pdfwindow/PWL_ListCtrl.h', - 'fpdfsdk/pdfwindow/PWL_Note.cpp', - 'fpdfsdk/pdfwindow/PWL_Note.h', 'fpdfsdk/pdfwindow/PWL_ScrollBar.cpp', 'fpdfsdk/pdfwindow/PWL_ScrollBar.h', 'fpdfsdk/pdfwindow/PWL_Signature.cpp', -- cgit v1.2.3