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

Noel Grandin noel.grandin at collabora.co.uk
Tue Feb 27 09:25:26 UTC 2018


 basegfx/source/polygon/b2dpolygontriangulator.cxx |   18 ++++--------------
 sw/inc/swrect.hxx                                 |    4 ++--
 sw/source/core/frmedt/fetab.cxx                   |    8 ++++----
 sw/source/core/inc/flyfrms.hxx                    |    2 +-
 sw/source/core/layout/paintfrm.cxx                |   18 +++++++++++-------
 sw/source/core/text/inftxt.hxx                    |    4 ++--
 sw/source/core/unocore/unoframe.cxx               |    3 ++-
 sw/source/core/view/pagepreviewlayout.cxx         |    6 ++++--
 sw/source/core/view/vdraw.cxx                     |    3 ++-
 sw/source/core/view/vprint.cxx                    |    5 ++++-
 sw/source/filter/xml/xmltexti.cxx                 |   19 ++++++++++---------
 sw/source/ui/frmdlg/column.cxx                    |    3 ++-
 sw/source/uibase/config/viewopt.cxx               |   11 +++++++++--
 sw/source/uibase/uiview/viewport.cxx              |    9 +++------
 sw/source/uibase/uiview/viewtab.cxx               |   10 ++++++++--
 sw/source/uibase/wrtsh/wrtsh1.cxx                 |    3 ++-
 16 files changed, 70 insertions(+), 56 deletions(-)

New commits:
commit b7e08c594066e626a92a460931d93b7f64c16df6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 26 14:45:17 2018 +0200

    loplugin:useuniqueptr in Triangulator
    
    Change-Id: If963704ec8af82ed2af1418621ef7fc5e475567f
    Reviewed-on: https://gerrit.libreoffice.org/50364
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx
index a2c740f91798..ab97419144d4 100644
--- a/basegfx/source/polygon/b2dpolygontriangulator.cxx
+++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx
@@ -104,13 +104,12 @@ namespace basegfx
         };
 
         typedef std::vector< EdgeEntry > EdgeEntries;
-        typedef std::vector< EdgeEntry* > EdgeEntryPointers;
 
         class Triangulator
         {
             EdgeEntry*                                      mpList;
             EdgeEntries                                     maStartEntries;
-            EdgeEntryPointers                               maNewEdgeEntries;
+            std::vector< std::unique_ptr<EdgeEntry> >       maNewEdgeEntries;
             B2DPolygon                                      maResult;
 
             void handleClosingEdge(const B2DPoint& rStart, const B2DPoint& rEnd);
@@ -119,7 +118,6 @@ namespace basegfx
 
         public:
             explicit Triangulator(const B2DPolyPolygon& rCandidate);
-            ~Triangulator();
 
             const B2DPolygon& getResult() const { return maResult; }
         };
@@ -155,7 +153,7 @@ namespace basegfx
             {
                 // insert closing edge
                 EdgeEntry* pNew = new EdgeEntry(aNew);
-                maNewEdgeEntries.push_back(pNew);
+                maNewEdgeEntries.emplace_back(pNew);
                 pCurr = mpList;
                 pPrev = nullptr;
 
@@ -189,8 +187,8 @@ namespace basegfx
                     // found point in triangle -> split triangle inserting two edges
                     EdgeEntry* pStart = new EdgeEntry(pEdgeA->getStart(), rTestPoint);
                     EdgeEntry* pEnd = new EdgeEntry(*pStart);
-                    maNewEdgeEntries.push_back(pStart);
-                    maNewEdgeEntries.push_back(pEnd);
+                    maNewEdgeEntries.emplace_back(pStart);
+                    maNewEdgeEntries.emplace_back(pEnd);
 
                     pStart->setNext(pEnd);
                     pEnd->setNext(pEdgeA->getNext());
@@ -365,14 +363,6 @@ namespace basegfx
             }
         }
 
