editeng/source/editeng/editeng.cxx | 19 +------------------ editeng/source/editeng/impedit.hxx | 1 + editeng/source/editeng/impedit2.cxx | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 18 deletions(-)
New commits: commit d42957a83660565695ada1a91547148860a5c10b Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Jun 17 19:16:07 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jun 18 11:15:03 2024 +0200 move GetParaBounds code from EditEngine to ImpEditEngine so we have the implementation in one class, instead of bouncing back and forth between two. Change-Id: I103c53783b286be0c8472b1850e3cf3e3d6a925f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169057 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 8f5ba24de8d7..e86e4b40b5d4 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -454,24 +454,7 @@ sal_uInt32 EditEngine::GetLineHeight( sal_Int32 nParagraph ) tools::Rectangle EditEngine::GetParaBounds( sal_Int32 nPara ) { - ensureDocumentFormatted(); - Point aPnt = GetDocPosTopLeft( nPara ); - - if( IsEffectivelyVertical() ) - { - sal_Int32 nTextHeight = getImpl().GetTextHeight(); - sal_Int32 nParaWidth = getImpl().CalcParaWidth(nPara, true); - sal_Int32 nParaHeight = getImpl().GetParaHeight(nPara); - - return tools::Rectangle( nTextHeight - aPnt.Y() - nParaHeight, 0, nTextHeight - aPnt.Y(), nParaWidth ); - } - else - { - sal_Int32 nParaWidth = getImpl().CalcParaWidth( nPara, true ); - sal_Int32 nParaHeight = getImpl().GetParaHeight( nPara ); - - return tools::Rectangle( 0, aPnt.Y(), nParaWidth, aPnt.Y() + nParaHeight ); - } + return getImpl().GetParaBounds(nPara); } sal_uInt32 EditEngine::GetTextHeight( sal_Int32 nParagraph ) const diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index edc2fbe60c9d..a1086a8cab93 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -1060,6 +1060,7 @@ public: sal_uInt16 GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine ); sal_uInt32 GetParaHeight(sal_Int32 nParagraph) const; Point GetDocPosTopLeft( sal_Int32 nParagraph ); + tools::Rectangle GetParaBounds( sal_Int32 nPara ); SfxItemSet GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags = GetAttribsFlags::ALL ) const; SfxItemSet GetAttribs( EditSelection aSel, EditEngineAttribs nOnlyHardAttrib = EditEngineAttribs::All ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 92017257334e..83c495072ab8 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3747,6 +3747,29 @@ sal_uInt16 ImpEditEngine::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine ) return 0xFFFF; } +tools::Rectangle ImpEditEngine::GetParaBounds( sal_Int32 nPara ) +{ + if (!IsFormatted()) + FormatDoc(); + Point aPnt = GetDocPosTopLeft( nPara ); + + if( IsEffectivelyVertical() ) + { + sal_Int32 nTextHeight = GetTextHeight(); + sal_Int32 nParaWidth = CalcParaWidth(nPara, true); + sal_Int32 nParaHeight = GetParaHeight(nPara); + + return tools::Rectangle( nTextHeight - aPnt.Y() - nParaHeight, 0, nTextHeight - aPnt.Y(), nParaWidth ); + } + else + { + sal_Int32 nParaWidth = CalcParaWidth( nPara, true ); + sal_Int32 nParaHeight = GetParaHeight( nPara ); + + return tools::Rectangle( 0, aPnt.Y(), nParaWidth, aPnt.Y() + nParaHeight ); + } +} + Point ImpEditEngine::GetDocPosTopLeft( sal_Int32 nParagraph ) { const ParaPortion* pPPortion = maParaPortionList.SafeGetObject(nParagraph);