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

Matteo Casalin matteo.casalin at yahoo.com
Sat Aug 17 06:40:30 PDT 2013


 include/svtools/svtabbx.hxx       |    2 
 svtools/source/contnr/svtabbx.cxx |   77 +++++++-------------------------------
 svx/source/dialog/ctredlin.cxx    |   24 ++---------
 3 files changed, 21 insertions(+), 82 deletions(-)

New commits:
commit 4ee77518f56915fec9dac2a0649eb633eeb27e25
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Aug 16 22:19:38 2013 +0200

    SvTabListBox::GetToken: sal_Unicode* to OUString + OUString::getToken
    
    Change-Id: I1006b33aaf4ba31cfbd38dd2a39b06cb7a381af6
    Reviewed-on: https://gerrit.libreoffice.org/5461
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/include/svtools/svtabbx.hxx b/include/svtools/svtabbx.hxx
index 86138df..93502c3 100644
--- a/include/svtools/svtabbx.hxx
+++ b/include/svtools/svtabbx.hxx
@@ -53,7 +53,7 @@ private:
 protected:
     SvTreeListEntry*                pViewParent;
 
-    static const sal_Unicode*   GetToken( const sal_Unicode* pPtr, sal_uInt16& rLen );
+    static OUString             GetToken( const OUString &sStr, sal_Int32 &nIndex );
 
     virtual void                SetTabs();
     virtual void                InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind);
diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx
index 0a0de29..584dd1e 100644
--- a/svtools/source/contnr/svtabbx.cxx
+++ b/svtools/source/contnr/svtabbx.cxx
@@ -76,25 +76,15 @@ void SvTabListBox::InitEntry(SvTreeListEntry* pEntry, const OUString& rStr,
     const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind)
 {
     SvTreeListBox::InitEntry(pEntry, rStr, rColl, rExp, eButtonKind);
-    OUString aToken;
 
-    const sal_Unicode* pCurToken = aCurEntry.getStr();
-    sal_uInt16 nCurTokenLen;
-    const sal_Unicode* pNextToken = GetToken( pCurToken, nCurTokenLen );
-    sal_uInt16 nCount = nTabCount; nCount--;
+    sal_Int32 nIndex = 0;
+    // TODO: verify if nTabCount is always >0 here!
+    const sal_uInt16 nCount = nTabCount - 1;
     for( sal_uInt16 nToken = 0; nToken < nCount; nToken++ )
     {
-        if( pCurToken && nCurTokenLen )
-            aToken = OUString(pCurToken, nCurTokenLen);
-        else
-            aToken = OUString();
+        const OUString aToken = GetToken(aCurEntry, nIndex);
         SvLBoxString* pStr = new SvLBoxString( pEntry, 0, aToken );
         pEntry->AddItem( pStr );
-        pCurToken = pNextToken;
-        if( pCurToken )
-            pNextToken = GetToken( pCurToken, nCurTokenLen );
-        else
-            nCurTokenLen = 0;
     }
 }
 
