editeng/source/editeng/editeng.cxx | 2 -- editeng/source/editeng/impedit.hxx | 4 ++-- editeng/source/editeng/impedit2.cxx | 10 +++++++--- editeng/source/editeng/impedit3.cxx | 13 ++++++++----- 4 files changed, 17 insertions(+), 12 deletions(-)
New commits: commit 3b551da96e1ddb0824002c06ee668055ab077a0e Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jun 17 18:24:36 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jun 17 21:02:36 2024 +0200 move GetLineLen code from EditEngine to ImpEditEngine so we have the implementation in one class, instead of bouncing back and forth between two. Change-Id: Ied2b0ed968987f44446abf1066b7e9af106e909d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169039 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 2f09ba0a1f61..c06823d9ddbc 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -433,7 +433,6 @@ sal_Int32 EditEngine::GetLineCount( sal_Int32 nParagraph ) const sal_Int32 EditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const { - ensureDocumentFormatted(); return getImpl().GetLineLen(nParagraph, nLine); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 7dc8ec798efd..a72acecf8f74 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -1054,7 +1054,7 @@ public: sal_uInt32 CalcParaWidth( sal_Int32 nParagraph, bool bIgnoreExtraSpace ); sal_uInt32 CalcLineWidth(ParaPortion const& rPortion, EditLine const& rLine, bool bIgnoreExtraSpace); sal_Int32 GetLineCount( sal_Int32 nParagraph ); - sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const; + sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ); void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const; sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const; sal_uInt16 GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 96546d6ae89e..377c66888a6a 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3666,8 +3666,10 @@ sal_Int32 ImpEditEngine::GetLineCount( sal_Int32 nParagraph ) return -1; } -sal_Int32 ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const +sal_Int32 ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) { + if (!IsFormatted()) + FormatDoc(); OSL_ENSURE(GetParaPortions().exists(nParagraph), "GetLineLen: Out of range"); const ParaPortion* pPPortion = GetParaPortions().SafeGetObject(nParagraph); OSL_ENSURE(pPPortion, "Paragraph not found: GetLineLen"); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index dcc93f5312c6..6ae2804b4690 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -638,9 +638,13 @@ void ImpEditEngine::CheckPageOverflow() SAL_INFO("editeng.chaining", "[OVERFLOW-CHECK] Current Text Height is " << nTxtHeight); sal_uInt32 nParaCount = maParaPortionList.Count(); - bool bOnlyOneEmptyPara = (nParaCount == 1) && - (maParaPortionList.SafeGetObject(0)->GetLines().Count() == 1) && - (GetLineLen(0,0) == 0); + bool bOnlyOneEmptyPara = false; + if (nParaCount == 1) + { + const ParaPortion* pPPortion = GetParaPortions().SafeGetObject(0); + bOnlyOneEmptyPara = pPPortion->GetLines().Count() == 1 + && pPPortion->GetLines()[0].GetLen() == 0; + } if (nTxtHeight > nBoxHeight && !bOnlyOneEmptyPara) { commit adf72803071cf96e7aafb1b9fcd0480d0a14de3a Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jun 17 18:19:42 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jun 17 21:02:27 2024 +0200 move GetText code from EditEngine to ImpEditEngine so we have the implementation in one class, instead of bouncing back and forth between two. Change-Id: I3979577a82539c6b9d36bef0faa2a34689be2a17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169038 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index abf2ea72f4da..2f09ba0a1f61 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -428,7 +428,6 @@ void EditEngine::ensureDocumentFormatted() const sal_Int32 EditEngine::GetLineCount( sal_Int32 nParagraph ) const { - ensureDocumentFormatted(); return getImpl().GetLineCount(nParagraph); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index f493231aaaad..7dc8ec798efd 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -1053,7 +1053,7 @@ public: sal_uInt32 CalcTextWidth( bool bIgnoreExtraSpace); sal_uInt32 CalcParaWidth( sal_Int32 nParagraph, bool bIgnoreExtraSpace ); sal_uInt32 CalcLineWidth(ParaPortion const& rPortion, EditLine const& rLine, bool bIgnoreExtraSpace); - sal_Int32 GetLineCount( sal_Int32 nParagraph ) const; + sal_Int32 GetLineCount( sal_Int32 nParagraph ); sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const; void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const; sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index c77325fc87c5..96546d6ae89e 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3653,8 +3653,10 @@ tools::Long ImpEditEngine::CalcTextHeight(tools::Long* pHeightNTP) return nCurrentTextHeight; } -sal_Int32 ImpEditEngine::GetLineCount( sal_Int32 nParagraph ) const +sal_Int32 ImpEditEngine::GetLineCount( sal_Int32 nParagraph ) { + if (!IsFormatted()) + FormatDoc(); OSL_ENSURE(GetParaPortions().exists(nParagraph), "GetLineCount: Out of range"); const ParaPortion* pPPortion = GetParaPortions().SafeGetObject(nParagraph); OSL_ENSURE( pPPortion, "Paragraph not found: GetLineCount" ); @@ -3702,7 +3704,7 @@ sal_Int32 ImpEditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex // we explicitly allow for the index to point at the character right behind the text const bool bValidIndex = /*0 <= nIndex &&*/ nIndex <= pNode->Len(); OSL_ENSURE( bValidIndex, "GetLineNumberAtIndex: invalid index" ); - const sal_Int32 nLineCount = GetLineCount( nPara ); + const sal_Int32 nLineCount = maParaPortionList.SafeGetObject(nPara)->GetLines().Count(); if (nIndex == pNode->Len()) nLineNo = nLineCount > 0 ? nLineCount - 1 : 0; else if (bValidIndex) // nIndex < pNode->Len() diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 5195bc3d4cb1..dcc93f5312c6 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -637,10 +637,9 @@ void ImpEditEngine::CheckPageOverflow() tools::Long nTxtHeight = CalcTextHeight(nullptr); SAL_INFO("editeng.chaining", "[OVERFLOW-CHECK] Current Text Height is " << nTxtHeight); - sal_uInt32 nParaCount = GetParaPortions().Count(); - sal_uInt32 nFirstLineCount = GetLineCount(0); + sal_uInt32 nParaCount = maParaPortionList.Count(); bool bOnlyOneEmptyPara = (nParaCount == 1) && - (nFirstLineCount == 1) && + (maParaPortionList.SafeGetObject(0)->GetLines().Count() == 1) && (GetLineLen(0,0) == 0); if (nTxtHeight > nBoxHeight && !bOnlyOneEmptyPara)