diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-06-17 19:16:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-06-18 11:15:03 +0200 |
commit | d42957a83660565695ada1a91547148860a5c10b (patch) | |
tree | 96cd5a8a4462be13b5ae0b166aae0b4a22db3487 /editeng | |
parent | 77c9e4bdbaae0a96d2c64a8e7e6b54f3e0f3a067 (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 19 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 1 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 23 |
3 files changed, 25 insertions, 18 deletions
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); |