From b22d4785310eac35696df771803dfba0871a50ac Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 17 Sep 2021 21:49:21 +0200 Subject: clean up ambiguous confusing rectangle APIs like IsInside() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading 'rectA.IsInside( rectB )' kind of suggests that the code checks whether 'rectA is inside rectB', but it's actually the other way around. Rename IsInside() -> Contains(), IsOver() -> Overlaps(), which should make it clear which way the logic goes. Change-Id: I9347450fe7dc34c96df6d636a4e3e660de1801ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122271 Reviewed-by: Noel Grandin Reviewed-by: Luboš Luňák Tested-by: Jenkins --- sc/source/ui/Accessibility/AccessibleContextBase.cxx | 4 ++-- sc/source/ui/Accessibility/AccessibleDocument.cxx | 2 +- .../ui/Accessibility/AccessibleDocumentPagePreview.cxx | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sc/source/ui/Accessibility') diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx b/sc/source/ui/Accessibility/AccessibleContextBase.cxx index b1d9cf3dfab6..38620240baaf 100644 --- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx @@ -143,7 +143,7 @@ sal_Bool SAL_CALL ScAccessibleContextBase::containsPoint(const awt::Point& rPoin { SolarMutexGuard aGuard; IsObjectValid(); - return tools::Rectangle (Point(), GetBoundingBox().GetSize()).IsInside(VCLPoint(rPoint)); + return tools::Rectangle (Point(), GetBoundingBox().GetSize()).Contains(VCLPoint(rPoint)); } uno::Reference< XAccessible > SAL_CALL ScAccessibleContextBase::getAccessibleAtPoint( @@ -193,7 +193,7 @@ bool ScAccessibleContextBase::isShowing( ) { tools::Rectangle aParentBounds(VCLRectangle(xParentComponent->getBounds())); tools::Rectangle aBounds(VCLRectangle(getBounds())); - bShowing = aBounds.IsOver(aParentBounds); + bShowing = aBounds.Overlaps(aParentBounds); } } return bShowing; diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 3b78798d05c0..0ac7d931d6e6 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -1647,7 +1647,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoin if (xComp.is()) { tools::Rectangle aBound(VCLRectangle(xComp->getBounds())); - if (aBound.IsInside(VCLPoint(rPoint))) + if (aBound.Contains(VCLPoint(rPoint))) xAccessible = mxTempAcc; } } diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index 336fd112af8b..9656b82af035 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -273,7 +273,7 @@ struct ScPointFound bool operator() (const ScAccNote& rNote) { bool bResult(false); - if (maPoint.IsInside(rNote.maRect)) + if (maPoint.Contains(rNote.maRect)) bResult = true; else mnParagraphs += rNote.mnParaCount; @@ -918,7 +918,7 @@ struct ScShapePointFound bool operator() (const ScShapeChild& rShape) { bool bResult(false); - if (VCLRectangle(rShape.mpAccShape->getBounds()).IsInside(maPoint)) + if (VCLRectangle(rShape.mpAccShape->getBounds()).Contains(maPoint)) bResult = true; return bResult; } @@ -1117,10 +1117,10 @@ ScPagePreviewCountData::ScPagePreviewCountData( const ScPreviewLocationData& rDa tools::Rectangle aObjRect; - if ( rData.GetHeaderPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) ) + if ( rData.GetHeaderPosition( aObjRect ) && aObjRect.Overlaps( aVisRect ) ) nHeaders = 1; - if ( rData.GetFooterPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) ) + if ( rData.GetFooterPosition( aObjRect ) && aObjRect.Overlaps( aVisRect ) ) nFooters = 1; if ( rData.HasCellsInRange( aVisRect ) ) @@ -1289,7 +1289,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAcces mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex ); mpTable->Init(); } - if (mpTable.is() && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint))) + if (mpTable.is() && VCLRectangle(mpTable->getBounds()).Contains(VCLPoint(rPoint))) xAccessible = mpTable.get(); } if (!xAccessible.is()) @@ -1313,9 +1313,9 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAcces Point aPoint(VCLPoint(rPoint)); - if (VCLRectangle(mpHeader->getBounds()).IsInside(aPoint)) + if (VCLRectangle(mpHeader->getBounds()).Contains(aPoint)) xAccessible = mpHeader.get(); - else if (VCLRectangle(mpFooter->getBounds()).IsInside(aPoint)) + else if (VCLRectangle(mpFooter->getBounds()).Contains(aPoint)) xAccessible = mpFooter.get(); } if (!xAccessible.is()) -- cgit