Index: regexp/source/reclass.cxx =================================================================== RCS file: /cvs/external/regexp/source/reclass.cxx,v retrieving revision 1.3 diff -u -p -r1.3 reclass.cxx --- regexp/source/reclass.cxx 25 Feb 2004 13:59:59 -0000 1.3 +++ regexp/source/reclass.cxx 11 Feb 2006 13:29:25 -0000 @@ -61,7 +61,7 @@ `re_match_2' returns information about at least this many registers the first time a `regs' structure is passed. */ #ifndef RE_NREGS -# define RE_NREGS 30 +# define RE_NREGS 10 #endif @@ -2202,6 +2202,7 @@ Regexpr::re_match2(struct re_registers * else { regs->start[mcnt] = (sal_Int32) POINTER_TO_OFFSET(regstart[mcnt]); regs->end[mcnt] = (sal_Int32) POINTER_TO_OFFSET(regend[mcnt]); + regs->num_of_match++; } } Index: i18npool/source/search/textsearch.cxx =================================================================== RCS file: /cvs/l10n/i18npool/source/search/textsearch.cxx,v retrieving revision 1.7 diff -u -p -r1.7 textsearch.cxx --- i18npool/source/search/textsearch.cxx 1 Nov 2005 14:57:03 -0000 1.7 +++ i18npool/source/search/textsearch.cxx 11 Feb 2006 13:30:23 -0000 @@ -753,7 +753,7 @@ SearchResult TextSearch::RESrchFrwrd( co throw(RuntimeException) { SearchResult aRet; - sal_Int32 nOffset = 0; + sal_Int32 nOffset = 0, i = 0; aRet.subRegExpressions = 0; OUString aStr( searchStr ); @@ -778,13 +778,17 @@ SearchResult TextSearch::RESrchFrwrd( co if( regs.num_of_match > 0 && (regs.start[0] != -1 && regs.end[0] != -1) ) { - aRet.subRegExpressions = 1; - aRet.startOffset.realloc(1); - aRet.endOffset.realloc(1); + aRet.subRegExpressions = regs.num_of_match; + aRet.startOffset.realloc(regs.num_of_match); + aRet.endOffset.realloc(regs.num_of_match); nOffset = bSearchInSel ? startPos : 0; - aRet.startOffset[0] = regs.start[0] + nOffset; - aRet.endOffset[0] = regs.end[0] + nOffset; + while(i < regs.num_of_match) + { + aRet.startOffset[i] = regs.start[i] + nOffset; + aRet.endOffset[i] = regs.end[i] + nOffset; + i++; + } } if ( regs.num_regs > 0 ) { @@ -809,7 +813,7 @@ SearchResult TextSearch::RESrchBkwrd( co aRet.subRegExpressions = 0; OUString aStr( searchStr ); - sal_Int32 nOffset = 0; + sal_Int32 nOffset = 0, i; sal_Int32 nStrEnde = aStr.getLength() == endPos ? 0 : endPos; bool bSearchInSel = (0 != (( SearchFlags::REG_NOT_BEGINOFLINE | @@ -833,15 +837,17 @@ SearchResult TextSearch::RESrchBkwrd( co if( regs.num_of_match > 0 && (regs.start[0] != -1 && regs.end[0] != -1) ) { - aRet.subRegExpressions = 1; - aRet.startOffset.realloc(1); - aRet.endOffset.realloc(1); - // aRet.startOffset[0] = regs.start[0]; - // aRet.endOffset[0] = regs.end[0]; + aRet.subRegExpressions = regs.num_of_match; + aRet.startOffset.realloc(regs.num_of_match); + aRet.endOffset.realloc(regs.num_of_match); nOffset = bSearchInSel ? nStrEnde : 0; - aRet.startOffset[0] = regs.end[0] + nOffset; - aRet.endOffset[0] = regs.start[0] + nOffset; + while(i < regs.num_of_match) + { + aRet.startOffset[i] = regs.end[i] + nOffset; + aRet.endOffset[i] = regs.start[i] + nOffset; + i++; + } } if ( regs.num_regs > 0 ) { Index: unotools/source/i18n/textsearch.cxx =================================================================== RCS file: /cvs/util/unotools/source/i18n/textsearch.cxx,v retrieving revision 1.8 diff -u -p -r1.8 textsearch.cxx --- unotools/source/i18n/textsearch.cxx 9 Sep 2005 09:46:01 -0000 1.8 +++ unotools/source/i18n/textsearch.cxx 11 Feb 2006 13:31:50 -0000 @@ -247,13 +247,13 @@ int TextSearch::SearchFrwrd( const Strin { SearchResult aRet( xTextSearch->searchForward( rStr, *pStart, *pEnde )); - if( 1 == aRet.subRegExpressions ) + if(aRet.subRegExpressions ) { nRet = 1; // the XTextsearch returns in startOffset the higher position - // and the endposition is allways exclusive. + // and the endposition is always exclusive. // The caller of this function will have in startPos the - // lower pos. and end + // higher pos. and end *pStart = (xub_StrLen)aRet.startOffset[ 0 ]; *pEnde = (xub_StrLen)aRet.endOffset[ 0 ]; if( pRes ) @@ -282,7 +282,7 @@ int TextSearch::SearchBkwrd( const Strin { nRet = 1; // the XTextsearch returns in startOffset the higher position - // and the endposition is allways exclusive. + // 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 ]; Index: sw/source/core/crsr/findtxt.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/crsr/findtxt.cxx,v retrieving revision 1.16 diff -u -p -r1.16 findtxt.cxx --- sw/source/core/crsr/findtxt.cxx 9 Sep 2005 03:05:15 -0000 1.16 +++ sw/source/core/crsr/findtxt.cxx 11 Feb 2006 13:32:32 -0000 @@ -290,8 +290,8 @@ BYTE SwPaM::Find( const SearchOptions& r pScriptIter->Next(); } - if( nSearchScript == nCurrScript && - (rSTxt.*fnMove->fnSearch)( sCleanStr, &nStart, &nEnde, 0 )) + if ( nSearchScript == nCurrScript && + (rSTxt.*fnMove->fnSearch)( sCleanStr, &nStart, &nEnde, rSearchOpt.algorithmType == SearchAlgorithms_REGEXP ? &searchResult : 0 )) { // setze den Bereich richtig *GetPoint() = *pPam->GetPoint(); Index: sw/inc/pam.hxx =================================================================== RCS file: /cvs/sw/sw/inc/pam.hxx,v retrieving revision 1.14 diff -u -p -r1.14 pam.hxx --- sw/inc/pam.hxx 8 Nov 2005 17:13:30 -0000 1.14 +++ sw/inc/pam.hxx 11 Feb 2006 13:35:41 -0000 @@ -60,6 +60,10 @@ #include "swdllapi.h" #endif +#ifndef _COM_SUN_STAR_UTIL_XTEXTSEARCH_HPP_ +#include +#endif + class SwFmt; class SfxPoolItem; class SfxItemSet; @@ -193,6 +197,7 @@ public: SwMoveFn fnMove = fnMoveForward, const SwPaM *pPam =0, FASTBOOL bInReadOnly = FALSE ); + ::com::sun::star::util::SearchResult searchResult; inline FASTBOOL IsInFrontOfLabel() const { return bIsInFrontOfLabel; } inline void _SetInFrontOfLabel( FASTBOOL bNew ) { bIsInFrontOfLabel = bNew; } Index: sw/source/core/doc/docedt.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/doc/docedt.cxx,v retrieving revision 1.25 diff -u -p -r1.25 docedt.cxx --- sw/source/core/doc/docedt.cxx 9 Sep 2005 03:11:38 -0000 1.25 +++ sw/source/core/doc/docedt.cxx 17 Feb 2006 13:34:28 -0000 @@ -2048,24 +2048,86 @@ uno::Reference< XHyphenatedWord > SwDoc return aHyphArg.GetHyphWord(); // will be set by lcl_HyphenateNode } -void ReplaceTabsStr( String& rStr, const String& rSrch, const String& rRepl ) +void ActualStrReplace( String& rReplStr, const String& rFndStr, SwPaM& rPam ) { + String sTab( '\t' ); + sal_Unicode sSrchChrs[] = {'\\', '&', 0}; + String sTmp; + xub_StrLen nPos = 0; - while( STRING_NOTFOUND != ( nPos = rStr.Search( rSrch, nPos )) ) + sal_Char sFndChar; + while( STRING_NOTFOUND != ( nPos = rReplStr.SearchChar( sSrchChrs, nPos )) ) { - // wurde das escaped? - if( nPos && '\\' == rStr.GetChar( nPos-1 )) + // Ampersand gefunden? + if(rReplStr.GetChar( nPos ) == '&') { - // noch nicht am Ende ?? - rStr.Erase( nPos-1, 1 ); // den \\ noch loeschen - if( nPos >= rStr.Len() ) - break; + rReplStr.Erase( nPos, 1 ); // Ampersand löschen + // kompletten Fundstring einsetzen + rReplStr.Insert( rFndStr, nPos ); + // und drübersteigen + nPos += rFndStr.Len(); } else { - rStr.Erase( nPos, rSrch.Len() ); - rStr.Insert( rRepl, nPos ); - nPos += rRepl.Len(); + // noch mindestens ein Zeichen mehr vorhanden? + if( nPos + 1 < rReplStr.Len()) + { + sFndChar = rReplStr.GetChar( nPos + 1 ); + switch(sFndChar) + { + // sind beide zusammen ein escapter Backslash + // oder ein escaptes Ampersand? + case '\\': + case '&': + rReplStr.Erase( nPos, 1 ); // dann unescapen + nPos++; // und dann drübersteigen + break; + // sind beide zusammen ein Tab? + case 't': + rReplStr.Erase( nPos, 2 ); // beide löschen + rReplStr.Insert( sTab, nPos ); // echten Tab einsetzen + nPos++; // und dann drübersteigen + break; + // sind beide zusammen ein Platzhalter für ein Register? + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + // index draus machen + int i = sFndChar - '0'; // geht's besser? + // ist das angegebene Register überhaupt befüllt? + // was tun wenn nicht? Stehen lassen, Fehlermeldung oder entfernen (wie jetzt)? + if(i <= rPam.searchResult.subRegExpressions) + { + rReplStr.Erase( nPos, 2 ); // beide löschen + // nStt ist der Anfang der Selektion + // die Positionen in den Registern sind absolut und + // müssen erst auf den Selektionsanfang relativiert werden + xub_StrLen nSttReg = rPam.searchResult.startOffset[i] - + rPam.searchResult.startOffset[0], + nRegLen = rPam.searchResult.endOffset[i] - + rPam.searchResult.startOffset[i]; + // Registerteil aus Fundstring kopieren, + sTmp = rFndStr.Copy(nSttReg, nRegLen); + // einsetzen + rReplStr.Insert( sTmp, nPos ); + // und drübersteigen + nPos += sTmp.Len(); + } + break; + // folgt ein Zeichen ohne Sonderbedeutung? + // was dann? Stehen lassen(wie jetzt), Fehlermeldung oder entfernen? + default: + nPos += 2; // beide Zeichen übergehen + break; + } + } } } } @@ -2143,10 +2205,7 @@ sal_Bool SwDoc::Replace( SwPaM& rPam, co sFndStr.EraseAllChars( CH_TXTATR_BREAKWORD ); sFndStr.EraseAllChars( CH_TXTATR_INWORD ); - String sTmp( String::CreateFromAscii( - RTL_CONSTASCII_STRINGPARAM( "\\t" ))); - ReplaceTabsStr( sRepl, String( '&' ), sFndStr ); - ReplaceTabsStr( sRepl, sTmp, String( '\t' ) ); + ActualStrReplace(sRepl, sFndStr, rPam); } SwDataChanged aTmp( aDelPam, 0 );