[Libreoffice-commits] core.git: 8 commits - include/svx svx/source sw/source

Matteo Casalin matteo.casalin at yahoo.com
Sun Feb 11 14:43:28 UTC 2018


 include/svx/ipolypolygoneditorcontroller.hxx |    1 
 include/svx/svdmodel.hxx                     |    8 -
 include/svx/svdmrkv.hxx                      |    6 -
 svx/source/svdraw/svddrgmt.cxx               |   65 +++++---------
 svx/source/svdraw/svdedtv1.cxx               |   71 ++++++++-------
 svx/source/svdraw/svdedxv.cxx                |    8 -
 svx/source/svdraw/svdmodel.cxx               |  122 +++++++++------------------
 svx/source/svdraw/svdmrkv.cxx                |   18 +--
 svx/source/svdraw/svdobj.cxx                 |   17 +--
 svx/source/svdraw/svdomeas.cxx               |   10 +-
 svx/source/svdraw/svdopath.cxx               |   77 +++++------------
 svx/source/svdraw/svdview.cxx                |    6 -
 sw/source/core/doc/doctxm.cxx                |    2 
 sw/source/core/tox/tox.cxx                   |   43 ++++-----
 14 files changed, 186 insertions(+), 268 deletions(-)

New commits:
commit 20a646aeda7e940340b0ab11f243c0f09887e1b3
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Jan 14 19:52:47 2018 +0100

    Pointer is always non-null ==> use reference
    
    Change-Id: I9ea6a8233a2f046d2ca56c08b3a2e922cbba2f3b

diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index c86b4c9efc50..d93174cf58af 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -733,15 +733,12 @@ OUString SwFormToken::GetString() const
    Returns the type of a token.
 
    @param sToken     the string representation of the token
