[Libreoffice-commits] core.git: 23 commits - cui/source editeng/source sd/source starmath/source sw/source

Matteo Casalin matteo.casalin at yahoo.com
Mon Sep 14 13:41:47 PDT 2015


 cui/source/options/optpath.cxx            |  106 +++++++++++++++++-------------
 cui/source/tabpages/macroass.cxx          |    2 
 editeng/source/editeng/editdbg.cxx        |    7 -
 sd/source/filter/ppt/pptin.cxx            |   20 +++--
 starmath/source/view.cxx                  |   55 +++++++--------
 sw/source/ui/dbui/mmoutputtypepage.cxx    |   15 +---
 sw/source/uibase/dbui/mailmergehelper.cxx |   21 ++---
 7 files changed, 117 insertions(+), 109 deletions(-)

New commits:
commit 8be829eebf92f5af32e370e8c00b9b1e28ff95c7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Sep 14 22:34:35 2015 +0200

    sal_uInt16 to sal_Int32
    
    Change-Id: I7010e7daefd1710c41b526c085c892ac13f54cd0

diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx
index a4cbb28..5e65479 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -349,8 +349,7 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
 
         fprintf( fp, "\nCharacter attribute:" );
         bool bZeroAttr = false;
-        sal_uInt16 z;
-        for ( z = 0; z < pPPortion->GetNode()->GetCharAttribs().Count(); z++ )
+        for ( sal_Int32 z = 0; z < pPPortion->GetNode()->GetCharAttribs().Count(); ++z )
         {
             const EditCharAttrib& rAttr = pPPortion->GetNode()->GetCharAttribs().GetAttribs()[z];
             OStringBuffer aCharAttribs;
@@ -372,7 +371,7 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
         if ( bZeroAttr )
             fprintf( fp, "\nNULL-Attribute!" );
 
-        sal_uInt16 nTextPortions = pPPortion->GetTextPortions().Count();
+        const sal_Int32 nTextPortions = pPPortion->GetTextPortions().Count();
         OStringBuffer aPortionStr("\nText portions: #");
         aPortionStr.append(static_cast<sal_Int32>(nTextPortions));
         aPortionStr.append(" \nA");
@@ -383,7 +382,7 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
         aPortionStr.append(static_cast<sal_Int32>(nPortion));
         aPortionStr.append(": ");
         sal_Int32 n = 0;
-        for ( z = 0; z < nTextPortions; z++ )
+        for ( sal_Int32 z = 0; z < nTextPortions; ++z )
         {
             TextPortion& rPortion = pPPortion->GetTextPortions()[z];
             aPortionStr.append(' ');
commit 552e68a15a41e01b2e9f5ef75b32f5acdf7b41ce
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:58:24 2015 +0200

    Avoid getTokenCount in SmViewShell::DrawText
    
    Change-Id: I1a4ee666900c3c412777ea2e8c01a4f38dc58b3a

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 803c30a..a84ea4f 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1081,13 +1081,16 @@ void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, co
 
 void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const OUString& rText, sal_uInt16 MaxWidth)
 {
-    sal_uInt16 nLines = comphelper::string::getTokenCount(rText, '\n');
+    if (rText.isEmpty())
+        return;
+
     Point aPoint(rPosition);
     Size aSize;
 
-    for (sal_uInt16 i = 0; i < nLines; i++)
+    sal_Int32 nPos = 0;
+    do
     {
-        OUString aLine = rText.getToken(i, '\n');
+        OUString aLine = rText.getToken(0, '\n', nPos);
         aLine = comphelper::string::remove(aLine, '\r');
         aSize = GetTextLineSize(rDevice, aLine);
         if (aSize.Width() > MaxWidth)
@@ -1135,6 +1138,7 @@ void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const
             aPoint.Y() += aSize.Height();
         }
     }
+    while ( nPos >= 0 );
 }
 
 void SmViewShell::Impl_Print(OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, Rectangle aOutRect, Point aZeroPoint )