-        Triangulator::~Triangulator()
-        {
-            for (auto const& newEdgeEntry : maNewEdgeEntries)
-            {
-                delete newEdgeEntry;
-            }
-        }
-
     } // end of anonymous namespace
 } // end of namespace basegfx
 
commit 68e6706fb931ed2f53c08bc9c0a02cbb559c8c53
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 26 13:28:01 2018 +0200

    drop old tools/gen.hxx methods in sw
    
    Change-Id: I1db8954b86e9b2ec27ecc1f65e8ff7715612d756
    Reviewed-on: https://gerrit.libreoffice.org/50363
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/swrect.hxx b/sw/inc/swrect.hxx
index 924e4adc2ebd..c4b1889ae4ae 100644
--- a/sw/inc/swrect.hxx
+++ b/sw/inc/swrect.hxx
@@ -191,7 +191,7 @@ inline void SwRect::Height( long nNew )
 }
 inline void SwRect::Left( const long nLeft )
 {
-    m_Size.Width() += m_Point.getX() - nLeft;
+    m_Size.AdjustWidth( m_Point.getX() - nLeft );
     m_Point.setX(nLeft);
 }
 inline void SwRect::Right( const long nRight )
@@ -200,7 +200,7 @@ inline void SwRect::Right( const long nRight )
 }
 inline void SwRect::Top( const long nTop )
 {
-    m_Size.Height() += m_Point.getY() - nTop;
+    m_Size.AdjustHeight( m_Point.getY() - nTop );
     m_Point.setY(nTop);
 }
 inline void SwRect::Bottom( const long nBottom )
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index bf312fe6a642..e0595f05fe17 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -1455,8 +1455,8 @@ static const SwCellFrame *lcl_FindFrame( const SwLayoutFrame *pLay, const Point
                                           aRectFnSet.GetLeft(aTabRect);
                     const SwTwips nTop  = aRectFnSet.GetTop(aTabRect);
 
-                    SwTwips& rPointX = aRectFnSet.IsVert() ? aPt.Y() : aPt.X();
-                    SwTwips& rPointY = aRectFnSet.IsVert() ? aPt.X() : aPt.Y();
+                    SwTwips const rPointX = aRectFnSet.IsVert() ? aPt.Y() : aPt.X();
+                    SwTwips const rPointY = aRectFnSet.IsVert() ? aPt.X() : aPt.Y();
 
                     const SwTwips nXDiff = aRectFnSet.XDiff( nLeft, rPointX ) * ( bRTL ? -1 : 1 );
                     const SwTwips nYDiff = aRectFnSet.YDiff( nTop, rPointY );
@@ -1485,9 +1485,9 @@ static const SwCellFrame *lcl_FindFrame( const SwLayoutFrame *pLay, const Point
                     if ( bCloseToRow && bCloseToCol )
                         aPt = bRTL ? aTabRect.TopRight() : aRectFnSet.GetPos(aTabRect);
                     else if ( bCloseToRow )
-                        rPointX = nLeft;
+                        aRectFnSet.IsVert() ? aPt.setY(nLeft) : aPt.setX(nLeft);
                     else if ( bCloseToCol )
-                        rPointY = nTop;
+                        aRectFnSet.IsVert() ? aPt.setX(nTop) : aPt.setY(nTop);
 
                     if ( !bCloseToRow && !bCloseToCol )
                         bSearchForFrameInTab = false;
diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx
index c0fafd733efc..e59a7fe332b1 100644
--- a/sw/source/core/inc/flyfrms.hxx
+++ b/sw/source/core/inc/flyfrms.hxx
@@ -228,7 +228,7 @@ public:
     void RegistFlys();
 
     //see layact.cxx
-    void AddRefOfst( long nOfst ) { aRef.Y() += nOfst; }
+    void AddRefOfst( long nOfst ) { aRef.AdjustY( nOfst ); }
 
     // #i26791#
     virtual void MakeObjPos() override;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index e79c37e4564e..bc9b35e7be7b 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -6439,10 +6439,14 @@ static void lcl_RefreshLine( const SwLayoutFrame *pLay,
     const bool bHori = rP1.Y() == rP2.Y();
 
     // use pointers to member function in order to unify flow
-    typedef long& (Point:: *pmfPt)();
-    const pmfPt pmfPtX = &Point::X;
-    const pmfPt pmfPtY = &Point::Y;
-    const pmfPt pDirPt = bHori ? pmfPtX : pmfPtY;
+    typedef long (Point:: *pmfPtGet)() const;
+    typedef void (Point:: *pmfPtSet)(long);
+    const pmfPtGet pDirPtX = &Point::X;
+    const pmfPtGet pDirPtY = &Point::Y;
+    const pmfPtGet pDirPt = bHori ? pDirPtX : pDirPtY;
+    const pmfPtSet pDirPtSetX = &Point::setX;
+    const pmfPtSet pDirPtSetY = &Point::setY;
+    const pmfPtSet pDirPtSet = bHori ? pDirPtSetX : pDirPtSetY;
 
     Point aP1( rP1 );
     Point aP2( rP2 );
@@ -6511,10 +6515,10 @@ static void lcl_RefreshLine( const SwLayoutFrame *pLay,
                 const long nDrDirSz = bHori ? aDrSz.Width() : aDrSz.Height();
 
                 if ( (aP1.*pDirPt)() >= nDrDirPt && (aP1.*pDirPt)() <= nDrDirPt + nDrDirSz )
-                    (aP1.*pDirPt)() = nDrDirPt + nDrDirSz;
+                    (aP1.*pDirPtSet)( nDrDirPt + nDrDirSz );
 
                 if ( (aP2.*pDirPt)() >= nDrDirPt && (aP1.*pDirPt)() < (nDrDirPt - 1) )
-                    (aP2.*pDirPt)() = nDrDirPt - 1;
+                    (aP2.*pDirPtSet)( nDrDirPt - 1 );
             }
             aIter.Next();
         }
@@ -6528,7 +6532,7 @@ static void lcl_RefreshLine( const SwLayoutFrame *pLay,
                     nullptr, nSubColor, gProp );
         }
         aP1 = aP2;
-        (aP1.*pDirPt)() += 1;
+        (aP1.*pDirPtSet)( (aP1.*pDirPt)() + 1 );
         aP2 = rP2;
     }
 }
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index 78a896f9f231..91f7ef655fb0 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -391,9 +391,9 @@ public:
     SwTextPaintInfo( SwTextFrame *pFrame, const SwRect &rPaint );
 
     SwTwips X() const { return aPos.X(); }