-   @param pTokenLen  return parameter the length of the head of the token
-
-   If pTokenLen is non-NULL the length of the token's head is
-   written to *pTokenLen
+   @param rTokenLen  return parameter the length of the head of the token
 
    @return the type of the token
 */
 static FormTokenType lcl_GetTokenType(const OUString & sToken,
-                                      sal_Int32 *const pTokenLen)
+                                      sal_Int32 & rTokenLen)
 {
     static struct
     {
@@ -765,8 +762,7 @@ static FormTokenType lcl_GetTokenType(const OUString & sToken,
     {
         if( sToken.startsWith( i.sTokenStart ) )
         {
-            if (pTokenLen)
-                *pTokenLen = i.nTokenLength;
+            rTokenLen = i.nTokenLength;
             return i.eTokenType;
         }
     }
@@ -827,7 +823,7 @@ lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
     OUString sToken( lcl_SearchNextToken(sPattern, nCurPatternPos) );
     nCurPatternPos += sToken.getLength();
     sal_Int32 nTokenLen = 0;
-    FormTokenType const eTokenType = lcl_GetTokenType(sToken, &nTokenLen);
+    FormTokenType const eTokenType = lcl_GetTokenType(sToken, nTokenLen);
     if (TOKEN_END == eTokenType) // invalid input? skip it
     {
         nCurPatternPos = sPattern.getLength();
commit 34b98af8e5a4e568d8316700bea1ce604d825ce8
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Jan 14 19:12:30 2018 +0100

    Return correct length for Authority token
    
    Regression from f4fd558ac9d61fe06aa0f56d829916ef9e5ee7b9
    Take the chance to calculate token prefix just once.
    
    Change-Id: I19ce5cb037198cb918e79c760a92b285f9b725f1

diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index ed4716579063..c86b4c9efc50 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -745,30 +745,29 @@ static FormTokenType lcl_GetTokenType(const OUString & sToken,
 {
     static struct
     {
-        OUString sNm;
-        sal_uInt16 nOffset;
-        FormTokenType eToken;
+        OUString sTokenStart;
+        sal_Int16 nTokenLength;
+        FormTokenType eTokenType;
     } const aTokenArr[] = {
-        { SwForm::GetFormTab(),         1, TOKEN_TAB_STOP },
-        { SwForm::GetFormPageNums(),    1, TOKEN_PAGE_NUMS },
-        { SwForm::GetFormLinkStt(),     1, TOKEN_LINK_START },
-        { SwForm::GetFormLinkEnd(),     1, TOKEN_LINK_END },
-        { SwForm::GetFormEntryNum(),    1, TOKEN_ENTRY_NO },
-        { SwForm::GetFormEntryText(),    1, TOKEN_ENTRY_TEXT },
-        { SwForm::GetFormChapterMark(), 1, TOKEN_CHAPTER_INFO },
-        { SwForm::GetFormText(),        1, TOKEN_TEXT },
-        { SwForm::GetFormEntry(),       1, TOKEN_ENTRY },
-        { SwForm::GetFormAuth(),        3, TOKEN_AUTHORITY }
+        { SwForm::GetFormTab().copy(0, 2),         3, TOKEN_TAB_STOP },
+        { SwForm::GetFormPageNums().copy(0, 2),    3, TOKEN_PAGE_NUMS },
+        { SwForm::GetFormLinkStt().copy(0, 3),     4, TOKEN_LINK_START },
+        { SwForm::GetFormLinkEnd().copy(0, 3),     4, TOKEN_LINK_END },
+        { SwForm::GetFormEntryNum().copy(0, 3),    4, TOKEN_ENTRY_NO },
+        { SwForm::GetFormEntryText().copy(0, 3),   4, TOKEN_ENTRY_TEXT },
+        { SwForm::GetFormChapterMark().copy(0, 2), 3, TOKEN_CHAPTER_INFO },
+        { SwForm::GetFormText().copy(0, 2),        3, TOKEN_TEXT },
+        { SwForm::GetFormEntry().copy(0, 2),       3, TOKEN_ENTRY },
+        { SwForm::GetFormAuth().copy(0, 2),        5, TOKEN_AUTHORITY }
     };
 
     for(const auto & i : aTokenArr)
     {
-        const sal_Int32 nLen(i.sNm.getLength());
-        if( sToken.startsWith( i.sNm.copy(0, nLen - i.nOffset) ))
+        if( sToken.startsWith( i.sTokenStart ) )
         {
             if (pTokenLen)
-                *pTokenLen = nLen;
-            return i.eToken;
+                *pTokenLen = i.nTokenLength;
+            return i.eTokenType;
         }
     }
 
commit e3e9870aacdd8df1f449b802cd9dc3fbd083182f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Jan 14 17:46:55 2018 +0100

    Fix reverse check in f4fd558ac9d61fe06aa0f56d829916ef9e5ee7b9
    
    Change-Id: I90a4f30f8ec0e908a1cdf976979622be1284ec02

diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index aa2bee2db1ad..a5250bfd8463 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -639,7 +639,7 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType,
         if (rSect.GetType()==TOX_CONTENT_SECTION)
         {
             const OUString rNm = rSect.GetSectionName();
-            if ( aName.startsWith(rNm) )
+            if ( rNm.startsWith(aName) )
             {
                 // Calculate number and set the Flag
                 nNum = rNm.copy( nNmLen ).toInt32();
commit 6c2b92a78d55b56cdb576dcf5b4b3cd2fb2820e4
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Jan 12 19:12:11 2018 +0100

    Unneeded #include
    
    Change-Id: I61424026fff1256c620b29ae8b1eca259e048d5b

diff --git a/include/svx/ipolypolygoneditorcontroller.hxx b/include/svx/ipolypolygoneditorcontroller.hxx
index c7cdad9fccf8..f9df283e6404 100644
--- a/include/svx/ipolypolygoneditorcontroller.hxx
+++ b/include/svx/ipolypolygoneditorcontroller.hxx
@@ -21,7 +21,6 @@
 #define INCLUDED_SVX_IPOLYPOLYGONEDITORCONTROLLER_HXX
 
 #include <svx/svxdllapi.h>
-#include <svx/svdedtv.hxx>
 
 
 //   Defines
commit d0216f56862d2c8d35a8a174262f3e5a1dc58d45
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Jan 6 17:41:42 2018 +0100

    SdrMarkView: provide OUString as return value
    
    Change-Id: I2d45f4ada683da4f69df6d81a072d2f3ba813dae

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index 0f725547033c..981b1e29e5d1 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -79,8 +79,8 @@ enum class SdrViewEditMode {
     GluePointEdit   // Glue point editing mode
 };
 
-/** options for ImpTakeDescriptionStr() */
-enum class ImpTakeDescriptionOptions
+/** options for ImpGetDescriptionString() */
+enum class ImpGetDescriptionOptions
 {
     NONE       = 0,
     POINTS     = 1,
@@ -154,7 +154,7 @@ protected:
     SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList const * pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj) const;
     SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList const * pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj,const SdrMarkList * pMarkList) const;
     bool ImpIsFrameHandles() const;
-    void ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr, ImpTakeDescriptionOptions nOpt=ImpTakeDescriptionOptions::NONE) const;
+    OUString ImpGetDescriptionString(const char* pStrCacheID, ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE) const;
 
     // Generates a string including degrees symbol, from an angel specification in 1/100deg
     bool ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, bool bUnmark);
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 4a93aa1fd2fd..6233184ab494 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -552,13 +552,13 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag()
 
 void SdrDragMethod::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr) const
 {
-    ImpTakeDescriptionOptions nOpt=ImpTakeDescriptionOptions::NONE;
+    ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE;
     if (IsDraggingPoints()) {
-        nOpt=ImpTakeDescriptionOptions::POINTS;
+        nOpt=ImpGetDescriptionOptions::POINTS;
     } else if (IsDraggingGluePoints()) {
-        nOpt=ImpTakeDescriptionOptions::GLUEPOINTS;
+        nOpt=ImpGetDescriptionOptions::GLUEPOINTS;
     }
-    getSdrDragView().ImpTakeDescriptionStr(pStrCacheID,rStr,nOpt);
+    rStr = getSdrDragView().ImpGetDescriptionString(pStrCacheID, nOpt);
 }
 
 SdrObject* SdrDragMethod::GetDragObj() const
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index ab5389aacf13..d2469a703c67 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -83,12 +83,10 @@ void SdrEditView::SetMarkedObjRect(const tools::Rectangle& rRect)
     long y1=rRect.Top();
     long w1=rRect.Right()-x1;
     long h1=rRect.Bottom()-y1;
-    OUString aStr;
-    ImpTakeDescriptionStr(STR_EditPosSize,aStr);
 
     const bool bUndo = IsUndoEnabled();
     if( bUndo )
-        BegUndo(aStr);
+        BegUndo(ImpGetDescriptionString(STR_EditPosSize));
 
     for (size_t nm=0; nm<nCount; ++nm)
     {
@@ -211,8 +209,7 @@ void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, cons
     const bool bUndo = IsUndoEnabled();
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(STR_EditResize,aStr);
+        OUString aStr {ImpGetDescriptionString(STR_EditResize)};
         if (bCopy)
             aStr+=ImpGetResStr(STR_EditWithCopy);
         BegUndo(aStr);
@@ -247,9 +244,7 @@ void SdrEditView::ResizeMultMarkedObj(const Point& rRef,
     const bool bUndo = IsUndoEnabled();
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(STR_EditResize,aStr);
-        BegUndo(aStr);
+        BegUndo(ImpGetDescriptionString(STR_EditResize));
     }
 
     const size_t nMarkCount=GetMarkedObjectCount();
@@ -310,8 +305,7 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy)
     const bool bUndo = IsUndoEnabled();
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(STR_EditRotate,aStr);
+        OUString aStr {ImpGetDescriptionString(STR_EditRotate)};
         if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
         BegUndo(aStr);
     }
@@ -370,10 +364,14 @@ void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool b
     {
         OUString aStr;
         Point aDif(rRef2-rRef1);
-        if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr);
-        else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr);
-        else if (std::abs(aDif.X()) == std::abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr);
-        else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr);
+        if (aDif.X()==0)
+            aStr = ImpGetDescriptionString(STR_EditMirrorHori);
+        else if (aDif.Y()==0)
+            aStr = ImpGetDescriptionString(STR_EditMirrorVert);
+        else if (std::abs(aDif.X()) == std::abs(aDif.Y()))
+            aStr = ImpGetDescriptionString(STR_EditMirrorDiag);
+        else
+            aStr = ImpGetDescriptionString(STR_EditMirrorFree);
         if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
         BegUndo(aStr);
     }
