[PATCH] Strin->OUString unotools textsearch and dep

Norbert Thiebaud (via Code Review) gerrit at gerrit.libreoffice.org
Thu Jun 13 06:19:16 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/4249

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/49/4249/1

Strin->OUString unotools textsearch and dep

Change-Id: I1934ba31b966ee79f10e200c37c8db4924272cb4
---
M editeng/source/editeng/impedit4.cxx
M include/unotools/textsearch.hxx
M reportdesign/source/ui/inspection/GeometryHandler.cxx
M sc/source/core/data/table3.cxx
M sc/source/core/data/table6.cxx
M sc/source/core/tool/interpr1.cxx
M svx/source/form/fmsrcimp.cxx
M sw/source/core/crsr/findtxt.cxx
M sw/source/core/crsr/paminit.cxx
M sw/source/core/inc/pamtyp.hxx
M unotools/source/config/fontcfg.cxx
M unotools/source/i18n/textsearch.cxx
M unotools/source/misc/fontdefs.cxx
M vcl/source/edit/xtextedt.cxx
14 files changed, 135 insertions(+), 215 deletions(-)



diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 69fac7d..306f056 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -84,13 +84,6 @@
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::linguistic2;
 
-void Swapsal_uIt16s( sal_uInt16& rX, sal_uInt16& rY )
-{
-    sal_uInt16 n = rX;
-    rX = rY;
-    rY = n;
-}
-
 EditPaM ImpEditEngine::Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, EditSelection aSel, SvKeyValueIterator* pHTTPHeaderAttrs )
 {
     sal_Bool _bUpdate = GetUpdateMode();
@@ -2611,8 +2604,8 @@
 
         ContentNode* pNode = aEditDoc.GetObject( nNode );
 
-        sal_uInt16 nStartPos = 0;
-        sal_uInt16 nEndPos = pNode->Len();
+        sal_Int32 nStartPos = 0;
+        sal_Int32 nEndPos = (sal_Int32)pNode->Len();
         if ( nNode == nStartNode )
         {
             if ( bBack )
@@ -2633,11 +2626,11 @@
         bool bFound = false;
         if ( bBack )
         {
-            Swapsal_uIt16s( nStartPos, nEndPos );
-            bFound = aSearcher.SearchBkwrd( aParaStr, &nStartPos, &nEndPos);
+            {sal_Int32 nt = nStartPos; nStartPos = nEndPos; nEndPos = nt;}
+            bFound = aSearcher.SearchBackward( aParaStr, &nStartPos, &nEndPos);
         }
         else
-            bFound = aSearcher.SearchFrwrd( aParaStr, &nStartPos, &nEndPos);
+            bFound = aSearcher.SearchForward( aParaStr, &nStartPos, &nEndPos);
 
         if ( bFound )
         {
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index 1a07e8b..31c1a0e 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -159,16 +159,9 @@
                     search forward: start <= end
                     search backward: end <= start
     */
-    int SearchFrwrd( const String &rStr,
-                    xub_StrLen* pStart, xub_StrLen* pEnde,
-                    ::com::sun::star::util::SearchResult* pSrchResult = 0 );
     bool SearchForward( const OUString &rStr,
                         sal_Int32* pStart, sal_Int32* pEnd,
                         ::com::sun::star::util::SearchResult* pRes = 0 );
-    int SearchBkwrd( const String &rStr,
-                    xub_StrLen* pStart, xub_StrLen* pEnde,
-                    ::com::sun::star::util::SearchResult* pSrchResult = 0 );
-
     bool SearchBackward( const OUString &rStr,
                          sal_Int32* pStart, sal_Int32* pEnde,
                          ::com::sun::star::util::SearchResult* pSrchResult = 0 );
@@ -177,7 +170,7 @@
                     const ::com::sun::star::lang::Locale& rLocale );
 
     /* replace back references in the replace string by the sub expressions from the search result */
-    void ReplaceBackReferences( String& rReplaceStr, const String &rStr, const ::com::sun::star::util::SearchResult& rResult );
+    void ReplaceBackReferences( OUString& rReplaceStr, const OUString &rStr, const ::com::sun::star::util::SearchResult& rResult );
 
 };
 
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index 5831490..b2bdc35 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -2088,9 +2088,9 @@
             aSearchOptions.searchFlag = 0x00000100;
             aSearchOptions.searchString = m_aCounterFunction.m_sSearchString;
             utl::TextSearch aTextSearch(aSearchOptions);
-            xub_StrLen start = 0;
-            xub_StrLen end = sFormula.Len();
-            if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && start == 0 && end == sFormula.Len()) // counter function found
+            sal_Int32 start = 0;
+            sal_Int32 end = (sal_Int32)sFormula.Len();
+            if ( aTextSearch.SearchForward(sFormula, &start, &end) && start == 0 && end == (sal_Int32)sFormula.Len()) // counter function found
             {
                 const uno::Reference< report::XGroup > xGroup(aFind.first->second.second,uno::UNO_QUERY);
                 if ( xGroup.is() )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 0058cac..371a5f4 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1375,8 +1375,8 @@
 
         if ( bRealRegExp || bTestRegExp )
         {
-            xub_StrLen nStart = 0;
-            xub_StrLen nEnd   = aCellStr.getLength();
+            sal_Int32 nStart = 0;
+            sal_Int32 nEnd   = aCellStr.getLength();
 
             // from 614 on, nEnd is behind the found text
             bool bMatch = false;
@@ -1385,12 +1385,12 @@
                 nEnd = 0;
                 nStart = aCellStr.getLength();
                 bMatch = (bool) rEntry.GetSearchTextPtr( mrParam.bCaseSens )
-                    ->SearchBkwrd( aCellStr, &nStart, &nEnd );
+                    ->SearchBackward( aCellStr, &nStart, &nEnd );
             }
             else
             {
                 bMatch = (bool) rEntry.GetSearchTextPtr( mrParam.bCaseSens )
-                    ->SearchFrwrd( aCellStr, &nStart, &nEnd );
+                    ->SearchForward( aCellStr, &nStart, &nEnd );
             }
             if ( bMatch && bMatchWholeCell
                     && (nStart != 0 || nEnd != aCellStr.getLength()) )
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 17f62da..e2a3bcb 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -97,21 +97,21 @@
             default:
                 break;
         }
