diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-06-17 19:06:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-06-18 10:21:03 +0200 |
commit | 11b4159b520fc6f84527cd510d44ffd248f1fac0 (patch) | |
tree | 4fa7993732bdd802aa60c77b2daa4e7aff266822 /editeng | |
parent | dfffe516199b595e78a23178bc6e508a28ee48e6 (diff) |
move GetLineBoundaries code from EditEngine to ImpEditEngine
so we have the implementation in one class, instead of bouncing
back and forth between two.
Change-Id: Ic0d740d336f291f80d82989283dafc0704e97958
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169053
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 1 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 12 |
3 files changed, 10 insertions, 5 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index c06823d9ddbc..51d54d15b2fc 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -438,7 +438,6 @@ sal_Int32 EditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const void EditEngine::GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const { - ensureDocumentFormatted(); return getImpl().GetLineBoundaries(rStart, rEnd, nParagraph, nLine); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index a72acecf8f74..0295f5cd2cef 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -1055,7 +1055,7 @@ public: 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 ); - void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const; + void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ); sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const; sal_uInt16 GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine ); sal_uInt32 GetParaHeight(sal_Int32 nParagraph) const; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 377c66888a6a..535cd26012eb 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3682,8 +3682,10 @@ sal_Int32 ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) return -1; } -void ImpEditEngine::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const +void ImpEditEngine::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) { + if (!IsFormatted()) + FormatDoc(); OSL_ENSURE(GetParaPortions().exists(nParagraph), "GetLineCount: Out of range"); const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); OSL_ENSURE( pPPortion, "Paragraph not found: GetLineBoundaries" ); @@ -3706,7 +3708,9 @@ 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 = maParaPortionList.SafeGetObject(nPara)->GetLines().Count(); + const ParaPortion* pPPortion = maParaPortionList.SafeGetObject(nPara); + const EditLineList& rLineList = pPPortion->GetLines(); + const sal_Int32 nLineCount = rLineList.Count(); if (nIndex == pNode->Len()) nLineNo = nLineCount > 0 ? nLineCount - 1 : 0; else if (bValidIndex) // nIndex < pNode->Len() @@ -3714,7 +3718,9 @@ sal_Int32 ImpEditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex sal_Int32 nStart = -1, nEnd = -1; for (sal_Int32 i = 0; i < nLineCount && nLineNo == -1; ++i) { - GetLineBoundaries( nStart, nEnd, nPara, i ); + const EditLine& rLine = rLineList[i]; + nStart = rLine.GetStart(); + nEnd = rLine.GetEnd(); if (nStart >= 0 && nStart <= nIndex && nEnd >= 0 && nIndex < nEnd) nLineNo = i; } |