@@ -464,8 +462,7 @@ void SdrEditView::ShearMarkedObj(const Point& rRef, long nAngle, bool bVShear, b
 
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(STR_EditShear,aStr);
+        OUString aStr {ImpGetDescriptionString(STR_EditShear)};
         if (bCopy)
             aStr+=ImpGetResStr(STR_EditWithCopy);
         BegUndo(aStr);
@@ -581,8 +578,7 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM
 
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr);
+        OUString aStr {ImpGetDescriptionString(bNoContortion ? STR_EditCrook : STR_EditCrookContortion)};
         if (bCopy)
             aStr+=ImpGetResStr(STR_EditWithCopy);
         BegUndo(aStr);
@@ -655,8 +651,7 @@ void SdrEditView::DistortMarkedObj(const tools::Rectangle& rRef, const XPolygon&
 
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(STR_EditDistort,aStr);
+        OUString aStr {ImpGetDescriptionString(STR_EditDistort)};
         if (bCopy)
             aStr+=ImpGetResStr(STR_EditWithCopy);
         BegUndo(aStr);
@@ -1009,9 +1004,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
     const bool bUndo = IsUndoEnabled();
     if( bUndo )
     {
-        OUString aStr;
-        ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
-        BegUndo(aStr);
+        BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
     }
 
     const size_t nMarkCount(GetMarkedObjectCount());
@@ -1190,9 +1183,9 @@ void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRe
         {
             OUString aStr;
             if (pStyleSheet!=nullptr)
-                ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr);
+                aStr = ImpGetDescriptionString(STR_EditSetStylesheet);
             else
-                ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr);
+                aStr = ImpGetDescriptionString(STR_EditDelStylesheet);
             BegUndo(aStr);
         }
 
