[Libreoffice-commits] core.git: sw/inc sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 20 08:18:33 UTC 2020


 sw/inc/swrect.hxx                        |    5 -----
 sw/source/core/crsr/crsrsh.cxx           |    7 ++++---
 sw/source/core/draw/dflyobj.cxx          |    4 ++--
 sw/source/core/layout/anchoredobject.cxx |    4 ++--
 sw/source/core/layout/findfrm.cxx        |    2 +-
 sw/source/core/layout/fly.cxx            |    8 ++++----
 sw/source/core/layout/ftnfrm.cxx         |    2 +-
 sw/source/core/layout/hffrm.cxx          |    2 +-
 sw/source/core/layout/pagechg.cxx        |    6 +++---
 sw/source/core/layout/paintfrm.cxx       |    6 +++---
 sw/source/core/layout/virtoutp.cxx       |    4 ++--
 sw/source/core/layout/wsfrm.cxx          |   10 +++++-----
 sw/source/core/text/frmcrsr.cxx          |    8 ++++----
 sw/source/core/text/frmform.cxx          |    4 ++--
 sw/source/core/view/viewimp.cxx          |    2 +-
 sw/source/core/view/viewsh.cxx           |   10 +++++-----
 16 files changed, 40 insertions(+), 44 deletions(-)

New commits:
commit 4e578adbc7dc5c4ece45b9f362e71b4cbe24752a
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Apr 20 09:22:08 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Apr 20 10:17:51 2020 +0200

    remove direct access to Size field on SwRect
    
    so I can add asserts to prevent construction of invalid rectangles
    
    Change-Id: I01ac97b3cc780acbd182a646f0e072e518a45bee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92520
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/swrect.hxx b/sw/inc/swrect.hxx
index 459f63b28cb3..b2c5279dc129 100644
--- a/sw/inc/swrect.hxx
+++ b/sw/inc/swrect.hxx
@@ -72,7 +72,6 @@ public:
 
     // In order to be able to access the members of Pos and SSize from the layout side.
     inline Point &Pos();
-    inline Size  &SSize();
 
     Point Center() const;
 
@@ -225,10 +224,6 @@ inline const Size  &SwRect::SSize() const
 {
     return m_Size;
 }
-inline Size  &SwRect::SSize()
-{
-    return m_Size;
-}
 inline long SwRect::Width()  const
 {
     return m_Size.Width();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 5c5e01f1c871..16ccab6ef876 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3070,8 +3070,8 @@ void SwCursorShell::MakeSelVisible()
         }
         if( !aTmp.HasArea() )
         {
-            aTmp.SSize().AdjustHeight(1 );
-            aTmp.SSize().AdjustWidth(1 );
+            aTmp.AddHeight(1 );
+            aTmp.AddWidth(1 );
         }
         MakeVisible( aTmp );
     }