-    void X( const long nNew ) { aPos.X() = nNew; }
+    void X( const long nNew ) { aPos.setX(nNew); }
     SwTwips Y() const { return aPos.Y(); }
-    void Y( const SwTwips nNew ) { aPos.Y() = nNew; }
+    void Y( const SwTwips nNew ) { aPos.setY(nNew); }
 
     SwTextFly& GetTextFly() { return aTextFly; }
     const SwTextFly& GetTextFly() const { return aTextFly; }
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index cb59f4ddae79..f93ed469dd21 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2908,7 +2908,8 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
                     Size aSz( aSize.Width, aSize.Height );
                     if ( !aSz.Width() || !aSz.Height() )
                     {
-                        aSz.Width() = aSz.Height() = 5000;
+                        aSz.setWidth(5000);
+                        aSz.setHeight(5000);
                         aSz = OutputDevice::LogicToLogic(aSz,
                                 MapMode(MapUnit::Map100thMM), MapMode(aRefMap));
                     }
diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx
index edcc554a5d24..f7fdcc0efae4 100644
--- a/sw/source/core/view/pagepreviewlayout.cxx
+++ b/sw/source/core/view/pagepreviewlayout.cxx
@@ -97,8 +97,10 @@ void SwPagePreviewLayout::ClearPreviewLayoutSizes()
 
     maMaxPageSize.setWidth( 0 );
     maMaxPageSize.setHeight( 0 );