@@ -1748,9 +1741,15 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert)
         {
             switch (eVert)
             {
-                case SdrVertAlign::Top   : ImpTakeDescriptionStr(STR_EditAlignVTop   ,aStr); break;
-                case SdrVertAlign::Bottom: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break;
-                case SdrVertAlign::Center: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break;
+                case SdrVertAlign::Top:
+                    aStr = ImpGetDescriptionString(STR_EditAlignVTop);
+                    break;
+                case SdrVertAlign::Bottom:
+                    aStr = ImpGetDescriptionString(STR_EditAlignVBottom);
+                    break;
+                case SdrVertAlign::Center:
+                    aStr = ImpGetDescriptionString(STR_EditAlignVCenter);
+                    break;
                 default: break;
             }
         }
@@ -1758,19 +1757,25 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert)
         {
             switch (eHor)
             {
-                case SdrHorAlign::Left  : ImpTakeDescriptionStr(STR_EditAlignHLeft  ,aStr); break;
-                case SdrHorAlign::Right : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break;
-                case SdrHorAlign::Center: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break;
+                case SdrHorAlign::Left:
+                    aStr = ImpGetDescriptionString(STR_EditAlignHLeft);
+                    break;
+                case SdrHorAlign::Right:
+                    aStr = ImpGetDescriptionString(STR_EditAlignHRight);
+                    break;
+                case SdrHorAlign::Center:
+                    aStr = ImpGetDescriptionString(STR_EditAlignHCenter);
+                    break;
                 default: break;
             }
         }
         else if (eHor==SdrHorAlign::Center && eVert==SdrVertAlign::Center)
         {
-            ImpTakeDescriptionStr(STR_EditAlignCenter,aStr);
+            aStr = ImpGetDescriptionString(STR_EditAlignCenter);
         }
         else
         {
-            ImpTakeDescriptionStr(STR_EditAlign,aStr);
+            aStr = ImpGetDescriptionString(STR_EditAlign);
         }
         BegUndo(aStr);
     }
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 29d54d576e4f..f239c5cb5b8b 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2096,9 +2096,7 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
 
                 if( bUndo )
                 {
-                    OUString aStr;
-                    ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
-                    BegUndo(aStr);
+                    BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
 
                     // If this is a text object also rescue the OutlinerParaObject since
@@ -2143,9 +2141,7 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
             {
                 if( IsUndoEnabled() )
                 {
-                    OUString aStr;
-                    ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
-                    BegUndo(aStr);
+                    BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get()));
                     EndUndo();
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 7e148a98c303..85ede4828fa7 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -2075,28 +2075,28 @@ const tools::Rectangle& SdrMarkView::GetMarkedObjRect() const
 }
 
 
-void SdrMarkView::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr, ImpTakeDescriptionOptions nOpt) const
+OUString SdrMarkView::ImpGetDescriptionString(const char* pStrCacheID, ImpGetDescriptionOptions nOpt) const
 {
-    rStr = ImpGetResStr(pStrCacheID);
-    sal_Int32 nPos = rStr.indexOf("%1");
+    OUString sStr = ImpGetResStr(pStrCacheID);
+    const sal_Int32 nPos = sStr.indexOf("%1");
 
     if(nPos != -1)
     {
-        if(nOpt == ImpTakeDescriptionOptions::POINTS)
+        if(nOpt == ImpGetDescriptionOptions::POINTS)
         {
-            rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedPoints());
+            sStr = sStr.replaceAt(nPos, 2, GetDescriptionOfMarkedPoints());
         }
-        else if(nOpt == ImpTakeDescriptionOptions::GLUEPOINTS)
+        else if(nOpt == ImpGetDescriptionOptions::GLUEPOINTS)
         {
-            rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedGluePoints());
+            sStr = sStr.replaceAt(nPos, 2, GetDescriptionOfMarkedGluePoints());
         }
         else
         {
-            rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedObjects());
+            sStr = sStr.replaceAt(nPos, 2, GetDescriptionOfMarkedObjects());
         }
     }
 
