sw/inc/swrect.hxx | 2 sw/source/core/access/accmap.cxx | 12 -- sw/source/core/bastyp/swrect.cxx | 2 sw/source/core/crsr/viscrs.cxx | 4 sw/source/core/doc/notxtfrm.cxx | 8 - sw/source/core/layout/frmtool.cxx | 6 - sw/source/core/layout/paintfrm.cxx | 56 +++++----- sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx | 16 +- sw/source/core/text/inftxt.cxx | 12 -- sw/source/core/view/vdraw.cxx | 8 - sw/source/uibase/utlui/viewlayoutctrl.cxx | 4 11 files changed, 62 insertions(+), 68 deletions(-)
New commits: commit 1f59cbe36c9899f6fa9a869331c9be454abd4606 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Apr 17 15:38:05 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Apr 18 20:36:35 2020 +0200 simplify some SwRect code - use the SwRect Add* variants which makes it easier to assert the correct stuff in later commits. And add AddTop() and AddLeft() methods for symmetry. Change-Id: I0e03d9d1e933fc14eb007f6f31862f14fee9ef7a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92451 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/swrect.hxx b/sw/inc/swrect.hxx index 6cde3c3f01e7..459f63b28cb3 100644 --- a/sw/inc/swrect.hxx +++ b/sw/inc/swrect.hxx @@ -120,7 +120,9 @@ public: long Width_() const; long Height_() const; void SubTop( const long nSub ); + void AddTop( const long nAdd ); void AddBottom( const long nAdd ); + void AddLeft( const long nAdd ); void SubLeft( const long nSub ); void AddRight( const long nAdd ); void AddWidth( const long nAdd ); diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index da0852618fa6..ebe72049816e 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -869,20 +869,16 @@ void SwAccPreviewData::AdjustLogicPgRectToVisibleArea( SwTwips nTmpDiff; // left nTmpDiff = aVisPreviewPgSwRect.Left() - _rPreviewPgSwRect.Left(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Left( _iorLogicPgSwRect.Left() + nTmpDiff ); + _iorLogicPgSwRect.AddLeft( nTmpDiff ); // top nTmpDiff = aVisPreviewPgSwRect.Top() - _rPreviewPgSwRect.Top(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Top( _iorLogicPgSwRect.Top() + nTmpDiff ); + _iorLogicPgSwRect.AddTop( nTmpDiff ); // right nTmpDiff = _rPreviewPgSwRect.Right() - aVisPreviewPgSwRect.Right(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Right( _iorLogicPgSwRect.Right() - nTmpDiff ); + _iorLogicPgSwRect.AddRight( - nTmpDiff ); // bottom nTmpDiff = _rPreviewPgSwRect.Bottom() - aVisPreviewPgSwRect.Bottom(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Bottom( _iorLogicPgSwRect.Bottom() - nTmpDiff ); + _iorLogicPgSwRect.AddBottom( - nTmpDiff ); } static bool AreInSameTable( const uno::Reference< XAccessible >& rAcc, diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx index 884c155003e2..09246fe2c70e 100644 --- a/sw/source/core/bastyp/swrect.cxx +++ b/sw/source/core/bastyp/swrect.cxx @@ -163,8 +163,10 @@ long SwRect::Bottom_() const{ return m_Point.getY() + m_Size.getHeight(); } void SwRect::AddWidth( const long nAdd ) { m_Size.AdjustWidth(nAdd ); } void SwRect::AddHeight( const long nAdd ) { m_Size.AdjustHeight(nAdd ); } +void SwRect::AddLeft( const long nAdd ){ m_Size.AdjustWidth(-nAdd ); m_Point.setX(m_Point.getX() + nAdd); } void SwRect::SubLeft( const long nSub ){ m_Size.AdjustWidth(nSub ); m_Point.setX(m_Point.getX() - nSub); } void SwRect::AddRight( const long nAdd ){ m_Size.AdjustWidth(nAdd ); } +void SwRect::AddTop( const long nAdd ){ m_Size.AdjustHeight(-nAdd ); m_Point.setY(m_Point.getY() + nAdd); } void SwRect::SubTop( const long nSub ){ m_Size.AdjustHeight(nSub ); m_Point.setY(m_Point.getY() - nSub); } void SwRect::AddBottom( const long nAdd ){ m_Size.AdjustHeight(nAdd ); } void SwRect::SetPosX( const long nNew ){ m_Point.setX(nNew); } diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index d51471057b4e..35650f665ee0 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -579,9 +579,9 @@ void SwSelPaintRects::Invalidate( const SwRect& rRect ) { SwRect& rRectIt = *it; if( rRectIt.Right() == GetShell()->m_aOldRBPos.X() ) - rRectIt.Right( rRectIt.Right() + s_nPixPtX ); + rRectIt.AddRight( s_nPixPtX ); if( rRectIt.Bottom() == GetShell()->m_aOldRBPos.Y() ) - rRectIt.Bottom( rRectIt.Bottom() + s_nPixPtY ); + rRectIt.AddBottom( s_nPixPtY ); } } } diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 8c77fd28c93f..550f0df508db 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -861,22 +861,22 @@ static void lcl_correctlyAlignRect( SwRect& rAlignedGrfArea, const SwRect& rInAr tools::Rectangle aNewPxRect( aPxRect ); while( aNewPxRect.Left() < aPxRect.Left() ) { - rAlignedGrfArea.Left( rAlignedGrfArea.Left()+1 ); + rAlignedGrfArea.AddLeft( 1 ); aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() ); } while( aNewPxRect.Top() < aPxRect.Top() ) { - rAlignedGrfArea.Top( rAlignedGrfArea.Top()+1 ); + rAlignedGrfArea.AddTop(+1); aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() ); } while( aNewPxRect.Bottom() > aPxRect.Bottom() ) { - rAlignedGrfArea.Bottom( rAlignedGrfArea.Bottom()-1 ); + rAlignedGrfArea.AddBottom( -1 ); aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() ); } while( aNewPxRect.Right() > aPxRect.Right() ) { - rAlignedGrfArea.Right( rAlignedGrfArea.Right()-1 ); + rAlignedGrfArea.AddRight(-1); aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() ); } } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index d9a24922dcf7..d43191d63ecc 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -3716,13 +3716,11 @@ SwRect SwPageFrame::PrtWithoutHeaderAndFooter() const // always at top respectively at bottom of the page frame. if ( pLowerFrame->IsHeaderFrame() ) { - aPrtWithoutHeaderFooter.Top( aPrtWithoutHeaderFooter.Top() + - pLowerFrame->getFrameArea().Height() ); + aPrtWithoutHeaderFooter.AddTop( pLowerFrame->getFrameArea().Height() ); } if ( pLowerFrame->IsFooterFrame() ) { - aPrtWithoutHeaderFooter.Bottom( aPrtWithoutHeaderFooter.Bottom() - - pLowerFrame->getFrameArea().Height() ); + aPrtWithoutHeaderFooter.AddBottom( - pLowerFrame->getFrameArea().Height() ); } pLowerFrame = pLowerFrame->GetNext(); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 43e1f4eb2f11..12191cb4fecf 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -772,13 +772,13 @@ void SwSubsRects::RemoveSuperfluousSubsidiaryLines( const SwLineRects &rRects, S SwRect aSubsRect( aSubsLineRect ); if ( bVerticalSubs ) { - aSubsRect.Left ( aSubsRect.Left() - (properties.nSPixelSzW+properties.nSHalfPixelSzW) ); - aSubsRect.Right ( aSubsRect.Right() + (properties.nSPixelSzW+properties.nSHalfPixelSzW) ); + aSubsRect.AddLeft ( - (properties.nSPixelSzW+properties.nSHalfPixelSzW) ); + aSubsRect.AddRight ( properties.nSPixelSzW+properties.nSHalfPixelSzW ); } else { - aSubsRect.Top ( aSubsRect.Top() - (properties.nSPixelSzH+properties.nSHalfPixelSzH) ); - aSubsRect.Bottom( aSubsRect.Bottom() + (properties.nSPixelSzH+properties.nSHalfPixelSzH) ); + aSubsRect.AddTop ( - (properties.nSPixelSzH+properties.nSHalfPixelSzH) ); + aSubsRect.AddBottom( properties.nSPixelSzH+properties.nSHalfPixelSzH ); } for (const_iterator itK = rRects.aLineRects.begin(); itK != rRects.aLineRects.end(); ++itK) { @@ -1143,25 +1143,25 @@ void SwAlignRect( SwRect &rRect, const SwViewShell *pSh, const vcl::RenderContex if ( rRect.Top() > aPxCenterRect.Top() ) { // 'leave pixel overlapping on top' - aAlignedPxRect.Top( aAlignedPxRect.Top() + 1 ); + aAlignedPxRect.AddTop( 1 ); } if ( rRect.Bottom() < aPxCenterRect.Bottom() ) { // 'leave pixel overlapping on bottom' - aAlignedPxRect.Bottom( aAlignedPxRect.Bottom() - 1 ); + aAlignedPxRect.AddBottom( - 1 ); } if ( rRect.Left() > aPxCenterRect.Left() ) { // 'leave pixel overlapping on left' - aAlignedPxRect.Left( aAlignedPxRect.Left() + 1 ); + aAlignedPxRect.AddLeft( 1 ); } if ( rRect.Right() < aPxCenterRect.Right() ) { // 'leave pixel overlapping on right' - aAlignedPxRect.Right( aAlignedPxRect.Right() - 1 ); + aAlignedPxRect.AddRight( - 1 ); } // Consider negative width/height check, if aligned SwRect has negative width/height. @@ -4243,8 +4243,8 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, if ( bDrawFullShadowRectangle ) { // draw full shadow rectangle - aOut.Top( rOutRect.Top() + nHeight ); - aOut.Left( rOutRect.Left() + nWidth ); + aOut.AddTop( nHeight ); + aOut.AddLeft( nWidth ); aRegion.push_back( aOut ); } else @@ -4253,26 +4253,26 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, { aOut.Top( rOutRect.Bottom() - nHeight ); if( bLeft ) - aOut.Left( rOutRect.Left() + nWidth ); + aOut.AddLeft( nWidth ); aRegion.push_back( aOut ); } if( bRight ) { aOut.Left( rOutRect.Right() - nWidth ); if( bTop ) - aOut.Top( rOutRect.Top() + nHeight ); + aOut.AddTop( nHeight ); else aOut.Top( rOutRect.Top() ); if( bBottom ) - aOut.Bottom( rOutRect.Bottom() - nHeight ); + aOut.AddBottom( - nHeight ); aRegion.push_back( aOut ); } } if( bRight ) - rOutRect.Right( rOutRect.Right() - nWidth ); + rOutRect.AddRight(- nWidth ); if( bBottom ) - rOutRect.Bottom( rOutRect.Bottom()- nHeight ); + rOutRect.AddBottom(- nHeight ); } break; case SvxShadowLocation::TopLeft: @@ -4280,8 +4280,8 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, if ( bDrawFullShadowRectangle ) { // draw full shadow rectangle - aOut.Bottom( rOutRect.Bottom() - nHeight ); - aOut.Right( rOutRect.Right() - nWidth ); + aOut.AddBottom( - nHeight ); + aOut.AddRight( - nWidth ); aRegion.push_back( aOut ); } else @@ -4290,7 +4290,7 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, { aOut.Bottom( rOutRect.Top() + nHeight ); if( bRight ) - aOut.Right( rOutRect.Right() - nWidth ); + aOut.AddRight( - nWidth ); aRegion.push_back( aOut ); } if( bLeft ) @@ -4307,9 +4307,9 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, } if( bLeft ) - rOutRect.Left( rOutRect.Left() + nWidth ); + rOutRect.AddLeft( nWidth ); if( bTop ) - rOutRect.Top( rOutRect.Top() + nHeight ); + rOutRect.AddTop( nHeight ); } break; case SvxShadowLocation::TopRight: @@ -4344,9 +4344,9 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, } if( bRight ) - rOutRect.Right( rOutRect.Right() - nWidth ); + rOutRect.AddRight( - nWidth ); if( bTop ) - rOutRect.Top( rOutRect.Top() + nHeight ); + rOutRect.AddTop( nHeight ); } break; case SvxShadowLocation::BottomLeft: @@ -4381,9 +4381,9 @@ static void lcl_PaintShadow( const SwRect& rRect, SwRect& rOutRect, } if( bLeft ) - rOutRect.Left( rOutRect.Left() + nWidth ); + rOutRect.AddLeft( nWidth ); if( bBottom ) - rOutRect.Bottom( rOutRect.Bottom() - nHeight ); + rOutRect.AddBottom( - nHeight ); } break; default: @@ -5733,9 +5733,9 @@ bool SwPageFrame::IsLeftShadowNeeded() const // Notes are displayed, we've to extend borders SwTwips aSidebarTotalWidth = pMgr->GetSidebarWidth(true) + pMgr->GetSidebarBorderWidth(true); if(bRightSidebar) - _orHorizontalShadowRect.Right( _orHorizontalShadowRect.Right() + aSidebarTotalWidth ); + _orHorizontalShadowRect.AddRight( aSidebarTotalWidth ); else - _orHorizontalShadowRect.Left( _orHorizontalShadowRect.Left() - aSidebarTotalWidth ); + _orHorizontalShadowRect.AddLeft( - aSidebarTotalWidth ); } } @@ -6087,8 +6087,8 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin SwRect aAlignedPageRect( _rPageRect ); ::SwAlignRect( aAlignedPageRect, _pViewShell, pRenderContext ); SwRect aPagePxRect = pRenderContext->LogicToPixel( aAlignedPageRect.SVRect() ); - aPagePxRect.Bottom( aPagePxRect.Bottom() + mnShadowPxWidth + 1 ); - aPagePxRect.Top( aPagePxRect.Top() - mnShadowPxWidth - 1 ); + aPagePxRect.AddBottom( mnShadowPxWidth + 1 ); + aPagePxRect.AddTop( - mnShadowPxWidth - 1 ); SwRect aTmpRect; diff --git a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx index 3f094d6c7d06..ffe9a3682a6d 100644 --- a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx @@ -153,10 +153,10 @@ void SwAsCharAnchoredObjectPosition::CalcPosition() } // enlarge bounding rectangle of object by its spacing. - aObjBoundRect.Left( aObjBoundRect.Left() - nLRSpaceLeft ); - aObjBoundRect.Width( aObjBoundRect.Width() + nLRSpaceRight ); - aObjBoundRect.Top( aObjBoundRect.Top() - nULSpaceUpper ); - aObjBoundRect.Height( aObjBoundRect.Height() + nULSpaceLower ); + aObjBoundRect.AddLeft( - nLRSpaceLeft ); + aObjBoundRect.AddWidth( nLRSpaceRight ); + aObjBoundRect.AddTop( - nULSpaceUpper ); + aObjBoundRect.AddHeight( nULSpaceLower ); // calculate relative position to given base line. const SwFormatVertOrient& rVert = rFrameFormat.GetVertOrient(); @@ -307,10 +307,10 @@ void SwAsCharAnchoredObjectPosition::CalcPosition() { // recalculate object bound rectangle, if object width has changed. aObjBoundRect = GetAnchoredObj().GetObjRect(); - aObjBoundRect.Left( aObjBoundRect.Left() - rLRSpace.GetLeft() ); - aObjBoundRect.Width( aObjBoundRect.Width() + rLRSpace.GetRight() ); - aObjBoundRect.Top( aObjBoundRect.Top() - rULSpace.GetUpper() ); - aObjBoundRect.Height( aObjBoundRect.Height() + rULSpace.GetLower() ); + aObjBoundRect.AddLeft( - rLRSpace.GetLeft() ); + aObjBoundRect.AddWidth( rLRSpace.GetRight() ); + aObjBoundRect.AddTop( - rULSpace.GetUpper() ); + aObjBoundRect.AddHeight( rULSpace.GetLower() ); } } OSL_ENSURE( aRectFnSet.GetHeight(rFlyInContentFrame.getFrameArea()), diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index cd6781ca4b87..5cebec8c1e18 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -850,17 +850,13 @@ void SwTextPaintInfo::CalcRect( const SwLinePortion& rPor, static_cast<const SwTextPortion&>(rPor).GetJoinBorderWithNext(); const bool bIsVert = GetTextFrame()->IsVertical(); const bool bIsVertLRBT = GetTextFrame()->IsVertLRBT(); - aRect.Top(aRect.Top() - + GetFont()->CalcShadowSpace(SvxShadowItemSide::TOP, bIsVert, bIsVertLRBT, + aRect.AddTop( GetFont()->CalcShadowSpace(SvxShadowItemSide::TOP, bIsVert, bIsVertLRBT, bJoinWithPrev, bJoinWithNext)); - aRect.Bottom(aRect.Bottom() - - GetFont()->CalcShadowSpace(SvxShadowItemSide::BOTTOM, bIsVert, bIsVertLRBT, + aRect.AddBottom( - GetFont()->CalcShadowSpace(SvxShadowItemSide::BOTTOM, bIsVert, bIsVertLRBT, bJoinWithPrev, bJoinWithNext)); - aRect.Left(aRect.Left() - + GetFont()->CalcShadowSpace(SvxShadowItemSide::LEFT, bIsVert, bIsVertLRBT, + aRect.AddLeft( GetFont()->CalcShadowSpace(SvxShadowItemSide::LEFT, bIsVert, bIsVertLRBT, bJoinWithPrev, bJoinWithNext)); - aRect.Right(aRect.Right() - - GetFont()->CalcShadowSpace(SvxShadowItemSide::RIGHT, bIsVert, bIsVertLRBT, + aRect.AddRight( - GetFont()->CalcShadowSpace(SvxShadowItemSide::RIGHT, bIsVert, bIsVertLRBT, bJoinWithPrev, bJoinWithNext)); } diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx index 4f6853615138..b59e432757b4 100644 --- a/sw/source/core/view/vdraw.cxx +++ b/sw/source/core/view/vdraw.cxx @@ -182,10 +182,10 @@ bool SwViewShellImp::IsDragPossible( const Point &rPoint ) else aRect = GetShell()->GetLayout()->getFrameArea(); - aRect.Top( aRect.Top() - FUZZY_EDGE ); - aRect.Bottom( aRect.Bottom() + FUZZY_EDGE ); - aRect.Left( aRect.Left() - FUZZY_EDGE ); - aRect.Right( aRect.Right() + FUZZY_EDGE ); + aRect.AddTop (- FUZZY_EDGE ); + aRect.AddBottom( FUZZY_EDGE ); + aRect.AddLeft (- FUZZY_EDGE ); + aRect.AddRight ( FUZZY_EDGE ); return aRect.IsInside( rPoint ); } diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx b/sw/source/uibase/utlui/viewlayoutctrl.cxx index 43b302e3a6d1..bdb18bbb376e 100644 --- a/sw/source/uibase/utlui/viewlayoutctrl.cxx +++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx @@ -103,8 +103,8 @@ void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt ) const long nXOffset = (aRect.GetWidth() - nImageWidthSum) / 2; const long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height()) / 2; - aRect.SetLeft( aRect.Left() + nXOffset ); - aRect.SetTop( aRect.Top() + nYOffset ); + aRect.AdjustLeft( nXOffset ); + aRect.AdjustTop( nYOffset ); // draw single column image: pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits