diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-09-21 12:59:20 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-22 12:21:34 +0100 |
commit | bcc8e86a1e2e4d7067c0d8320b4bdec9f1d2a2da (patch) | |
tree | 8c5359d5457ff77521f835e984ca97671f74bcca | |
parent | configure: oops, there were 2 harfbuzz lines to fix (diff) | |
download | core-bcc8e86a1e2e4d7067c0d8320b4bdec9f1d2a2da.tar.gz core-bcc8e86a1e2e4d7067c0d8320b4bdec9f1d2a2da.zip |
drop remaining easy UniString::InsertAscii cases
Change-Id: Ie7f33d0debfdb91db842608d5b14d0671b44c76d
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 63 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerwordglue.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/docvw/SidebarTxtControl.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin2.cxx | 67 |
5 files changed, 77 insertions, 78 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index b54e1a383a85..d3e0f96a82f4 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8041,14 +8041,14 @@ bool IsDBCS(sal_Unicode ch) { return lcl_getScriptClass(ch); } -sal_Int32 getLengthB(String &str) +sal_Int32 getLengthB(const OUString &str) { + if(str.isEmpty()) + return 0; sal_Int32 index = 0; sal_Int32 length = 0; - if(0 == str.Len()) - return 0; - while(index < str.Len()){ - if(IsDBCS(str.GetChar(index))) + while(index < str.getLength()){ + if(IsDBCS(str[index])) length += 2; else length++; @@ -8058,33 +8058,35 @@ sal_Int32 getLengthB(String &str) } void ScInterpreter::ScLenB() { - String aStr( GetString() ); - PushDouble( getLengthB(aStr) ); + PushDouble( getLengthB(GetString()) ); } -void lcl_RightB(String &aStr, sal_Int32 n) +OUString lcl_RightB(const OUString &rStr, sal_Int32 n) { - if( n < getLengthB(aStr) ) + if( n < getLengthB(rStr) ) { - sal_Int32 index = aStr.Len(); + OUStringBuffer aBuf(rStr); + sal_Int32 index = aBuf.getLength(); while(index-- >= 0) { if(0 == n) { - aStr.Erase( 0, index + 1); + aBuf.remove( 0, index + 1); break; } if(-1 == n) { - aStr.Erase( 0, index + 2 ); - aStr.InsertAscii(" ", 0); + aBuf.remove( 0, index + 2 ); + aBuf.insert( 0, " "); break; } - if(IsDBCS(aStr.GetChar(index))) + if(IsDBCS(aBuf[index])) n -= 2; else n--; } + return aBuf.makeStringAndClear(); } + return rStr; } void ScInterpreter::ScRightB() { @@ -8105,35 +8107,37 @@ void ScInterpreter::ScRightB() } else n = 1; - String aStr( GetString() ); - lcl_RightB(aStr, n); + OUString aStr(lcl_RightB(GetString(), n)); PushString( aStr ); } } -void lcl_LeftB(String &aStr, sal_Int32 n) +OUString lcl_LeftB(const OUString &rStr, sal_Int32 n) { - if( n < getLengthB(aStr) ) + if( n < getLengthB(rStr) ) { + OUStringBuffer aBuf(rStr); sal_Int32 index = -1; - while(index++ < aStr.Len()) + while(index++ < aBuf.getLength()) { if(0 == n) { - aStr.Erase( index ); + aBuf.truncate(index); break; } if(-1 == n) { - aStr.Erase( index - 1 ); - aStr.InsertAscii(" "); + aBuf.truncate( index - 1 ); + aBuf.append(" "); break; } - if(IsDBCS(aStr.GetChar(index))) + if(IsDBCS(aBuf[index])) n -= 2; else n--; } + return aBuf.makeStringAndClear(); } + return rStr; } void ScInterpreter::ScLeftB() { @@ -8154,8 +8158,7 @@ void ScInterpreter::ScLeftB() } else n = 1; - String aStr( GetString() ); - lcl_LeftB(aStr, n); + OUString aStr(lcl_LeftB(GetString(), n)); PushString( aStr ); } } @@ -8165,16 +8168,16 @@ void ScInterpreter::ScMidB() { double fAnz = ::rtl::math::approxFloor(GetDouble()); double fAnfang = ::rtl::math::approxFloor(GetDouble()); - String rStr( GetString() ); + OUString aStr( GetString() ); if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN)) PushIllegalArgument(); else { - lcl_LeftB(rStr, (xub_StrLen)fAnfang + (xub_StrLen)fAnz - 1); - sal_Int32 nCnt = getLengthB(rStr) - (xub_StrLen)fAnfang + 1; - lcl_RightB(rStr, nCnt>0 ? nCnt:0); - PushString(rStr); + aStr = lcl_LeftB(aStr, (xub_StrLen)fAnfang + (xub_StrLen)fAnz - 1); + sal_Int32 nCnt = getLengthB(aStr) - (xub_StrLen)fAnfang + 1; + aStr = lcl_RightB(aStr, nCnt>0 ? nCnt:0); + PushString(aStr); } } } diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index c8bc889261ca..a4e6d9618661 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -242,7 +242,7 @@ namespace myImplHelpers private: MapperImpl<C> maHelper; std::set<const C*> maUsedStyles; - C* MakeNonCollidingStyle(const String& rName); + C* MakeNonCollidingStyle(const OUString& rName); public: typedef std::pair<C*, bool> StyleResult; StyleMapperImpl(SwDoc &rDoc) : maHelper(rDoc) {} @@ -286,9 +286,9 @@ namespace myImplHelpers } template<class C> - C* StyleMapperImpl<C>::MakeNonCollidingStyle(const String& rName) + C* StyleMapperImpl<C>::MakeNonCollidingStyle(const OUString& rName) { - String aName(rName); + OUString aName(rName); C* pColl = 0; if (0 != (pColl = maHelper.GetStyle(aName))) @@ -296,11 +296,11 @@ namespace myImplHelpers //If the style collides first stick WW- in front of it, unless //it already has it and then successively add a larger and //larger number after it, its got to work at some stage! - if (!aName.EqualsIgnoreCaseAscii("WW-", 0, 3)) - aName.InsertAscii("WW-" , 0); + if (!aName.startsWith("WW-")) + aName = "WW-" + aName; sal_Int32 nI = 1; - String aBaseName = aName; + OUString aBaseName = aName; while ( 0 != (pColl = maHelper.GetStyle(aName)) && (nI < SAL_MAX_INT32) diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index c4dd5bd0675a..e736f99b8cb9 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2281,7 +2281,7 @@ bool ConvertMacroSymbol( const String& rName, String& rReference ) // "MACROSCHALTFL"ACHE" eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr) { - String aName; + OUString aName; String aVText; bool bNewVText = true; bool bBracket = false; @@ -2297,7 +2297,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr) switch( nRet ) { case -2: - if( !aName.Len() ) + if( aName.isEmpty() ) aName = aReadParam.GetResult(); else if( !aVText.Len() || bBracket ) { @@ -2318,12 +2318,12 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr) break; } } - if( !aName.Len() ) + if( aName.isEmpty() ) return FLD_TAGIGN; // makes no sense without Makro-Name //try converting macro symbol according to macro name bool bApplyWingdings = ConvertMacroSymbol( aName, aVText ); - aName.InsertAscii( "StarOffice.Standard.Modul1.", 0 ); + aName = "StarOffice.Standard.Modul1." + aName; SwMacroField aFld( (SwMacroFieldType*) rDoc.GetSysFldType( RES_MACROFLD ), aName, aVText ); diff --git a/sw/source/ui/docvw/SidebarTxtControl.cxx b/sw/source/ui/docvw/SidebarTxtControl.cxx index 4db10d0d6541..1351f7baee53 100644 --- a/sw/source/ui/docvw/SidebarTxtControl.cxx +++ b/sw/source/ui/docvw/SidebarTxtControl.cxx @@ -241,12 +241,11 @@ void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt ) const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld ); if ( pURL ) { - String sURL( pURL->GetURL() ); + OUString sURL( pURL->GetURL() ); SvtSecurityOptions aSecOpts; if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) ) { - sURL.InsertAscii( ": ", 0 ); - sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 ); + sURL = ViewShell::GetShellRes()->aHyperlinkClick + ": " + sURL; } Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL); } diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx index a63553036c04..0ba2eb75abed 100644 --- a/sw/source/ui/docvw/edtwin2.cxx +++ b/sw/source/ui/docvw/edtwin2.cxx @@ -69,7 +69,7 @@ #include <IDocumentMarkAccess.hxx> #include <ndtxt.hxx> -static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, sal_Bool bBalloon ) +static OUString lcl_GetRedlineHelp( const SwRedline& rRedl, sal_Bool bBalloon ) { sal_uInt16 nResId = 0; switch( rRedl.GetType() ) @@ -81,16 +81,18 @@ static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, sal_Bool b case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLL; break; } + OUStringBuffer sBuf; if( nResId ) { - rTxt = SW_RESSTR( nResId ); - rTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " )); - rTxt += rRedl.GetAuthorString(); - rTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " )); - rTxt += GetAppLangDateTimeString( rRedl.GetTimeStamp() ); + sBuf.append(SW_RESSTR(nResId)); + sBuf.append(": "); + sBuf.append(rRedl.GetAuthorString()); + sBuf.append(" - "); + sBuf.append(GetAppLangDateTimeString(rRedl.GetTimeStamp())); if( bBalloon && rRedl.GetComment().Len() ) - ( rTxt += '\n' ) += rRedl.GetComment(); + sBuf.append('\n').append(rRedl.GetComment()); } + return sBuf.makeStringAndClear(); } @@ -102,7 +104,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) return; bool bWeiter = true; SET_CURR_SHELL(&rSh); - String sTxt; + OUString sTxt; Point aPos( PixelToLogic( ScreenToOutputPixel( rEvt.GetMousePosPixel() ) )); sal_Bool bBalloon = static_cast< sal_Bool >(rEvt.GetMode() & HELPMODE_BALLOON); @@ -140,7 +142,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) switch( aCntntAtPos.eCntntAtPos ) { case SwContentAtPos::SW_TABLEBOXFML: - sTxt.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "= " )); + sTxt = "= "; sTxt += ((SwTblBoxFormula*)aCntntAtPos.aFnd.pAttr)->GetFormula(); break; #ifdef DBG_UTIL @@ -163,10 +165,10 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS); //#i63832# remove the link target type - xub_StrLen nFound = sTxt.Search(cMarkSeparator); - if( nFound != STRING_NOTFOUND && (++nFound) < sTxt.Len() ) + sal_Int32 nFound = sTxt.indexOf(cMarkSeparator); + if( nFound != -1 && (++nFound) < sTxt.getLength() ) { - OUString sSuffix( sTxt.Copy(nFound) ); + OUString sSuffix( sTxt.copy(nFound) ); if( sSuffix == "table" || sSuffix == "frame" || sSuffix == "region" || @@ -174,12 +176,12 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) sSuffix == "text" || sSuffix == "graphic" || sSuffix == "ole" ) - sTxt = sTxt.Copy( 0, nFound - 1); + sTxt = sTxt.copy( 0, nFound - 1); } // #i104300# // special handling if target is a cross-reference bookmark { - String sTmpSearchStr = sTxt.Copy( 1, sTxt.Len() ); + String sTmpSearchStr = sTxt.copy( 1, sTxt.getLength() ); IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); IDocumentMarkAccess::const_iterator_t ppBkmk = @@ -193,7 +195,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) { sTxt = pTxtNode->GetExpandTxt( 0, pTxtNode->Len(), true, true ); - if( sTxt.Len() ) + if( !sTxt.isEmpty() ) { OUStringBuffer sTmp(comphelper::string::remove(sTxt, 0xad)); for (sal_Int32 i = 0; i < sTmp.getLength(); ++i) @@ -217,8 +219,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) if ( !bExecHyperlinks ) { - sTxt.InsertAscii( ": ", 0 ); - sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 ); + sTxt = ": " + sTxt; + sTxt = ViewShell::GetShellRes()->aHyperlinkClick + sTxt; } } break; @@ -240,9 +242,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) const SwFmtFtn* pFtn = (SwFmtFtn*)aCntntAtPos.aFnd.pAttr; OUString sTmp; pFtn->GetFtnText( sTmp ); - sTxt = sTmp; - sTxt.Insert( SW_RESSTR( pFtn->IsEndNote() - ? STR_ENDNOTE : STR_FTNNOTE ), 0 ); + sTxt = SW_RESSTR( pFtn->IsEndNote() + ? STR_ENDNOTE : STR_FTNNOTE ) + sTmp; bBalloon = sal_True; if( aCntntAtPos.IsInRTLText() ) nStyle |= QUICKHELP_BIDI_RTL; @@ -250,19 +251,19 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) break; case SwContentAtPos::SW_REDLINE: - lcl_GetRedlineHelp( *aCntntAtPos.aFnd.pRedl, sTxt, bBalloon ); + sTxt = lcl_GetRedlineHelp(*aCntntAtPos.aFnd.pRedl, bBalloon); break; case SwContentAtPos::SW_TOXMARK: sTxt = aCntntAtPos.sStr; - if( sTxt.Len() && aCntntAtPos.pFndTxtAttr ) + if( !sTxt.isEmpty() && aCntntAtPos.pFndTxtAttr ) { const SwTOXType* pTType = aCntntAtPos.pFndTxtAttr-> GetTOXMark().GetTOXType(); if( pTType && !pTType->GetTypeName().isEmpty() ) { - sTxt.InsertAscii( ": ", 0 ); - sTxt.Insert( pTType->GetTypeName(), 0 ); + sTxt = ": " + sTxt; + sTxt = pTType->GetTypeName() + sTxt; } } break; @@ -270,7 +271,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) if(aCntntAtPos.aFnd.pAttr) { sTxt = SW_RESSTR(STR_CONTENT_TYPE_SINGLE_REFERENCE); - sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": ")); + sTxt += ": "; sTxt += ((const SwFmtRefMark*)aCntntAtPos.aFnd.pAttr)->GetRefName(); } break; @@ -333,12 +334,9 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) pRefFld->IsRefToNumItemCrossRefBookmark() ) { sTxt = pRefFld->GetExpandedTxtOfReferencedTxtNode(); - if ( sTxt.Len() > 80 ) + if ( sTxt.getLength() > 80 ) { - sTxt.Erase( 80 ); - sTxt += '.'; - sTxt += '.'; - sTxt += '.'; + sTxt = sTxt.copy(0, 80) + "..."; } } else @@ -351,16 +349,15 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) } } - if( !sTxt.Len() ) + if( sTxt.isEmpty() ) { aCntntAtPos.eCntntAtPos = SwContentAtPos::SW_REDLINE; if( rSh.GetContentAtPos( aPos, aCntntAtPos, sal_False, &aFldRect ) ) - lcl_GetRedlineHelp( *aCntntAtPos.aFnd.pRedl, - sTxt, bBalloon ); + sTxt = lcl_GetRedlineHelp(*aCntntAtPos.aFnd.pRedl, bBalloon); } } } - if (sTxt.Len() ) + if (!sTxt.isEmpty()) { if( bBalloon ) Help::ShowBalloon( this, rEvt.GetMousePosPixel(), sTxt ); @@ -465,7 +462,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) } } } - if (sTxt.Len() && pObj) + if (!sTxt.isEmpty() && pObj) { sTxt = URIHelper::removePassword( sTxt, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS); |