-    rStr = rStr.replaceFirst("%2", "0");
+    return sStr.replaceFirst("%2", "0");
 }
 
 
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index 798afa63c23c..ed9157389e8b 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -1269,14 +1269,14 @@ OUString SdrView::GetStatusText()
     if(aStr == STR_NOTHING)
     {
         if (AreObjectsMarked()) {
-            ImpTakeDescriptionStr(STR_ViewMarked,aStr);
+            aStr = ImpGetDescriptionString(STR_ViewMarked);
             if (IsGluePointEditMode()) {
                 if (HasMarkedGluePoints()) {
-                    ImpTakeDescriptionStr(STR_ViewMarked,aStr,ImpTakeDescriptionOptions::GLUEPOINTS);
+                    aStr = ImpGetDescriptionString(STR_ViewMarked, ImpGetDescriptionOptions::GLUEPOINTS);
                 }
             } else {
                 if (HasMarkedPoints()) {
-                    ImpTakeDescriptionStr(STR_ViewMarked,aStr,ImpTakeDescriptionOptions::POINTS);
+                    aStr = ImpGetDescriptionString(STR_ViewMarked, ImpGetDescriptionOptions::POINTS);
                 }
             }
         } else {
commit dbc3c4eda146fe1132fb35911a4d0656ce0e68e2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Jan 1 13:51:51 2018 +0100

    SdrModel: provide OUString as return value
    
    instead of modifying it through referenced parameter.
    Also modify related function names to Get* instead of Take*.
    
    Change-Id: Iac824562bb51d5388e6f56116fee01ba8b8909f4

diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index b30493328d24..91df6466d5be 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -352,10 +352,10 @@ public:
     // Setting both simultaneously performs a little better
     void             SetUIUnit(FieldUnit eUnit, const Fraction& rScale);
 
-    static void      TakeUnitStr(FieldUnit eUnit, OUString& rStr);
-    void             TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const;
-    static void      TakeAngleStr(long nAngle, OUString& rStr);
-    static void      TakePercentStr(const Fraction& rVal, OUString& rStr);
+    static OUString  GetUnitString(FieldUnit eUnit);
+    OUString         GetMetricString(long nVal, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const;
+    static OUString  GetAngleString(long nAngle);
+    static OUString  GetPercentString(const Fraction& rVal);
 
     // RecalcPageNums is ordinarily only called by the Page.
     bool             IsPagNumsDirty() const                     { return bPagNumsDirty; };
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 3ba7c41b8b6b..4a93aa1fd2fd 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -1482,14 +1482,12 @@ SdrDragMove::SdrDragMove(SdrDragView& rNewView)
 
 void SdrDragMove::TakeSdrDragComment(OUString& rStr) const
 {
-    OUString aStr;
-
     ImpTakeDescriptionStr(STR_DragMethMove, rStr);
-    rStr += " (x=";
-    getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr);
-    rStr += aStr + " y=";
-    getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr);
-    rStr += aStr + ")";
+    rStr += " (x="
+            + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDX())
+            + " y="
+            + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDY())
+            + ")";
 
     if(getSdrDragView().IsDragWithCopy())
     {
@@ -1753,8 +1751,6 @@ void SdrDragResize::TakeSdrDragComment(OUString& rStr) const
 
     if(bX || bY)
     {
-        OUString aStr;
-
         rStr += " (";
 
         bool bEqual(aXFact == aYFact);
@@ -1763,8 +1759,7 @@ void SdrDragResize::TakeSdrDragComment(OUString& rStr) const
             if(!bEqual)
                 rStr += "x=";
 
-            SdrModel::TakePercentStr(aXFact, aStr);
-            rStr += aStr;
+            rStr += SdrModel::GetPercentString(aXFact);
         }
 
         if(bY && !bEqual)
@@ -1772,9 +1767,7 @@ void SdrDragResize::TakeSdrDragComment(OUString& rStr) const
             if(bX)
                 rStr += " ";
 
-            rStr += "y=";
-            SdrModel::TakePercentStr(aYFact, aStr);
-            rStr += aStr;
+            rStr += "y=" + SdrModel::GetPercentString(aYFact);
         }
 
         rStr += ")";
@@ -2085,9 +2078,7 @@ void SdrDragRotate::TakeSdrDragComment(OUString& rStr) const
         nTmpAngle -= 36000;
     }
 
-    OUString aStr;
-    SdrModel::TakeAngleStr(nTmpAngle, aStr);
-    rStr += aStr + ")";
+    rStr += SdrModel::GetAngleString(nTmpAngle) + ")";
 
     if(getSdrDragView().IsDragWithCopy())
         rStr += ImpGetResStr(STR_EditWithCopy);
@@ -2228,9 +2219,7 @@ void SdrDragShear::TakeSdrDragComment(OUString& rStr) const
 
     nTmpAngle = NormAngle180(nTmpAngle);
 
-    OUString aStr;
-    SdrModel::TakeAngleStr(nTmpAngle, aStr);
-    rStr += aStr + ")";
+    rStr += SdrModel::GetAngleString(nTmpAngle) + ")";
 
     if(getSdrDragView().IsDragWithCopy())
         rStr += ImpGetResStr(STR_EditWithCopy);
@@ -2804,9 +2793,7 @@ void SdrDragCrook::TakeSdrDragComment(OUString& rStr) const
             nVal *= 2;
 
         nVal = std::abs(nVal);
-        OUString aStr;
-        SdrModel::TakeAngleStr(nVal, aStr);
-        rStr += aStr + ")";
+        rStr += SdrModel::GetAngleString(nVal) + ")";
     }
 
     if(getSdrDragView().IsDragWithCopy())
@@ -3414,13 +3401,11 @@ void SdrDragDistort::TakeSdrDragComment(OUString& rStr) const
 {
     ImpTakeDescriptionStr(STR_DragMethDistort, rStr);
 
-    OUString aStr;
-
-    rStr += " (x=";
-    getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr);
-    rStr += aStr + " y=";
-    getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr);
-    rStr += aStr + ")";
+    rStr += " (x="
+            + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDX())
+            + " y="
+            + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDY())
+            + ")";
 
     if(getSdrDragView().IsDragWithCopy())
         rStr += ImpGetResStr(STR_EditWithCopy);