-        xub_StrLen nStart = 0;
-        xub_StrLen nEnd = aString.getLength();
+        sal_Int32 nStart = 0;
+        sal_Int32 nEnd = aString.getLength();
         ::com::sun::star::util::SearchResult aSearchResult;
         if (pSearchText)
         {
             if ( bDoBack )
             {
                 xub_StrLen nTemp=nStart; nStart=nEnd; nEnd=nTemp;
-                bFound = (bool)(pSearchText->SearchBkwrd(aString, &nStart, &nEnd, &aSearchResult));
+                bFound = (bool)(pSearchText->SearchBackward(aString, &nStart, &nEnd, &aSearchResult));
                 // change results to definition before 614:
                 --nEnd;
             }
             else
             {
-                bFound = (bool)(pSearchText->SearchFrwrd(aString, &nStart, &nEnd, &aSearchResult));
+                bFound = (bool)(pSearchText->SearchForward(aString, &nStart, &nEnd, &aSearchResult));
                 // change results to definition before 614:
                 --nEnd;
             }
@@ -153,7 +153,7 @@
                 if ( nEnd < nStart || nEnd == STRING_MAXLEN )
                     bRepeat = false;
 
-                String sReplStr = rSearchItem.GetReplaceString();
+                OUString sReplStr = rSearchItem.GetReplaceString();
                 if (rSearchItem.GetRegExp())
                 {
                     pSearchText->ReplaceBackReferences( sReplStr, aString, aSearchResult );
@@ -178,7 +178,7 @@
                 }
                 else
                 {
-                    nStart = sal::static_int_cast<xub_StrLen>( nStart + sReplStr.Len() );
+                    nStart = sal::static_int_cast<xub_StrLen>( nStart + sReplStr.getLength() );
                     nEnd = aString.getLength();
                 }
 
@@ -190,13 +190,13 @@
                     else if (bDoBack)
                     {
                         xub_StrLen nTemp=nStart; nStart=nEnd; nEnd=nTemp;
-                        bRepeat = ((bool)(pSearchText->SearchBkwrd(aString, &nStart, &nEnd, &aSearchResult)));
+                        bRepeat = ((bool)(pSearchText->SearchBackward(aString, &nStart, &nEnd, &aSearchResult)));
                         // change results to definition before 614:
                         --nEnd;
                     }
                     else
                     {
-                        bRepeat = ((bool)(pSearchText->SearchFrwrd(aString, &nStart, &nEnd, &aSearchResult)));
+                        bRepeat = ((bool)(pSearchText->SearchForward(aString, &nStart, &nEnd, &aSearchResult)));
                         // change results to definition before 614:
                         --nEnd;
                     }
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c4960c5..2d02ba9 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -930,12 +930,12 @@
             OSL_ENSURE(rEntry.GetQueryItem().maString.equals(*rComp.pVal[1]), "ScInterpreter::CompareFunc: broken options");
             if (pOptions->bRegEx)
             {
-                xub_StrLen nStart = 0;
-                xub_StrLen nStop  = rComp.pVal[0]->Len();
+                sal_Int32 nStart = 0;
+                sal_Int32 nStop  = (sal_Int32)rComp.pVal[0]->Len();
                 bool bMatch = rEntry.GetSearchTextPtr(
-                        !pOptions->bIgnoreCase)->SearchFrwrd( *rComp.pVal[0],
+                        !pOptions->bIgnoreCase)->SearchForward( *rComp.pVal[0],
                             &nStart, &nStop);
-                if (bMatch && pOptions->bMatchWholeCell && (nStart != 0 || nStop != rComp.pVal[0]->Len()))
+                if (bMatch && pOptions->bMatchWholeCell && (nStart != 0 || nStop != (sal_Int32)rComp.pVal[0]->Len()))
                     bMatch = false;     // RegEx must match entire string.
                 fRes = (bMatch ? 0 : 1);
             }
@@ -8846,8 +8846,8 @@
             fAnz = 1.0;
         String sStr = GetString();
         OUString SearchStr = GetString();
-        xub_StrLen nPos = (xub_StrLen) fAnz - 1;
-        xub_StrLen nEndPos = sStr.Len();
+        sal_Int32 nPos = fAnz - 1;
+        sal_Int32 nEndPos = (sal_Int32)sStr.Len();
         if( nPos >= nEndPos )
             PushNoValue();
         else
@@ -8857,7 +8857,7 @@
                 utl::SearchParam::SRCH_REGEXP : utl::SearchParam::SRCH_NORMAL);
             utl::SearchParam sPar(SearchStr, eSearchType, false, false, false);
             utl::TextSearch sT( sPar, *ScGlobal::pCharClass );
