From e13a3d566ecc34a46e037aca1b2d70e58501e422 Mon Sep 17 00:00:00 2001 From: Jean-Noël Rouvignac Date: Sun, 20 Jan 2013 10:51:58 +0100 Subject: fdo#38838 Some removal/replacement of the String/UniString with OUString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also used the new OUString::number(...) methods. Change-Id: I3174c43d56d1ae359901bb8a13fe0096f2c74808 Reviewed-on: https://gerrit.libreoffice.org/1766 Reviewed-by: Luboš Luňák Tested-by: Luboš Luňák --- basctl/source/basicide/baside2.cxx | 43 ++++++++++++++++----------------- basctl/source/basicide/baside2b.cxx | 47 +++++++++++++++++-------------------- basctl/source/basicide/brkdlg.cxx | 11 ++++----- basctl/source/basicide/moduldl2.cxx | 11 ++++----- 4 files changed, 52 insertions(+), 60 deletions(-) (limited to 'basctl') diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index c6c354508435..4dcc13a9e1bd 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -149,25 +149,27 @@ void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, pPrinter->SetLineColor( aOldLineColor ); } -void lcl_ConvertTabsToSpaces( String& rLine ) +void lcl_ConvertTabsToSpaces( OUString& rLine ) { - if ( rLine.Len() ) + if ( !rLine.isEmpty() ) { - sal_uInt16 nPos = 0; - sal_uInt16 nMax = rLine.Len(); + OUStringBuffer aResult( rLine ); + sal_Int32 nPos = 0; + sal_Int32 nMax = aResult.getLength(); while ( nPos < nMax ) { - if ( rLine.GetChar( nPos ) == '\t' ) + if ( aResult[nPos] == '\t' ) { // not 4 Blanks, but at 4 TabPos: - rtl::OUStringBuffer aBlanker; + OUStringBuffer aBlanker; string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' '); - rLine.Erase( nPos, 1 ); - rLine.Insert( aBlanker.makeStringAndClear(), nPos ); - nMax = rLine.Len(); + aResult.remove( nPos, 1 ); + aResult.insert( nPos, aBlanker.makeStringAndClear() ); + nMax = aResult.getLength(); } ++nPos; } + rLine = aResult.makeStringAndClear(); } } @@ -756,7 +758,6 @@ long ModulWindow::BasicBreakHdl( StarBASIC* pBasic ) void ModulWindow::BasicAddWatch() { DBG_CHKTHIS( ModulWindow, 0 ); - String aWatchStr; AssertValidEditEngine(); bool bAdd = true; if ( !GetEditView()->HasSelection() ) @@ -903,7 +904,7 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage ) pPrinter->SetFont( aFont ); pPrinter->SetMapMode( MAP_100TH_MM ); - String aTitle( CreateQualifiedName() ); + OUString aTitle( CreateQualifiedName() ); sal_uInt16 nLineHeight = (sal_uInt16) pPrinter->GetTextHeight(); // etwas mehr. sal_uInt16 nParaSpace = 10; @@ -924,12 +925,12 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage ) Point aPos( Print::nLeftMargin, Print::nTopMargin ); for ( sal_uLong nPara = 0; nPara < nParas; nPara++ ) { - String aLine( GetEditEngine()->GetText( nPara ) ); + OUString aLine( GetEditEngine()->GetText( nPara ) ); lcl_ConvertTabsToSpaces( aLine ); - sal_uInt16 nLines = aLine.Len()/nCharspLine+1; + sal_uInt16 nLines = aLine.getLength()/nCharspLine+1; for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ ) { - String aTmpLine( aLine, nLine*nCharspLine, nCharspLine ); + OUString aTmpLine = aLine.copy(nLine*nCharspLine, nCharspLine ); aPos.Y() += nLineHeight; if ( aPos.Y() > ( aPaperSz.Height() + Print::nTopMargin ) ) { @@ -1154,13 +1155,13 @@ void ModulWindow::GetState( SfxItemSet &rSet ) if ( pView ) { TextSelection aSel = pView->GetSelection(); - String aPos( IDEResId( RID_STR_LINE ) ); - aPos += ' '; - aPos += String::CreateFromInt32( aSel.GetEnd().GetPara()+1 ); - aPos += String( ", " ); - aPos += String( IDEResId( RID_STR_COLUMN ) ); - aPos += ' '; - aPos += String::CreateFromInt32( aSel.GetEnd().GetIndex()+1 ); + OUString aPos = OUString( IDEResId( RID_STR_LINE ) ) + + " " + + OUString::number(aSel.GetEnd().GetPara()+1) + + ", " + + OUString( IDEResId( RID_STR_COLUMN ) ) + + " " + + OUString::number(aSel.GetEnd().GetIndex()+1); SfxStringItem aItem( SID_BASICIDE_STAT_POS, aPos ); rSet.Put( aItem ); } diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index ffa93e407a2a..bbb7baf17b4e 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -106,7 +106,7 @@ OUString getTextEngineText (ExtTextEngine& rEngine) void setTextEngineText (ExtTextEngine& rEngine, OUString const& aStr) { - rEngine.SetText(String()); + rEngine.SetText(OUString()); OString aUTF8Str = OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 ); SvMemoryStream aMemStream( (void*)aUTF8Str.getStr(), aUTF8Str.getLength(), STREAM_READ | STREAM_SEEK_TO_BEGIN ); @@ -1549,20 +1549,19 @@ void StackWindow::UpdateCalls() SbxError eOld = SbxBase::GetError(); aTreeListBox.SetSelectionMode( SINGLE_SELECTION ); - sal_uInt16 nScope = 0; + sal_Int32 nScope = 0; SbMethod* pMethod = StarBASIC::GetActiveMethod( nScope ); while ( pMethod ) { - String aEntry( String::CreateFromInt32(nScope )); - if ( aEntry.Len() < 2 ) - aEntry.Insert( ' ', 0 ); - aEntry += OUString( ": " ); - aEntry += pMethod->GetName(); + OUString aEntry( OUString::number(nScope )); + if ( aEntry.getLength() < 2 ) + aEntry = " " + aEntry; + aEntry += ": " + pMethod->GetName(); SbxArray* pParams = pMethod->GetParameters(); SbxInfo* pInfo = pMethod->GetInfo(); if ( pParams ) { - aEntry += '('; + aEntry += "("; // 0 is the sub's name... for ( sal_uInt16 nParam = 1; nParam < pParams->Count(); nParam++ ) { @@ -1580,11 +1579,11 @@ void StackWindow::UpdateCalls() aEntry += pParam->aName; } } - aEntry += '='; + aEntry += "="; SbxDataType eType = pVar->GetType(); if( eType & SbxARRAY ) { - aEntry += OUString( "..." ); + aEntry += "..." ; } else if( eType != SbxOBJECT ) { @@ -1592,10 +1591,10 @@ void StackWindow::UpdateCalls() } if ( nParam < ( pParams->Count() - 1 ) ) { - aEntry += OUString( ", " ); + aEntry += ", "; } } - aEntry += ')'; + aEntry += ")"; } aTreeListBox.InsertEntry( aEntry, 0, false, LIST_APPEND ); nScope++; @@ -1814,23 +1813,21 @@ void WatchTreeListBox::RequestingChildren( SvTreeListEntry * pParent ) // Copy data and create name - String aIndexStr = OUString( "(" ); + OUString aIndexStr = "("; pChildItem->mpArrayParentItem = pItem; pChildItem->nDimLevel = nThisLevel; pChildItem->nDimCount = pItem->nDimCount; pChildItem->vIndices.resize(pChildItem->nDimCount); - sal_uInt16 j; + sal_Int32 j; for( j = 0 ; j < nParentLevel ; j++ ) { short n = pChildItem->vIndices[j] = pItem->vIndices[j]; - aIndexStr += String::CreateFromInt32( n ); - aIndexStr += OUString( "," ); + aIndexStr += OUString::number( n ) + ","; } pChildItem->vIndices[nParentLevel] = sal::static_int_cast( i ); - aIndexStr += String::CreateFromInt32( i ); - aIndexStr += OUString( ")" ); + aIndexStr += OUString::number( i ) + ")"; - String aDisplayName; + OUString aDisplayName; WatchItem* pArrayRootItem = pChildItem->GetRootItem(); if( pArrayRootItem && pArrayRootItem->mpArrayParentItem ) aDisplayName = pItem->maDisplayName; @@ -1981,7 +1978,7 @@ void implCollapseModifiedObjectEntry( SvTreeListEntry* pParent, WatchTreeListBox String implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType ) { - String aRetStr = getBasicTypeName( eType ); + OUString aRetStr = getBasicTypeName( eType ); SbxDimArray* pArray = pItem->mpArray; if( !pArray ) @@ -1992,18 +1989,16 @@ String implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType ) int nDims = pItem->nDimCount; if( nDimLevel < nDims ) { - aRetStr += '('; + aRetStr += "("; for( int i = nDimLevel ; i < nDims ; i++ ) { short nMin, nMax; pArray->GetDim( sal::static_int_cast( i+1 ), nMin, nMax ); - aRetStr += String::CreateFromInt32( nMin ); - aRetStr += OUString( " to " ); - aRetStr += String::CreateFromInt32( nMax ); + aRetStr += OUString::number(nMin) + " to " + OUString::number(nMax); if( i < nDims - 1 ) - aRetStr += OUString( ", " ); + aRetStr += ", "; } - aRetStr += ')'; + aRetStr += ")"; } } return aRetStr; diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx index 6f424ce8c9b3..bb32586a1525 100644 --- a/basctl/source/basicide/brkdlg.cxx +++ b/basctl/source/basicide/brkdlg.cxx @@ -82,8 +82,7 @@ BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList for ( size_t i = 0, n = m_aModifiedBreakPointList.size(); i < n; ++i ) { BreakPoint* pBrk = m_aModifiedBreakPointList.at( i ); - OUString aEntryStr( "# " ); - aEntryStr += String::CreateFromInt32( pBrk->nLine ); + OUString aEntryStr( "# " + OUString::number(pBrk->nLine) ); aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND ); } aComboBox.SetUpdateMode(true); @@ -111,8 +110,7 @@ BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList void BreakPointDialog::SetCurrentBreakPoint( BreakPoint* pBrk ) { - String aStr( "# " ); - aStr += String::CreateFromInt32( pBrk->nLine ); + OUString aStr( "# " + OUString::number(pBrk->nLine) ); aComboBox.SetText( aStr ); UpdateFields( pBrk ); } @@ -191,7 +189,7 @@ IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton ) else if ( pButton == &aNewButton ) { // keep checkbox in mind! - String aText( aComboBox.GetText() ); + OUString aText( aComboBox.GetText() ); size_t nLine; bool bValid = lcl_ParseText( aText, nLine ); if ( bValid ) @@ -200,8 +198,7 @@ IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton ) pBrk->bEnabled = aCheckBox.IsChecked(); pBrk->nStopAfter = (size_t) aNumericField.GetValue(); m_aModifiedBreakPointList.InsertSorted( pBrk ); - OUString aEntryStr( "# " ); - aEntryStr += String::CreateFromInt32( pBrk->nLine ); + OUString aEntryStr( "# " + OUString::number(pBrk->nLine) ); aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND ); if (SfxDispatcher* pDispatcher = GetDispatcher()) pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED ); diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 68b459ea14b5..4437f64a7021 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -1566,15 +1566,14 @@ void createLibImpl( Window* pWin, const ScriptDocument& rDocument, return; // create library name - String aLibName; - String aLibStdName( String( "Library" ) ); + OUString aLibName; + OUString aLibStdName( "Library" ); //String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) ); bool bValid = false; - sal_uInt16 i = 1; + sal_Int32 i = 1; while ( !bValid ) { - aLibName = aLibStdName; - aLibName += String::CreateFromInt32( i ); + aLibName = aLibStdName + OUString::number( i ); if ( !rDocument.hasLibrary( E_SCRIPTS, aLibName ) && !rDocument.hasLibrary( E_DIALOGS, aLibName ) ) bValid = true; i++; @@ -1588,7 +1587,7 @@ void createLibImpl( Window* pWin, const ScriptDocument& rDocument, if (aNewDlg.GetObjectName().Len()) aLibName = aNewDlg.GetObjectName(); - if ( aLibName.Len() > 30 ) + if ( aLibName.getLength() > 30 ) { ErrorBox( pWin, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute(); } -- cgit