@@ -3564,13 +3549,11 @@ void SdrDragCrop::TakeSdrDragComment(OUString& rStr) const
 {
     ImpTakeDescriptionStr(STR_DragMethCrop, rStr);
 
-    OUString aStr;
-
-    rStr += " (x=";
-    getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr);
-    rStr += aStr + " y=";
-    getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr);
-    rStr += aStr + ")";
+    rStr += " (x="
+            + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDX())
+            + " y="
+            + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDY())
+            + ")";
 
     if(getSdrDragView().IsDragWithCopy())
         rStr += ImpGetResStr(STR_EditWithCopy);
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 2ae0fe62856f..03330c13720c 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1005,7 +1005,7 @@ void SdrModel::ImpSetUIUnit()
 
     // end preparations, set member values
     aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
-    TakeUnitStr(eUIUnit, aUIUnitStr);
+    aUIUnitStr = GetUnitString(eUIUnit);
 }
 
 void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
@@ -1072,81 +1072,42 @@ void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale)
     }
 }
 
-void SdrModel::TakeUnitStr(FieldUnit eUnit, OUString& rStr)
+OUString SdrModel::GetUnitString(FieldUnit eUnit)
 {
     switch(eUnit)
     {
         default:
         case FUNIT_NONE   :
         case FUNIT_CUSTOM :
-        {
-            rStr.clear();
-            break;
-        }
+            return OUString();
         case FUNIT_100TH_MM:
-        {
-            rStr = "/100mm";
-            break;
-        }
+            return OUString{"/100mm"};
         case FUNIT_MM     :
-        {
-            rStr = "mm";
-            break;
-        }
+            return OUString{"mm"};
         case FUNIT_CM     :
-        {
-            rStr = "cm";
-            break;
-        }
+            return OUString{"cm"};
         case FUNIT_M      :
-        {
-            rStr = "m";
-            break;
-        }
+            return OUString{"m"};
         case FUNIT_KM     :
-        {
-            rStr ="km";
-            break;
-        }
+            return OUString{"km"};
         case FUNIT_TWIP   :
-        {
-            rStr = "twip";
-            break;
-        }
+            return OUString{"twip"};
         case FUNIT_POINT  :
-        {
-            rStr = "pt";
-            break;
-        }
+            return OUString{"pt"};
         case FUNIT_PICA   :
-        {
-            rStr = "pica";
-            break;
-        }
+            return OUString{"pica"};
         case FUNIT_INCH   :
-        {
-            rStr = "\"";
-            break;
-        }
+            return OUString{"\""};
         case FUNIT_FOOT   :
-        {
-            rStr = "ft";
-            break;
-        }
+            return OUString{"ft"};
         case FUNIT_MILE   :
-        {
-            rStr = "mile(s)";
-            break;
-        }
+            return OUString{"mile(s)"};
         case FUNIT_PERCENT:
-        {
-            rStr = "%";
-            break;
-        }
+            return OUString{"%"};
     }
 }
 
-void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_Int32 nNumDigits) const
+OUString SdrModel::GetMetricString(long nVal, bool bNoUnitChars, sal_Int32 nNumDigits) const
 {
     // #i22167#
     // change to double precision usage to not lose decimal places
@@ -1265,10 +1226,10 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
     if(!bNoUnitChars)
         aBuf.append(aUIUnitStr);
 
-    rStr = aBuf.makeStringAndClear();
+    return aBuf.makeStringAndClear();
 }
 
-void SdrModel::TakeAngleStr(long nAngle, OUString& rStr)
+OUString SdrModel::GetAngleString(long nAngle)
 {
     bool bNeg = nAngle < 0;
 
@@ -1295,10 +1256,10 @@ void SdrModel::TakeAngleStr(long nAngle, OUString& rStr)
 
     aBuf.append(DEGREE_CHAR);
 
-    rStr = aBuf.makeStringAndClear();
+    return aBuf.makeStringAndClear();
 }
 