@@ -3082,7 +3082,8 @@ void SwCursorShell::MakeSelVisible()
         else
         {
             SwRect aTmp( m_aCharRect );
-            aTmp.SSize().AdjustHeight(1 ); aTmp.SSize().AdjustWidth(1 );
+            aTmp.AddHeight(1 );
+            aTmp.AddWidth(1 );
             MakeVisible( aTmp );
         }
     }
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 964fde20a56d..756ea9e33fdf 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -1271,8 +1271,8 @@ SdrObject* SwVirtFlyDrawObj::CheckMacroHit( const SdrObjMacroHitRec& rRec ) cons
         {
             aRect.Pos().setX(aRect.Pos().getX() + rRec.nTol);
             aRect.Pos().setY(aRect.Pos().getY() + rRec.nTol);
-            aRect.SSize().AdjustHeight( -(2 * rRec.nTol) );
-            aRect.SSize().AdjustWidth( -(2 * rRec.nTol) );
+            aRect.AddHeight( -(2 * rRec.nTol) );
+            aRect.AddWidth( -(2 * rRec.nTol) );
 
             if( aRect.IsInside( rRec.aPos ) )
             {
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index f064d20d8035..df9d0cb08ef8 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -577,8 +577,8 @@ const SwRect& SwAnchoredObject::GetObjRectWithSpaces() const
         {
             maObjRectWithSpaces.Top ( std::max( maObjRectWithSpaces.Top() - long(rUL.GetUpper()), 0L ));
             maObjRectWithSpaces.Left( std::max( maObjRectWithSpaces.Left()- rLR.GetLeft(),  0L ));
-            maObjRectWithSpaces.SSize().AdjustHeight(rUL.GetLower() );
-            maObjRectWithSpaces.SSize().AdjustWidth(rLR.GetRight() );
+            maObjRectWithSpaces.AddHeight(rUL.GetLower() );
+            maObjRectWithSpaces.AddWidth(rLR.GetRight() );
         }
 
         mbObjRectWithSpacesValid = true;
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index d71fc59ff489..548399e40478 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -577,7 +577,7 @@ const SwPageFrame* SwRootFrame::GetPageAtPos( const Point& rPt, const Size* pSiz
     if ( pSize )
     {
         aRect.Pos()  = rPt;
-        aRect.SSize() = *pSize;
+        aRect.SSize( *pSize );
     }
 
     const SwFrame* pPage = Lower();
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index f5974f053b86..f89d9166e4a9 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -778,10 +778,10 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
                 SwRect aOld( getFrameArea() );
                 const SvxULSpaceItem &rUL = static_cast<const SwFormatChg*>(pOld)->pChangedFormat->GetULSpace();
                 aOld.Top( std::max( aOld.Top() - long(rUL.GetUpper()), 0L ) );
-                aOld.SSize().AdjustHeight(rUL.GetLower() );
+                aOld.AddHeight(rUL.GetLower() );
                 const SvxLRSpaceItem &rLR = static_cast<const SwFormatChg*>(pOld)->pChangedFormat->GetLRSpace();
                 aOld.Left  ( std::max( aOld.Left() - rLR.GetLeft(), 0L ) );
-                aOld.SSize().AdjustWidth(rLR.GetRight() );
+                aOld.AddWidth(rLR.GetRight() );
                 aNew.Union( aOld );
                 NotifyBackground( FindPageFrame(), aNew, PrepareHint::Clear );
 
@@ -880,13 +880,13 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
                 {
                     const SvxULSpaceItem &rUL = *static_cast<const SvxULSpaceItem*>(pNew);
                     aOld.Top( std::max( aOld.Top() - long(rUL.GetUpper()), 0L ) );
-                    aOld.SSize().AdjustHeight(rUL.GetLower() );
+                    aOld.AddHeight(rUL.GetLower() );
                 }
                 else
                 {
                     const SvxLRSpaceItem &rLR = *static_cast<const SvxLRSpaceItem*>(pNew);
                     aOld.Left  ( std::max( aOld.Left() - rLR.GetLeft(), 0L ) );
-                    aOld.SSize().AdjustWidth(rLR.GetRight() );
+                    aOld.AddWidth(rLR.GetRight() );
                 }
             }
             aNew.Union( aOld );
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 0431934534f4..274c3ef159d5 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -430,7 +430,7 @@ SwTwips SwFootnoteContFrame::GrowFrame( SwTwips nDist, bool bTst, bool )
 
             // We can only respect the boundless wish so much
             SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
-            aFrm.SSize().AdjustHeight( -nDist );
+            aFrm.AddHeight( -nDist );
 
             if( IsVertical() && !IsVertLR() )
             {
diff --git a/sw/source/core/layout/hffrm.cxx b/sw/source/core/layout/hffrm.cxx
index 1decf6c583e3..87d63ebb76a3 100644
--- a/sw/source/core/layout/hffrm.cxx
+++ b/sw/source/core/layout/hffrm.cxx
@@ -383,7 +383,7 @@ void SwHeadFootFrame::FormatSize(SwTwips nUL, const SwBorderAttrs * pAttrs)
                         aFrm.Bottom( nDeadLine );
 
                         SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
-                        aPrt.SSize().setHeight( getFrameArea().Height() - nBorder );
+                        aPrt.Height( getFrameArea().Height() - nBorder );
                     }
                 }
 
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index c9f2469591dd..4a29018a424d 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1394,7 +1394,7 @@ SwTwips SwRootFrame::GrowFrame( SwTwips nDist, bool bTst, bool )
     if ( !bTst )
     {
         SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
-        aFrm.SSize().AdjustHeight(nDist );
+        aFrm.AddHeight(nDist );
     }
 
     return nDist;
@@ -1408,7 +1408,7 @@ SwTwips SwRootFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool )
     if ( !bTst )
     {
         SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
-        aFrm.SSize().AdjustHeight( -nDist );
+        aFrm.AddHeight( -nDist );
     }
 
     return nDist;
