diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-09-21 15:27:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-22 12:21:35 +0100 |
commit | 28c9207da43551059e283008225abfdfb4a988be (patch) | |
tree | 111ae9308cd0903e8c930cca45857ad119a493e2 | |
parent | 3656a57e885065db046d774e27d0834884744a3c (diff) |
Related: fdo#38838 remove UniString::InsertAscii
Change-Id: I949b62842d77fe83caed2cc79784fe1e3f3ae400
-rw-r--r-- | include/tools/string.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/doccomp.cxx | 32 | ||||
-rw-r--r-- | sw/source/core/draw/dpage.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1filter.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 21 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 2 | ||||
-rw-r--r-- | tools/source/string/strascii.cxx | 35 |
9 files changed, 46 insertions, 93 deletions
diff --git a/include/tools/string.hxx b/include/tools/string.hxx index 543ad6fe0ac3..eedb3bdf3077 100644 --- a/include/tools/string.hxx +++ b/include/tools/string.hxx @@ -221,7 +221,6 @@ public: UniString& Insert( const UniString& rStr, xub_StrLen nPos, xub_StrLen nLen, xub_StrLen nIndex = STRING_LEN ); UniString& Insert( sal_Unicode c, xub_StrLen nIndex = STRING_LEN ); - UniString& InsertAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex = STRING_LEN ); UniString& Replace( xub_StrLen nIndex, xub_StrLen nLen, const UniString& rStr ); UniString& Erase( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ); UniString Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const; diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 9bf69d7ab2c2..944baf7d0175 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1069,24 +1069,24 @@ bool SwCompareLine::Compare( const CompareLine& rLine ) const namespace { - static String SimpleTableToText(const SwNode &rNode) + static OUString SimpleTableToText(const SwNode &rNode) { - String sRet; + OUStringBuffer sRet; const SwNode* pEndNd = rNode.EndOfSectionNode(); SwNodeIndex aIdx( rNode ); while (&aIdx.GetNode() != pEndNd) { if (aIdx.GetNode().IsTxtNode()) { - if (sRet.Len()) + if (sRet.getLength()) { - sRet.Append( '\n' ); + sRet.append( '\n' ); } - sRet.Append( aIdx.GetNode().GetTxtNode()->GetExpandTxt() ); + sRet.append( aIdx.GetNode().GetTxtNode()->GetExpandTxt() ); } ++aIdx; } - return sRet; + return sRet.makeStringAndClear(); } } @@ -1185,7 +1185,7 @@ bool SwCompareLine::CompareNode( const SwNode& rDstNd, const SwNode& rSrcNd ) String SwCompareLine::GetText() const { - String sRet; + OUString sRet; switch( rNode.GetNodeType() ) { case ND_TEXTNODE: @@ -1194,14 +1194,13 @@ String SwCompareLine::GetText() const case ND_TABLENODE: { - sRet = SimpleTableToText(rNode); - sRet.InsertAscii( "Tabelle: ", 0 ); + sRet = "Tabelle: " + SimpleTableToText(rNode); } break; case ND_SECTIONNODE: { - sRet.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Section - Node:" )); + sRet = "Section - Node:"; const SwSectionNode& rSNd = (SwSectionNode&)rNode; const SwSection& rSect = rSNd.GetSection(); @@ -1209,8 +1208,8 @@ String SwCompareLine::GetText() const { case CONTENT_SECTION: if( rSect.IsProtect() ) - sRet.Append( OUString::number( - rSNd.EndOfSectionIndex() - rSNd.GetIndex() )); + sRet += OUString::number( + rSNd.EndOfSectionIndex() - rSNd.GetIndex() ); break; case TOX_HEADER_SECTION: @@ -1218,9 +1217,8 @@ String SwCompareLine::GetText() const { const SwTOXBase* pTOX = rSect.GetTOXBase(); if( pTOX ) - sRet.Append( pTOX->GetTitle() ) - .Append( pTOX->GetTypeName() ) - .Append( OUString::number( pTOX->GetType() )); + sRet += pTOX->GetTitle() + pTOX->GetTypeName() + + OUString::number(pTOX->GetType()); } break; @@ -1233,10 +1231,10 @@ String SwCompareLine::GetText() const break; case ND_GRFNODE: - sRet.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Grafik - Node:" )); + sRet = "Grafik - Node:"; break; case ND_OLENODE: - sRet.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "OLE - Node:" )); + sRet = "OLE - Node:"; break; } return sRet; diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx index db945d6ac19c..a512539f4b78 100644 --- a/sw/source/core/draw/dpage.cxx +++ b/sw/source/core/draw/dpage.cxx @@ -139,14 +139,14 @@ sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView, { SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm(); const SwFmtURL &rURL = pFly->GetFmt()->GetURL(); - String sTxt; + OUString sTxt; if( rURL.GetMap() ) { IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly ); if( pTmpObj ) { sTxt = pTmpObj->GetAltText(); - if ( !sTxt.Len() ) + if ( sTxt.isEmpty() ) sTxt = URIHelper::removePassword( pTmpObj->GetURL(), INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS); @@ -167,12 +167,12 @@ sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView, // without MapMode-Offset, without Offset, w ... !!!!! aPt = pWindow->LogicToPixel( aPt, MapMode( MAP_TWIP ) ); - ((( sTxt += '?' ) += OUString::number( aPt.getX() )) - += ',' ) += OUString::number( aPt.getY() ); + sTxt += "?" + OUString::number( aPt.getX() ) + + "," + OUString::number( aPt.getY() ); } } - if ( sTxt.Len() ) + if ( !sTxt.isEmpty() ) { // #i80029# sal_Bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly(); @@ -183,8 +183,7 @@ sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView, if ( !bExecHyperlinks ) { - sTxt.InsertAscii( ": ", 0 ); - sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 ); + sTxt = ViewShell::GetShellRes()->aHyperlinkClick + ": " + sTxt; } } diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 8dee53aad6c4..f411842f575d 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -2623,7 +2623,7 @@ static sal_uInt16 lcl_GetIdByName( String& rName, String& rTypeName ) //rName.SearchAndReplace('.', DB_DELIM); //rName.SetChar( rName.SearchBackward( '.' ), DB_DELIM ); - rName.InsertAscii( "DataBase.", 0 ); + rName = OUString("DataBase.") + rName; nResId = RES_DBFLD; } } diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 8bd79871aa81..dafdf10b2131 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -550,7 +550,7 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt, const String& aFName = rSection.GetLinkFileName(); String aURL( aFName.GetToken(0,sfx2::cTokenSeparator) ); String aFilter( aFName.GetToken(1,sfx2::cTokenSeparator) ); - String aSection( aFName.GetToken(2,sfx2::cTokenSeparator) ); + OUString aSection( aFName.GetToken(2,sfx2::cTokenSeparator) ); String aEncURL( URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aURL ) ); sal_Unicode cDelim = 255U; @@ -561,28 +561,26 @@ static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ); const sal_Char *pDelim = "ÿ"; - if( aFilter.Len() || aSection.Len() || bURLContainsDelim ) + if( aFilter.Len() || !aSection.isEmpty() || bURLContainsDelim ) rHTMLWrt.Strm() << pDelim; if( aFilter.Len() ) HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ); - if( aSection.Len() || bURLContainsDelim ) + if( !aSection.isEmpty() || bURLContainsDelim ) rHTMLWrt.Strm() << pDelim; - if( aSection.Len() ) + if( !aSection.isEmpty() ) { - xub_StrLen nPos = aSection.Search( '%' ); - while( STRING_NOTFOUND != nPos ) + sal_Int32 nPos = aSection.indexOf( '%' ); + while( nPos != -1 ) { - aSection.Erase( nPos, 1 ); - aSection.InsertAscii( "%25", nPos ); - nPos = aSection.Search( '%', nPos+3 ); + aSection.replaceAt(nPos, 1, "%25"); + nPos = aSection.indexOf( '%', nPos+3 ); } - nPos = aSection.Search( cDelim ); - while( STRING_NOTFOUND != nPos ) + nPos = aSection.indexOf( cDelim ); + while( nPos != -1 ) { - aSection.Erase( nPos, 1 ); - aSection.InsertAscii( "%FF", nPos ); - nPos = aSection.Search( cDelim, nPos+3 ); + aSection.replaceAt(nPos, 1, "%FF" ); + nPos = aSection.indexOf( cDelim, nPos+3 ); } HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ); diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx index b7f880b4f30d..9e5d56dcb32c 100644 --- a/sw/source/filter/ww1/w1filter.cxx +++ b/sw/source/filter/ww1/w1filter.cxx @@ -876,16 +876,15 @@ oncemore: case 51: // macro button { pos = aStr.Search(' '); - String aName( aStr.Copy( 0, pos )); + OUString aName( aStr.Copy( 0, pos )); aStr.Erase(0, pos ); aStr.Erase(0, 1); - if( !aName.Len() || !aStr.Len() ) + if( aName.isEmpty() || !aStr.Len() ) break; - aName.InsertAscii( "StarOffice.Standard.Modul1.", 0 ); pField = new SwMacroField( (SwMacroFieldType*) rOut.GetSysFldType( RES_MACROFLD ), - aName, aStr ); + "StarOffice.Standard.Modul1." + aName, aStr ); } break; case 55: // read tiff / or better: import anything diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 633c70982528..75caf0c0de6f 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1065,7 +1065,7 @@ void WW8AttributeOutput::FieldVanish( const String& rTxt, ww::eField /*eType*/ ) void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAttr ) { // its a field; so get the Text form the Node and build the field - String sTxt; + OUString sTxt; ww::eField eType = ww::eNONE; const SwTxtTOXMark& rTxtTOXMark = *rAttr.GetTxtTOXMark(); @@ -1086,31 +1086,26 @@ void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAtt { if ( !rAttr.GetSecondaryKey().isEmpty() ) { - sTxt.Insert( ':', 0 ); - sTxt.Insert( rAttr.GetSecondaryKey(), 0 ); + sTxt = rAttr.GetSecondaryKey() + ":" + sTxt; } - sTxt.Insert( ':', 0 ); - sTxt.Insert( rAttr.GetPrimaryKey(), 0 ); + sTxt = rAttr.GetPrimaryKey() + ":" + sTxt; } - sTxt.InsertAscii( " XE \"", 0 ); - sTxt.InsertAscii( "\" " ); + sTxt = " XE \"" + sTxt + "\" "; break; case TOX_USER: - ( sTxt.AppendAscii( "\" \\f \"" ) ) - += (sal_Char)( 'A' + GetExport( ).GetId( *rAttr.GetTOXType() ) ); + sTxt += "\" \\f \"" + OUString((sal_Char)( 'A' + GetExport( ).GetId( *rAttr.GetTOXType() ) )); // fall through - no break; case TOX_CONTENT: { eType = ww::eTC; - sTxt.InsertAscii( " TC \"", 0 ); + sTxt = " TC \"" + sTxt; sal_uInt16 nLvl = rAttr.GetLevel(); if (nLvl > WW8ListManager::nMaxLevel) nLvl = WW8ListManager::nMaxLevel; - ((sTxt.AppendAscii( "\" \\l " )) - += OUString::number( nLvl )) += ' '; + sTxt += "\" \\l " + OUString::number(nLvl) + " "; } break; default: @@ -1118,7 +1113,7 @@ void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAtt break; } - if ( sTxt.Len() ) + if (!sTxt.isEmpty()) FieldVanish( sTxt, eType ); } diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index dab63e7f712f..9bb1e6acd768 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -1513,7 +1513,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) if( rShell.HasReadonlySel() ) { if( sStr.Len() ) - sStr.InsertAscii( sStatusDelim, 0 ); + sStr = OUString(sStatusDelim) + sStr; sStr.Insert( SW_RESSTR(SW_STR_READONLY), 0 ); } if( sStr.Len() ) diff --git a/tools/source/string/strascii.cxx b/tools/source/string/strascii.cxx index 7cae272cf7a6..83094ffac273 100644 --- a/tools/source/string/strascii.cxx +++ b/tools/source/string/strascii.cxx @@ -294,41 +294,6 @@ UniString& UniString::AppendAscii( const sal_Char* pAsciiStr, xub_StrLen nLen ) return *this; } -UniString& UniString::InsertAscii( const char* pAsciiStr, xub_StrLen nIndex ) -{ - DBG_CHKTHIS( UniString, DbgCheckUniString ); - DBG_ASSERT( pAsciiStr, "UniString::InsertAscii() - pAsciiStr is NULL" ); - - // Determine string length - sal_Int32 nCopyLen = ImplStringLen( pAsciiStr ); - - // detect overflow - nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen ); - - // If appended string is not empty - if ( !nCopyLen ) - return *this; - - // Adjust index if exceeds length - if ( nIndex > mpData->mnLen ) - nIndex = static_cast< xub_StrLen >(mpData->mnLen); - - // Allocate new string - UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen ); - - // copy string data - memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( sal_Unicode ) ); - ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, nCopyLen ); - memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex, - (mpData->mnLen-nIndex)*sizeof( sal_Unicode ) ); - - // release old string - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - - return *this; -} - StringCompare UniString::CompareToAscii( const sal_Char* pAsciiStr, xub_StrLen nLen ) const { |