-void SdrModel::TakePercentStr(const Fraction& rVal, OUString& rStr)
+OUString SdrModel::GetPercentString(const Fraction& rVal)
 {
     sal_Int32 nMul(rVal.GetNumerator());
     sal_Int32 nDiv(rVal.GetDenominator());
@@ -1321,7 +1282,7 @@ void SdrModel::TakePercentStr(const Fraction& rVal, OUString& rStr)
     if (bNeg)
         nPct = -nPct;
 
-    rStr = OUString::number(nPct) + "%";
+    return OUString::number(nPct) + "%";
 }
 
 void SdrModel::SetChanged(bool bFlg)
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 32a73f6a5fe6..2f36f79853fa 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1042,20 +1042,17 @@ void SdrObject::ImpForcePlusData()
 
 OUString SdrObject::GetAngleStr(long nAngle) const
 {
-    OUString aStr;
-    if (pModel!=nullptr) {
-        SdrModel::TakeAngleStr(nAngle,aStr);
-    }
-    return aStr;
+    if (pModel!=nullptr)
+        return SdrModel::GetAngleString(nAngle);
+
+    return OUString();
 }
 
 OUString SdrObject::GetMetrStr(long nVal) const
 {
-    OUString aStr;
-    if (pModel!=nullptr) {
-        pModel->TakeMetricStr(nVal,aStr);
-    }
-    return aStr;
+    if (pModel!=nullptr)
+        return pModel->GetMetricString(nVal);
+    return OUString();
 }
 
 basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 78b77fc5509b..fa6cc17cac2f 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -121,14 +121,14 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind
                     nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
                 }
 
-                OUString aTmp;
-                pModel->TakeMetricStr(nLen, aTmp, true, nNumDigits);
-                aStr = aTmp;
-
                 if(!aFact.IsValid())
                 {
                     aStr = "?";
                 }
+                else
+                {
+                    aStr = pModel->GetMetricString(nLen, true, nNumDigits);
+                }
 
                 SvtSysLocale aSysLocale;
                 const LocaleDataWrapper& rLocaleDataWrapper = aSysLocale.GetLocaleData();
@@ -175,7 +175,7 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind
                         eMeasureUnit = eModUIUnit;
 
                     if(bShowUnit)
-                        SdrModel::TakeUnitStr(eMeasureUnit, aStr);
+                        aStr = SdrModel::GetUnitString(eMeasureUnit);
                 }
             }
 
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index b71e20f92a94..b883abdf1d00 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -937,36 +937,26 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
         aNow -= aPrev;
         aStr += " (";
 
-        OUString aMetr;
-
         if(pU->bCircle)
         {
-            SdrModel::TakeAngleStr(std::abs(pU->nCircRelAngle), aMetr);
-            aStr += aMetr;
-            aStr += " r=";
-            mrSdrPathObject.GetModel()->TakeMetricStr(pU->nCircRadius, aMetr, true);
-            aStr += aMetr;
+            aStr += SdrModel::GetAngleString(std::abs(pU->nCircRelAngle))
+                    + " r="
+                    + mrSdrPathObject.GetModel()->GetMetricString(pU->nCircRadius, true);
         }
 
-        aStr += "dx=";
-        mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X(), aMetr, true);
-        aStr += aMetr;
-
-        aStr += " dy=";
-        mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y(), aMetr, true);
-        aStr += aMetr;
+        aStr += "dx="
+                + mrSdrPathObject.GetModel()->GetMetricString(aNow.X(), true)
+                + " dy="
+                + mrSdrPathObject.GetModel()->GetMetricString(aNow.Y(), true);
 
         if(!IsFreeHand(meObjectKind))
         {
             sal_Int32 nLen(GetLen(aNow));
-            aStr += "  l=";
-            mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, true);
-            aStr += aMetr;
-
             sal_Int32 nAngle(GetAngle(aNow));
-            aStr += " ";
-            SdrModel::TakeAngleStr(nAngle, aMetr);
-            aStr += aMetr;
+            aStr += "  l="
+                    + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+                    + " "
+                    + SdrModel::GetAngleString(nAngle);
         }
 
         aStr += ")";
@@ -1016,18 +1006,14 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
         // dx=0.00 dy=0.00                -- both sides bezier
         // dx=0.00 dy=0.00  l=0.00 0.00\302\260  -- one bezier/lever on one side, a start, or an ending
         // dx=0.00 dy=0.00  l=0.00 0.00\302\260 / l=0.00 0.00\302\260 -- in between
-        OUString aMetr;
         Point aBeg(rDrag.GetStart());
         Point aNow(rDrag.GetNow());
 
         aStr.clear();
-        aStr += "dx=";
-        mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X() - aBeg.X(), aMetr, true);
-        aStr += aMetr;
-
-        aStr += " dy=";
-        mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y() - aBeg.Y(), aMetr, true);
-        aStr += aMetr;
+        aStr += "dx="
+                + mrSdrPathObject.GetModel()->GetMetricString(aNow.X() - aBeg.X(), true)
+                + " dy="
+                + mrSdrPathObject.GetModel()->GetMetricString(aNow.Y() - aBeg.Y(), true);
 
         if(!pDragData->IsMultiPointDrag())
         {
@@ -1052,14 +1038,11 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
                 aNow -= rXPoly[nRef];
 
                 sal_Int32 nLen(GetLen(aNow));
-                aStr += "  l=";
-                mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, true);
-                aStr += aMetr;
-
                 sal_Int32 nAngle(GetAngle(aNow));
