[Libreoffice-commits] core.git: i18npool/source sw/source
Herbert Dürr
hdu at apache.org
Thu Mar 7 10:05:12 PST 2013
i18npool/source/search/textsearch.cxx | 2 +-
sw/source/core/crsr/findtxt.cxx | 29 ++++++-----------------------
2 files changed, 7 insertions(+), 24 deletions(-)
New commits:
commit 9a93475d6eba53b2e1fba1585dbd11c94ea4b4a3
Author: Herbert Dürr <hdu at apache.org>
Date: Wed May 9 12:57:20 2012 +0000
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
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index cdca853..075cd21 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -710,7 +710,7 @@ SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr,
// 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(;;)
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index e251ee6..b2fbea8 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 );
}
}
More information about the Libreoffice-commits
mailing list