-            int nBool = sT.SearchFrwrd(sStr, &nPos, &nEndPos);
+            int nBool = sT.SearchForward(sStr, &nPos, &nEndPos);
             if (!nBool)
                 PushNoValue();
             else
diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx
index 2e393f0..5f3ea35 100644
--- a/svx/source/form/fmsrcimp.cxx
+++ b/svx/source/form/fmsrcimp.cxx
@@ -603,8 +603,9 @@
 
         // (don't care about case here, this is done by the TextSearch object, 'cause we passed our case parameter to it)
 
-        xub_StrLen nStart = 0, nEnd = (xub_StrLen)sCurrentCheck.getLength();
-        bFound = aLocalEngine.SearchFrwrd(sCurrentCheck, &nStart, &nEnd);
+        sal_Int32 nStart = 0;
+        sal_Int32 nEnd = sCurrentCheck.getLength();
+        bFound = aLocalEngine.SearchForward(sCurrentCheck, &nStart, &nEnd);
             // das heisst hier 'forward' aber das bezieht sich nur auf die Suche innerhalb von sCurrentCheck, hat also mit
             // der Richtung meines Datensatz-Durchwanderns nix zu tun (darum kuemmert sich MoveField)
 
@@ -613,21 +614,21 @@
         {
             switch (m_nPosition)
             {
-                case MATCHING_WHOLETEXT :
-                    if (nEnd != sCurrentCheck.getLength())
-                    {
-                        bFound = false;
-                        break;
-                    }
-                    // laeuft in den naechsten Case rein !
-                case MATCHING_BEGINNING :
-                    if (nStart != 0)
-                        bFound = false;
+            case MATCHING_WHOLETEXT :
+                if (nEnd != sCurrentCheck.getLength())
+                {
+                    bFound = false;
                     break;
-                case MATCHING_END :
-                    if (nEnd != sCurrentCheck.getLength())
-                        bFound = false;
-                    break;
+                }
+                // laeuft in den naechsten Case rein !
+            case MATCHING_BEGINNING :
+                if (nStart != 0)
+                    bFound = false;
+                break;
+            case MATCHING_END :
+                if (nEnd != sCurrentCheck.getLength())
+                    bFound = false;
+                break;
             }
         }
 
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 6c2359f..a18fb6e 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -479,10 +479,15 @@
             pScriptIter->Next();
         }
 
