sw/inc/mdiexp.hxx | 8 +++---- sw/source/core/access/accdoc.cxx | 42 ++++++------------------------------- sw/source/core/access/accpara.cxx | 2 - sw/source/core/crsr/crsrsh.cxx | 2 - sw/source/core/frmedt/feshview.cxx | 4 +-- sw/source/core/view/viewsh.cxx | 10 ++++---- sw/source/uibase/docvw/edtwin3.cxx | 16 +++++++------- 7 files changed, 28 insertions(+), 56 deletions(-)
New commits: commit 2f6c7c7ba2031575177ec6ad56bc34dfeaae301d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 16 10:42:31 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 17 07:07:02 2025 +0200 sw a11y: Deduplicate SwAccessibleDocumentBase methods a bit Reuse SwAccessibleDocumentBase::getBounds logic in SwAccessibleDocumentBase::getLocation and SwAccessibleDocumentBase::getSize instead of reimplementing it. While SwAccessibleDocumentBase::getSize was previously using absolute coordinates, using relative ones is fine because the size is the same. Change-Id: Ic4b17b383c995e92cb35e47133b969c05c6d1369 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184275 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index 99fe54c01c2e..ece52286a633 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -236,18 +236,8 @@ awt::Rectangle SAL_CALL SwAccessibleDocumentBase::getBounds() awt::Point SAL_CALL SwAccessibleDocumentBase::getLocation() { - SolarMutexGuard aGuard; - - vcl::Window *pWin = GetWindow(); - if (!pWin) - { - throw uno::RuntimeException(u"no Window"_ustr, getXWeak()); - } - - Point aPixPos( pWin->GetWindowExtentsRelative( *pWin->GetAccessibleParentWindow() ).TopLeft() ); - awt::Point aLoc( aPixPos.getX(), aPixPos.getY() ); - - return aLoc; + const awt::Rectangle aBounds = getBounds(); + return awt::Point(aBounds.X, aBounds.Y); } css::awt::Point SAL_CALL SwAccessibleDocumentBase::getLocationOnScreen() @@ -268,18 +258,8 @@ css::awt::Point SAL_CALL SwAccessibleDocumentBase::getLocationOnScreen() css::awt::Size SAL_CALL SwAccessibleDocumentBase::getSize() { - SolarMutexGuard aGuard; - - vcl::Window *pWin = GetWindow(); - if (!pWin) - { - throw uno::RuntimeException(u"no Window"_ustr, getXWeak()); - } - - Size aPixSize( pWin->GetWindowExtentsAbsolute().GetSize() ); - awt::Size aSize( aPixSize.Width(), aPixSize.Height() ); - - return aSize; + const awt::Rectangle aBounds = getBounds(); + return awt::Size(aBounds.Width, aBounds.Height); } sal_Bool SAL_CALL SwAccessibleDocumentBase::containsPoint( commit 3fd9b68d466acf3146202dd8c81d3be53f17c285 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 16 10:34:31 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 17 07:06:55 2025 +0200 sw a11y: Simplify SwAccessibleDocumentBase::containsPoint Reuse existing logic in SwAccessibleDocumentBase::getSize to retrieve the bounding rectangle and use its size instead of duplicating some code to calculate it. Change-Id: Ib5524489367fe4aa6da35c4aed09cd34ed3cf55c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184274 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index d76bbdcf18c9..99fe54c01c2e 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -285,18 +285,10 @@ css::awt::Size SAL_CALL SwAccessibleDocumentBase::getSize() sal_Bool SAL_CALL SwAccessibleDocumentBase::containsPoint( const awt::Point& aPoint ) { - SolarMutexGuard aGuard; - - vcl::Window *pWin = GetWindow(); - if (!pWin) - { - throw uno::RuntimeException(u"no Window"_ustr, getXWeak()); - } - - tools::Rectangle aPixBounds( pWin->GetWindowExtentsAbsolute() ); - aPixBounds.Move(-aPixBounds.Left(), -aPixBounds.Top()); - + const Size aSize = vcl::unohelper::ConvertToVCLSize(getSize()); + tools::Rectangle aPixBounds(Point(0, 0), aSize); Point aPixPoint( aPoint.X, aPoint.Y ); + return aPixBounds.Contains( aPixPoint ); } commit f35d637458c77f6d152986b2f1f47ba24d66aa4b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 16 10:20:49 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 17 07:06:49 2025 +0200 sw: Pass SwViewShell by ref to some helper functions It's non-null for all callers and unconditionally dereferenced in the function implementations. Change-Id: I6f82edc7ed05f069c0c05486a8175117e8c40794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184273 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sw/inc/mdiexp.hxx b/sw/inc/mdiexp.hxx index 2e98f0c44f29..59b245f0bbac 100644 --- a/sw/inc/mdiexp.hxx +++ b/sw/inc/mdiexp.hxx @@ -32,13 +32,13 @@ class SwViewShell; class SwDocShell; class ReferenceMarkerName; -extern void ScrollMDI(SwViewShell const * pVwSh, const SwRect &, sal_uInt16 nRangeX, sal_uInt16 nRangeY +extern void ScrollMDI(SwViewShell const & rVwSh, const SwRect &, sal_uInt16 nRangeX, sal_uInt16 nRangeY , ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault); -extern bool IsScrollMDI(SwViewShell const * pVwSh, const SwRect &); -extern void SizeNotify(SwViewShell const * pVwSh, const Size &); +extern bool IsScrollMDI(SwViewShell const & rVwSh, const SwRect &); +extern void SizeNotify(SwViewShell const & rVwSh, const Size &); // Update of status bar during an action. -extern void PageNumNotify(SwViewShell const * pVwSh); +extern void PageNumNotify(SwViewShell const & rVwSh); enum FlyMode { FLY_DRAG_START, FLY_DRAG, FLY_DRAG_END }; extern void FrameNotify( SwViewShell* pVwSh, FlyMode eMode = FLY_DRAG ); diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index ffc6309155bd..2fe51641cbf4 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2429,7 +2429,7 @@ sal_Bool SwAccessibleParagraph::scrollSubstringTo( sal_Int32 nStartIndex, const SwRect aRect(startPoint, endPoint); SwViewShell& rViewShell = GetMap()->GetShell(); - ScrollMDI(&rViewShell, aRect, USHRT_MAX, USHRT_MAX); + ScrollMDI(rViewShell, aRect, USHRT_MAX, USHRT_MAX); return true; } diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 0578fd0cd487..d1d33f19e58d 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -3128,7 +3128,7 @@ bool SwCursorShell::SetVisibleCursor( const Point &rPt, ScrollSizeMode eScrollSi return true; m_pVisibleCursor->Hide(); // always hide visible cursor - if( IsScrollMDI( this, m_aCharRect )) + if( IsScrollMDI( *this, m_aCharRect )) { MakeVisible( m_aCharRect, eScrollSizeMode ); m_pCurrentCursor->Show(nullptr); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 27367439bc2e..02f3d8b5e27e 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -716,11 +716,11 @@ bool SwFEShell::IsSelContainsControl() const void SwFEShell::ScrollTo( const Point &rPt ) { const SwRect aRect( rPt, rPt ); - if ( IsScrollMDI( this, aRect ) && + if ( IsScrollMDI( *this, aRect ) && (!Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() || Imp()->IsDragPossible( rPt )) ) { - ScrollMDI( this, aRect, SCROLLVAL, SCROLLVAL ); + ScrollMDI( *this, aRect, SCROLLVAL, SCROLLVAL ); } } diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index c65dd6e53f5b..a388e12109d0 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -687,7 +687,7 @@ const SwRect& SwViewShell::VisArea() const void SwViewShell::MakeVisible( const SwRect &rRect, ScrollSizeMode eScrollSizeMode ) { - if ( !(!VisArea().Contains( rRect ) || IsScrollMDI( this, rRect ) || GetCareDialog(*this)) ) + if ( !(!VisArea().Contains( rRect ) || IsScrollMDI( *this, rRect ) || GetCareDialog(*this)) ) return; if ( IsViewLocked() ) @@ -701,7 +701,7 @@ void SwViewShell::MakeVisible( const SwRect &rRect, ScrollSizeMode eScrollSizeMo do{ nOldH = pRoot->getFrameArea().Height(); SwViewShell::StartAction(); - ScrollMDI( this, rRect, USHRT_MAX, USHRT_MAX, eScrollSizeMode ); + ScrollMDI( *this, rRect, USHRT_MAX, USHRT_MAX, eScrollSizeMode ); SwViewShell::EndAction(); // DO NOT call virtual here! } while( nOldH != pRoot->getFrameArea().Height() && nLoopCnt-- ); } @@ -1274,7 +1274,7 @@ void SwViewShell::SizeChgNotify() if ( !Imp()->IsCalcLayoutProgress() && dynamic_cast<const SwCursorShell*>( this ) != nullptr ) { - PageNumNotify(this); + PageNumNotify(*this); if (comphelper::LibreOfficeKit::isActive()) { @@ -1290,7 +1290,7 @@ void SwViewShell::SizeChgNotify() else { mbDocSizeChgd = false; - ::SizeNotify( this, GetDocSize() ); + ::SizeNotify( *this, GetDocSize() ); } } @@ -2677,7 +2677,7 @@ void SwViewShell::UISizeNotify() mbDocSizeChgd = false; bool bOld = bInSizeNotify; bInSizeNotify = true; - ::SizeNotify( this, GetDocSize() ); + ::SizeNotify( *this, GetDocSize() ); bInSizeNotify = bOld; } } diff --git a/sw/source/uibase/docvw/edtwin3.cxx b/sw/source/uibase/docvw/edtwin3.cxx index 757a9ccdfd97..c95c8259455d 100644 --- a/sw/source/uibase/docvw/edtwin3.cxx +++ b/sw/source/uibase/docvw/edtwin3.cxx @@ -32,20 +32,20 @@ #include <uiobject.hxx> // Core-Notify -void ScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect, +void ScrollMDI( SwViewShell const & rVwSh, const SwRect &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY, ScrollSizeMode eScrollSizeMode) { - SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell(); + SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell(); if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell)) pSwView->Scroll(rRect.SVRect(), nRangeX, nRangeY, eScrollSizeMode); } // Docmdi - movable -bool IsScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect ) +bool IsScrollMDI( SwViewShell const & rVwSh, const SwRect &rRect ) { - SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell(); + SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell(); if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell)) return pSwView->IsScroll(rRect.SVRect()); @@ -54,9 +54,9 @@ bool IsScrollMDI( SwViewShell const * pVwSh, const SwRect &rRect ) } // Notify for size change -void SizeNotify(SwViewShell const * pVwSh, const Size &rSize) +void SizeNotify(SwViewShell const & rVwSh, const Size &rSize) { - SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell(); + SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell(); if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell)) pSwView->DocSzChgd(rSize); @@ -65,9 +65,9 @@ void SizeNotify(SwViewShell const * pVwSh, const Size &rSize) } // Notify for page number update -void PageNumNotify(SwViewShell const * pVwSh) +void PageNumNotify(SwViewShell const & rVwSh) { - SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell(); + SfxViewShell *pSfxViewShell = rVwSh.GetSfxViewShell(); if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell)) {