-    maPreviewDocRect.Left() = maPreviewDocRect.Top() = 0;
-    maPreviewDocRect.Right() = maPreviewDocRect.Bottom() = 0;
+    maPreviewDocRect.SetLeft( 0 );
+    maPreviewDocRect.SetTop( 0 );
+    maPreviewDocRect.SetRight( 0 );
+    maPreviewDocRect.SetBottom( 0 );
     mnColWidth = mnRowHeight = 0;
     mnPreviewLayoutWidth = mnPreviewLayoutHeight = 0;
 }
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index 0af8f1f0dc55..fabae25e722c 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -264,7 +264,8 @@ void SwViewShellImp::NotifySizeChg( const Size &rNewSz )
                     pObj->Move( aSz );
 
                 // Don't let large objects disappear to the top
-                aSz.Width() = aSz.Height() = 0;
+                aSz.setWidth(0);
+                aSz.setHeight(0);
                 if ( aObjBound.Right() < aDocRect.Left() )
                     aSz.setWidth( (aDocRect.Left() - aObjBound.Right()) + MINFLY );
                 if ( aObjBound.Bottom() < aDocRect.Top() )
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index d7884a6f190c..4683d9ad984d 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -210,7 +210,10 @@ void SwViewShell::InitPrt( OutputDevice *pOutDev )
         pOutDev->SetFillColor();
     }
     else
-        maPrtOffset.X() = maPrtOffset.Y() = 0;
+    {
+        maPrtOffset.setX(0);
+        maPrtOffset.setY(0);
+    }
 
     if ( !mpWin )
         mpOut = pOutDev;
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index 0986e089a6ae..cf4f328c47b3 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -94,7 +94,7 @@ const XMLServiceMapEntry_Impl aServiceMap[] =
 };
 static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet,
         sal_Int32 nHeight, sal_Int32 nWidth,
-        long *pTwipHeight=nullptr, long *pTwipWidth=nullptr )
+        Size *pTwipSize = nullptr )
 {
     if( nWidth > 0 && nHeight > 0 )
     {
@@ -110,10 +110,11 @@ static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet,
     SwFormatAnchor aAnchor( RndStdIds::FLY_AT_CHAR );
     rItemSet.Put( aAnchor );
 
-    if( pTwipWidth )
-        *pTwipWidth = nWidth;
-    if( pTwipHeight )
-        *pTwipHeight = nHeight;
+    if( pTwipSize )
+    {
+        pTwipSize->setWidth( nWidth );
+        pTwipSize->setHeight( nHeight);
+    }
 }
 
 static void lcl_setObjectVisualArea( const uno::Reference< embed::XEmbeddedObject >& xObj,
@@ -238,7 +239,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
     Size aTwipSize( 0, 0 );
     tools::Rectangle aVisArea( 0, 0, nWidth, nHeight );
     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
-                           &aTwipSize.Height(), &aTwipSize.Width() );
+                           &aTwipSize );
 
     SwFrameFormat *pFrameFormat = nullptr;
     SwOLENode *pOLENd = nullptr;
@@ -550,7 +551,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
                          RES_FRMATR_END>{} );
     Size aTwipSize( 0, 0 );
     lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
-                           &aTwipSize.Height(), &aTwipSize.Width() );
+                           &aTwipSize );
 
     // We'll need a (valid) URL. If we don't have do not insert the link and return early.
     // Copy URL into URL object on the way.
