[Libreoffice-commits] core.git: 5 commits - cui/source fpicker/source sc/source sd/source

Matteo Casalin matteo.casalin at yahoo.com
Sun Sep 13 02:06:40 PDT 2015


 cui/source/dialogs/multipat.cxx          |   56 ++++++++++++++++---------------
 fpicker/source/office/iodlg.cxx          |   33 ++++++------------
 sc/source/core/tool/rangelst.cxx         |   19 +++-------
 sc/source/ui/view/viewfun2.cxx           |    8 ++--
 sd/source/core/CustomAnimationPreset.cxx |   30 ++++++++--------
 5 files changed, 69 insertions(+), 77 deletions(-)

New commits:
commit 22547d056c5fc36aff666b68b03a2d9471022ac2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 11:04:21 2015 +0200

    Avoid getTokenCount in CustomAnimationPreset::getProperties/hasProperty
    
    Change-Id: Ic5b9c152ef2faf8333ad797232e26b817668e965

diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx
index e014280..f1a8005 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -32,7 +32,6 @@
 #include <comphelper/getexpandeduri.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/random.hxx>
-#include <comphelper/string.hxx>
 #include <unotools/pathoptions.hxx>
 #include <tools/stream.hxx>
 
@@ -199,28 +198,31 @@ Reference< XAnimationNode > CustomAnimationPreset::create( const OUString& rstrS
 
 UStringList CustomAnimationPreset::getProperties() const
 {
-    OUString aProperties( maProperty );
-    sal_uInt16 nTokens = comphelper::string::getTokenCount(aProperties, ';');
-    sal_uInt16 nToken;
     UStringList aPropertyList;
-    for( nToken = 0; nToken < nTokens; nToken++ )
-        aPropertyList.push_back( aProperties.getToken( nToken, ';' ) );
-
+    if (!maProperty.isEmpty())
+    {
+        sal_Int32 nPos = 0;
+        do
+        {
+            aPropertyList.push_back(maProperty.getToken(0, ';', nPos));
+        }
+        while (nPos >= 0);
+    }
     return aPropertyList;
-
 }
 
 bool CustomAnimationPreset::hasProperty( const OUString& rProperty )const
 {
-    OUString aProperties( maProperty );
-    OUString aProperty( rProperty );
-    sal_uInt16 nTokens = comphelper::string::getTokenCount(aProperties, ';');
-    sal_uInt16 nToken;
-    for( nToken = 0; nToken < nTokens; nToken++ )
+    if (maProperty.isEmpty())
+        return false;
+
+    sal_Int32 nPos = 0;
+    do
     {
-        if( aProperties.getToken( nToken, ';' ) == aProperty )
+        if (maProperty.getToken(0, ';', nPos) == rProperty)
             return true;
     }
+    while (nPos >= 0);
 
     return false;
 }
commit 77ca5fec1ff78508f892afe25953f8c31da202df
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 10:58:53 2015 +0200

    Avoid getTokenCount in ScViewFunc::SetPrintRanges
    
    Change-Id: I1eba76ba0fdfc79de7e8f78f9bb5b0e932d343f4

diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index c085289..8aa822e 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -18,7 +18,6 @@
  */
 
 #include "scitems.hxx"
-#include <comphelper/string.hxx>
 #include <editeng/eeitem.hxx>
 
 #include <sfx2/app.hxx>
@@ -923,13 +922,14 @@ void ScViewFunc::SetPrintRanges( bool bEntireSheet, const OUString* pPrint,
             if ( !pPrint->isEmpty() )
             {
                 const sal_Unicode sep = ScCompiler::GetNativeSymbolChar(ocSep);
-                sal_uInt16 nTCount = comphelper::string::getTokenCount(*pPrint, sep);
-                for (sal_uInt16 i=0; i<nTCount; i++)
+                sal_Int32 nPos = 0;
+                do
                 {
-                    OUString aToken = pPrint->getToken(i, sep);
+                    const OUString aToken = pPrint->getToken(0, sep, nPos);
                     if ( aRange.ParseAny( aToken, &rDoc, aDetails ) & SCA_VALID )
                         rDoc.AddPrintRange( nTab, aRange );
                 }
+                while (nPos >= 0);
             }
         }
         else    // NULL = use selection (print range is always set), use empty string to delete all ranges
commit 865c9fbbfd683dc212e94513ffe3e3b86d231828
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 10:52:11 2015 +0200

    Avoid getTokenCount in ScRangeList::Parse
    
    Change-Id: I2c9628e5064ea03c878d6e45118755596a060d5a

diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 9243a34..5a0882e 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <stdlib.h>
-#include <comphelper/string.hxx>
 #include <unotools/collatorwrapper.hxx>
 #include <osl/diagnose.h>
 
@@ -170,18 +169,12 @@ sal_uInt16 ScRangeList::Parse( const OUString& rStr, ScDocument* pDoc, sal_uInt1
         nMask |= SCA_VALID;             // falls das jemand vergessen sollte
         sal_uInt16 nResult = (sal_uInt16)~0;    // alle Bits setzen
         ScRange aRange;
-        OUString aOne;
-        SCTAB nTab = 0;
-        if ( pDoc )
-        {
-            nTab = nDefaultTab;
-        }
-        else
-            nTab = 0;
-        sal_uInt16 nTCount = comphelper::string::getTokenCount(rStr, cDelimiter);
-        for ( sal_uInt16 i=0; i<nTCount; i++ )
+        const SCTAB nTab = pDoc ? nDefaultTab : 0;
+
+        sal_Int32 nPos = 0;
+        do
         {
-            aOne = rStr.getToken( i, cDelimiter );
+            const OUString aOne = rStr.getToken( 0, cDelimiter, nPos );
             aRange.aStart.SetTab( nTab );   // Default Tab wenn nicht angegeben
             sal_uInt16 nRes = aRange.ParseAny( aOne, pDoc, eConv );
             sal_uInt16 nEndRangeBits = SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2;
@@ -197,6 +190,8 @@ sal_uInt16 ScRangeList::Parse( const OUString& rStr, ScDocument* pDoc, sal_uInt1
                 Append( aRange );
             nResult &= nRes;        // alle gemeinsamen Bits bleiben erhalten
         }
+        while (nPos >= 0);
+
         return nResult;             // SCA_VALID gesetzt wenn alle ok
     }
     else
commit a37535e3ff7be959d9a3aab3399ffbcc89688662
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 10:44:38 2015 +0200

    Avoid getTokenCount
    
    in SvxMultiPathDialog::SetPath and SvxPathSelectDialog::SetPath
    
    Change-Id: I4d360caacf438949ccd9a90c4fec14a7e7d1c009

diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx
index cd6dca3..2b91b89 100644
--- a/cui/source/dialogs/multipat.cxx
+++ b/cui/source/dialogs/multipat.cxx
@@ -29,7 +29,6 @@
 
 #include <cuires.hrc>
 #include <comphelper/processfactory.hxx>
-#include <comphelper/string.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
@@ -304,25 +303,26 @@ OUString SvxPathSelectDialog::GetPath() const
 
 void SvxMultiPathDialog::SetPath( const OUString& rPath )
 {
-    sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER;
-    sal_uInt16 nCount = comphelper::string::getTokenCount(rPath, cDelim);
-
-    for ( sal_uInt16 i = 0; i < nCount; ++i )
+    if ( !rPath.isEmpty() )
     {
-        OUString sPath = rPath.getToken( i, cDelim );
-        OUString sSystemPath;
-        bool bIsSystemPath =
-            osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None;
-
-        OUString sEntry( '\t' );
-        sEntry += (bIsSystemPath ? sSystemPath : OUString(sPath));
-        SvTreeListEntry* pEntry = m_pRadioLB->InsertEntry( sEntry );
-        OUString* pURL = new OUString( sPath );
-        pEntry->SetUserData( pURL );
-    }
+        const sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER;
+        sal_uLong nCount = 0;
+        sal_Int32 nIndex = 0;
+        do
+        {
+            const OUString sPath = rPath.getToken( 0, cDelim, nIndex );
+            OUString sSystemPath;
+            bool bIsSystemPath =
+                osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None;
+
+            const OUString sEntry( "\t" + bIsSystemPath ? sSystemPath : sPath);
+            SvTreeListEntry* pEntry = m_pRadioLB->InsertEntry( sEntry );
+            OUString* pURL = new OUString( sPath );
+            pEntry->SetUserData( pURL );
+            ++nCount;
+        }
+        while (nIndex >= 0);
 
-    if (nCount > 0)
-    {
         SvTreeListEntry* pEntry = m_pRadioLB->GetEntry( nCount - 1 );
         if ( pEntry )
         {
@@ -337,17 +337,21 @@ void SvxMultiPathDialog::SetPath( const OUString& rPath )
 void SvxPathSelectDialog::SetPath(const OUString& rPath)
 {
     sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER;
-    sal_uInt16 nCount = comphelper::string::getTokenCount(rPath, cDelim);
 
-    for ( sal_uInt16 i = 0; i < nCount; ++i )
+    if ( !rPath.isEmpty() )
     {
-        OUString sPath = rPath.getToken( i, cDelim );
-        OUString sSystemPath;
-        bool bIsSystemPath =
-            osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None;
+        sal_Int32 nIndex = 0;
+        do
+        {
+            const OUString sPath = rPath.getToken( 0, cDelim, nIndex );
+            OUString sSystemPath;
+            bool bIsSystemPath =
+                osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None;
 
-        const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath );
-        m_pPathLB->SetEntryData( nPos, new OUString( sPath ) );
+            const sal_Int32 nPos = m_pPathLB->InsertEntry( bIsSystemPath ? sSystemPath : sPath );
+            m_pPathLB->SetEntryData( nPos, new OUString( sPath ) );
+        }
+        while (nIndex >= 0);
     }
 
     SelectHdl_Impl( NULL );
commit c488f3fc0c07a5c9ef0aed7f9d4e6447fc397292
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 13 03:49:52 2015 +0200

    Simplify SvtFileDialog::appendDefaultExtension
    
    Change-Id: I7d2d2aff6e26b66e73b6ccefdecf095c867d4f7d

diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index 43666b1..960579e 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -2839,35 +2839,26 @@ void SvtFileDialog::appendDefaultExtension(OUString& _rFileName,
                                            const OUString& _rFilterDefaultExtension,
                                            const OUString& _rFilterExtensions)
 {
-    OUString aTemp(_rFileName);
-    aTemp = aTemp.toAsciiLowerCase();
-    OUString aType(_rFilterExtensions);
-    aType = aType.toAsciiLowerCase();
+    const OUString aType(_rFilterExtensions.toAsciiLowerCase());
 
     if ( aType != FILEDIALOG_FILTER_ALL )
     {
-        sal_uInt16 nWildCard = comphelper::string::getTokenCount(aType, FILEDIALOG_DEF_EXTSEP);
-        sal_uInt16 nIndex;
+        const OUString aTemp(_rFileName.toAsciiLowerCase());
         sal_Int32 nPos = 0;
 
-        for ( nIndex = 0; nIndex < nWildCard; nIndex++ )
+        do
         {
-            OUString aExt(aType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
-            // take care of a leading *
-            sal_Int32 nExtOffset = (aExt[0] == '*' ? 1 : 0);
-            const sal_Unicode* pExt = aExt.getStr() + nExtOffset;
-            sal_Int32 nExtLen = aExt.getLength() - nExtOffset;
-            sal_Int32 nOffset = aTemp.getLength() - nExtLen;
-            // minimize search by starting at last possible index
-            if ( aTemp.indexOf(pExt, nOffset) == nOffset )
-                break;
+            if (nPos+1<aType.getLength() && aType[nPos]=='*') // take care of a leading *
+                ++nPos;
+            const OUString aExt(aType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
+            if (aExt.isEmpty())
+                continue;
+            if (aTemp.endsWith(aExt))
+                return;
         }
+        while (nPos>=0);
 
-        if ( nIndex >= nWildCard )
-        {
-            _rFileName += ".";
-            _rFileName += _rFilterDefaultExtension;
-        }
+        _rFileName += "." + _rFilterDefaultExtension;
     }
 }
 


More information about the Libreoffice-commits mailing list