@@ -1698,7 +1698,7 @@ Size SwRootFrame::ChgSize( const Size& aNewSize )
 {
     {
         SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
-        aFrm.SSize() = aNewSize;
+        aFrm.SSize(aNewSize);
     }
 
     InvalidatePrt_();
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 12191cb4fecf..d5ec987896b1 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3228,7 +3228,7 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const&
 
             // code from vprint.cxx
             const SwPageFrame& rFormatPage = pPage->GetFormatPage();
-            aEmptyPageRect.SSize() = rFormatPage.getFrameArea().SSize();
+            aEmptyPageRect.SSize( rFormatPage.getFrameArea().SSize() );
 
             SwPageFrame::GetBorderAndShadowBoundRect( aEmptyPageRect, pSh, &rRenderContext, aPaintRect,
                 bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
@@ -7413,9 +7413,9 @@ Graphic SwFlyFrameFormat::MakeGraphic( ImageMap* pMap )
         SwBorderAttrAccess aAccess( SwFrame::GetCache(), pFly );
         const SwBorderAttrs &rAttrs = *aAccess.Get();
         if ( rAttrs.CalcRightLine() )
-            aOut.SSize().AdjustWidth(2*gProp.nSPixelSzW );
+            aOut.AddWidth(2*gProp.nSPixelSzW );
         if ( rAttrs.CalcBottomLine() )
-            aOut.SSize().AdjustHeight(2*gProp.nSPixelSzH );
+            aOut.AddHeight(2*gProp.nSPixelSzH );
 
         // #i92711# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev
         const vcl::Region aRepaintRegion(aOut.SVRect());
diff --git a/sw/source/core/layout/virtoutp.cxx b/sw/source/core/layout/virtoutp.cxx
index 50821ad73677..ace9cb283347 100644
--- a/sw/source/core/layout/virtoutp.cxx
+++ b/sw/source/core/layout/virtoutp.cxx
@@ -142,8 +142,8 @@ void SwLayVout::Enter(  SwViewShell *pShell, SwRect &rRect, bool bOn )
     pOut = pO;
     Size aPixSz( pOut->PixelToLogic( Size( 1,1 )) );
     SwRect aTmp( rRect );
-    aTmp.SSize().AdjustWidth(aPixSz.Width()/2 + 1 );
-    aTmp.SSize().AdjustHeight(aPixSz.Height()/2 + 1 );
+    aTmp.AddWidth(aPixSz.Width()/2 + 1 );
+    aTmp.AddHeight(aPixSz.Height()/2 + 1 );
     tools::Rectangle aTmpRect( pO->LogicToPixel( aTmp.SVRect() ) );
 
     OSL_ENSURE( !pSh->GetWin()->IsReallyVisible() ||
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 1bb1ae04159d..d143ec52d868 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1671,12 +1671,12 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
         {
             {
                 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*pUp);
-                aFrm.SSize().AdjustHeight(nChg );
+                aFrm.AddHeight(nChg );
             }
 
             {
                 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*pUp);
-                aPrt.SSize().AdjustHeight(nChg );
+                aPrt.AddHeight(nChg );
             }
 
             if ( pViewShell )
@@ -1707,7 +1707,7 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
                 if ( IsBodyFrame() )
                 {
                     SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
-                    aPrt.SSize().setHeight( nOldFrameHeight );
+                    aPrt.Height( nOldFrameHeight );
                 }
 
                 if ( pUp->GetUpper() )
@@ -1716,10 +1716,10 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
                 }
 
                 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
-                aFrm.SSize().setHeight( nOldFrameHeight );
+                aFrm.Height( nOldFrameHeight );
 
                 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
-                aPrt.SSize().setHeight( nOldPrtHeight );
+                aPrt.Height( nOldPrtHeight );
 
                 mbCompletePaint = bOldComplete;
             }
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 1b14768b5639..23ee0cd34106 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -822,7 +822,7 @@ bool SwTextFrame::UnitUp_( SwPaM *pPam, const SwTwips nOffset,
 
             if ( bPrevLine || bSecondOfDouble )
             {
-                aCharBox.SSize().setWidth( aCharBox.SSize().Width() / 2 );
+                aCharBox.Width( aCharBox.SSize().Width() / 2 );
                 aCharBox.Pos().setX( aCharBox.Pos().X() - 150 );
 
                 // See comment in SwTextFrame::GetModelPositionForViewPoint()
@@ -850,7 +850,7 @@ bool SwTextFrame::UnitUp_( SwPaM *pPam, const SwTwips nOffset,
             if ( IsFollow() )
             {
                 aLine.GetCharRect( &aCharBox, nPos );
-                aCharBox.SSize().setWidth( aCharBox.SSize().Width() / 2 );
+                aCharBox.Width( aCharBox.SSize().Width() / 2 );
             }
             break;
         } while ( true );
@@ -1185,7 +1185,7 @@ bool SwTextFrame::UnitDown_(SwPaM *pPam, const SwTwips nOffset,
 
             if( pNextLine || bFirstOfDouble )
             {
-                aCharBox.SSize().setWidth( aCharBox.SSize().Width() / 2 );
+                aCharBox.Width( aCharBox.SSize().Width() / 2 );
 #if OSL_DEBUG_LEVEL > 0
                 // See comment in SwTextFrame::GetModelPositionForViewPoint()
                 const sal_uLong nOldNode = pPam->GetPoint()->nNode.GetIndex();
@@ -1230,7 +1230,7 @@ bool SwTextFrame::UnitDown_(SwPaM *pPam, const SwTwips nOffset,
                 }
 
                 aLine.GetCharRect( &aCharBox, nPos );
-                aCharBox.SSize().setWidth( aCharBox.SSize().Width() / 2 );
+                aCharBox.Width( aCharBox.SSize().Width() / 2 );
             }
             else if( !IsFollow() )
             {
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index d8bb575a7c83..c3167561a496 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -400,11 +400,11 @@ void SwTextFrame::AdjustFrame( const SwTwips nChgHght, bool bHasToFit )
 
                         if( aRectFnSet.IsVert() )
                         {
-                            aPrt.SSize().AdjustWidth(nChgHght );
+                            aPrt.AddWidth(nChgHght );
                         }
                         else
                         {
-                            aPrt.SSize().AdjustHeight(nChgHght );
+                            aPrt.AddHeight(nChgHght );
                         }
 
                         return;
diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index 78c0bc0e0020..317480500eac 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -184,7 +184,7 @@ void SwViewShellImp::SetFirstVisPage(OutputDevice const * pRenderContext)
                 if ( bBookMode && pPage->IsEmptyPage() )
                 {
                     const SwPageFrame& rFormatPage = pPage->GetFormatPage();
-                    aPageRect.SSize() = rFormatPage.GetBoundRect(pRenderContext).SSize();
+                    aPageRect.SSize( rFormatPage.GetBoundRect(pRenderContext).SSize() );
                 }
             }
         }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index cef9ecffb3e6..7b9529155a91 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1133,7 +1133,7 @@ void SwViewShell::VisPortChgd( const SwRect &rRect)
                 if ( bBookMode )
                 {
                     const SwPageFrame& rFormatPage = pPage->GetFormatPage();
-                    aPageRect.SSize() = rFormatPage.GetBoundRect(GetWin()).SSize();
+                    aPageRect.SSize( rFormatPage.GetBoundRect(GetWin()).SSize() );
                 }
 
                 // #i9719# - consider new border and shadow width
@@ -1298,12 +1298,12 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const tools::Rectangle
                 aRect.Right( std::min(aRect.Right()+2*aPixSz.Width(), pRect->Right()+aPixSz.Width()));
             }
             else
-                aRect.SSize().AdjustWidth(2*aPixSz.Width() );
+                aRect.AddWidth(2*aPixSz.Width() );
             aRect.Pos().setY( lYDiff < 0 ? aOldVis.Bottom() - aPixSz.Height()
                                          : aRect.Top() - aSize.Height() + aPixSz.Height() );
             aRect.Pos().setX( std::max( 0L, aRect.Left()-aPixSz.Width() ) );
             aRect.Pos()  = GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.Pos()));
-            aRect.SSize()= GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.SSize()));
+            aRect.SSize( GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.SSize())) );
             maVisArea = aRect;
             const Point aPt( -aRect.Left(), -aRect.Top() );
             aMapMode.SetOrigin( aPt );
@@ -1537,13 +1537,13 @@ void SwViewShell::PaintDesktop(vcl::RenderContext& rRenderContext, const SwRect
             if ( bBookMode )
             {
                 const SwPageFrame& rFormatPage = static_cast<const SwPageFrame*>(pPage)->GetFormatPage();
-                aPageRect.SSize() = rFormatPage.getFrameArea().SSize();
+                aPageRect.SSize( rFormatPage.getFrameArea().SSize() );
             }
 
             const bool bSidebarRight =
                 static_cast<const SwPageFrame*>(pPage)->SidebarPosition() == sw::sidebarwindows::SidebarPosition::RIGHT;
             aPageRect.Pos().AdjustX( -(bSidebarRight ? 0 : nSidebarWidth) );
-            aPageRect.SSize().AdjustWidth(nSidebarWidth );
+            aPageRect.AddWidth(nSidebarWidth );
 
             if ( aPageRect.IsOver( rRect ) )
                 aRegion -= aPageRect;


More information about the Libreoffice-commits mailing list