From b696f7d616ef397a01af1d6bd01c061922a259f7 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 2 May 2016 06:49:58 -0700 Subject: Remove IFDE_TxtEdt interfaces where possible. This CL removes the following and uses the only instance instead. * IFDE_TxtEdtParag * IFDE_TxtEdtEventSink * IFDE_TxtEdtEngine * IFDE_TxtEdtBuf Review-Url: https://codereview.chromium.org/1927973003 --- xfa/fee/fde_txtedtbuf.cpp | 59 ++++++++------ xfa/fee/fde_txtedtbuf.h | 63 +++++++-------- xfa/fee/fde_txtedtengine.cpp | 143 +++++++++++++++------------------ xfa/fee/fde_txtedtengine.h | 139 +++++++++++++++----------------- xfa/fee/fde_txtedtpage.cpp | 13 ++- xfa/fee/fde_txtedtpage.h | 4 +- xfa/fee/fde_txtedtparag.cpp | 5 +- xfa/fee/fde_txtedtparag.h | 26 +++--- xfa/fee/ifde_txtedtbuf.h | 39 --------- xfa/fee/ifde_txtedtengine.h | 129 ++++------------------------- xfa/fee/ifde_txtedtpage.h | 7 +- xfa/fwl/basewidget/fwl_comboboximp.cpp | 1 + xfa/fwl/basewidget/fwl_editimp.cpp | 45 ++++------- xfa/fwl/basewidget/fwl_editimp.h | 48 ++++------- 14 files changed, 273 insertions(+), 448 deletions(-) delete mode 100644 xfa/fee/ifde_txtedtbuf.h (limited to 'xfa') diff --git a/xfa/fee/fde_txtedtbuf.cpp b/xfa/fee/fde_txtedtbuf.cpp index 4464a0f515..988ca4a5c1 100644 --- a/xfa/fee/fde_txtedtbuf.cpp +++ b/xfa/fee/fde_txtedtbuf.cpp @@ -8,9 +8,14 @@ #include -#include "xfa/fee/ifde_txtedtbuf.h" #include "xfa/fee/ifde_txtedtengine.h" +namespace { + +const int kDefaultChunkSize = 1024; + +} // namespace + #define FDE_DEFCHUNKCOUNT 2 #define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9 #define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB @@ -34,7 +39,7 @@ FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) { return FALSE; } ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize()); - CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunk = NULL; + CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = nullptr; if (m_nCurIndex > 0) { m_nCurIndex--; } else { @@ -55,14 +60,14 @@ FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) { return FALSE; } ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize()); - CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunk = m_pBuf->m_Chunks[m_nCurChunk]; + CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = m_pBuf->m_Chunks[m_nCurChunk]; if (lpChunk->nUsed != (m_nCurIndex + 1)) { m_nCurIndex++; } else { int32_t nEnd = m_pBuf->m_Chunks.GetSize() - 1; while (m_nCurChunk < nEnd) { m_nCurChunk++; - CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunkTemp = + CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunkTemp = m_pBuf->m_Chunks[m_nCurChunk]; if (lpChunkTemp->nUsed > 0) { m_nCurIndex = 0; @@ -103,8 +108,9 @@ IFX_CharIter* CFDE_TxtEdtBufIter::Clone() { pIter->m_Alias = m_Alias; return pIter; } -CFDE_TxtEdtBuf::CFDE_TxtEdtBuf(int32_t nDefChunkSize) - : m_nChunkSize(nDefChunkSize), + +CFDE_TxtEdtBuf::CFDE_TxtEdtBuf() + : m_nChunkSize(kDefaultChunkSize), m_nTotal(0), m_bChanged(FALSE), m_pAllocator(NULL) { @@ -138,8 +144,9 @@ void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) { ((nTextLength - 1) / m_nChunkSize + 1) - m_Chunks.GetSize(); int32_t i = 0; for (i = 0; i < nNeedCount; i++) { - FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc( - sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)); + FDE_CHUNKHEADER* lpChunk = + static_cast(m_pAllocator->Alloc( + sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR))); lpChunk->nUsed = 0; m_Chunks.Add(lpChunk); } @@ -151,7 +158,7 @@ void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) { if (nLeave < nCopyedLength) { nCopyedLength = nLeave; } - FDE_LPCHUNKHEADER lpChunk = m_Chunks[i]; + FDE_CHUNKHEADER* lpChunk = m_Chunks[i]; FXSYS_memcpy(lpChunk->wChars, lpSrcBuf, nCopyedLength * sizeof(FX_WCHAR)); nLeave -= nCopyedLength; lpSrcBuf += nCopyedLength; @@ -165,7 +172,7 @@ void CFDE_TxtEdtBuf::GetText(CFX_WideString& wsText) const { } FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const { ASSERT(nIndex >= 0 && nIndex < GetTextLength()); - FDE_LPCHUNKHEADER pChunkHeader = NULL; + FDE_CHUNKHEADER* pChunkHeader = nullptr; int32_t nTotal = 0; int32_t nCount = m_Chunks.GetSize(); int32_t i = 0; @@ -188,7 +195,7 @@ void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText, int32_t nCount = m_Chunks.GetSize(); FX_WCHAR* lpDstBuf = wsText.GetBuffer(nLength); int32_t nChunkIndex = cp.nChunkIndex; - FDE_LPCHUNKHEADER lpChunkHeader = m_Chunks[nChunkIndex]; + FDE_CHUNKHEADER* lpChunkHeader = m_Chunks[nChunkIndex]; int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex; FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex; while (nLeave > 0) { @@ -216,9 +223,10 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos, Index2CP(nPos, cp); int32_t nLengthTemp = nLength; if (cp.nCharIndex != 0) { - FDE_LPCHUNKHEADER lpNewChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc( - sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)); - FDE_LPCHUNKHEADER lpChunk = m_Chunks[cp.nChunkIndex]; + FDE_CHUNKHEADER* lpNewChunk = + static_cast(m_pAllocator->Alloc( + sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR))); + FDE_CHUNKHEADER* lpChunk = m_Chunks[cp.nChunkIndex]; int32_t nCopy = lpChunk->nUsed - cp.nCharIndex; FXSYS_memcpy(lpNewChunk->wChars, lpChunk->wChars + cp.nCharIndex, nCopy * sizeof(FX_WCHAR)); @@ -229,7 +237,7 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos, cp.nCharIndex = 0; } if (cp.nChunkIndex != 0) { - FDE_LPCHUNKHEADER lpChunk = m_Chunks[cp.nChunkIndex - 1]; + FDE_CHUNKHEADER* lpChunk = m_Chunks[cp.nChunkIndex - 1]; if (lpChunk->nUsed != m_nChunkSize) { cp.nChunkIndex--; int32_t nFree = m_nChunkSize - lpChunk->nUsed; @@ -243,8 +251,9 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos, } } while (nLengthTemp > 0) { - FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc( - sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)); + FDE_CHUNKHEADER* lpChunk = + static_cast(m_pAllocator->Alloc( + sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR))); ASSERT(lpChunk); int32_t nCopy = std::min(nLengthTemp, m_nChunkSize); FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR)); @@ -262,7 +271,7 @@ void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) { FDE_CHUNKPLACE cpEnd; Index2CP(nIndex + nLength - 1, cpEnd); m_nTotal -= nLength; - FDE_LPCHUNKHEADER lpChunk = m_Chunks[cpEnd.nChunkIndex]; + FDE_CHUNKHEADER* lpChunk = m_Chunks[cpEnd.nChunkIndex]; int32_t nFirstPart = cpEnd.nCharIndex + 1; int32_t nMovePart = lpChunk->nUsed - nFirstPart; if (nMovePart != 0) { @@ -316,7 +325,7 @@ FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) { } int32_t i = 0; for (; i < nCount; i++) { - FDE_LPCHUNKHEADER lpChunk = m_Chunks[i]; + FDE_CHUNKHEADER* lpChunk = m_Chunks[i]; if (lpChunk->nUsed == 0) { m_pAllocator->Free(lpChunk); m_Chunks.RemoveAt(i); @@ -324,11 +333,11 @@ FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) { --nCount; } } - if (pPause != NULL && pPause->NeedToPauseNow()) { + if (pPause && pPause->NeedToPauseNow()) return FALSE; - } - FDE_LPCHUNKHEADER lpPreChunk = m_Chunks[0]; - FDE_LPCHUNKHEADER lpCurChunk = NULL; + + FDE_CHUNKHEADER* lpPreChunk = m_Chunks[0]; + FDE_CHUNKHEADER* lpCurChunk = nullptr; for (i = 1; i < nCount; i++) { lpCurChunk = m_Chunks[i]; if (lpPreChunk->nUsed + lpCurChunk->nUsed <= m_nChunkSize) { @@ -364,8 +373,8 @@ void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount, m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, nDefChunkCount, nChunkLength); ASSERT(m_pAllocator); - FDE_LPCHUNKHEADER lpChunkHeader = - (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(nChunkLength); + FDE_CHUNKHEADER* lpChunkHeader = + static_cast(m_pAllocator->Alloc(nChunkLength)); ASSERT(lpChunkHeader); lpChunkHeader->nUsed = 0; m_Chunks.Add(lpChunkHeader); diff --git a/xfa/fee/fde_txtedtbuf.h b/xfa/fee/fde_txtedtbuf.h index 102217da87..5d7de45401 100644 --- a/xfa/fee/fde_txtedtbuf.h +++ b/xfa/fee/fde_txtedtbuf.h @@ -7,7 +7,6 @@ #ifndef XFA_FEE_FDE_TXTEDTBUF_H_ #define XFA_FEE_FDE_TXTEDTBUF_H_ -#include "xfa/fee/ifde_txtedtbuf.h" #include "xfa/fee/ifde_txtedtengine.h" #include "xfa/fgas/crt/fgas_memory.h" @@ -36,47 +35,43 @@ class CFDE_TxtEdtBufIter : public IFX_CharIter { int32_t m_nIndex; FX_WCHAR m_Alias; }; -class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf { +class CFDE_TxtEdtBuf { + public: + CFDE_TxtEdtBuf(); + + void Release(); + FX_BOOL SetChunkSize(int32_t nChunkSize); + int32_t GetChunkSize() const; + int32_t GetTextLength() const; + void SetText(const CFX_WideString& wsText); + void GetText(CFX_WideString& wsText) const; + FX_WCHAR GetCharByIndex(int32_t nIndex) const; + void GetRange(CFX_WideString& wsText, + int32_t nBegin, + int32_t nCount = -1) const; + + void Insert(int32_t nPos, const FX_WCHAR* lpText, int32_t nLength = 1); + void Delete(int32_t nIndex, int32_t nLength = 1); + void Clear(FX_BOOL bRelease = TRUE); + + FX_BOOL Optimize(IFX_Pause* pPause = nullptr); + + protected: + ~CFDE_TxtEdtBuf(); + + private: friend class CFDE_TxtEdtBufIter; - struct _FDE_CHUNKHEADER { + + struct FDE_CHUNKHEADER { int32_t nUsed; FX_WCHAR wChars[1]; }; - typedef _FDE_CHUNKHEADER FDE_CHUNKHEADER; - typedef _FDE_CHUNKHEADER* FDE_LPCHUNKHEADER; - struct _FDE_CHUNKPLACE { + + struct FDE_CHUNKPLACE { int32_t nChunkIndex; int32_t nCharIndex; }; - typedef _FDE_CHUNKPLACE FDE_CHUNKPLACE; - typedef _FDE_CHUNKPLACE* FDE_LPCHUNKPLACE; - - public: - CFDE_TxtEdtBuf(int32_t nDefChunkSize = FDE_DEFCHUNKLENGTH); - - virtual void Release(); - virtual FX_BOOL SetChunkSize(int32_t nChunkSize); - virtual int32_t GetChunkSize() const; - virtual int32_t GetTextLength() const; - virtual void SetText(const CFX_WideString& wsText); - virtual void GetText(CFX_WideString& wsText) const; - virtual FX_WCHAR GetCharByIndex(int32_t nIndex) const; - virtual void GetRange(CFX_WideString& wsText, - int32_t nBegine, - int32_t nCount = -1) const; - - virtual void Insert(int32_t nPos, - const FX_WCHAR* lpText, - int32_t nLength = 1); - virtual void Delete(int32_t nIndex, int32_t nLength = 1); - virtual void Clear(FX_BOOL bRelease = TRUE); - - virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL); - - protected: - virtual ~CFDE_TxtEdtBuf(); - private: void ResetChunkBuffer(int32_t nDefChunkCount, int32_t nChunkSize); int32_t CP2Index(const FDE_CHUNKPLACE& cp) const; void Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const; diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fee/fde_txtedtengine.cpp index 1dc03dcc85..812817fbfa 100644 --- a/xfa/fee/fde_txtedtengine.cpp +++ b/xfa/fee/fde_txtedtengine.cpp @@ -9,11 +9,10 @@ #include #include "xfa/fde/tto/fde_textout.h" -#include "xfa/fee/fde_txtedtbuf.h" #include "xfa/fee/fde_txtedtparag.h" -#include "xfa/fee/ifde_txtedtbuf.h" #include "xfa/fee/ifde_txtedtengine.h" #include "xfa/fee/ifde_txtedtpage.h" +#include "xfa/fwl/basewidget/fwl_editimp.h" #define FDE_PAGEWIDTH_MAX 0xFFFF #define FDE_TXTPLATESIZE (1024 * 12) @@ -21,9 +20,6 @@ #define FDE_TXTEDT_DORECORD_INS 0 #define FDE_TXTEDT_DORECORD_DEL 1 -IFDE_TxtEdtEngine* IFDE_TxtEdtEngine::Create() { - return new CFDE_TxtEdtEngine(); -} CFDE_TxtEdtEngine::CFDE_TxtEdtEngine() : m_pTextBreak(nullptr), m_nPageLineCount(20), @@ -71,7 +67,7 @@ void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) { m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto); UpdateTxtBreak(); } -const FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() const { +FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() { return &m_Param; } int32_t CFDE_TxtEdtEngine::CountPages() const { @@ -329,7 +325,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart, int32_t nTotalLength = GetTextBufLength(); int32_t nCount = m_SelRangePtrArr.GetSize(); for (int32_t i = 0; i < nCount; i++) { - FDE_LPTXTEDTSELRANGE lpSelRange = m_SelRangePtrArr.GetAt(i); + FDE_TXTEDTSELRANGE* lpSelRange = m_SelRangePtrArr.GetAt(i); nTotalLength -= lpSelRange->nCount; } int32_t nExpectLength = nTotalLength + nLength; @@ -538,7 +534,7 @@ void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) { } void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) { - FDE_LPTXTEDTSELRANGE lpTemp = NULL; + FDE_TXTEDTSELRANGE* lpTemp = nullptr; int32_t nRangeCount = m_SelRangePtrArr.GetSize(); int32_t i = 0; for (i = 0; i < nRangeCount; i++) { @@ -557,17 +553,17 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { } int32_t nSize = m_SelRangePtrArr.GetSize(); if (nSize <= 0) { - FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; + FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE; lpSelRange->nStart = nStart; lpSelRange->nCount = nCount; m_SelRangePtrArr.Add(lpSelRange); m_Param.pEventSink->On_SelChanged(this); return; } - FDE_LPTXTEDTSELRANGE lpTemp = NULL; + FDE_TXTEDTSELRANGE* lpTemp = nullptr; lpTemp = m_SelRangePtrArr[nSize - 1]; if (nStart >= lpTemp->nStart + lpTemp->nCount) { - FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; + FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE; lpSelRange->nStart = nStart; lpSelRange->nCount = nCount; m_SelRangePtrArr.Add(lpSelRange); @@ -602,7 +598,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { } } if (nRangeCnt == 0) { - FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE; + FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE; lpSelRange->nStart = nStart; lpSelRange->nCount = nCount; m_SelRangePtrArr.InsertAt(nRangeBgn, lpSelRange); @@ -683,7 +679,7 @@ int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) { for (; m_nLayoutPos < nCount; m_nLayoutPos++) { pParag = m_ParagPtrArray[m_nLayoutPos]; pParag->CalcLines(); - nLineCount += pParag->m_nLineCount; + nLineCount += pParag->GetLineCount(); if ((pPause != NULL) && (nLineCount > m_nPageLineCount) && pPause->NeedToPauseNow()) { m_nLineCount += nLineCount; @@ -709,8 +705,8 @@ void CFDE_TxtEdtEngine::EndLayout() { FX_BOOL CFDE_TxtEdtEngine::Optimize(IFX_Pause* pPause) { return m_pTxtBuf->Optimize(pPause); } -IFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const { - return (IFDE_TxtEdtBuf*)m_pTxtBuf; +CFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const { + return m_pTxtBuf; } int32_t CFDE_TxtEdtEngine::GetTextBufLength() const { return m_pTxtBuf->GetTextLength() - 1; @@ -727,7 +723,7 @@ int32_t CFDE_TxtEdtEngine::GetPageLineCount() const { int32_t CFDE_TxtEdtEngine::CountParags() const { return m_ParagPtrArray.GetSize(); } -IFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const { +CFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const { return m_ParagPtrArray[nParagIndex]; } IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() { @@ -746,12 +742,12 @@ int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag, int32_t i = nStartParag; for (; i < nCount; i++) { pParag = m_ParagPtrArray[i]; - nLineTotal += pParag->m_nLineCount; + nLineTotal += pParag->GetLineCount(); if (nLineTotal > nLineIndex) { break; } } - nStartLine = nLineTotal - pParag->m_nLineCount; + nStartLine = nLineTotal - pParag->GetLineCount(); return i; } void CFDE_TxtEdtEngine::GetPreDeleteText(CFX_WideString& wsText, @@ -812,14 +808,14 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); int32_t nParagCount = m_ParagPtrArray.GetSize(); int32_t i = 0; - for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++) { - m_ParagPtrArray[i]->m_nCharStart += nLength; - } + for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++) + m_ParagPtrArray[i]->IncrementStartIndex(nLength); + CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - int32_t nReserveLineCount = pParag->m_nLineCount; - int32_t nReserveCharStart = pParag->m_nCharStart; + int32_t nReserveLineCount = pParag->GetLineCount(); + int32_t nReserveCharStart = pParag->GetStartIndex(); int32_t nLeavePart = ParagPos.nCharIndex; - int32_t nCutPart = pParag->m_nCharCount - ParagPos.nCharIndex; + int32_t nCutPart = pParag->GetTextLength() - ParagPos.nCharIndex; int32_t nTextStart = 0; FX_WCHAR wCurChar = L' '; const FX_WCHAR* lpPos = lpText; @@ -829,30 +825,30 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, wCurChar = *lpPos; if (wCurChar == m_wLineEnd) { if (bFirst) { - pParag->m_nCharCount = nLeavePart + (i - nTextStart + 1); - pParag->m_nLineCount = -1; - nReserveCharStart += pParag->m_nCharCount; + pParag->SetTextLength(nLeavePart + (i - nTextStart + 1)); + pParag->SetLineCount(-1); + nReserveCharStart += pParag->GetTextLength(); bFirst = FALSE; } else { pParag = new CFDE_TxtEdtParag(this); - pParag->m_nLineCount = -1; - pParag->m_nCharCount = i - nTextStart + 1; - pParag->m_nCharStart = nReserveCharStart; + pParag->SetLineCount(-1); + pParag->SetTextLength(i - nTextStart + 1); + pParag->SetStartIndex(nReserveCharStart); m_ParagPtrArray.InsertAt(++nParagIndex, pParag); - nReserveCharStart += pParag->m_nCharCount; + nReserveCharStart += pParag->GetTextLength(); } nTextStart = i + 1; } } if (bFirst) { - pParag->m_nCharCount += nLength; - pParag->m_nLineCount = -1; + pParag->IncrementTextLength(nLength); + pParag->SetLineCount(-1); bFirst = FALSE; } else { pParag = new CFDE_TxtEdtParag(this); - pParag->m_nLineCount = -1; - pParag->m_nCharCount = nLength - nTextStart + nCutPart; - pParag->m_nCharStart = nReserveCharStart; + pParag->SetLineCount(-1); + pParag->SetTextLength(nLength - nTextStart + nCutPart); + pParag->SetStartIndex(nReserveCharStart); m_ParagPtrArray.InsertAt(++nParagIndex, pParag); } m_pTxtBuf->Insert(nStart, lpText, nLength); @@ -860,7 +856,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) { pParag = m_ParagPtrArray[i]; pParag->CalcLines(); - nTotalLineCount += pParag->m_nLineCount; + nTotalLineCount += pParag->GetLineCount(); } m_nLineCount += nTotalLineCount - nReserveLineCount; m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); @@ -879,7 +875,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { TextPos2ParagPos(nEnd, ParagPosEnd); CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPosEnd.nParagIndex]; FX_BOOL bLastParag = FALSE; - if (ParagPosEnd.nCharIndex == pParag->m_nCharCount - 1) { + if (ParagPosEnd.nCharIndex == pParag->GetTextLength() - 1) { if (ParagPosEnd.nParagIndex < m_ParagPtrArray.GetSize() - 1) { ParagPosEnd.nParagIndex++; } else { @@ -892,8 +888,8 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { for (i = ParagPosBgn.nParagIndex; i <= ParagPosEnd.nParagIndex; i++) { CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i]; pParag->CalcLines(); - nTotalLineCount += pParag->m_nLineCount; - nTotalCharCount += pParag->m_nCharCount; + nTotalLineCount += pParag->GetLineCount(); + nTotalCharCount += pParag->GetTextLength(); } m_pTxtBuf->Delete(nStart, nCount); int32_t nNextParagIndex = (ParagPosBgn.nCharIndex == 0 && bLastParag) @@ -905,14 +901,14 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { } if (!(bLastParag && ParagPosBgn.nCharIndex == 0)) { pParag = m_ParagPtrArray[ParagPosBgn.nParagIndex]; - pParag->m_nCharCount = nTotalCharCount - nCount; + pParag->SetTextLength(nTotalCharCount - nCount); pParag->CalcLines(); - nTotalLineCount -= pParag->m_nLineCount; + nTotalLineCount -= pParag->GetTextLength(); } int32_t nParagCount = m_ParagPtrArray.GetSize(); - for (i = nNextParagIndex; i < nParagCount; i++) { - m_ParagPtrArray[i]->m_nCharStart -= nCount; - } + for (i = nNextParagIndex; i < nParagCount; i++) + m_ParagPtrArray[i]->DecrementStartIndex(nCount); + m_nLineCount -= nTotalLineCount; UpdatePages(); int32_t nPageCount = CountPages(); @@ -964,9 +960,9 @@ void CFDE_TxtEdtEngine::RebuildParagraphs() { nIndex = pIter->GetAt(); if (wChar == m_wLineEnd) { CFDE_TxtEdtParag* pParag = new CFDE_TxtEdtParag(this); - pParag->m_nCharStart = nParagStart; - pParag->m_nCharCount = nIndex - nParagStart + 1; - pParag->m_nLineCount = -1; + pParag->SetStartIndex(nParagStart); + pParag->SetTextLength(nIndex - nParagStart + 1); + pParag->SetLineCount(-1); m_ParagPtrArray.Add(pParag); nParagStart = nIndex + 1; } @@ -1002,22 +998,22 @@ void CFDE_TxtEdtEngine::UpdateParags() { int32_t i = 0; for (i = 0; i < nCount; i++) { pParag = m_ParagPtrArray[i]; - if (pParag->m_nLineCount == -1) { + if (pParag->GetLineCount() == -1) pParag->CalcLines(); - } - nLineCount += pParag->m_nLineCount; + + nLineCount += pParag->GetLineCount(); } m_nLineCount = nLineCount; } void CFDE_TxtEdtEngine::UpdatePages() { - if (m_nLineCount == 0) { + if (m_nLineCount == 0) return; - } + int32_t nPageCount = (m_nLineCount - 1) / (m_nPageLineCount) + 1; int32_t nSize = m_PagePtrArray.GetSize(); - if (nSize == nPageCount) { + if (nSize == nPageCount) return; - } + if (nSize > nPageCount) { IFDE_TxtEdtPage* pPage = NULL; int32_t i = 0; @@ -1028,7 +1024,6 @@ void CFDE_TxtEdtEngine::UpdatePages() { } m_PagePtrArray.RemoveAt(i); } - m_Param.pEventSink->On_PageCountChanged(this); return; } if (nSize < nPageCount) { @@ -1038,7 +1033,6 @@ void CFDE_TxtEdtEngine::UpdatePages() { pPage = IFDE_TxtEdtPage::Create(this, i); m_PagePtrArray.Add(pPage); } - m_Param.pEventSink->On_PageCountChanged(this); return; } } @@ -1244,25 +1238,24 @@ int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { int32_t i = 0; for (i = 0; i < nParagCount; i++) { pParag = m_ParagPtrArray[i]; - if (pParag->m_nCharStart <= nIndex && - nIndex < (pParag->m_nCharStart + pParag->m_nCharCount)) { + if (pParag->GetStartIndex() <= nIndex && + nIndex < (pParag->GetStartIndex() + pParag->GetTextLength())) { break; } - nLineCount += pParag->m_nLineCount; + nLineCount += pParag->GetLineCount(); } pParag->LoadParag(); int32_t nLineStart = -1; int32_t nLineCharCount = -1; - for (i = 0; i < pParag->m_nLineCount; i++) { + for (i = 0; i < pParag->GetLineCount(); i++) { pParag->GetLineRange(i, nLineStart, nLineCharCount); if (nLineStart <= nIndex && nIndex < (nLineStart + nLineCharCount)) { break; } } - ASSERT(i < pParag->m_nLineCount); + ASSERT(i < pParag->GetLineCount()); nLineCount += (i + 1); m_nCaretPage = (nLineCount - 1) / m_nPageLineCount + 1 - 1; - m_Param.pEventSink->On_PageChange(this, m_nCaretPage); pParag->UnloadParag(); return m_nCaretPage; } @@ -1276,9 +1269,9 @@ void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex, while (nEnd > nBgn) { nMid = (nBgn + nEnd) / 2; CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nMid]; - if (nIndex < pParag->m_nCharStart) { + if (nIndex < pParag->GetStartIndex()) { nEnd = nMid - 1; - } else if (nIndex >= (pParag->m_nCharStart + pParag->m_nCharCount)) { + } else if (nIndex >= (pParag->GetStartIndex() + pParag->GetTextLength())) { nBgn = nMid + 1; } else { break; @@ -1287,11 +1280,11 @@ void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex, if (nBgn == nEnd) { nMid = nBgn; } - ASSERT(nIndex >= m_ParagPtrArray[nMid]->m_nCharStart && - (nIndex < m_ParagPtrArray[nMid]->m_nCharStart + - m_ParagPtrArray[nMid]->m_nCharCount)); + ASSERT(nIndex >= m_ParagPtrArray[nMid]->GetStartIndex() && + (nIndex < m_ParagPtrArray[nMid]->GetStartIndex() + + m_ParagPtrArray[nMid]->GetTextLength())); ParagPos.nParagIndex = nMid; - ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->m_nCharStart; + ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->GetStartIndex(); } int32_t CFDE_TxtEdtEngine::MoveForward(FX_BOOL& bBefore) { if (m_nCaret == m_pTxtBuf->GetTextLength() - 1) { @@ -1343,7 +1336,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) { } else { m_nCaretPage--; } - m_Param.pEventSink->On_PageChange(this, m_nCaretPage); ptCaret.x -= rtContent.left; IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage); ptCaret.x += pCurPage->GetContentsBox().right(); @@ -1357,7 +1349,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) { } ptCaret.y -= rtContent.top; m_nCaretPage--; - m_Param.pEventSink->On_PageChange(this, m_nCaretPage); IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage); ptCaret.y += pCurPage->GetContentsBox().bottom(); } @@ -1387,7 +1378,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) { } else { m_nCaretPage++; } - m_Param.pEventSink->On_PageChange(this, m_nCaretPage); ptCaret.x -= rtContent.right(); IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage); ptCaret.x += pCurPage->GetContentsBox().left; @@ -1401,7 +1391,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) { } ptCaret.y -= rtContent.bottom(); m_nCaretPage++; - m_Param.pEventSink->On_PageChange(this, m_nCaretPage); IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage); ptCaret.y += pCurPage->GetContentsBox().top; } @@ -1414,7 +1403,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineStart() { TextPos2ParagPos(nIndex, ParagPos); CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; pParag->LoadParag(); - int32_t nLineCount = pParag->m_nLineCount; + int32_t nLineCount = pParag->GetLineCount(); int32_t i = 0; int32_t nStart = 0; int32_t nCount = 0; @@ -1434,7 +1423,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() { TextPos2ParagPos(nIndex, ParagPos); CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; pParag->LoadParag(); - int32_t nLineCount = pParag->m_nLineCount; + int32_t nLineCount = pParag->GetLineCount(); int32_t i = 0; int32_t nStart = 0; int32_t nCount = 0; @@ -1469,7 +1458,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveParagStart() { FDE_TXTEDTPARAGPOS ParagPos; TextPos2ParagPos(nIndex, ParagPos); CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - UpdateCaretRect(pParag->m_nCharStart, TRUE); + UpdateCaretRect(pParag->GetStartIndex(), TRUE); return TRUE; } FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() { @@ -1477,7 +1466,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() { FDE_TXTEDTPARAGPOS ParagPos; TextPos2ParagPos(nIndex, ParagPos); CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; - nIndex = pParag->m_nCharStart + pParag->m_nCharCount - 1; + nIndex = pParag->GetStartIndex() + pParag->GetTextLength() - 1; FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex); if (wChar == L'\n' && nIndex > 0) { nIndex--; diff --git a/xfa/fee/fde_txtedtengine.h b/xfa/fee/fde_txtedtengine.h index b122969eae..4671bf549a 100644 --- a/xfa/fee/fde_txtedtengine.h +++ b/xfa/fee/fde_txtedtengine.h @@ -8,7 +8,7 @@ #define XFA_FEE_FDE_TXTEDTENGINE_H_ #include "core/fxcrt/include/fx_string.h" -#include "xfa/fee/ifde_txtedtbuf.h" +#include "xfa/fee/fde_txtedtbuf.h" #include "xfa/fee/ifde_txtedtengine.h" #include "xfa/fgas/layout/fgas_textbreak.h" @@ -28,83 +28,64 @@ class IFDE_TxtEdtDoRecord { virtual void Serialize(CFX_ByteString& bsDoRecord) const = 0; }; -class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine { - friend class CFDE_TxtEdtDoRecord_Insert; - friend class CFDE_TxtEdtDoRecord_DeleteRange; - friend class CFDE_TxtEdtPage; - struct _FDE_TXTEDTSELRANGE { - int32_t nStart; - int32_t nCount; - }; - typedef _FDE_TXTEDTSELRANGE FDE_TXTEDTSELRANGE; - typedef _FDE_TXTEDTSELRANGE* FDE_LPTXTEDTSELRANGE; - struct _FDE_TXTEDTPARAGPOS { - int32_t nParagIndex; - int32_t nCharIndex; - }; - typedef _FDE_TXTEDTPARAGPOS FDE_TXTEDTPARAGPOS; - typedef _FDE_TXTEDTPARAGPOS* FDE_LPTXTEDTPARAGPOS; - +class CFDE_TxtEdtEngine { public: CFDE_TxtEdtEngine(); - virtual void Release(); - - virtual void SetEditParams(const FDE_TXTEDTPARAMS& params); - virtual const FDE_TXTEDTPARAMS* GetEditParams() const; - - virtual int32_t CountPages() const; - virtual IFDE_TxtEdtPage* GetPage(int32_t nIndex); - - virtual FX_BOOL SetBufChunkSize(int32_t nChunkSize); - virtual void SetTextByStream(IFX_Stream* pStream); - virtual void SetText(const CFX_WideString& wsText); - virtual int32_t GetTextLength() const; - virtual void GetText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount = -1); - virtual void ClearText(); - - virtual int32_t GetCaretRect(CFX_RectF& rtCaret) const; - virtual int32_t GetCaretPos() const; - virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore); - virtual int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, - FX_BOOL bShift = FALSE, - FX_BOOL bCtrl = FALSE); - virtual void Lock(); - virtual void Unlock(); - virtual FX_BOOL IsLocked() const; - - virtual int32_t Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLength); - virtual int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE); - virtual int32_t DeleteRange(int32_t nStart, int32_t nCount = -1); - virtual int32_t Replace(int32_t nStart, - int32_t nLength, - const CFX_WideString& wsReplace); - virtual void SetLimit(int32_t nLimit); - virtual void SetAliasChar(FX_WCHAR wcAlias); + void Release(); + + void SetEditParams(const FDE_TXTEDTPARAMS& params); + FDE_TXTEDTPARAMS* GetEditParams(); + + int32_t CountPages() const; + IFDE_TxtEdtPage* GetPage(int32_t nIndex); + + FX_BOOL SetBufChunkSize(int32_t nChunkSize); + void SetTextByStream(IFX_Stream* pStream); + void SetText(const CFX_WideString& wsText); + int32_t GetTextLength() const; + void GetText(CFX_WideString& wsText, int32_t nStart, int32_t nCount = -1); + void ClearText(); + + int32_t GetCaretRect(CFX_RectF& rtCaret) const; + int32_t GetCaretPos() const; + int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore); + int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, + FX_BOOL bShift = FALSE, + FX_BOOL bCtrl = FALSE); + void Lock(); + void Unlock(); + FX_BOOL IsLocked() const; + + int32_t Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); + int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE); + int32_t DeleteRange(int32_t nStart, int32_t nCount = -1); + int32_t Replace(int32_t nStart, + int32_t nLength, + const CFX_WideString& wsReplace); + + void SetLimit(int32_t nLimit); + void SetAliasChar(FX_WCHAR wcAlias); void RemoveSelRange(int32_t nStart, int32_t nCount = -1); - virtual void AddSelRange(int32_t nStart, int32_t nCount = -1); - virtual int32_t CountSelRanges(); - virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); - virtual void ClearSelection(); + void AddSelRange(int32_t nStart, int32_t nCount = -1); + int32_t CountSelRanges(); + int32_t GetSelRange(int32_t nIndex, int32_t& nStart); + void ClearSelection(); - virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo); - virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo); + FX_BOOL Redo(const CFX_ByteStringC& bsRedo); + FX_BOOL Undo(const CFX_ByteStringC& bsUndo); - virtual int32_t StartLayout(); - virtual int32_t DoLayout(IFX_Pause* pPause); - virtual void EndLayout(); + int32_t StartLayout(); + int32_t DoLayout(IFX_Pause* pPause); + void EndLayout(); - virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL); - virtual int32_t CountParags() const; - virtual IFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const; - virtual IFX_CharIter* CreateCharIter(); - IFDE_TxtEdtBuf* GetTextBuf() const; + FX_BOOL Optimize(IFX_Pause* pPause = NULL); + int32_t CountParags() const; + CFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const; + IFX_CharIter* CreateCharIter(); + CFDE_TxtEdtBuf* GetTextBuf() const; int32_t GetTextBufLength() const; CFX_TxtBreak* GetTextBreak() const; int32_t GetLineCount() const; @@ -117,9 +98,23 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine { FX_WCHAR GetAliasChar() const { return m_wcAliasChar; } protected: - virtual ~CFDE_TxtEdtEngine(); + ~CFDE_TxtEdtEngine(); private: + friend class CFDE_TxtEdtDoRecord_Insert; + friend class CFDE_TxtEdtDoRecord_DeleteRange; + friend class CFDE_TxtEdtPage; + + struct FDE_TXTEDTSELRANGE { + int32_t nStart; + int32_t nCount; + }; + + struct FDE_TXTEDTPARAGPOS { + int32_t nParagIndex; + int32_t nCharIndex; + }; + void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); void GetPreDeleteText(CFX_WideString& wsText, int32_t nIndex, @@ -173,12 +168,12 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine { FX_BOOL IsSelect(); void DeleteSelect(); - IFDE_TxtEdtBuf* m_pTxtBuf; + CFDE_TxtEdtBuf* m_pTxtBuf; CFX_TxtBreak* m_pTextBreak; FDE_TXTEDTPARAMS m_Param; CFX_ArrayTemplate m_PagePtrArray; CFX_ArrayTemplate m_ParagPtrArray; - CFX_ArrayTemplate m_SelRangePtrArr; + CFX_ArrayTemplate m_SelRangePtrArr; int32_t m_nPageLineCount; int32_t m_nLineCount; int32_t m_nAnchorPos; diff --git a/xfa/fee/fde_txtedtpage.cpp b/xfa/fee/fde_txtedtpage.cpp index c50f66e2ff..d46e1a11b0 100644 --- a/xfa/fee/fde_txtedtpage.cpp +++ b/xfa/fee/fde_txtedtpage.cpp @@ -12,13 +12,12 @@ #include "xfa/fee/fde_txtedtengine.h" #include "xfa/fee/fde_txtedtparag.h" #include "xfa/fee/fx_wordbreak/fx_wordbreak.h" -#include "xfa/fee/ifde_txtedtbuf.h" #include "xfa/fee/ifde_txtedtengine.h" #include "xfa/fee/ifde_txtedtpage.h" #define FDE_TXTEDT_TOLERANCE 0.1f -IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(IFDE_TxtEdtEngine* pEngine, +IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine, int32_t nIndex) { return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex); } @@ -122,7 +121,7 @@ int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText, tr.wLineBreakChar = pTextParams->wLineBreakChar; return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox); } -CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) +CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) : m_pIter(nullptr), m_pTextSet(nullptr), m_pBgnParag(nullptr), @@ -151,8 +150,8 @@ CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { void CFDE_TxtEdtPage::Release() { delete this; } -IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { - return (IFDE_TxtEdtEngine*)m_pEditEngine; +CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const { + return m_pEditEngine; } FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() { return FDE_VISUALOBJ_Text; @@ -349,7 +348,7 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { if (m_nRefCount < 0) { return -1; } - IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); + CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); FX_BOOL bBefore; int32_t nIndex = GetCharIndex(fPoint, bBefore); if (nIndex == m_pEditEngine->GetTextBufLength()) { @@ -375,7 +374,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, m_nRefCount++; return m_nRefCount; } - IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); + CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf(); const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams(); if (m_pIter != NULL) { m_pIter->Release(); diff --git a/xfa/fee/fde_txtedtpage.h b/xfa/fee/fde_txtedtpage.h index 13a444f0da..8ac104c2a7 100644 --- a/xfa/fee/fde_txtedtpage.h +++ b/xfa/fee/fde_txtedtpage.h @@ -97,11 +97,11 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet { class CFDE_TxtEdtPage : public IFDE_TxtEdtPage { public: - CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nLineIndex); + CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nLineIndex); // IFDE_TxtEditPage: void Release() override; - IFDE_TxtEdtEngine* GetEngine() const override; + CFDE_TxtEdtEngine* GetEngine() const override; int32_t GetCharRect(int32_t nIndex, CFX_RectF& rect, FX_BOOL bBBox = FALSE) const override; diff --git a/xfa/fee/fde_txtedtparag.cpp b/xfa/fee/fde_txtedtparag.cpp index 0aae327b16..f49f43147d 100644 --- a/xfa/fee/fde_txtedtparag.cpp +++ b/xfa/fee/fde_txtedtparag.cpp @@ -9,7 +9,6 @@ #include "xfa/fee/fde_txtedtbuf.h" #include "xfa/fee/fde_txtedtengine.h" #include "xfa/fee/fx_wordbreak/fx_wordbreak.h" -#include "xfa/fee/ifde_txtedtbuf.h" #include "xfa/fee/ifde_txtedtengine.h" #include "xfa/fgas/layout/fgas_textbreak.h" @@ -32,7 +31,7 @@ void CFDE_TxtEdtParag::LoadParag() { return; } CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); - IFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); + CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams(); FX_WCHAR wcAlias = 0; if (pParam->dwMode & FDE_TEXTEDITMODE_Password) { @@ -102,7 +101,7 @@ void CFDE_TxtEdtParag::UnloadParag() { } void CFDE_TxtEdtParag::CalcLines() { CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak(); - IFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); + CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf(); IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf); int32_t nCount = 0; uint32_t dwBreakStatus = FX_TXTBREAK_None; diff --git a/xfa/fee/fde_txtedtparag.h b/xfa/fee/fde_txtedtparag.h index 39921d5ef7..24ecbc7bf0 100644 --- a/xfa/fee/fde_txtedtparag.h +++ b/xfa/fee/fde_txtedtparag.h @@ -7,29 +7,35 @@ #ifndef XFA_FEE_FDE_TXTEDTPARAG_H_ #define XFA_FEE_FDE_TXTEDTPARAG_H_ -#include "xfa/fee/ifde_txtedtengine.h" +#include class CFDE_TxtEdtEngine; -class CFDE_TxtEdtParag : public IFDE_TxtEdtParag { +class CFDE_TxtEdtParag { public: explicit CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine); ~CFDE_TxtEdtParag(); - virtual int32_t GetTextLength() const { return m_nCharCount; } - virtual int32_t GetStartIndex() const { return m_nCharStart; } - virtual int32_t CountLines() const { return m_nLineCount; } - virtual void GetLineRange(int32_t nLineIndex, - int32_t& nStart, - int32_t& nCount) const; + int32_t GetTextLength() const { return m_nCharCount; } + int32_t GetStartIndex() const { return m_nCharStart; } + int32_t GetLineCount() const { return m_nLineCount; } + + void SetTextLength(int32_t len) { m_nCharCount = len; } + void IncrementTextLength(int32_t len) { m_nCharCount += len; } + void SetStartIndex(int32_t idx) { m_nCharStart = idx; } + void IncrementStartIndex(int32_t val) { m_nCharStart += val; } + void DecrementStartIndex(int32_t val) { m_nCharStart -= val; } + void SetLineCount(int32_t count) { m_nLineCount = count; } + + void GetLineRange(int32_t nLineIndex, int32_t& nStart, int32_t& nCount) const; void LoadParag(); void UnloadParag(); void CalcLines(); + + private: int32_t m_nCharStart; int32_t m_nCharCount; int32_t m_nLineCount; - - private: void* m_lpData; CFDE_TxtEdtEngine* m_pEngine; }; diff --git a/xfa/fee/ifde_txtedtbuf.h b/xfa/fee/ifde_txtedtbuf.h deleted file mode 100644 index db744b1b54..0000000000 --- a/xfa/fee/ifde_txtedtbuf.h +++ /dev/null @@ -1,39 +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 XFA_FEE_IFDE_TXTEDTBUF_H_ -#define XFA_FEE_IFDE_TXTEDTBUF_H_ - -#include "core/fxcrt/include/fx_basic.h" - -#define FDE_DEFCHUNKLENGTH (1024) - -class IFDE_TxtEdtBuf { - public: - virtual ~IFDE_TxtEdtBuf() {} - virtual void Release() = 0; - - virtual FX_BOOL SetChunkSize(int32_t nChunkSize) = 0; - virtual int32_t GetChunkSize() const = 0; - virtual int32_t GetTextLength() const = 0; - virtual void SetText(const CFX_WideString& wsText) = 0; - virtual void GetText(CFX_WideString& wsText) const = 0; - virtual FX_WCHAR GetCharByIndex(int32_t nIndex) const = 0; - virtual void GetRange(CFX_WideString& wsText, - int32_t nBegin, - int32_t nCount = -1) const = 0; - - virtual void Insert(int32_t nPos, - const FX_WCHAR* lpText, - int32_t nLength = 1) = 0; - virtual void Delete(int32_t nIndex, int32_t nLength = 1) = 0; - - virtual void Clear(FX_BOOL bRelease = TRUE) = 0; - - virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL) = 0; -}; - -#endif // XFA_FEE_IFDE_TXTEDTBUF_H_ diff --git a/xfa/fee/ifde_txtedtengine.h b/xfa/fee/ifde_txtedtengine.h index e03a53e1ab..1855f6f769 100644 --- a/xfa/fee/ifde_txtedtengine.h +++ b/xfa/fee/ifde_txtedtengine.h @@ -10,10 +10,9 @@ #include "core/fxge/include/fx_dib.h" #include "xfa/fgas/font/fgas_font.h" +class CFDE_TxtEdtEngine; +class CFWL_EditImp; class IFDE_TxtEdtPage; -class IFDE_TxtEdtEngine; -class IFDE_TxtEdtEventSink; -class IFDE_TxtEdtParag; typedef struct FDE_HTXTEDTFIND_ { void* pData; } * FDE_HTXTEDTFIND; @@ -62,6 +61,7 @@ enum FDE_TXTEDTMOVECARET { MC_Home, MC_End, }; + enum FDE_TXTEDT_MODIFY_RET { FDE_TXTEDT_MODIFY_RET_F_Tab = -6, FDE_TXTEDT_MODIFY_RET_F_Locked = -5, @@ -75,21 +75,23 @@ enum FDE_TXTEDT_MODIFY_RET { FDE_TXTEDT_MODIFY_RET_S_Empty = 3, FDE_TXTEDT_MODIFY_RET_T_Tab = 4, }; + enum FDE_TXTEDIT_LINEEND { FDE_TXTEDIT_LINEEND_Auto, FDE_TXTEDIT_LINEEND_CRLF, FDE_TXTEDIT_LINEEND_CR, FDE_TXTEDIT_LINEEND_LF, }; -struct _FDE_TXTEDTPARAMS { - _FDE_TXTEDTPARAMS() + +struct FDE_TXTEDTPARAMS { + FDE_TXTEDTPARAMS() : fPlateWidth(0), fPlateHeight(0), nLineCount(0), dwLayoutStyles(0), dwAlignment(0), dwMode(0), - pFont(NULL), + pFont(nullptr), fFontSize(10.0f), dwFontColor(0xff000000), fLineSpace(10.0f), @@ -101,7 +103,8 @@ struct _FDE_TXTEDTPARAMS { nLineEnd(0), nHorzScale(100), fCharSpace(0), - pEventSink(NULL) {} + pEventSink(nullptr) {} + FX_FLOAT fPlateWidth; FX_FLOAT fPlateHeight; int32_t nLineCount; @@ -120,56 +123,22 @@ struct _FDE_TXTEDTPARAMS { int32_t nLineEnd; int32_t nHorzScale; FX_FLOAT fCharSpace; - IFDE_TxtEdtEventSink* pEventSink; + CFWL_EditImp* pEventSink; }; -typedef _FDE_TXTEDTPARAMS FDE_TXTEDTPARAMS; -typedef _FDE_TXTEDTPARAMS* FDE_LPTXTEDTPARAMS; + enum FDE_TXTEDT_TEXTCHANGE_TYPE { FDE_TXTEDT_TEXTCHANGE_TYPE_Insert = 0, FDE_TXTEDT_TEXTCHANGE_TYPE_Delete, FDE_TXTEDT_TEXTCHANGE_TYPE_Replace, }; -struct _FDE_TXTEDT_TEXTCHANGE_INFO { + +struct FDE_TXTEDT_TEXTCHANGE_INFO { int32_t nChangeType; CFX_WideString wsInsert; CFX_WideString wsDelete; CFX_WideString wsPrevText; }; -typedef _FDE_TXTEDT_TEXTCHANGE_INFO FDE_TXTEDT_TEXTCHANGE_INFO; -typedef _FDE_TXTEDT_TEXTCHANGE_INFO* FDE_LPTXTEDT_TEXTCHANGE_INFO; -class IFDE_TxtEdtEventSink { - public: - virtual ~IFDE_TxtEdtEventSink() {} - virtual void On_CaretChanged(IFDE_TxtEdtEngine* pEdit, - int32_t nPage, - FX_BOOL bVisible = TRUE) = 0; - virtual void On_TextChanged(IFDE_TxtEdtEngine* pEdit, - FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) = 0; - virtual void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) = 0; - virtual void On_SelChanged(IFDE_TxtEdtEngine* pEdit) = 0; - virtual FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose) = 0; - virtual FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose) = 0; - virtual FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex) = 0; - virtual void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit, - const CFX_ByteStringC& bsDoRecord) = 0; - virtual FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex, - int32_t nFieldIndex, - const CFX_WideString& wsFieldText, - int32_t nCharIndex) = 0; - virtual FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex) = 0; - virtual FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex, - CFX_WideString& wsBlockText) = 0; - virtual FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit, - CFX_WideString& wsText) = 0; -}; + class IFX_CharIter { public: virtual ~IFX_CharIter() {} @@ -181,73 +150,5 @@ class IFX_CharIter { virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const = 0; virtual IFX_CharIter* Clone() = 0; }; -class IFDE_TxtEdtEngine { - public: - static IFDE_TxtEdtEngine* Create(); - - virtual ~IFDE_TxtEdtEngine() {} - virtual void Release() = 0; - virtual void SetEditParams(const FDE_TXTEDTPARAMS& params) = 0; - virtual const FDE_TXTEDTPARAMS* GetEditParams() const = 0; - - virtual int32_t CountPages() const = 0; - virtual IFDE_TxtEdtPage* GetPage(int32_t nIndex) = 0; - virtual FX_BOOL SetBufChunkSize(int32_t nChunkSize) = 0; - virtual void SetTextByStream(IFX_Stream* pStream) = 0; - virtual void SetText(const CFX_WideString& wsText) = 0; - virtual int32_t GetTextLength() const = 0; - virtual void GetText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount = -1) = 0; - virtual void ClearText() = 0; - - virtual int32_t GetCaretRect(CFX_RectF& rtCaret) const = 0; - virtual int32_t GetCaretPos() const = 0; - virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE) = 0; - virtual int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, - FX_BOOL bShift = FALSE, - FX_BOOL bCtrl = FALSE) = 0; - - virtual void Lock() = 0; - virtual void Unlock() = 0; - virtual FX_BOOL IsLocked() const = 0; - - virtual int32_t Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLength) = 0; - virtual int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE) = 0; - virtual int32_t DeleteRange(int32_t nStart, int32_t nCount = -1) = 0; - virtual int32_t Replace(int32_t nStart, - int32_t nLength, - const CFX_WideString& wsReplace) = 0; - virtual void SetLimit(int32_t nLimit) = 0; - virtual void SetAliasChar(FX_WCHAR wAlias) = 0; - virtual void AddSelRange(int32_t nStart, int32_t nCount = -1) = 0; - virtual int32_t CountSelRanges() = 0; - virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart) = 0; - virtual void ClearSelection() = 0; - - virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo) = 0; - virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo) = 0; - - virtual int32_t StartLayout() = 0; - virtual int32_t DoLayout(IFX_Pause* pPause) = 0; - virtual void EndLayout() = 0; - - virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL) = 0; - virtual int32_t CountParags() const = 0; - virtual IFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const = 0; - virtual IFX_CharIter* CreateCharIter() = 0; -}; -class IFDE_TxtEdtParag { - public: - virtual ~IFDE_TxtEdtParag() {} - virtual int32_t GetTextLength() const = 0; - virtual int32_t GetStartIndex() const = 0; - virtual int32_t CountLines() const = 0; - virtual void GetLineRange(int32_t nLineIndex, - int32_t& nStart, - int32_t& nCount) const = 0; -}; #endif // XFA_FEE_IFDE_TXTEDTENGINE_H_ diff --git a/xfa/fee/ifde_txtedtpage.h b/xfa/fee/ifde_txtedtpage.h index 094568834a..695b442b99 100644 --- a/xfa/fee/ifde_txtedtpage.h +++ b/xfa/fee/ifde_txtedtpage.h @@ -11,14 +11,15 @@ #include "xfa/fde/fde_visualset.h" #include "xfa/fgas/layout/fgas_textbreak.h" -class IFDE_TxtEdtEngine; +class CFDE_TxtEdtEngine; + class IFDE_TxtEdtPage : public IFDE_CanvasSet, public IFX_TxtAccess { public: - static IFDE_TxtEdtPage* Create(IFDE_TxtEdtEngine* pEngine, int32_t nIndex); + static IFDE_TxtEdtPage* Create(CFDE_TxtEdtEngine* pEngine, int32_t nIndex); virtual void Release() = 0; - virtual IFDE_TxtEdtEngine* GetEngine() const = 0; + virtual CFDE_TxtEdtEngine* GetEngine() const = 0; virtual int32_t GetCharRect(int32_t nIndex, CFX_RectF& rect, FX_BOOL bBBox = FALSE) const = 0; diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp index 60794da476..55f0910c4a 100644 --- a/xfa/fwl/basewidget/fwl_comboboximp.cpp +++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp @@ -7,6 +7,7 @@ #include "xfa/fwl/basewidget/fwl_comboboximp.h" #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fee/fde_txtedtengine.h" #include "xfa/fwl/basewidget/fwl_editimp.h" #include "xfa/fwl/basewidget/fwl_formproxyimp.h" #include "xfa/fwl/basewidget/fwl_listboximp.h" diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index 17aef3bb16..29fab8b9b3 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -11,6 +11,7 @@ #include "xfa/fde/fde_gedevice.h" #include "xfa/fde/fde_render.h" +#include "xfa/fee/fde_txtedtengine.h" #include "xfa/fee/ifde_txtedtpage.h" #include "xfa/fwl/basewidget/fwl_caretimp.h" #include "xfa/fwl/basewidget/fwl_comboboximp.h" @@ -755,8 +756,7 @@ FX_BOOL CFWL_EditImp::CanRedo() { FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { if (!m_pEdtEngine) return FWL_ERR_Succeeded; - FDE_LPTXTEDTPARAMS pParams = - (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams(); + FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); pParams->fTabWidth = fTabWidth; pParams->bTabEquidistant = bEquidistant; return FWL_ERR_Succeeded; @@ -771,7 +771,7 @@ FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { m_bSetRange = TRUE; return FWL_ERR_Succeeded; } -void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit, +void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, int32_t nPage, FX_BOOL bVisible) { if (m_rtEngine.IsEmpty()) { @@ -799,7 +799,7 @@ void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit, Repaint(&rtInvalid); } } -void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit, +void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) { @@ -864,25 +864,25 @@ void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit, LayoutScrollBar(); Repaint(&rtTemp); } -void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine* pEdit) { +void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { CFX_RectF rtTemp; GetClientRect(rtTemp); Repaint(&rtTemp); } -FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine* pEdit, +FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, int32_t nPurpose) { - IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; + CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); if (!pPage) return FALSE; pPage->LoadPage(nullptr, nullptr); return TRUE; } -FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine* pEdit, +FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, int32_t nPurpose) { - IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; + CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); if (!pPage) return FALSE; @@ -890,28 +890,12 @@ FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine* pEdit, return TRUE; } -void CFWL_EditImp::On_AddDoRecord(IFDE_TxtEdtEngine* pEdit, +void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, const CFX_ByteStringC& bsDoRecord) { AddDoRecord(bsDoRecord); } -FX_BOOL CFWL_EditImp::On_ValidateField(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex, - int32_t nFieldIndex, - const CFX_WideString& wsFieldText, - int32_t nCharIndex) { - return TRUE; -} -FX_BOOL CFWL_EditImp::On_ValidateBlock(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex) { - return TRUE; -} -FX_BOOL CFWL_EditImp::On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex, - CFX_WideString& wsBlockText) { - return FALSE; -} -FX_BOOL CFWL_EditImp::On_Validate(IFDE_TxtEdtEngine* pEdit, +FX_BOOL CFWL_EditImp::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { IFWL_Widget* pDst = GetOuter(); if (!pDst) { @@ -1607,11 +1591,10 @@ void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) { pScrollBar->Initialize(); (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); } + void CFWL_EditImp::InitEngine() { - if (m_pEdtEngine) { - return; - } - m_pEdtEngine = IFDE_TxtEdtEngine::Create(); + if (!m_pEdtEngine) + m_pEdtEngine = new CFDE_TxtEdtEngine; } FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, diff --git a/xfa/fwl/basewidget/fwl_editimp.h b/xfa/fwl/basewidget/fwl_editimp.h index f8fb1aa37d..226a0e8b41 100644 --- a/xfa/fwl/basewidget/fwl_editimp.h +++ b/xfa/fwl/basewidget/fwl_editimp.h @@ -24,7 +24,7 @@ class IFWL_Caret; class CFWL_EditImp; class CFWL_EditImpDelegate; -class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { +class CFWL_EditImp : public CFWL_WidgetImp { public: CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); ~CFWL_EditImp() override; @@ -79,38 +79,24 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { virtual FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); virtual FWL_ERR SetOuter(IFWL_Widget* pOuter); virtual FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax); - void On_CaretChanged(IFDE_TxtEdtEngine* pEdit, + virtual FWL_ERR SetBackgroundColor(uint32_t color); + virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); + + void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, int32_t nPage, - FX_BOOL bVisible = true) override; - void On_TextChanged(IFDE_TxtEdtEngine* pEdit, - FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) override; - void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) override {} - void On_SelChanged(IFDE_TxtEdtEngine* pEdit) override; - FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit, + FX_BOOL bVisible = true); + void On_TextChanged(CFDE_TxtEdtEngine* pEdit, + FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); + void On_SelChanged(CFDE_TxtEdtEngine* pEdit); + FX_BOOL On_PageLoad(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, - int32_t nPurpose) override; - FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit, + int32_t nPurpose); + FX_BOOL On_PageUnload(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, - int32_t nPurpose) override; - FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit, int32_t nPageIndex) override { - return TRUE; - } - void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit, - const CFX_ByteStringC& bsDoRecord) override; - FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex, - int32_t nFieldIndex, - const CFX_WideString& wsFieldText, - int32_t nCharIndex) override; - FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex) override; - FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit, - int32_t nBlockIndex, - CFX_WideString& wsBlockText) override; - FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit, - CFX_WideString& wsText) override; - virtual FWL_ERR SetBackgroundColor(uint32_t color); - virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); + int32_t nPurpose); + void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, + const CFX_ByteStringC& bsDoRecord); + FX_BOOL On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); void SetScrollOffset(FX_FLOAT fScrollOffset); FX_BOOL GetSuggestWords(CFX_PointF pointf, std::vector& sSuggest); @@ -160,7 +146,7 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { FX_FLOAT m_fVAlignOffset; FX_FLOAT m_fScrollOffsetX; FX_FLOAT m_fScrollOffsetY; - IFDE_TxtEdtEngine* m_pEdtEngine; + CFDE_TxtEdtEngine* m_pEdtEngine; FX_BOOL m_bLButtonDown; int32_t m_nSelStart; int32_t m_nLimit; -- cgit v1.2.3