@@ -324,45 +314,26 @@ void SvTabListBox::SetEntryText(const OUString& rStr, SvTreeListEntry* pEntry, s
     if (sOldText == rStr)
         return;
 
-    sal_uInt16 nTextColumn = nCol;
-    const sal_Unicode* pCurToken = rStr.getStr();
-    sal_uInt16 nCurTokenLen;
-    const sal_Unicode* pNextToken = GetToken( pCurToken, nCurTokenLen );
-
-    OUString aTemp;
-    sal_uInt16 nCount = pEntry->ItemCount();
-    sal_uInt16 nCur = 0;
-    while( nCur < nCount )
+    sal_Int32 nIndex = 0;
+    const sal_uInt16 nTextColumn = nCol;
+    const sal_uInt16 nCount = pEntry->ItemCount();
+    for (sal_uInt16 nCur = 0; nCur < nCount; ++nCur)
     {
         SvLBoxItem* pStr = pEntry->GetItem( nCur );
         if (pStr && pStr->GetType() == SV_ITEM_ID_LBOXSTRING)
         {
-            if( nCol == 0xffff )
+            if (!nCol || nCol==0xFFFF)
             {
-                if( pCurToken )
-                    aTemp = OUString(pCurToken, nCurTokenLen);
-                else
-                    aTemp = OUString(); // delete all columns without a token
+                const OUString aTemp(GetToken(rStr, nIndex));
                 ((SvLBoxString*)pStr)->SetText( aTemp );
-                pCurToken = pNextToken;
-                pNextToken = GetToken( pCurToken, nCurTokenLen );
+                if (!nCol && nIndex<0)
+                    break;
             }
             else
             {
-                if( !nCol )
-                {
-                    aTemp = OUString(pCurToken, nCurTokenLen);
-                    ((SvLBoxString*)pStr)->SetText( aTemp );
-                    if( !pNextToken )
-                        break;
-                    pCurToken = pNextToken;
-                    pNextToken = GetToken( pCurToken, nCurTokenLen );
-                }
-                else
-                    nCol--;
+                --nCol;
             }
         }
-        nCur++;
     }
     GetModel()->InvalidateEntry( pEntry );
 
@@ -420,27 +391,9 @@ void SvTabListBox::Resize()
 }
 
 // static
-const sal_Unicode* SvTabListBox::GetToken( const sal_Unicode* pPtr, sal_uInt16& rLen )
+OUString SvTabListBox::GetToken( const OUString &sStr, sal_Int32& nIndex )
 {
-    if( !pPtr || *pPtr == 0 )
-    {
-        rLen = 0;
-        return 0;
-    }
-    sal_Unicode c = *pPtr;
-    sal_uInt16 nLen = 0;
-    while( c != '\t' && c != 0 )
-    {
-        pPtr++;
-        nLen++;
-        c = *pPtr;
-    }
-    if( c )
-        pPtr++; // skip tab
-    else
-        pPtr = 0;
-    rLen = nLen;
-    return pPtr;
+    return sStr.getToken(0, '\t', nIndex);
 }
 
 OUString SvTabListBox::GetTabEntryText( sal_uLong nPos, sal_uInt16 nCol ) const
diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx
index 85c0dfe..1b5a883 100644
--- a/svx/source/dialog/ctredlin.cxx
+++ b/svx/source/dialog/ctredlin.cxx
@@ -383,28 +383,14 @@ void SvxRedlinTable::InitEntry(SvTreeListEntry* pEntry, const OUString& rStr,
     pString = new SvLBoxColorString( pEntry, 0, rStr ,aEntryColor);
     pEntry->AddItem( pString );
 
-    XubString aToken;
-
-    sal_Unicode* pCurToken = (sal_Unicode*)aCurEntry.GetBuffer();
-    sal_uInt16 nCurTokenLen;
-    sal_Unicode* pNextToken = (sal_Unicode*)GetToken( pCurToken, nCurTokenLen );
-    sal_uInt16 nCount = TabCount(); nCount--;
-
+    sal_Int32 nIndex = 0;
+    // TODO: verify if TabCount() is always >0 here!
+    const sal_uInt16 nCount = TabCount()-1;
     for( sal_uInt16 nToken = 0; nToken < nCount; nToken++ )
     {
-        if( pCurToken && nCurTokenLen )
-            aToken = OUString(pCurToken, nCurTokenLen);
-        else
-            aToken.Erase();
-
-        SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken ,aEntryColor);
+        const OUString aToken = GetToken(aCurEntry, nIndex);
+        SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken, aEntryColor);
         pEntry->AddItem( pStr );
-
-        pCurToken = pNextToken;
-        if( pCurToken )
-            pNextToken = (sal_Unicode*)GetToken( pCurToken, nCurTokenLen );
-        else
-            nCurTokenLen = 0;
     }
 }
 


More information about the Libreoffice-commits mailing list