+        sal_Int32 ns = (sal_Int32)nStart;
+        sal_Int32 ne = (sal_Int32)nEnd;
+
         if( nSearchScript == nCurrScript &&
-                (rSTxt.*fnMove->fnSearch)( sCleanStr, &nStart, &nEnd, 0 ) &&
-                !(bZeroMatch = (nStart == nEnd)))
+                (rSTxt.*fnMove->fnSearch)( sCleanStr, &ns, &ne, 0 ) &&
+                !(bZeroMatch = (ns == ne)))
         {
+            nStart = (sal_uInt16)ns;
+            nEnd = (sal_uInt16)ne;
             // set section correctly
             *GetPoint() = *pPam->GetPoint();
             SetMark();
@@ -669,7 +674,7 @@
             SearchResult aResult;
             if( aSTxt.SearchForward( rStr, &nStart, &nEnd, &aResult ) )
             {
-                String aReplaceStr( rSearchOpt.replaceString );
+                OUString aReplaceStr( rSearchOpt.replaceString );
                 aSTxt.ReplaceBackReferences( aReplaceStr, rStr, aResult );
                 pRet = new String( aReplaceStr );
             }
diff --git a/sw/source/core/crsr/paminit.cxx b/sw/source/core/crsr/paminit.cxx
index 17fe0e0..0e3e161 100644
--- a/sw/source/core/crsr/paminit.cxx
+++ b/sw/source/core/crsr/paminit.cxx
@@ -28,7 +28,7 @@
     /* fnSections   */  &GoEndSection,
     /* fnCmpOp      */  &SwPosition::operator<,
     /* fnGetHint    */  &GetFrwrdTxtHint,
-    /* fnSearch     */  &utl::TextSearch::SearchFrwrd,
+    /* fnSearch     */  &utl::TextSearch::SearchForward,
     /* fnSection    */  &SwNodes::GoStartOfSection
 };
 
@@ -39,7 +39,7 @@
     /* fnSections   */  &GoStartSection,
     /* fnCmpOp      */  &SwPosition::operator>,
     /* fnGetHint    */  &GetBkwrdTxtHint,
-    /* fnSearch     */  &utl::TextSearch::SearchBkwrd,
+    /* fnSearch     */  &utl::TextSearch::SearchBackward,
     /* fnSection    */  &SwNodes::GoEndOfSection
 };
 
diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx
index b20c4e9..5fda2c6 100644
--- a/sw/source/core/inc/pamtyp.hxx
+++ b/sw/source/core/inc/pamtyp.hxx
@@ -68,8 +68,8 @@
 typedef void (*GoSection)( SwPosition* );
 typedef bool (SwPosition:: *CmpOp)( const SwPosition& ) const;
 typedef const SwTxtAttr* (*GetHint)( const SwpHints&, sal_uInt16&, xub_StrLen );
