Related: fdo#38838 remove UniString::SearchBackward

Change-Id: Ia474ee07b1bd411eae8cd1ddd55c4fa83dbd5f47
This commit is contained in:
Caolán McNamara 2013-09-26 11:27:22 +02:00
parent b3c860acf3
commit b3a8056a49
20 changed files with 93 additions and 116 deletions

View File

@ -467,16 +467,15 @@ void SvxHyperlinkInternetTp::RefreshMarkWindow()
void SvxHyperlinkInternetTp::SetMarkStr ( const String& aStrMark )
{
String aStrURL ( maCbbTarget.GetText() );
OUString aStrURL ( maCbbTarget.GetText() );
const sal_Unicode sUHash = '#';
xub_StrLen nPos = aStrURL.SearchBackward( sUHash );
sal_Int32 nPos = aStrURL.lastIndexOf( sUHash );
if( nPos != STRING_NOTFOUND )
aStrURL.Erase ( nPos );
if( nPos != -1 )
aStrURL = aStrURL.copy(0, nPos);
aStrURL += sUHash;
aStrURL += aStrMark;
aStrURL += OUString(sUHash) + aStrMark;
maCbbTarget.SetText ( aStrURL );
}

View File

@ -151,7 +151,7 @@ String SvxHyphenWordDialog::EraseUnusableHyphens_Impl(
// find position nIdx after which all hyphen positions are unusable
xub_StrLen nIdx = STRING_NOTFOUND;
xub_StrLen nPos = 0, nPos1 = 0, nPos2 = 0;
xub_StrLen nPos = 0, nPos1 = 0;
if (nLen)
{
xub_StrLen nStart = 0;
@ -185,11 +185,11 @@ String SvxHyphenWordDialog::EraseUnusableHyphens_Impl(
nPos = aTxt.SearchAndReplace( aTmp, aEmpty, nPos + 1 );
// 2) remove all hyphenation positions from the start that are not considered by the core
const String aSearchRange( aTxt.Copy( 0, nPos1 ) );
nPos2 = aSearchRange.SearchBackward( '-' ); // the '-' position the core will use by default
if (nPos2 != STRING_NOTFOUND)
const OUString aSearchRange( aTxt.Copy( 0, nPos1 ) );
sal_Int32 nPos2 = aSearchRange.lastIndexOf( '-' ); // the '-' position the core will use by default
if (nPos2 != -1 )
{
String aLeft( aSearchRange.Copy( 0, nPos2 ) );
String aLeft( aSearchRange.copy( 0, nPos2 ) );
nPos = 0;
while (nPos != STRING_NOTFOUND)
{

View File

@ -2349,10 +2349,10 @@ void SvxAutoCorrectLanguageLists::MakeUserStorage_Impl()
{
try
{
String sMain(aDest.GetMainURL( INetURLObject::DECODE_TO_IURI ));
OUString sMain(aDest.GetMainURL( INetURLObject::DECODE_TO_IURI ));
sal_Unicode cSlash = '/';
xub_StrLen nSlashPos = sMain.SearchBackward(cSlash);
sMain.Erase(nSlashPos);
sal_Int32 nSlashPos = sMain.lastIndexOf(cSlash);
sMain = sMain.copy(0, nSlashPos);
::ucbhelper::Content aNewContent( sMain, uno::Reference< XCommandEnvironment >(), comphelper::getProcessComponentContext() );
Any aAny;
TransferInfo aInfo;

View File

@ -837,13 +837,13 @@ sal_Bool SvtFileDialog::createNewUserFilter( const String& _rNewFilter, sal_Bool
// if the former is not allowed (_bAllowUserDefExt = <FALSE/>), we have to use the ext of the current filter
// (if possible)
sal_Bool bUseCurFilterExt = sal_True;
String sUserFilter = _pImp->_pUserFilter->GetType();
xub_StrLen nSepPos = sUserFilter.SearchBackward( '.' );
if ( STRING_NOTFOUND != nSepPos )
OUString sUserFilter = _pImp->_pUserFilter->GetType();
sal_Int32 nSepPos = sUserFilter.lastIndexOf( '.' );
if ( nSepPos != -1 )
{
String sUserExt = sUserFilter.Copy( nSepPos + 1 );
if ( ( STRING_NOTFOUND == sUserExt.Search( '*' ) )
&& ( STRING_NOTFOUND == sUserExt.Search( '?' ) )
OUString sUserExt = sUserFilter.copy( nSepPos + 1 );
if ( ( -1 == sUserExt.indexOf( '*' ) )
&& ( -1 == sUserExt.indexOf( '?' ) )
)
bUseCurFilterExt = sal_False;
}

View File

@ -240,7 +240,6 @@ public:
xub_StrLen Search( sal_Unicode c, xub_StrLen nIndex = 0 ) const;
xub_StrLen Search( const UniString& rStr, xub_StrLen nIndex = 0 ) const;
xub_StrLen SearchAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex = 0 ) const;
xub_StrLen SearchBackward( sal_Unicode c, xub_StrLen nIndex = STRING_LEN ) const;
xub_StrLen SearchAndReplace( sal_Unicode c, sal_Unicode cRep,
xub_StrLen nIndex = 0 );

View File

@ -265,8 +265,8 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
std::list< OUString >::iterator dir;
for( dir = aDirs.begin(); dir != aDirs.end(); ++dir )
{
::std::list< String > aFiles;
::std::list< String >::iterator file;
::std::list< OUString > aFiles;
::std::list< OUString >::iterator file;
OUStringBuffer aDir( *dir );
aDir.append( sal_Unicode( '/' ) );
aDir.appendAscii( PRINTER_PPDDIR );
@ -279,8 +279,9 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton )
aFile += "/";
aFile += *file;
int nPos = file->SearchBackward( '.' );
if( file->Copy( 0, nPos ) == String( aPPD ) )
sal_Int32 nPos = file->lastIndexOf( '.' );
OUString sCopy = nPos == -1 ? *file : file->copy(0, nPos);
if( sCopy == aPPD )
{
OString aSysPath(OUStringToOString(aFile, aEncoding));
if (unlink(aSysPath.getStr()))

View File

@ -79,7 +79,7 @@ ResId padmin::PaResId( sal_uInt32 nId )
* FindFiles
*/
void padmin::FindFiles( const OUString& rDirectory, ::std::list< String >& rResult, const OUString& rSuffixes, bool bRecursive )
void padmin::FindFiles( const OUString& rDirectory, ::std::list< OUString >& rResult, const OUString& rSuffixes, bool bRecursive )
{
rResult.clear();
@ -121,9 +121,9 @@ void padmin::FindFiles( const OUString& rDirectory, ::std::list< String >& rResu
OUStringBuffer aSubDir( rDirectory );
aSubDir.appendAscii( "/", 1 );
aSubDir.append( aStatus.getFileName() );
std::list< String > subfiles;
std::list< OUString > subfiles;
FindFiles( aSubDir.makeStringAndClear(), subfiles, rSuffixes, bRecursive );
for( std::list< String >::const_iterator it = subfiles.begin(); it != subfiles.end(); ++it )
for( std::list< OUString >::const_iterator it = subfiles.begin(); it != subfiles.end(); ++it )
{
OUStringBuffer aSubFile( aStatus.getFileName() );
aSubFile.appendAscii( "/", 1 );

View File

@ -103,7 +103,7 @@ sal_Bool AreYouSure( Window*, int nRid = -1 );
ResId PaResId( sal_uInt32 nId );
void FindFiles( const OUString& rDirectory, ::std::list< String >& rResult, const OUString& rSuffixes, bool bRecursive = false );
void FindFiles( const OUString& rDirectory, ::std::list< OUString >& rResult, const OUString& rSuffixes, bool bRecursive = false );
Config& getPadminRC();
void freePadminRC();

View File

@ -122,7 +122,7 @@ void PPDImportDialog::Import()
ProgressDialog aProgress( Application::GetFocusWindow() );
aProgress.startOperation( m_aLoadingPPD );
::std::list< String > aFiles;
::std::list< OUString > aFiles;
FindFiles( aImportPath, aFiles, OUString( "PS;PPD;PS.GZ;PPD.GZ" ), true );
int i = 0;

View File

@ -1056,8 +1056,8 @@ lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAdd
{
// Specified table name is not found in this document. Assume this is an external document.
aDocName = aTab;
xub_StrLen n = aTab.SearchBackward('.');
if (n != STRING_NOTFOUND && n > 0)
sal_Int32 n = aDocName.lastIndexOf('.');
if (n != -1 && n > 0)
{
// Extension found. Strip it.
aTab.Erase(n);

View File

@ -130,7 +130,7 @@ XclRootData::XclRootData( XclBiff eBiff, SfxMedium& rMedium,
if( const SfxItemSet* pItemSet = mrMedium.GetItemSet() )
if( const SfxStringItem* pItem = static_cast< const SfxStringItem* >( pItemSet->GetItem( SID_FILE_NAME ) ) )
maDocUrl = pItem->GetValue();
maBasePath = maDocUrl.Copy( 0, maDocUrl.SearchBackward( '/' ) + 1 );
maBasePath = maDocUrl.copy( 0, maDocUrl.lastIndexOf( '/' ) + 1 );
// extended document options - always own object, try to copy existing data from document
if( const ScExtDocOptions* pOldDocOpt = mrDoc.GetExtDocOptions() )

View File

@ -82,7 +82,7 @@ struct XclRootData
SfxMedium& mrMedium; /// The medium to import from.
SotStorageRef mxRootStrg; /// The root OLE storage of imported/exported file.
ScDocument& mrDoc; /// The source or destination document.
String maDocUrl; /// Document URL of imported/exported file.
OUString maDocUrl; /// Document URL of imported/exported file.
String maBasePath; /// Base path of imported/exported file (path of maDocUrl).
String maUserName; /// Current user name.
const String maDefPassword; /// The default password used for stream encryption.
@ -178,7 +178,7 @@ public:
/** Returns the medium to import from. */
inline SfxMedium& GetMedium() const { return mrData.mrMedium; }
/** Returns the document URL of the imported/exported file. */
inline const String& GetDocUrl() const { return mrData.maDocUrl; }
inline const OUString& GetDocUrl() const { return mrData.maDocUrl; }
/** Returns the base path of the imported/exported file. */
inline const String& GetBasePath() const { return mrData.maBasePath; }
/** Returns the current user name. */

View File

@ -1116,13 +1116,13 @@ ANCHOR_SETEVENT:
// wir hier ganz rigoros raus.
if( aName.Len() )
{
String sDecoded( INetURLObject::decode( aName, INET_HEX_ESCAPE,
OUString sDecoded( INetURLObject::decode( aName, INET_HEX_ESCAPE,
INetURLObject::DECODE_UNAMBIGUOUS,
RTL_TEXTENCODING_UTF8 ));
xub_StrLen nPos = sDecoded.SearchBackward( cMarkSeparator );
if( STRING_NOTFOUND != nPos )
sal_Int32 nPos = sDecoded.lastIndexOf( cMarkSeparator );
if( nPos != -1 )
{
OUString sCmp(comphelper::string::remove(sDecoded.Copy(nPos+1), ' '));
OUString sCmp(comphelper::string::remove(sDecoded.copy(nPos+1), ' '));
if( !sCmp.isEmpty() )
{
sCmp = sCmp.toAsciiLowerCase();

View File

@ -64,8 +64,8 @@ using namespace ::com::sun::star;
void SwHTMLParser::NewDivision( int nToken )
{
OUString aId;
String aHRef, aStyle, aLang, aDir;
OUString aId, aHRef;
String aStyle, aLang, aDir;
OUString aClass;
SvxAdjust eAdjust = HTML_CENTER_ON==nToken ? SVX_ADJUST_CENTER
: SVX_ADJUST_END;
@ -114,7 +114,7 @@ void SwHTMLParser::NewDivision( int nToken )
sal_Bool bAppended = sal_False;
if( pPam->GetPoint()->nContent.GetIndex() )
{
AppendTxtNode( bHeader||bFooter||!aId.isEmpty()||aHRef.Len() ? AM_NORMAL
AppendTxtNode( bHeader||bFooter||!aId.isEmpty()|| !aHRef.isEmpty() ? AM_NORMAL
: AM_NOSPACE );
bAppended = sal_True;
}
@ -242,7 +242,7 @@ void SwHTMLParser::NewDivision( int nToken )
}
// Bereiche fuegen wir in Rahmen nur dann ein, wenn der Bereich gelinkt ist.
if( (!aId.isEmpty() && !bPositioned) || aHRef.Len() )
if( (!aId.isEmpty() && !bPositioned) || !aHRef.isEmpty() )
{
// Bereich einfuegen (muss vor dem Setzten von Attributen erfolgen,
// weil die Section vor der PaM-Position eingefuegt.
@ -266,49 +266,49 @@ void SwHTMLParser::NewDivision( int nToken )
// Namen der Section eindeutig machen
const OUString aName( pDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : 0 ) );
if( aHRef.Len() )
if( !aHRef.isEmpty() )
{
sal_Unicode cDelim = 255U;
String aURL;
xub_StrLen nPos = aHRef.SearchBackward( cDelim );
xub_StrLen nPos2 = STRING_NOTFOUND;
if( STRING_NOTFOUND != nPos )
sal_Int32 nPos = aHRef.lastIndexOf( cDelim );
sal_Int32 nPos2 = -1;
if( nPos != -1 )
{
nPos2 = aHRef.SearchBackward( cDelim, nPos );
if( STRING_NOTFOUND != nPos2 )
nPos2 = aHRef.lastIndexOf( cDelim, nPos );
if( nPos2 != -1 )
{
xub_StrLen nTmp = nPos;
sal_Int32 nTmp = nPos;
nPos = nPos2;
nPos2 = nTmp;
}
}
if( STRING_NOTFOUND == nPos )
OUString aURL;
if( nPos == -1 )
{
aURL = URIHelper::SmartRel2Abs(INetURLObject( sBaseURL ), aHRef, Link(), false);
}
else
{
aURL = URIHelper::SmartRel2Abs(INetURLObject( sBaseURL ), aHRef.Copy( 0, nPos ), Link(), false );
aURL += sfx2::cTokenSeparator;
if( STRING_NOTFOUND == nPos2 )
aURL = URIHelper::SmartRel2Abs(INetURLObject( sBaseURL ), aHRef.copy( 0, nPos ), Link(), false );
aURL += OUString(sfx2::cTokenSeparator);
if( nPos2 == -1 )
{
aURL += aHRef.Copy( nPos+1 );
aURL += aHRef.copy( nPos+1 );
}
else
{
aURL += aHRef.Copy( nPos+1, nPos2 - (nPos+1) );
aURL += sfx2::cTokenSeparator;
aURL += String(rtl::Uri::decode( aHRef.Copy( nPos2+1 ),
aURL += aHRef.copy( nPos+1, nPos2 - (nPos+1) );
aURL += OUString(sfx2::cTokenSeparator);
aURL += rtl::Uri::decode( aHRef.copy( nPos2+1 ),
rtl_UriDecodeWithCharset,
RTL_TEXTENCODING_ISO_8859_1 ));
RTL_TEXTENCODING_ISO_8859_1 );
}
}
aHRef = aURL;
}
SwSectionData aSection( (aHRef.Len()) ? FILE_LINK_SECTION
SwSectionData aSection( (!aHRef.isEmpty()) ? FILE_LINK_SECTION
: CONTENT_SECTION, aName );
if( aHRef.Len() )
if( !aHRef.isEmpty() )
{
aSection.SetLinkFileName( aHRef );
aSection.SetProtectFlag(true);

View File

@ -1085,11 +1085,11 @@ void SwHTMLWriter::OutImplicitMark( const String& rMark,
void SwHTMLWriter::OutHyperlinkHRefValue( const String& rURL )
{
String sURL( rURL );
xub_StrLen nPos = sURL.SearchBackward( cMarkSeparator );
if( STRING_NOTFOUND != nPos )
OUString sURL( rURL );
sal_Int32 nPos = sURL.lastIndexOf( cMarkSeparator );
if( nPos != -1 )
{
OUString sCmp(comphelper::string::remove(sURL.Copy(nPos+1), ' '));
OUString sCmp(comphelper::string::remove(sURL.copy(nPos+1), ' '));
if( !sCmp.isEmpty() )
{
sCmp = sCmp.toAsciiLowerCase();
@ -1101,7 +1101,7 @@ void SwHTMLWriter::OutHyperlinkHRefValue( const String& rURL )
sCmp == "outline" ||
sCmp == "text" )
{
sURL.SearchAndReplaceAll( '?', '_' ); // '?' causes problems in IE/Netscape 5
sURL = sURL.replace( '?', '_' ); // '?' causes problems in IE/Netscape 5
}
}
}

View File

@ -2854,13 +2854,13 @@ void MSWordExportBase::AddLinkTarget(const String& rURL)
if( !rURL.Len() || rURL.GetChar(0) != INET_MARK_TOKEN )
return;
String aURL( BookmarkToWriter( rURL.Copy( 1 ) ) );
xub_StrLen nPos = aURL.SearchBackward( cMarkSeparator );
OUString aURL( BookmarkToWriter( rURL.Copy( 1 ) ) );
sal_Int32 nPos = aURL.lastIndexOf( cMarkSeparator );
if( nPos < 2 )
return;
OUString sCmp(comphelper::string::remove(aURL.Copy(nPos+1), ' '));
OUString sCmp(comphelper::string::remove(aURL.copy(nPos+1), ' '));
if( sCmp.isEmpty() )
return;
@ -2869,7 +2869,7 @@ void MSWordExportBase::AddLinkTarget(const String& rURL)
if( sCmp == "outline" )
{
SwPosition aPos( *pCurPam->GetPoint() );
String aOutline( BookmarkToWriter(aURL.Copy( 0, nPos )) );
String aOutline( BookmarkToWriter(aURL.copy( 0, nPos )) );
// If we can find the outline this bookmark refers to
// save the name of the bookmark and the
// node index number of where it points to

View File

@ -2483,27 +2483,26 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
{
if (-2 == rReadParam.SkipToNextToken())
{
String sPart = rReadParam.GetResult();
xub_StrLen nBegin = sPart.Search('(');
OUString sPart = rReadParam.GetResult();
sal_Int32 nBegin = sPart.indexOf('(');
//Word disallows brackets in this field,
xub_StrLen nEnd = sPart.Search(')');
sal_Int32 nEnd = sPart.indexOf(')');
if ((nBegin != STRING_NOTFOUND) &&
(nEnd != STRING_NOTFOUND))
if ((nBegin != -1) &&
(nEnd != -1))
{
sRuby = sPart.Copy(nBegin+1,nEnd-nBegin-1);
sRuby = sPart.copy(nBegin+1,nEnd-nBegin-1);
}
if (STRING_NOTFOUND ==
(nBegin = sPart.Search(',',nEnd)))
if (-1 ==
(nBegin = sPart.indexOf(',',nEnd)))
{
nBegin = sPart.Search(';',nEnd);
nBegin = sPart.indexOf(';',nEnd);
}
nEnd = sPart.SearchBackward(')');
if ((nBegin != STRING_NOTFOUND) &&
(nEnd != STRING_NOTFOUND))
nEnd = sPart.lastIndexOf(')');
if ((nBegin != -1) && (nEnd != -1))
{
sText = sPart.Copy(nBegin+1,nEnd-nBegin-1);
sText = sPart.copy(nBegin+1,nEnd-nBegin-1);
}
}
}

View File

@ -1484,12 +1484,12 @@ void AddressMultiLineEdit::MoveCurrentItem(sal_uInt16 nMove)
{
//go left to find a predecessor or simple text
--nIndex;
String sPara = pTextEngine->GetText( nPara );
xub_StrLen nSearchIndex = sPara.SearchBackward( '>', nIndex+1 );
if( nSearchIndex != STRING_NOTFOUND && nSearchIndex == nIndex )
OUString sPara = pTextEngine->GetText( nPara );
sal_Int32 nSearchIndex = sPara.lastIndexOf( '>', nIndex+1 );
if( nSearchIndex != -1 && nSearchIndex == nIndex )
{
nSearchIndex = sPara.SearchBackward( '<', nIndex );
if( nSearchIndex != STRING_NOTFOUND )
nSearchIndex = sPara.lastIndexOf( '<', nIndex );
if( nSearchIndex != -1 )
nIndex = nSearchIndex;
}
}

View File

@ -235,27 +235,6 @@ xub_StrLen STRING::Match( const STRING& rStr ) const
return STRING_MATCH;
}
xub_StrLen STRING::SearchBackward( STRCODE c, xub_StrLen nIndex ) const
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
if ( nIndex > mpData->mnLen )
nIndex = (xub_StrLen)mpData->mnLen;
const STRCODE* pStr = mpData->maStr;
pStr += nIndex;
while ( nIndex )
{
nIndex--;
pStr--;
if ( *pStr == c )
return nIndex;
}
return STRING_NOTFOUND;
}
void STRING::SearchAndReplaceAll( const STRING& rStr, const STRING& rRepStr )
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );

View File

@ -676,19 +676,19 @@ void AquaSalMenu::SetItemText( unsigned /*i_nPos*/, SalMenuItem* i_pSalMenuItem,
AquaSalMenuItem *pAquaSalMenuItem = (AquaSalMenuItem *) i_pSalMenuItem;
// Delete mnemonics
String aText( comphelper::string::remove(i_rText, '~') );
OUString aText( comphelper::string::remove(i_rText, '~') );
/* #i90015# until there is a correct solution
strip out any appended (.*) in menubar entries
*/
if( mbMenuBar )
{
xub_StrLen nPos = aText.SearchBackward( sal_Unicode( '(' ) );
if( nPos != STRING_NOTFOUND )
sal_Int32 nPos = aText.lastIndexOf( sal_Unicode( '(' ) );
if( nPos != -1 )
{
xub_StrLen nPos2 = aText.Search( sal_Unicode( ')' ) );
if( nPos2 != STRING_NOTFOUND )
aText.Erase( nPos, nPos2-nPos+1 );
sal_Int32 nPos2 = aText.indexOf( sal_Unicode( ')' ) );
if( nPos2 != -1 )
aText = aText.replaceAt( nPos, nPos2-nPos+1, "" );
}
}