@@ -810,14 +811,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
                         {
                             sal_Int32 nVal = SIZE_NOT_SET;
                             rProp.maValue >>= nVal;
-                            aMargin.Width() = nVal;
+                            aMargin.setWidth( nVal );
                         }
                         break;
                     case CTF_FRAME_MARGIN_VERT:
                         {
                             sal_Int32 nVal = SIZE_NOT_SET;
                             rProp.maValue >>= nVal;
-                            aMargin.Height() = nVal;
+                            aMargin.setHeight( nVal );
                         }
                         break;
                     }
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index 528570fd4699..15fe828b5692 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -1417,7 +1417,8 @@ void ColumnValueSet::UserDraw(const UserDrawEvent& rUDEvt)
         Point aEnd(aBLPos.X() + nEnds[j], 0);
         for( sal_uInt16 i = 0; i < 12; i ++)
         {
-            aStart.Y() = aEnd.Y() = aBLPos.Y() + nTop + i * nStep;
+            aStart.setY( aBLPos.Y() + nTop + i * nStep);
+            aEnd.setY( aStart.Y() );
             pDev->DrawLine(aStart, aEnd);
         }
     }
diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx
index d291dc76ce50..90eb12c95c95 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -195,9 +195,16 @@ SwViewOption::SwViewOption() :
         ViewOptFlags2::AnyRuler;
 
     if (!utl::ConfigManager::IsFuzzing() && MeasurementSystem::Metric != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
-        m_aSnapSize.Width() = m_aSnapSize.Height() = 720;   // 1/2"
+    {
+        m_aSnapSize.setWidth(720);   // 1/2"
+        m_aSnapSize.setHeight(720);   // 1/2"
+
+    }
     else
-        m_aSnapSize.Width() = m_aSnapSize.Height() = 567;   // 1 cm
+    {
+        m_aSnapSize.setWidth(567);   // 1 cm
+        m_aSnapSize.setHeight(567);   // 1 cm
+    }
     m_nDivisionX = m_nDivisionY = 1;
 
     m_bSelectionInReadonly = !utl::ConfigManager::IsFuzzing() && SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index c1ce4ffe4d1a..dba6610de692 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -101,12 +101,9 @@ static void lcl_GetPos(SwView const * pView,
     if ( !bHori && nTmp > lSize )
         lDelta -= nTmp - lSize;
 
-    // use a reference to access/modify the correct coordinate
-    // returned by accessors to non-const object
-    long & rCoord = bHori ? rPos.X() : rPos.Y();
-    rCoord += lDelta;
-    if ( bBorder && rCoord < DOCUMENTBORDER )
-        rCoord = DOCUMENTBORDER;
+    bHori ? rPos.AdjustX(lDelta) : rPos.AdjustY(lDelta);
+    if ( bBorder && (bHori ? rPos.X() : rPos.Y()) < DOCUMENTBORDER )
+        bHori ? rPos.setX(DOCUMENTBORDER) : rPos.setY(DOCUMENTBORDER);
 }
 
 // Set zero ruler
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index 4fad05c26eda..4dab2bb0a4bf 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -2067,7 +2067,10 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                         aRectangle.AdjustLeft(aRect.Left() );
                     }
                     if(pFormat) // Range in frame - here you may up to the edge
-                        aRectangle.Left()  = aRectangle.Right() = 0;
+                    {
+                        aRectangle.SetLeft(0);
+                        aRectangle.SetRight(0);
+                    }
                     else
                     {
                         // Move the rectangle to the correct absolute position.
@@ -2210,7 +2213,10 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                 aRectangle.SetRight( aPageLRSpace.GetRight() );
             }
             else
-                aRectangle.Left()  = aRectangle.Right() = 0;
+            {
+                aRectangle.SetLeft(0);
+                aRectangle.SetRight(0);
+            }
 
             SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
             rSet.Put(aLR);
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 697adae10c90..1bb5fedd7588 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -282,7 +282,8 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
         Size aSz( pFrameMgr->GetSize() );
         if ( !aSz.Width() || !aSz.Height() )
         {
-            aSz.Width() = aSz.Height() = 567;
+            aSz.setWidth(567);
+            aSz.setHeight( 567);
             pFrameMgr->SetSize( aSz );
         }
         else if ( aSz.Width() != DFLT_WIDTH && aSz.Height() != DFLT_HEIGHT )


More information about the Libreoffice-commits mailing list