summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2012-05-09 12:57:20 +0000
committerEike Rathke <erack@redhat.com>2013-03-07 19:04:50 +0100
commit9a93475d6eba53b2e1fba1585dbd11c94ea4b4a3 (patch)
tree63aa9ce8d1d67012af06847724beab23aeea5842 /sw
parent0e91b7383a5c49ab4fd52e9d3a62aeef67eb2238 (diff)
i#118925# enhance textsearch's match-group references
to work for look-ahead/look-behind (cherry picked from commit 3b83c404c56e5db5bab29ffee41f02822410d625) Conflicts: sw/source/core/crsr/findtxt.cxx Change-Id: Ia5b31628b0f2af8f93132afa4b2eabd2f533bb91
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/crsr/findtxt.cxx29
1 files changed, 6 insertions, 23 deletions
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index e251ee6a2f18..b2fbea85104b 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -659,31 +659,14 @@ String *ReplaceBackReferences( const SearchOptions& rSearchOpt, SwPaM* pPam )
if( pTxtNode && pTxtNode->IsTxtNode() && pTxtNode == pPam->GetCntntNode( sal_False ) )
{
utl::TextSearch aSTxt( rSearchOpt );
- String aStr( pPam->GetTxt() );
- String aReplaceStr( rSearchOpt.replaceString );
- aStr = comphelper::string::remove(aStr, CH_TXTATR_BREAKWORD);
- aStr = comphelper::string::remove(aStr, CH_TXTATR_INWORD);
- xub_StrLen nStart = 0;
- OUString 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().getLength())
- {
- 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 );
}
}