diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fde/cfde_txtedtengine.cpp | 49 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedtengine.h | 9 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 5 |
3 files changed, 12 insertions, 51 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 86931737c5..063c730b1f 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -161,7 +161,6 @@ CFDE_TxtEdtEngine::CFDE_TxtEdtEngine() m_nPageLineCount(20), m_nLineCount(0), m_nAnchorPos(-1), - m_nLayoutPos(0), m_fCaretPosReserve(0.0), m_nCaret(0), m_bBefore(true), @@ -381,14 +380,6 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, return m_nCaret; } -void CFDE_TxtEdtEngine::Lock() { - m_bLock = true; -} - -void CFDE_TxtEdtEngine::Unlock() { - m_bLock = false; -} - bool CFDE_TxtEdtEngine::IsLocked() const { return m_bLock; } @@ -702,39 +693,16 @@ bool CFDE_TxtEdtEngine::Undo(const IFDE_TxtEdtDoRecord* pDoRecord) { return true; } -int32_t CFDE_TxtEdtEngine::StartLayout() { - Lock(); - RemoveAllPages(); - m_nLayoutPos = 0; - m_nLineCount = 0; - return 0; -} - -int32_t CFDE_TxtEdtEngine::DoLayout() { - int32_t nCount = pdfium::CollectionSize<int32_t>(m_ParagPtrArray); - CFDE_TxtEdtParag* pParag = nullptr; - int32_t nLineCount = 0; - for (; m_nLayoutPos < nCount; m_nLayoutPos++) { - pParag = m_ParagPtrArray[m_nLayoutPos].get(); - pParag->CalcLines(); - nLineCount += pParag->GetLineCount(); - } - m_nLineCount += nLineCount; - return 100; -} +void CFDE_TxtEdtEngine::Layout() { + CFX_AutoRestorer<bool> lock(&m_bLock); + m_bLock = true; -void CFDE_TxtEdtEngine::EndLayout() { + RemoveAllPages(); + UpdateLineCounts(); UpdatePages(); - int32_t nLength = GetTextLength(); - if (m_nCaret > nLength) - m_nCaret = nLength; - - int32_t nIndex = m_nCaret; - if (!m_bBefore) - nIndex--; + m_nCaret = std::min(m_nCaret, GetTextLength()); m_rtCaret = CFX_RectF(0, 0, 1, m_Param.fFontSize); - Unlock(); } CFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const { @@ -1012,14 +980,13 @@ void CFDE_TxtEdtEngine::RemoveAllPages() { m_PagePtrArray.clear(); } -void CFDE_TxtEdtEngine::UpdateParags() { +void CFDE_TxtEdtEngine::UpdateLineCounts() { if (m_ParagPtrArray.empty()) return; int32_t nLineCount = 0; for (auto& pParag : m_ParagPtrArray) { - if (pParag->GetLineCount() == -1) - pParag->CalcLines(); + pParag->CalcLines(); nLineCount += pParag->GetLineCount(); } m_nLineCount = nLineCount; diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h index c4db3e91b1..4d3490a9f4 100644 --- a/xfa/fde/cfde_txtedtengine.h +++ b/xfa/fde/cfde_txtedtengine.h @@ -111,8 +111,6 @@ class CFDE_TxtEdtEngine { int32_t GetCaretPos() const; int32_t SetCaretPos(int32_t nIndex, bool bBefore); int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, bool bShift, bool bCtrl); - void Lock(); - void Unlock(); bool IsLocked() const; int32_t Insert(int32_t nStart, const wchar_t* lpText, int32_t nLength); @@ -136,9 +134,7 @@ class CFDE_TxtEdtEngine { bool Redo(const IFDE_TxtEdtDoRecord* pRecord); bool Undo(const IFDE_TxtEdtDoRecord* pRecord); - int32_t StartLayout(); - int32_t DoLayout(); - void EndLayout(); + void Layout(); int32_t CountParags() const; CFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const; @@ -195,7 +191,7 @@ class CFDE_TxtEdtEngine { void RebuildParagraphs(); void RemoveAllParags(); void RemoveAllPages(); - void UpdateParags(); + void UpdateLineCounts(); void UpdatePages(); void UpdateTxtBreak(); @@ -230,7 +226,6 @@ class CFDE_TxtEdtEngine { int32_t m_nPageLineCount; int32_t m_nLineCount; int32_t m_nAnchorPos; - int32_t m_nLayoutPos; float m_fCaretPosReserve; int32_t m_nCaret; bool m_bBefore; diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index eb54375e29..9e38187ef8 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -726,9 +726,8 @@ void CFWL_Edit::UpdateEditLayout() { if (pPage) pPage->UnloadPage(nullptr); - m_EdtEngine.StartLayout(); - m_EdtEngine.DoLayout(); - m_EdtEngine.EndLayout(); + m_EdtEngine.Layout(); + pPage = m_EdtEngine.GetPage(0); if (pPage) pPage->LoadPage(nullptr); |