editeng/source/accessibility/AccessibleEditableTextPara.cxx | 42 ++++-------- editeng/source/accessibility/AccessibleParaManager.cxx | 3 editeng/source/accessibility/AccessibleStaticTextBase.cxx | 17 +--- include/editeng/AccessibleEditableTextPara.hxx | 3 4 files changed, 27 insertions(+), 38 deletions(-)
New commits: commit 138bc16c9aac04def13843bb9bf6f18075a88c0f Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 3 11:59:51 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 3 22:31:38 2025 +0200 editeng a11y: Let para manager dispose its child Instead of letting AccessibleParaManager dispose itself in AccessibleEditableTextPara::SetEditSource when called with a null edit source, let the AccessibleParaManager that created the paragraph and can therefore be considered the owner (see AccessibleParaManager::CreateChild) dispose it again in AccessibleParaManager::Release. This is consistent with how it also explicitly disposes all children in AccessibleParaManager::Dispose. This is the only place that calls AccessibleEditableTextPara::SetEditSource with a null param, so this change shouldn't change behavior in any way. Change-Id: I9d6ec8db69a789c18fd424e680624744b4913798 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183679 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 45d18f361a62..c55e272b56af 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -313,8 +313,6 @@ void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSourc UnSetState( AccessibleStateType::VISIBLE ); SetState( AccessibleStateType::INVALID ); SetState( AccessibleStateType::DEFUNC ); - - Dispose(); } mpEditSource = pEditSource; // #108900# Init last text content diff --git a/editeng/source/accessibility/AccessibleParaManager.cxx b/editeng/source/accessibility/AccessibleParaManager.cxx index 379ff46199ae..f0be469d0249 100644 --- a/editeng/source/accessibility/AccessibleParaManager.cxx +++ b/editeng/source/accessibility/AccessibleParaManager.cxx @@ -375,7 +375,10 @@ void AccessibleParaManager::Release( sal_Int32 nStartPara, sal_Int32 nEndPara ) { auto aChild(rPara.first.get()); if (IsReferencable(aChild)) + { aChild->SetEditSource(nullptr); + aChild->Dispose(); + } // clear reference return AccessibleParaManager::WeakChild(); commit 2f2f3ab30cd7251fe0dbd31afc3e7117106f4452 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 3 10:26:06 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 3 22:31:30 2025 +0200 editeng a11y: Deduplicate bullet text length calculation Add a helper method AccessibleEditableTextPara::GetBulletTextLength instead of duplicating the same logic 6 times in different places. Change-Id: I8f9fa307fe52c84ca0200126061c5a957c7e02ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183677 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 19ed64c8ab35..45d18f361a62 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -512,6 +512,15 @@ bool AccessibleEditableTextPara::HaveChildren() return GetTextForwarder().HaveImageBullet( GetParagraphIndex() ); } +sal_Int32 AccessibleEditableTextPara::GetBulletTextLength() const +{ + sal_Int32 nBulletLen = 0; + EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); + if (aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible) + nBulletLen = aBulletInfo.aText.getLength(); + return nBulletLen; +} + tools::Rectangle AccessibleEditableTextPara::LogicToPixel( const tools::Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder const & rForwarder ) { // convert to screen coordinates @@ -1996,10 +2005,7 @@ sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, s CheckRange(nStartIndex, nEndIndex); //Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet - sal_Int32 nBulletLen = 0; - EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); - if( aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible ) - nBulletLen = aBulletInfo.aText.getLength(); + const sal_Int32 nBulletLen = GetBulletTextLength(); // save current selection ESelection aOldSelection; @@ -2039,10 +2045,7 @@ sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sa CheckRange(nStartIndex, nEndIndex); // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet - sal_Int32 nBulletLen = 0; - EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); - if( aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible ) - nBulletLen = aBulletInfo.aText.getLength(); + const sal_Int32 nBulletLen = GetBulletTextLength(); ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) if( !rCacheTF.IsEditable( aSelection ) ) @@ -2076,10 +2079,7 @@ sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) CheckPosition(nIndex); // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet - sal_Int32 nBulletLen = 0; - EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); - if( aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible ) - nBulletLen = aBulletInfo.aText.getLength(); + const sal_Int32 nBulletLen = GetBulletTextLength(); if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) return false; // non-editable area selected @@ -2113,10 +2113,7 @@ sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, CheckRange(nStartIndex, nEndIndex); // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet - sal_Int32 nBulletLen = 0; - EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); - if( aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible ) - nBulletLen = aBulletInfo.aText.getLength(); + const sal_Int32 nBulletLen = GetBulletTextLength(); ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) @@ -2154,11 +2151,7 @@ sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const OUString& sText, CheckPosition(nIndex); // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet - sal_Int32 nBulletLen = 0; - EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); - if( aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible ) - nBulletLen = aBulletInfo.aText.getLength(); - + const sal_Int32 nBulletLen = GetBulletTextLength(); if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) return false; // non-editable area selected @@ -2194,10 +2187,7 @@ sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex CheckRange(nStartIndex, nEndIndex); // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet - sal_Int32 nBulletLen = 0; - EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo(GetParagraphIndex()); - if( aBulletInfo.nParagraph != EE_PARA_MAX && aBulletInfo.bVisible ) - nBulletLen = aBulletInfo.aText.getLength(); + const sal_Int32 nBulletLen = GetBulletTextLength(); ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) diff --git a/include/editeng/AccessibleEditableTextPara.hxx b/include/editeng/AccessibleEditableTextPara.hxx index 423852e4427f..9ed41a251b90 100644 --- a/include/editeng/AccessibleEditableTextPara.hxx +++ b/include/editeng/AccessibleEditableTextPara.hxx @@ -314,6 +314,9 @@ private: /// Do we have children? This is the case for image bullets bool HaveChildren(); + /// If there is a bullet, return it's text length, otherwise return 0 + sal_Int32 GetBulletTextLength() const; + const Point& GetEEOffset() const { return maEEOffset; } // Get text from forwarder commit eeb20233980c1b5262ce21f99549f0b0645ae9d0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 2 17:12:05 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 3 22:31:23 2025 +0200 editeng a11y: Simplify AccessibleStaticTextBase::GetParagraphBoundingBox Change-Id: I0bcc4d5ee3c6d9f976688cb25e7b6a3234d78da2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183676 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx index 253bc1b496fc..321b4c10da0b 100644 --- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx +++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx @@ -28,6 +28,7 @@ #include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> #include <vcl/svapp.hxx> +#include <vcl/unohelp.hxx> #include <comphelper/sequence.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/uno/Reference.hxx> @@ -817,17 +818,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleStaticTextBase::getRunA tools::Rectangle AccessibleStaticTextBase::GetParagraphBoundingBox() const { - tools::Rectangle aRect; - if (mxTextParagraph.is()) - { - awt::Rectangle aAwtRect = mxTextParagraph->getBounds(); - aRect = tools::Rectangle(Point(aAwtRect.X, aAwtRect.Y), Size(aAwtRect.Width, aAwtRect.Height)); - } - else - { - aRect.SetEmpty(); - } - return aRect; + if (!mxTextParagraph.is()) + return tools::Rectangle(); + + awt::Rectangle aAwtRect = mxTextParagraph->getBounds(); + return vcl::unohelper::ConvertToVCLRect(aAwtRect); } } // end of namespace accessibility