Author: hdu
Date: Wed May 9 13:57:20 2012
New Revision: 1336210
URL: http://svn.apache.org/viewvc?rev=1336210&view=rev
Log:
#i118925# enhance textsearch's match-group references to work for
look-ahead/look-behind
Modified:
incubator/ooo/trunk/main/i18npool/source/search/textsearch.cxx
incubator/ooo/trunk/main/sw/source/core/crsr/findtxt.cxx
Modified: incubator/ooo/trunk/main/i18npool/source/search/textsearch.cxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/i18npool/source/search/textsearch.cxx?rev=1336210&r1=1336209&r2=1336210&view=diff
==============================================================================
--- incubator/ooo/trunk/main/i18npool/source/search/textsearch.cxx (original)
+++ incubator/ooo/trunk/main/i18npool/source/search/textsearch.cxx Wed May 9
13:57:20 2012
@@ -752,7 +752,7 @@ SearchResult TextSearch::RESrchFrwrd( co
// use the ICU RegexMatcher to find the matches
UErrorCode nIcuErr = U_ZERO_ERROR;
- const IcuUniString aSearchTargetStr( (const UChar*)searchStr.getStr(),
endPos);
+ const IcuUniString aSearchTargetStr( (const UChar*)searchStr.getStr(),
searchStr.getLength());
pRegexMatcher->reset( aSearchTargetStr);
// search until there is a valid match
for(;;)
Modified: incubator/ooo/trunk/main/sw/source/core/crsr/findtxt.cxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/crsr/findtxt.cxx?rev=1336210&r1=1336209&r2=1336210&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/crsr/findtxt.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/crsr/findtxt.cxx Wed May 9
13:57:20 2012
@@ -676,36 +676,17 @@ String *ReplaceBackReferences( const Sea
if( pTxtNode && pTxtNode->IsTxtNode() && pTxtNode ==
pPam->GetCntntNode( sal_False ) )
{
utl::TextSearch aSTxt( rSearchOpt );
- String aStr( pPam->GetTxt() );
- String aSearchStr( rSearchOpt.searchString );
- String aReplaceStr( rSearchOpt.replaceString );
- aStr.EraseAllChars( CH_TXTATR_BREAKWORD );
- aStr.EraseAllChars( CH_TXTATR_INWORD );
- xub_StrLen nStart = 0;
- String sX( 'x' );
- if( pPam->Start()->nContent > 0 )
- {
- aStr.Insert( sX, 0 );
- ++nStart;
- }
- xub_StrLen nEnd = aStr.Len();
- bool bDeleteLastX = false;
- if( pPam->End()->nContent < (static_cast<const
SwTxtNode*>(pTxtNode))->GetTxt().Len() )
- {
- aStr.Insert( sX );
- bDeleteLastX = true;
- }
+ const String& rStr = static_cast<const
SwTxtNode*>(pTxtNode)->GetTxt();
+ xub_StrLen nStart = pPam->Start()->nContent.GetIndex();
+ xub_StrLen nEnd = pPam->End()->nContent.GetIndex();
SearchResult aResult;
- if( aSTxt.SearchFrwrd( aStr, &nStart, &nEnd, &aResult ) )
+ if( aSTxt.SearchFrwrd( rStr, &nStart, &nEnd, &aResult ) )
{
- if( bDeleteLastX )
- aStr.Erase( aStr.Len() - 1 );
- aSTxt.ReplaceBackReferences( aReplaceStr, aStr, aResult );
+ String aReplaceStr( rSearchOpt.replaceString );
+ aSTxt.ReplaceBackReferences( aReplaceStr, rStr, aResult );
pRet = new String( aReplaceStr );
}
}
}
return pRet;
}
-
-