-                aStr += " ";
-                SdrModel::TakeAngleStr(nAngle, aMetr);
-                aStr += aMetr;
+                aStr += "  l="
+                        + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+                        + " "
+                        + SdrModel::GetAngleString(nAngle);
             }
             else if(nPointCount > 1)
             {
@@ -1098,14 +1081,11 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
                     aPt -= rXPoly[nPt1];
 
                     sal_Int32 nLen(GetLen(aPt));
-                    aStr += "  l=";
-                    mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, true);
-                    aStr += aMetr;
-
                     sal_Int32 nAngle(GetAngle(aPt));
-                    aStr += " ";
-                    SdrModel::TakeAngleStr(nAngle, aMetr);
-                    aStr += aMetr;
+                    aStr += "  l="
+                            + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+                            + " "
+                            + SdrModel::GetAngleString(nAngle);
                 }
 
                 if(bPt2)
@@ -1119,14 +1099,11 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
                     aPt -= rXPoly[nPt2];
 
                     sal_Int32 nLen(GetLen(aPt));
-                    aStr += "l=";
-                    mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, true);
-                    aStr += aMetr;
-
                     sal_Int32 nAngle(GetAngle(aPt));
-                    aStr += " ";
-                    SdrModel::TakeAngleStr(nAngle, aMetr);
-                    aStr += aMetr;
+                    aStr += "l="
+                            + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+                            + " "
+                            + SdrModel::GetAngleString(nAngle);
                 }
             }
         }
commit 5cc52ae22c94c734add5e0654e7ce1dbeebebe3e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Dec 29 10:38:01 2017 +0100

    Simplify SdrModel::TakeMetricStr truncation for trailing 0s
    
    Change-Id: If2f3bceaada841f7a085e7c97786ef7234c85c61

diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 6e878d5ee372..2ae0fe62856f 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1212,7 +1212,7 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
             aBuf.insert(0, '0');
     }
 
-    sal_Unicode cDec( rLoc.getNumDecimalSep()[0] );
+    const sal_Unicode cDec( rLoc.getNumDecimalSep()[0] );
 
     // insert the decimal mark character
     sal_Int32 nBeforeDecimalMark = aBuf.getLength() - nDecimalMark;
@@ -1222,13 +1222,19 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
 
     if(!LocaleDataWrapper::isNumTrailingZeros())
     {
+        sal_Int32 aPos=aBuf.getLength()-1;
+
         // Remove all trailing zeros.
-        while (!aBuf.isEmpty() && aBuf[aBuf.getLength()-1] == '0')
-            aBuf.remove(aBuf.getLength()-1, 1);
+        while (aPos>=0 && aBuf[aPos]=='0')
+            --aPos;
 
         // Remove decimal if it's the last character.
-        if (!aBuf.isEmpty() && aBuf[aBuf.getLength()-1] == cDec)
-            aBuf.remove(aBuf.getLength()-1, 1);
+        if (aPos>=0 && aBuf[aPos]==cDec)
+            --aPos;
+
+        // Adjust aPos to index first char to be truncated, if any
+        if (++aPos<aBuf.getLength())
+            aBuf.truncate(aPos);
     }
 
     // if necessary, add separators before every third digit
commit 9f74b6fee1082caf96d78c731c77e10a67c3bc41
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Thu Dec 28 23:34:28 2017 +0100

    Simplify SdrModel::TakePercentStr
    
    * Group checks on sign
    * Let OUString::number print the sign
    
    Change-Id: I1ae22141f813eb4ff5b527423354e195485f8037

diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 2e09b6c18814..6e878d5ee372 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1296,27 +1296,26 @@ void SdrModel::TakePercentStr(const Fraction& rVal, OUString& rStr)
 {
     sal_Int32 nMul(rVal.GetNumerator());
     sal_Int32 nDiv(rVal.GetDenominator());
-    bool bNeg(nMul < 0);
+    bool bNeg {false};
 
-    if(nDiv < 0)
+    if (nDiv < 0)
+    {
         bNeg = !bNeg;
-
-    if(nMul < 0)
-        nMul = -nMul;
-
-    if(nDiv < 0)
         nDiv = -nDiv;
+    }
 
-    nMul *= 100;
-    nMul += nDiv/2;
-    nMul /= nDiv;
+    if (nMul < 0)
+    {
+        bNeg = !bNeg;
+        nMul = -nMul;
+    }
 
-    rStr = OUString::number(nMul);
+    sal_Int32 nPct = ((nMul*100) + nDiv/2)/nDiv;
 
-    if(bNeg)
-        rStr = "-" + rStr;
+    if (bNeg)
+        nPct = -nPct;
 
-    rStr += "%";
+    rStr = OUString::number(nPct) + "%";
 }
 
 void SdrModel::SetChanged(bool bFlg)


More information about the Libreoffice-commits mailing list