-typedef int (utl::TextSearch:: *SearchTxt)( const String&, xub_StrLen*,
-                    xub_StrLen*, ::com::sun::star::util::SearchResult* );
+typedef bool (utl::TextSearch:: *SearchTxt)( const OUString&, sal_Int32*,
+                    sal_Int32*, ::com::sun::star::util::SearchResult* );
 typedef void (SwNodes:: *MvSection)( SwNodeIndex * ) const;
 
 
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 3d08aac..cbee3e6 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -1040,9 +1040,9 @@
                 sal_Int32 nIndex = 0;
                 while( nIndex != -1 )
                 {
-                    String aToken( pLine->getToken( 0, ',', nIndex ) );
+                    OUString aToken( pLine->getToken( 0, ',', nIndex ) );
                     for( int k = 0; k < 32; k++ )
-                        if( aToken.EqualsIgnoreCaseAscii( pAttribNames[k] ) )
+                        if( aToken.equalsIgnoreAsciiCaseAscii( pAttribNames[k] ) )
                         {
                             type |= 1 << k;
                             break;
diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx
index 9d8470a..f75a155 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <rtl/ustrbuf.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/util/TextSearch.hpp>
@@ -206,37 +207,6 @@
  * methods, such as ordinary string searching or regular expression
  * matching, using the method pointer.
  */
-int TextSearch::SearchFrwrd( const String & rStr, xub_StrLen* pStart,
-                            xub_StrLen* pEnde, SearchResult* pRes )
-{
-    int nRet = 0;
-    try
-    {
-        if( xTextSearch.is() )
-        {
-            SearchResult aRet( xTextSearch->searchForward(
-                                                    rStr, *pStart, *pEnde ));
-            if( aRet.subRegExpressions > 0 )
-            {
-                nRet = 1;
-                // the XTextsearch returns in startOffset the higher position
-                // and the endposition is always exclusive.
-                // The caller of this function will have in startPos the
-                // lower pos. and end
-                *pStart = (xub_StrLen)aRet.startOffset[ 0 ];
-                *pEnde = (xub_StrLen)aRet.endOffset[ 0 ];
-                if( pRes )
-                    *pRes = aRet;
-            }
-        }
-    }
-    catch ( Exception& )
-    {
-        SAL_WARN( "unotools.i18n", "SearchForward: Exception caught!" );
-    }
-    return nRet;
-}
-
 bool TextSearch::SearchForward( const OUString &rStr,
                                 sal_Int32* pStart, sal_Int32* pEnd,
                                 ::com::sun::star::util::SearchResult* pRes)
@@ -270,37 +240,6 @@
 }
 
 
-int TextSearch::SearchBkwrd( const String & rStr, xub_StrLen* pStart,
-                            xub_StrLen* pEnde, SearchResult* pRes )
-{
-    int nRet = 0;
-    try
-    {
-        if( xTextSearch.is() )
-        {
-            SearchResult aRet( xTextSearch->searchBackward(
-                                                    rStr, *pStart, *pEnde ));
-            if( aRet.subRegExpressions )
-            {
-                nRet = 1;
-                // the XTextsearch returns in startOffset the higher position
-                // and the endposition is always exclusive.
-                // The caller of this function will have in startPos the
-                // lower pos. and end
-                *pEnde = (xub_StrLen)aRet.startOffset[ 0 ];
-                *pStart = (xub_StrLen)aRet.endOffset[ 0 ];
-                if( pRes )
-                    *pRes = aRet;
-            }
-        }
-    }
-    catch ( Exception& )
-    {
-        SAL_WARN( "unotools.i18n", "SearchBackward: Exception caught!" );
-    }
-    return nRet;
-}
-
 bool TextSearch::SearchBackward( const OUString & rStr, sal_Int32* pStart,
                                  sal_Int32* pEnde, SearchResult* pRes )
 {
@@ -331,103 +270,92 @@
     return nRet;
 }
 
-void TextSearch::ReplaceBackReferences( String& rReplaceStr, const String &rStr, const SearchResult& rResult )
+void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, const OUString &rStr, const SearchResult& rResult )
 {
     if( rResult.subRegExpressions > 0 )
     {
-        OUString sTab( '\t' );
-        sal_Unicode sSrchChrs[] = {'\\', '&', '$', 0};
-        String sTmp;
-        xub_StrLen nPos = 0;
         sal_Unicode sFndChar;
-        while( STRING_NOTFOUND != ( nPos = rReplaceStr.SearchChar( sSrchChrs, nPos )) )
+        sal_Int32 i;
+        OUStringBuffer sBuff(rReplaceStr.getLength()*4);
+        for(i = 0; i < rReplaceStr.getLength(); i++)
         {
-            if( rReplaceStr.GetChar( nPos ) == '&')
+            if( rReplaceStr[i] == '&')
             {
-                sal_uInt16 nStart = (sal_uInt16)(rResult.startOffset[0]);
-                sal_uInt16 nLength = (sal_uInt16)(rResult.endOffset[0] - rResult.startOffset[0]);
-                rReplaceStr.Erase( nPos, 1 );   // delete ampersand
-                // replace by found string
-                rReplaceStr.Insert( rStr, nStart, nLength, nPos );
-                // jump over
-                nPos = nPos + nLength;
+                sal_Int32 nStart = rResult.startOffset[0];
+                sal_Int32 nLength = rResult.endOffset[0] - rResult.startOffset[0];
+                sBuff.append(rStr.getStr() + nStart, nLength);
             }
-            else if( rReplaceStr.GetChar( nPos ) == '$')
+            else if( rReplaceStr[i] == '$' && i < rReplaceStr.getLength() - 1)
             {
-                if( nPos + 1 < rReplaceStr.Len())
-                {
-                    sFndChar = rReplaceStr.GetChar( nPos + 1 );
-                    switch(sFndChar)
-                    {   // placeholder for a backward reference?
-                        case '0':
-                        case '1':
-                        case '2':
-                        case '3':
-                        case '4':
-                        case '5':
-                        case '6':
-                        case '7':
-                        case '8':
-                        case '9':
+                sFndChar = rReplaceStr[ i + 1 ];
+                switch(sFndChar)
+                {   // placeholder for a backward reference?
+                case '0':
+                case '1':
+                case '2':
+                case '3':
+                case '4':
+                case '5':
+                case '6':
+                case '7':
+                case '8':
+                case '9':
+                    {
+                        int j = sFndChar - '0'; // index
+                        if(j < rResult.subRegExpressions)
                         {
-                            rReplaceStr.Erase( nPos, 2 );   // delete both
-                            int i = sFndChar - '0'; // index
-                            if(i < rResult.subRegExpressions)
+                            sal_Int32 nSttReg = rResult.startOffset[j];
+                            sal_Int32 nRegLen = rResult.endOffset[j];
+                            if( nRegLen > nSttReg )
                             {
-                                sal_uInt16 nSttReg = (sal_uInt16)(rResult.startOffset[i]);
-                                sal_uInt16 nRegLen = (sal_uInt16)(rResult.endOffset[i]);
-                                if( nRegLen > nSttReg )
-                                    nRegLen = nRegLen - nSttReg;
-                                else
-                                {
-                                    nRegLen = nSttReg - nRegLen;
-                                    nSttReg = (sal_uInt16)(rResult.endOffset[i]);
-                                }
-                                // Copy reference from found string
-                                sTmp = rStr.Copy((sal_uInt16)nSttReg, (sal_uInt16)nRegLen);
-                                // insert
-                                rReplaceStr.Insert( sTmp, nPos );
-                                // and step over
-                                nPos = nPos + sTmp.Len();
+                                nRegLen = nRegLen - nSttReg;
                             }
+                            else
+                            {
+                                nRegLen = nSttReg - nRegLen;
+                                nSttReg = rResult.endOffset[j];
+                            }
+                            // Copy reference from found string
+                            sBuff.append(rStr.getStr() + nSttReg, nRegLen);
                         }
-                        break;
-                        default:
-                            nPos += 2; // leave both chars unchanged
-                            break;
+                        i += 1;
                     }
+                    break;
+                default:
+                    sBuff.append(rReplaceStr[i]);
+                    sBuff.append(rReplaceStr[i+1]);
+                    i += 1;
+                    break;
                 }
-                else
-                    ++nPos;
+            }
+            else if( rReplaceStr[i] == '\\' && i < rReplaceStr.getLength() - 1)
+            {
+                sFndChar = rReplaceStr[ i+1 ];
+                switch(sFndChar)
+                {
+                case '\\':
+                case '&':
+                case '$':
+                    sBuff.append(sFndChar);
+                    i+=1;
+                    break;
+                case 't':
+                    sBuff.append('\t');
+                    i += 1;
+                    break;
+                default:
+                    sBuff.append(rReplaceStr[i]);
+                    sBuff.append(rReplaceStr[i+1]);
+                    i += 1;
+                    break;
+                }
             }
             else
             {
-                // at least another character?
-                if( nPos + 1 < rReplaceStr.Len())
-                {
-                    sFndChar = rReplaceStr.GetChar( nPos + 1 );
-                    switch(sFndChar)
-                    {
-                        case '\\':
-                        case '&':
-                        case '$':
-                            rReplaceStr.Erase( nPos, 1 );
-                            nPos++;
-                        break;
-                        case 't':
-                            rReplaceStr.Erase( nPos, 2 ); // delete both
-                            rReplaceStr.Insert( sTab, nPos ); // insert tabulator
-                            nPos++; // step over
-                        break;
-                        default:
-                            nPos += 2; // ignore both characters
-                        break;
-                    }
-                }
-                else
-                    ++nPos;
+                sBuff.append(rReplaceStr[i]);
             }
         }
+        rReplaceStr = sBuff.makeStringAndClear();
     }
 }
 
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index 9180e5b..c266ba0 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -473,14 +473,14 @@
     {
         // no token delimiter found => handle last token
         rIndex = -1;
-        nTokenLen = STRING_LEN;
 
         // optimize if the token string consists of just one token
         if( !nTokenStart )
             return rTokenStr;
+        nTokenLen = nStringLen - nTokenStart;
     }
 
-    return String( rTokenStr, nTokenStart, nTokenLen );
+    return OUString( rTokenStr.getStr() + nTokenStart, nTokenLen );
 }
 
 // =======================================================================
diff --git a/vcl/source/edit/xtextedt.cxx b/vcl/source/edit/xtextedt.cxx
index ace53c7..3fc0fd7 100644
--- a/vcl/source/edit/xtextedt.cxx
+++ b/vcl/source/edit/xtextedt.cxx
@@ -166,9 +166,9 @@
             bForward ?  ( nNode <= nEndNode) : ( nNode >= nEndNode );
             bForward ? nNode++ : nNode-- )
     {
-        String aText = GetText( nNode );
-        sal_uInt16 nStartPos = 0;
-        sal_uInt16 nEndPos = aText.Len();
+        OUString aText = GetText( nNode );
+        sal_Int32 nStartPos = 0;
+        sal_Int32 nEndPos = aText.getLength();
         if ( nNode == nStartNode )
         {
             if ( bForward )
@@ -185,9 +185,9 @@
         }
 
         if ( bForward )
-            bFound = aSearcher.SearchFrwrd( aText, &nStartPos, &nEndPos );
+            bFound = aSearcher.SearchForward( aText, &nStartPos, &nEndPos );
         else
-            bFound = aSearcher.SearchBkwrd( aText, &nEndPos, &nStartPos );
+            bFound = aSearcher.SearchBackward( aText, &nEndPos, &nStartPos );
 
         if ( bFound )
         {
@@ -197,7 +197,7 @@
             rSel.GetEnd().GetIndex() = nEndPos;
             // Select over the paragraph?
             // FIXME  This should be max long...
-            if( nEndPos == sal::static_int_cast<sal_uInt16>(-1) ) // sal_uInt16 for 0 and -1 !
+            if( nEndPos == -1 ) // sal_uInt16 for 0 and -1 !
             {
                 if ( (rSel.GetEnd().GetPara()+1) < GetParagraphCount() )
                 {

-- 
To view, visit https://gerrit.libreoffice.org/4249
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1934ba31b966ee79f10e200c37c8db4924272cb4
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Norbert Thiebaud <nthiebaud at gmail.com>



More information about the LibreOffice mailing list