commit 809a4ef445ef0290a4d05babac2f585d1e6ed56f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:54:17 2015 +0200

    Avoid getTokenCount in SmViewShell::DrawTextLine
    
    Change-Id: If2c059b1284257c73e64f30ffe845ee4d1ccc84d

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 7bfe1df..803c30a 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1058,23 +1058,21 @@ Size SmViewShell::GetTextSize(OutputDevice& rDevice, const OUString& rText, long
 void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, const OUString& rLine)
 {
     Point aPoint(rPosition);
-
-    sal_uInt16 nTabs = comphelper::string::getTokenCount(rLine, '\t');
-    long nTabPos = 0;
-    if (nTabs > 0)
-        nTabPos = rDevice.approximate_char_width() * 8;
+    const long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_char_width() * 8;
 
     if (nTabPos)
     {
-        for (sal_uInt16 i = 0; i < nTabs; ++i)
+        sal_Int32 nPos = 0;
+        do
         {
-            if (i > 0)
+            if (nPos > 0)
                 aPoint.X() = ((aPoint.X() / nTabPos) + 1) * nTabPos;
 
-            OUString aText = rLine.getToken(i, '\t');
+            OUString aText = rLine.getToken(0, '\t', nPos);
             rDevice.DrawText(aPoint, aText);
             aPoint.X() += rDevice.GetTextWidth(aText);
         }
+        while ( nPos >= 0 );
     }
     else
         rDevice.DrawText(aPoint, rLine);
commit fa29fab1be6a1e93ea25cf87aefec3da04dff357
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:48:47 2015 +0200

    Avoid getTokenCount in SmViewShell::GetTextSize
    
    Change-Id: Ic81b961ae2360ea3fe40c9e536a6f10a5788fe1a

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 8627f37..7bfe1df 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1000,11 +1000,13 @@ Size SmViewShell::GetTextSize(OutputDevice& rDevice, const OUString& rText, long
 {
     Size aSize;
     Size aTextSize;
-    sal_uInt16 nLines = comphelper::string::getTokenCount(rText, '\n');
+    if (rText.isEmpty())
+        return aTextSize;
 
-    for (sal_uInt16 i = 0; i < nLines; i++)
+    sal_Int32 nPos = 0;
+    do
     {
-        OUString aLine = rText.getToken(i, '\n');
+        OUString aLine = rText.getToken(0, '\n', nPos);
         aLine = comphelper::string::remove(aLine, '\r');
 
         aSize = GetTextLineSize(rDevice, aLine);
@@ -1048,6 +1050,7 @@ Size SmViewShell::GetTextSize(OutputDevice& rDevice, const OUString& rText, long
             aTextSize.Width() = std::max(aTextSize.Width(), aSize.Width());
         }
     }
+    while (nPos >= 0);
 
     return aTextSize;
 }
commit 584d55178d2e390e60355b18bbac4be16fe750dd
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:41:04 2015 +0200

    String tokens do not include token separator
    
    Change-Id: I03ab73e5f53b2068efc3c4cdaed15f2ec3854c76

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index b10981b..8627f37 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1006,8 +1006,6 @@ Size SmViewShell::GetTextSize(OutputDevice& rDevice, const OUString& rText, long
     {
         OUString aLine = rText.getToken(i, '\n');
         aLine = comphelper::string::remove(aLine, '\r');
-        aLine = comphelper::string::stripStart(aLine, '\n');
-        aLine = comphelper::string::stripEnd(aLine, '\n');
 
         aSize = GetTextLineSize(rDevice, aLine);
 
@@ -1071,8 +1069,6 @@ void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, co
                 aPoint.X() = ((aPoint.X() / nTabPos) + 1) * nTabPos;
 
             OUString aText = rLine.getToken(i, '\t');
-            aText = comphelper::string::stripStart(aText, '\t');
-            aText = comphelper::string::stripEnd(aText, '\t');
             rDevice.DrawText(aPoint, aText);
             aPoint.X() += rDevice.GetTextWidth(aText);
         }
@@ -1092,8 +1088,6 @@ void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const
     {
         OUString aLine = rText.getToken(i, '\n');
         aLine = comphelper::string::remove(aLine, '\r');
-        aLine = comphelper::string::stripEnd(aLine, '\n');
-        aLine = comphelper::string::stripEnd(aLine, '\n');
         aSize = GetTextLineSize(rDevice, aLine);
         if (aSize.Width() > MaxWidth)
         {
commit 90059da96a91dd2271aeba4101cee8ce827e3c4e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:14:23 2015 +0200

    Avoid getTokenCount in SmViewShell::SetZoomFactor
    
    Change-Id: Idb874a60868595ccc648da86c8bd32c28b92547b

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 1df935c..b10981b 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -976,23 +976,21 @@ void SmViewShell::SetZoomFactor( const Fraction &rX, const Fraction &rY )
 Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const OUString& rLine)
 {
     Size   aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
-    sal_uInt16 nTabs = comphelper::string::getTokenCount(rLine, '\t');
-    long nTabPos = 0;
-    if (nTabs > 0)
-        nTabPos = rDevice.approximate_char_width() * 8;
+    const long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_char_width() * 8;
 
     if (nTabPos)
     {
         aSize.Width() = 0;
-
-        for (sal_uInt16 i = 0; i < nTabs; i++)
+        sal_Int32 nPos = 0;
+        do
         {
-            if (i > 0)
+            if (nPos > 0)
                 aSize.Width() = ((aSize.Width() / nTabPos) + 1) * nTabPos;
 
-            OUString aText = rLine.getToken(i, '\t');
+            const OUString aText = rLine.getToken(0, '\t', nPos);
             aSize.Width() += rDevice.GetTextWidth(aText);
         }
+        while (nPos >= 0);
     }
 
     return aSize;
commit 13ea7ab912093d2c890e4533f54c21eca5f4f585
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:13:18 2015 +0200

    Fix typo in (my) commit 6f971c4de0d5377a9dd8e010512f5abbd399231e
    
    Change-Id: I6253addfede852c9c954de59c465a8cfd729ddf9

diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index f35bb59..fab65ab 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -433,7 +433,7 @@ bool ImplSdPPTImport::Import()
                                                 aStringAry[nTokenCount] =
                                                     OUStringToOString(aString.getToken( 0, (sal_Unicode)',', nPos ), RTL_TEXTENCODING_UTF8);
                                             }
-                                            while ( ++nTokenCount < SAL_N_ELMENTS(aStringAry) && nPos >= 0 );
+                                            while ( ++nTokenCount < SAL_N_ELEMENTS(aStringAry) && nPos >= 0 );
 
                                             bool bDocInternalSubAddress = false;
 
commit 4cc8558d8e93f57fef057d433e67c5a6c7438233
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 17:08:09 2015 +0200

    String tokens do not include token separator
    
    Change-Id: Ia469f84412bdaed59b9e9eb3c8942de3d14270b9

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index d3d093b..1df935c 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -991,8 +991,6 @@ Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const OUString& rLine)
                 aSize.Width() = ((aSize.Width() / nTabPos) + 1) * nTabPos;
 
             OUString aText = rLine.getToken(i, '\t');
-            aText = comphelper::string::stripStart(aText, '\t');
-            aText = comphelper::string::stripEnd(aText, '\t');
             aSize.Width() += rDevice.GetTextWidth(aText);
         }
     }
commit 895f24ffca080516b877e86ad0ce7b076e14418d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 16:59:29 2015 +0200

    Avoid getTokenCount in ImplSdPPTImport::Import
    
    Change-Id: I7ed99aa72bc775b98f5ca738c35706629a58dc96

diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 76f331d..f35bb59 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -426,17 +426,19 @@ bool ImplSdPPTImport::Import()
                                             sal_uInt32 nPageNumber = 0;
                                             OUString aString( pHyperlink->aSubAdress );
                                             OString aStringAry[ 3 ];
-                                            sal_uInt16 nTokenCount = comphelper::string::getTokenCount(aString, ',');
-                                            if ( nTokenCount > 3 )
-                                                nTokenCount = 3;
-                                            sal_uInt16 nToken;
-                                            for( nToken = 0; nToken < nTokenCount; nToken++ )
-                                                aStringAry[nToken] = OUStringToOString(aString.getToken( nToken, (sal_Unicode)',' ), RTL_TEXTENCODING_UTF8);
+                                            size_t nTokenCount = 0;
+                                            sal_Int32 nPos = 0;
+                                            do
+                                            {
+                                                aStringAry[nTokenCount] =
+                                                    OUStringToOString(aString.getToken( 0, (sal_Unicode)',', nPos ), RTL_TEXTENCODING_UTF8);
+                                            }
+                                            while ( ++nTokenCount < SAL_N_ELMENTS(aStringAry) && nPos >= 0 );
 
                                             bool bDocInternalSubAddress = false;
 
                                             // first pass, searching for a SlideId
-                                            for( nToken = 0; nToken < nTokenCount; nToken++ )
+                                            for( size_t nToken = 0; nToken < nTokenCount; ++nToken )
                                             {
                                                 if (comphelper::string::isdigitAsciiString(aStringAry[nToken]))
                                                 {
@@ -459,7 +461,7 @@ bool ImplSdPPTImport::Import()
                                             }
                                             if ( !bDocInternalSubAddress )
                                             {   // second pass, searching for a SlideName
-                                                for ( nToken = 0; nToken < nTokenCount; nToken++ )
+                                                for ( size_t nToken = 0; nToken < nTokenCount; ++nToken )
                                                 {
                                                     OUString aToken(OStringToOUString(aStringAry[nToken], RTL_TEXTENCODING_UTF8));
                                                     std::vector<OUString>::const_iterator pIter =
@@ -474,7 +476,7 @@ bool ImplSdPPTImport::Import()
                                             }
                                             if ( !bDocInternalSubAddress )
                                             {   // third pass, searching for a slide number
-                                                for ( nToken = 0; nToken < nTokenCount; nToken++ )
+                                                for ( size_t nToken = 0; nToken < nTokenCount; ++nToken )
                                                 {
                                                     if (comphelper::string::isdigitAsciiString(aStringAry[nToken]))
                                                     {
commit f7b305015043c4f9e0a669afc7222d873c548ad5
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 16:50:53 2015 +0200

    Avoid getTokenCount in (SwMailMergeOutputTypePage) TypeHdl_Impl link
    
    Change-Id: If506716a45a869c40a0a449189b049c38215e25c

diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx
index 382c09c..c2f84e9 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -77,7 +77,6 @@ IMPL_LINK_NOARG_TYPED(SwMailMergeOutputTypePage, TypeHdl_Impl, Button*, void)
 
 #include <rtl/ref.hxx>
 #include <com/sun/star/mail/XSmtpService.hpp>
-#include <comphelper/string.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/idle.hxx>
 
@@ -505,27 +504,25 @@ void  SwSendMailDialog::IterateMails()
         //CC and BCC are tokenized by ';'
         if(!pCurrentMailDescriptor->sCC.isEmpty())
         {
-            OUString sTokens( pCurrentMailDescriptor->sCC );
-            sal_uInt16 nTokens = comphelper::string::getTokenCount(sTokens, ';');
             sal_Int32 nPos = 0;
-            for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
+            do
             {
-                OUString sTmp = sTokens.getToken( 0, ';', nPos);
+                OUString sTmp = pCurrentMailDescriptor->sCC.getToken( 0, ';', nPos );
                 if( !sTmp.isEmpty() )
                     pMessage->addCcRecipient( sTmp );
             }
+            while (nPos >= 0);
         }
         if(!pCurrentMailDescriptor->sBCC.isEmpty())
         {
-            OUString sTokens( pCurrentMailDescriptor->sBCC );
-            sal_uInt16 nTokens = comphelper::string::getTokenCount(sTokens, ';');
             sal_Int32 nPos = 0;
-            for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
+            do
             {
-                OUString sTmp = sTokens.getToken( 0, ';', nPos);
+                OUString sTmp = pCurrentMailDescriptor->sBCC.getToken( 0, ';', nPos );
                 if( !sTmp.isEmpty() )
                     pMessage->addBccRecipient( sTmp );
             }
+            while (nPos >= 0);
         }
         m_pImpl->xMailDispatcher->enqueueMailMessage( xMessage );
         pCurrentMailDescriptor = m_pImpl->GetNextDescriptor();
commit b5e214f27c5fc8911e131597c628d5062aa056a1
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 16:45:25 2015 +0200

    Avoid getTokenCount in SwAddressPreview::DrawText_Impl
    
    Change-Id: I28c678d0d3db4cbea6c15141d1d0157447cd4db7

diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx
index 79113f1..2f91678 100644
--- a/sw/source/uibase/dbui/mailmergehelper.cxx
+++ b/sw/source/uibase/dbui/mailmergehelper.cxx
@@ -34,7 +34,6 @@
 #include <com/sun/star/mail/MailServiceProvider.hpp>
 #include <com/sun/star/mail/XSmtpService.hpp>
 #include <comphelper/processfactory.hxx>
-#include <comphelper/string.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/builderfactory.hxx>
@@ -449,16 +448,16 @@ void SwAddressPreview::DrawText_Impl(vcl::RenderContext& rRenderContext, const O
         rRenderContext.DrawRect(Rectangle(rTopLeft, rSize));
     }
     sal_Int32 nHeight = GetTextHeight();
-    OUString sAddress(rAddress);
-    sal_uInt16 nTokens = comphelper::string::getTokenCount(sAddress, '\n');
     Point aStart = rTopLeft;
     //put it away from the border
     aStart.Move(2, 2);
-    for (sal_uInt16 nToken = 0; nToken < nTokens; nToken++)
+    sal_Int32 nPos = 0;
+    do
     {
-        rRenderContext.DrawText(aStart, sAddress.getToken(nToken, '\n'));
+        rRenderContext.DrawText(aStart, rAddress.getToken(0, '\n', nPos));
         aStart.Y() += nHeight;
     }
+    while (nPos >= 0);
 }
 
 OUString SwAddressPreview::FillData(
commit f50c547e22e0793061c5123cccb8c292e57de470
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 16:38:49 2015 +0200

    No need to copy OUStrings in SwMailMergeHelper::CheckMailAddress
    
    Change-Id: I77ff719274991d901cf3869cd45ea416c772be2f

diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx
index 3901058..79113f1 100644
--- a/sw/source/uibase/dbui/mailmergehelper.cxx
+++ b/sw/source/uibase/dbui/mailmergehelper.cxx
@@ -72,17 +72,15 @@ OUString CallSaveAsDialog(OUString& rFilter)
 /*
     simple address check: check for '@'
                             for at least one '.' after the '@'
-                            and for at least to characters before and after the dot
+                            and for at least two characters before and after the dot
 */
 bool CheckMailAddress( const OUString& rMailAddress )
 {
-    OUString sAddress(rMailAddress);
-    if (!(comphelper::string::getTokenCount(sAddress, '@') == 2))
+    const sal_Int32 nPosAt = rMailAddress.indexOf('@');
+    if (nPosAt<0 || rMailAddress.lastIndexOf('@')!=nPosAt)
         return false;
-    sAddress = sAddress.getToken(1, '@');
-    if (comphelper::string::getTokenCount(sAddress, '.') < 2)
-        return false;
-    if(sAddress.getToken( 0, '.').getLength() < 2 || sAddress.getToken( 1, '.').getLength() < 2)
+    const sal_Int32 nPosDot = rMailAddress.indexOf('.', nPosAt);
+    if (nPosDot<0 || nPosDot-nPosAt<3 || rMailAddress.getLength()-nPosDot<3)
         return false;
     return true;
 }
commit 84e4d7d214505127abedfaadff2ff1e582a0633f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 16:16:17 2015 +0200

    sal_uInt16 to sal_Int32
    
    Change-Id: I16169aa22b373beb768d12bb304b5e816d40b2d4

diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx
index 2401676..0379d68 100644
--- a/cui/source/tabpages/macroass.cxx
+++ b/cui/source/tabpages/macroass.cxx
@@ -100,7 +100,7 @@ OUString ConvertToUIName_Impl( SvxMacro *pMacro )
     OUString aEntry;
     if ( pMacro->GetLanguage() != "JavaScript" )
     {
-        sal_uInt16 nCount = comphelper::string::getTokenCount(aName, '.');
+        const sal_Int32 nCount = comphelper::string::getTokenCount(aName, '.');
         aEntry = aName.getToken( nCount-1, '.' );
         if ( nCount > 2 )
         {
commit 356ba01b7c1c25ef01babd568f4adcf884dce249
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 15:05:58 2015 +0200

    Use search position in getToken
    
    Change-Id: If801cb8c4aef16ecac1c747e56bf0c1797d7db21

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 16bae49..2aa6aaf 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -801,11 +801,12 @@ void SvxPathTabPage::SetPathList(
 
         // save user paths
         char cDelim = MULTIPATH_DELIMITER;
-        sal_uInt16 nCount = comphelper::string::getTokenCount(_rUserPath, cDelim);
+        const sal_Int32 nCount = comphelper::string::getTokenCount(_rUserPath, cDelim);
         Sequence< OUString > aPathSeq( nCount );
         OUString* pArray = aPathSeq.getArray();
-        for ( sal_uInt16 i = 0; i < nCount; ++i )
-            pArray[i] = _rUserPath.getToken( i, cDelim );
+        sal_Int32 nPos = 0;
+        for ( sal_Int32 i = 0; i < nCount; ++i )
+            pArray[i] = _rUserPath.getToken( 0, cDelim, nPos );
         Any aValue = makeAny( aPathSeq );
         pImpl->m_xPathSettings->setPropertyValue(
             sCfgName + POSTFIX_USER, aValue);
commit af6d9db3fc1dddd65299eb0bfb5b366700edc742
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 14:56:22 2015 +0200

    Avoid getTokenCount in PathHdl_Impl link
    
    Change-Id: Idfc4977283373349d6c636c91e631eb98684ae56

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 370f71c..16bae49 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -584,19 +584,24 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void)
                 sWritable.clear();
                 OUString sFullPath;
                 OUString sNewPath = pMultiDlg->GetPath();
-                char cDelim = MULTIPATH_DELIMITER;
-                sal_uInt16 nCount = comphelper::string::getTokenCount(sNewPath, cDelim);
-                if ( nCount > 0 )
+                if ( !sNewPath.isEmpty() )
                 {
-                    sal_uInt16 i = 0;
-                    for ( ; i < nCount - 1; ++i )
+                    const sal_Unicode cDelim = MULTIPATH_DELIMITER;
+                    sal_Int32 nNextPos = 0;
+                    for (;;)
                     {
+                        const OUString sToken(sNewPath.getToken( 0, cDelim, nNextPos ));
+                        if ( nNextPos<0 )
+                        {
+                            // Last token need a different handling
+                            sWritable = sToken;
+                            break;
+                        }
                         if ( !sUser.isEmpty() )
                             sUser += OUString(cDelim);
-                        sUser += sNewPath.getToken( i, cDelim );
+                        sUser += sToken;
                     }
                     sFullPath = sUser;
-                    sWritable += sNewPath.getToken( i, cDelim );
                     if ( !sFullPath.isEmpty() )
                         sFullPath += OUString(cDelim);
                     sFullPath += sWritable;
commit a3bbb7e63c1f5e7f5d63678e7d35f8847e4a9370
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 14:51:08 2015 +0200

    sFullPath is empty for sure, here
    
    Change-Id: Idee351bf2515dd7343b6a74eba98d1df7f4d5ffc

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 98999d9..370f71c 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -595,9 +595,7 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void)
                             sUser += OUString(cDelim);
                         sUser += sNewPath.getToken( i, cDelim );
                     }
-                    if ( !sFullPath.isEmpty() )
-                        sFullPath += OUString(cDelim);
-                    sFullPath += sUser;
+                    sFullPath = sUser;
                     sWritable += sNewPath.getToken( i, cDelim );
                     if ( !sFullPath.isEmpty() )
                         sFullPath += OUString(cDelim);
commit aef2aa22180be4b99b0a4e28b3bc13f82ad436c5
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 14:33:09 2015 +0200

    Avoid getTokenCount in StandardHdl_Impl link (3)
    
    Change-Id: Ib68b48fd14cbfae234d03a2963991a1c8581423b

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 0a97795..98999d9 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -444,16 +444,23 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, StandardHdl_Impl, Button*, void)
             while ( nOldPos >= 0 );
 
             OUString sUserPath, sWritablePath;
-            sal_uInt16 nOldCount = comphelper::string::getTokenCount(sTemp, MULTIPATH_DELIMITER);
-            sal_uInt16 i;
-            for ( i = 0; nOldCount > 0 && i < nOldCount - 1; ++i )
+            if ( !sTemp.isEmpty() )
             {
-                if ( !sUserPath.isEmpty() )
-                    sUserPath += OUStringLiteral1<MULTIPATH_DELIMITER>();
-                sUserPath += sTemp.getToken( i, MULTIPATH_DELIMITER );
+                sal_Int32 nNextPos = 0;
+                for (;;)
+                {
+                    const OUString sToken = sTemp.getToken( 0, MULTIPATH_DELIMITER, nNextPos );
+                    if ( nNextPos<0 )
+                    {
+                        // Last token need a different handling
+                        sWritablePath = sToken;
+                        break;
+                    }
+                    if ( !sUserPath.isEmpty() )
+                        sUserPath += OUStringLiteral1<MULTIPATH_DELIMITER>();
+                    sUserPath += sToken;
+                }
             }
-            sWritablePath = sTemp.getToken( nOldCount - 1, MULTIPATH_DELIMITER );
-
             pPathBox->SetEntryText( Convert_Impl( sTemp ), pEntry, 1 );
             pPathImpl->eState = SfxItemState::SET;
             pPathImpl->sUserPath = sUserPath;
commit 57c0ca2e575813626d0c2c994e0a4b52253f42b1
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 13:09:42 2015 +0200

    Avoid getTokenCount in StandardHdl_Impl link (2)
    
    Change-Id: I0164f81e6308c5a5c1b4d93e8df55aa911ea8b4c

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 8354185..0a97795 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -419,12 +419,11 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, StandardHdl_Impl, Button*, void)
             bool bReadOnly = false;
             GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly );
 
-            sal_uInt16 i;
-            sal_uInt16 nOldCount = comphelper::string::getTokenCount(aOldPath, MULTIPATH_DELIMITER);
-            for ( i = 0; i < nOldCount; ++i )
+            sal_Int32 nOldPos = 0;
+            do
             {
                 bool bFound = false;
-                OUString sOnePath = aOldPath.getToken( i, MULTIPATH_DELIMITER );
+                const OUString sOnePath = aOldPath.getToken( 0, MULTIPATH_DELIMITER, nOldPos );
                 if ( !sInternal.isEmpty() )
                 {
                     sal_Int32 nInternalPos = 0;
@@ -442,9 +441,11 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, StandardHdl_Impl, Button*, void)
                     sTemp += sOnePath;
                 }
             }
+            while ( nOldPos >= 0 );
 
             OUString sUserPath, sWritablePath;
-            nOldCount = comphelper::string::getTokenCount(sTemp, MULTIPATH_DELIMITER);
+            sal_uInt16 nOldCount = comphelper::string::getTokenCount(sTemp, MULTIPATH_DELIMITER);
+            sal_uInt16 i;
             for ( i = 0; nOldCount > 0 && i < nOldCount - 1; ++i )
             {
                 if ( !sUserPath.isEmpty() )
commit 261471afa11f670a1ac19edc61c17e37d505dac0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 13:04:46 2015 +0200

    Avoid getTokenCount in StandardHdl_Impl link (1)
    
    Change-Id: I3a74980fec63085fe60f6f413c77b54dcd4df0ab

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 3cc1dce..8354185 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -421,15 +421,19 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, StandardHdl_Impl, Button*, void)
 
             sal_uInt16 i;
             sal_uInt16 nOldCount = comphelper::string::getTokenCount(aOldPath, MULTIPATH_DELIMITER);
-            sal_uInt16 nIntCount = comphelper::string::getTokenCount(sInternal, MULTIPATH_DELIMITER);
             for ( i = 0; i < nOldCount; ++i )
             {
                 bool bFound = false;
                 OUString sOnePath = aOldPath.getToken( i, MULTIPATH_DELIMITER );
-                for ( sal_uInt16 j = 0; !bFound && j < nIntCount; ++j )
+                if ( !sInternal.isEmpty() )
                 {
-                    if ( sInternal.getToken( j, MULTIPATH_DELIMITER ) == sOnePath )
-                        bFound = true;
+                    sal_Int32 nInternalPos = 0;
+                    do
+                    {
+                        if ( sInternal.getToken( 0, MULTIPATH_DELIMITER, nInternalPos ) == sOnePath )
+                            bFound = true;
+                    }
+                    while ( !bFound && nInternalPos >= 0 );
                 }
                 if ( !bFound )
                 {
commit 02d1aaf12cd1c9a6b7c79d7fbb5f65dd12199ab0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 12:45:08 2015 +0200

    Reduce OUString copies
    
    Change-Id: I443a327ce2f089b7930678d21572a43a28cdea51

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index bfc0b73..3cc1dce 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -317,8 +317,7 @@ void SvxPathTabPage::Reset( const SfxItemSet* )
                 if ( !sTmpPath.isEmpty() && !sWritable.isEmpty() )
                     sTmpPath += OUStringLiteral1<MULTIPATH_DELIMITER>();
                 sTmpPath += sWritable;
-                OUString aValue( sTmpPath );
-                aValue = Convert_Impl( aValue );
+                const OUString aValue = Convert_Impl( sTmpPath );
                 nWidth2 = std::max(nWidth2, pPathBox->GetTextWidth(aValue));
                 aStr += aValue;
                 SvTreeListEntry* pEntry = pPathBox->InsertEntry( aStr );
@@ -481,12 +480,11 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder )
     // old path is an URL?
     INetURLObject aObj( sWritable );
     bool bURL = ( aObj.GetProtocol() != INetProtocol::NotValid );
-    OUString aPathStr( _rFolder );
-    INetURLObject aNewObj( aPathStr );
+    INetURLObject aNewObj( _rFolder );
     aNewObj.removeFinalSlash();
 
     // then the new path also an URL else system path
-    OUString sNewPathStr = bURL ? aPathStr : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT );
+    OUString sNewPathStr = bURL ? _rFolder : aNewObj.getFSysPath( INetURLObject::FSYS_DETECT );
 
     bool bChanged =
 #ifdef UNX
@@ -564,9 +562,8 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void)
             sPath += sWritable;
             pMultiDlg->SetPath( sPath );
 
-            OUString sPathName = SvTabListBox::GetEntryText( pEntry, 0 );
-            OUString sNewTitle( pImpl->m_sMultiPathDlg );
-            sNewTitle = sNewTitle.replaceFirst( VAR_ONE, sPathName );
+            const OUString sPathName = SvTabListBox::GetEntryText( pEntry, 0 );
+            const OUString sNewTitle = pImpl->m_sMultiPathDlg.replaceFirst( VAR_ONE, sPathName );
             pMultiDlg->SetTitle( sNewTitle );
 
             if ( pMultiDlg->Execute() == RET_OK && pEntry )
@@ -799,7 +796,7 @@ void SvxPathTabPage::SetPathList(
             sCfgName + POSTFIX_USER, aValue);
 
         // then the writable path
-        aValue = makeAny( OUString( _rWritablePath ) );
+        aValue = makeAny( _rWritablePath );
         pImpl->m_xPathSettings->setPropertyValue(
             sCfgName + POSTFIX_WRITABLE, aValue);
     }
commit 9f3222789fa6684701b9f2088a7bb3b198274e20
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 12:33:37 2015 +0200

    This was probably the original intent (wrong index in inner loop body)
    
    Change-Id: I17bec80168cc56fa5ab47da65e85a90c32c958b3

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index e7f2a58..bfc0b73 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -429,7 +429,7 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, StandardHdl_Impl, Button*, void)
                 OUString sOnePath = aOldPath.getToken( i, MULTIPATH_DELIMITER );
                 for ( sal_uInt16 j = 0; !bFound && j < nIntCount; ++j )
                 {
-                    if ( sInternal.getToken( i, MULTIPATH_DELIMITER ) == sOnePath )
+                    if ( sInternal.getToken( j, MULTIPATH_DELIMITER ) == sOnePath )
                         bFound = true;
                 }
                 if ( !bFound )
commit 83dd91fb20b7fb28f3f4e3e28789b34534bcd4be
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 12:31:28 2015 +0200

    Convert_Impl can be static
    
    Change-Id: If99b39aa46bfb02ece72944b9122b04458a0dae6

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 289d295..e7f2a58 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -141,7 +141,7 @@ static OUString getCfgName_Impl( sal_uInt16 _nHandle )
 
 #define MULTIPATH_DELIMITER     ';'
 
-OUString Convert_Impl( const OUString& rValue )
+static OUString Convert_Impl( const OUString& rValue )
 {
     OUString aReturn;
     if (rValue.isEmpty())
commit bbdbdbc31de0236708ee3f918c49aa7193323b65
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 12:29:16 2015 +0200

    Avoid getTokenCount in Convert_Impl (optpath.cxx)
    
    Change-Id: Icc434c714fead503c3fd292bd9609c3905023676

diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 002d16e..289d295 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -143,17 +143,22 @@ static OUString getCfgName_Impl( sal_uInt16 _nHandle )
 
 OUString Convert_Impl( const OUString& rValue )
 {
-    char cDelim = MULTIPATH_DELIMITER;
-    sal_uInt16 nCount = comphelper::string::getTokenCount(rValue, cDelim);
     OUString aReturn;
-    for ( sal_uInt16 i=0; i<nCount ; ++i )
+    if (rValue.isEmpty())
+        return aReturn;
+
+    const sal_Unicode cDelim = MULTIPATH_DELIMITER;
+    sal_Int32 nPos = 0;
+
+    for (;;)
     {
-        OUString aValue = rValue.getToken( i, cDelim );
+        OUString aValue = rValue.getToken( 0, cDelim, nPos );
         INetURLObject aObj( aValue );
         if ( aObj.GetProtocol() == INetProtocol::File )
             aReturn += aObj.PathToFileName();
-        if ( i+1 < nCount)
-            aReturn += OUStringLiteral1<MULTIPATH_DELIMITER>();
+        if ( nPos < 0 )
+            break;
+        aReturn += OUStringLiteral1<MULTIPATH_DELIMITER>();
     }
 
     return aReturn;


More information about the Libreoffice-commits mailing list