diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-10-01 09:09:45 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-10-11 14:22:22 +0200 |
commit | 4f5b3e4bd53d6d61df1f65f496f7bc8dc525c8a1 (patch) | |
tree | e0ac44b8f22f944f3303bac8e494da41d6c7b164 | |
parent | 5f84c44e3d5ff19b800b6358e61228546e318d4f (diff) |
In O[U]StringBuffer, make string_view params replacements for OUString ones
...for LIBO_INTERNAL_ONLY, instead of having them as additional overloads. That
way, loplugin:bufferadd and loplugin:stringviewparam found many further
opportunities for simplification (all addressed here). Some notes:
* There is no longer an implicit conversion from O[U]String to O[U]StringBuffer
(as that goes via user-defined conversions through string_view now), which was
most noticeable in copy initializations like
OStringBuffer buf = someStr;
that had to be changed to direct initialization,
OStringBuffer buf(someStr);
But then again, it wasn't too many places that were affected and I think we can
live with that.
* I made the O[U]StringBuffer ctors taking string_view non-explicit, mainly to
get them in line with their counterparts taking O[U]String.
* I added an OUStringBuffer::lastIndexOf string_view overload that was missing
(relative to OUStringBuffer::indexOf).
* loplugin:stringconstant needed some addition to keep the
compilerplugins/clang/test/stringconstant.cxx checks related to
OStringBuffer::append and OStringBuffer::insert working.
* loplugin:stringviewparam no longer needs the special O[U]StringBuffer-related
code that had been introduced in 1250aecd71fabde4dba990bfceb61bbe8e06b8ea
"loplugin:stringviewparam extend to new.."
Change-Id: Ib1bb8c4632d99b744e742605a9fef6eae959fd72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122904
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
93 files changed, 326 insertions, 386 deletions
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index c254fb7470ad..4dadf17d8f3f 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -1506,7 +1506,7 @@ ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, SbxArr return nError; } -ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, OUString const& i_commaSeparatedArgs, SbxValue* i_retValue ) +ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, std::u16string_view i_commaSeparatedArgs, SbxValue* i_retValue ) { SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); if ( !pMethod ) diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index d02129f9f980..b98615cb66a6 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1188,7 +1188,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite) } } - OUStringBuffer aResultStr = aArgStr; + OUStringBuffer aResultStr(aArgStr); sal_Int32 nErase = nReplaceLen; aResultStr.remove( nStartPos, nErase ); aResultStr.insert( diff --git a/bridges/source/jni_uno/jni_uno2java.cxx b/bridges/source/jni_uno/jni_uno2java.cxx index eb152c110ec7..b8b69789a2ce 100644 --- a/bridges/source/jni_uno/jni_uno2java.cxx +++ b/bridges/source/jni_uno/jni_uno2java.cxx @@ -208,31 +208,29 @@ void Bridge::call_java( jmethodID method_id = info->m_methods[ function_pos ]; #if OSL_DEBUG_LEVEL > 0 - OUStringBuffer trace_buf( 128 ); - trace_buf.append( "calling " ); JLocalAutoRef jo_method( jni, jni->ToReflectedMethod( info->m_class, method_id, JNI_FALSE ) ); jni.ensure_no_exception(); - JLocalAutoRef jo_descr( + JLocalAutoRef jo_descr1( jni, jni->CallObjectMethodA( jo_method.get(), getJniInfo()->m_method_Object_toString, nullptr ) ); jni.ensure_no_exception(); - trace_buf.append( jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) ) ); - trace_buf.append( " on " ); - jo_descr.reset( + JLocalAutoRef jo_descr2( + jni, jni->CallObjectMethodA( javaI, getJniInfo()->m_method_Object_toString, nullptr ) ); jni.ensure_no_exception(); - trace_buf.append( jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) ) ); - trace_buf.append( " (" ); JLocalAutoRef jo_class( jni, jni->GetObjectClass( javaI ) ); - jo_descr.reset( + JLocalAutoRef jo_descr3( + jni, jni->CallObjectMethodA( jo_class.get(), getJniInfo()->m_method_Object_toString, nullptr ) ); jni.ensure_no_exception(); - trace_buf.append( jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) ) ); - trace_buf.append( ")" ); - SAL_INFO("bridges", trace_buf.makeStringAndClear()); + SAL_INFO( + "bridges", + "calling " << jstring_to_oustring( jni, static_cast<jstring>(jo_descr1.get()) ) << " on " + << jstring_to_oustring( jni, static_cast<jstring>(jo_descr2.get()) ) << " (" + << jstring_to_oustring( jni, static_cast<jstring>(jo_descr3.get()) ) << ")"); #endif // complex return value diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index 48895bd42bdd..9931afafb9df 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -147,7 +147,7 @@ public: static OUString createParticleForLegend( const css::uno::Reference< css::frame::XModel >& xChartModel ); - static OUString addChildParticle( const OUString& rParticle, std::u16string_view rChildParticle ); + static OUString addChildParticle( std::u16string_view rParticle, std::u16string_view rChildParticle ); static OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex ); static sal_Int32 getIndexFromParticleOrCID( const OUString& rParticleOrCID ); diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index dd23ec5d5338..beca934f5752 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -1054,7 +1054,7 @@ OUString ObjectIdentifier::createDataCurveEquationCID( return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION, aParticleID, rSeriesParticle ); } -OUString ObjectIdentifier::addChildParticle( const OUString& rParticle, std::u16string_view rChildParticle ) +OUString ObjectIdentifier::addChildParticle( std::u16string_view rParticle, std::u16string_view rChildParticle ) { OUStringBuffer aRet(rParticle); diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index 9f51dad4f148..5c237afa1924 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -94,6 +94,12 @@ CXXConstructExpr const * lookForCXXConstructExpr(Expr const * expr) { if (auto e = dyn_cast<CXXBindTemporaryExpr>(expr)) { expr = e->getSubExpr(); } + if (auto const e = dyn_cast<CXXMemberCallExpr>(expr)) { + // Look through OString::operator std::string_view: + if (auto const d = dyn_cast_or_null<CXXConversionDecl>(e->getCalleeDecl())) { + return lookForCXXConstructExpr(e->getImplicitObjectArgument()->IgnoreParenImpCasts()); + } + } return dyn_cast<CXXConstructExpr>(expr); } diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx index aa0899ca10a0..a500adf65d7c 100644 --- a/compilerplugins/clang/stringviewparam.cxx +++ b/compilerplugins/clang/stringviewparam.cxx @@ -65,23 +65,6 @@ StringType relevantStringType(QualType type) } } -bool isRelevantStringBufferType(QualType type) -{ - loplugin::TypeCheck const c(type); - if (c.Class("OStringBuffer").Namespace("rtl")) - { - return true; - } - else if (c.Class("OUStringBuffer").Namespace("rtl")) - { - return true; - } - else - { - return false; - } -} - bool relevantParmVarDecl(ParmVarDecl const* decl) { auto const t1 = decl->getType(); @@ -139,28 +122,13 @@ DeclRefExpr const* relevantImplicitCastExpr(ImplicitCastExpr const* expr) DeclRefExpr const* relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr) { - auto const d = expr->getMethodDecl(); - if (isRelevantStringBufferType(compat::getObjectType(expr))) - { - if (auto const i = d->getIdentifier()) - { - auto const n = i->getName(); - if (n == "append" || n == "indexOf" || n == "lastIndexOf") - { - return relevantDeclRefExpr(expr->getArg(0)); - } - else if (n == "insert") - { - return relevantDeclRefExpr(expr->getArg(1)); - } - } - } StringType t = relevantStringType(compat::getObjectType(expr)); if (t == StringType::None) { return nullptr; } bool good = false; + auto const d = expr->getMethodDecl(); if (d->getOverloadedOperator() == OO_Subscript) { good = true; diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 9805f63afba4..c0cefeaa1b13 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -180,7 +180,7 @@ OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,cons xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bIsAutoIncrement; const OUString sQuoteString = xMetaData->getIdentifierQuoteString(); - OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); + OUStringBuffer aSql(::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))); // check if the user enter a specific string to create autoincrement values OUString sAutoIncrementValue; diff --git a/connectivity/source/drivers/firebird/Tables.cxx b/connectivity/source/drivers/firebird/Tables.cxx index 6db17afade71..215ffe61bdf9 100644 --- a/connectivity/source/drivers/firebird/Tables.cxx +++ b/connectivity/source/drivers/firebird/Tables.cxx @@ -81,7 +81,7 @@ OUString Tables::createStandardColumnPart(const Reference< XPropertySet >& xColP xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bIsAutoIncrement; const OUString sQuoteString = xMetaData->getIdentifierQuoteString(); - OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); + OUStringBuffer aSql(::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))); // check if the user enter a specific string to create autoincrement values OUString sAutoIncrementValue; @@ -196,16 +196,13 @@ void Tables::dropObject(sal_Int32 nPosition, const OUString& sName) if (ODescriptor::isNew(xTable)) return; - OUStringBuffer sSql("DROP "); - OUString sType; xTable->getPropertyValue("Type") >>= sType; - sSql.append(sType); const OUString sQuoteString = m_xMetaData->getIdentifierQuoteString(); - sSql.append(::dbtools::quoteName(sQuoteString,sName)); - m_xMetaData->getConnection()->createStatement()->execute(sSql.makeStringAndClear()); + m_xMetaData->getConnection()->createStatement()->execute( + "DROP " + sType + ::dbtools::quoteName(sQuoteString,sName)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 86daec34ccc0..48c55051ef6b 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -307,7 +307,7 @@ void OSQLParseNode::parseNodeToStr(OUString& rString, if ( !_rxConnection.is() ) return; - OUStringBuffer sBuffer = rString; + OUStringBuffer sBuffer(rString); try { OSQLParseNode::impl_parseNodeToString_throw( sBuffer, diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 14ecdebdaddd..308e4be259dc 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -69,6 +69,7 @@ #include <vector> #include <algorithm> #include <memory> +#include <string_view> #include "mtftools.hxx" using namespace ::com::sun::star; @@ -215,7 +216,7 @@ namespace return BitmapEx( aSolid, aMask ); } - OUString convertToLocalizedNumerals(const OUString& rStr, + OUString convertToLocalizedNumerals(std::u16string_view rStr, LanguageType eTextLanguage) { OUStringBuffer aBuf(rStr); diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx index 5cbfc252c901..4af07c9d1944 100644 --- a/cppu/source/uno/lbenv.cxx +++ b/cppu/source/uno/lbenv.cxx @@ -840,19 +840,16 @@ static void unoenv_computeObjectIdentifier( return; (*pUnoI->release)( pUnoI ); - // interface - OUStringBuffer oid( 64 ); - oid.append( reinterpret_cast< sal_Int64 >(pUnoI), 16 ); - oid.append( ';' ); - // environment[context] - oid.append( pEnv->aBase.pTypeName ); - oid.append( '[' ); - oid.append( reinterpret_cast< sal_Int64 >( + OUString aStr( + // interface + OUString::number( reinterpret_cast< sal_Int64 >(pUnoI), 16 ) + ";" + // environment[context] + + OUString::unacquired(&pEnv->aBase.pTypeName) + "[" + + OUString::number( reinterpret_cast< sal_Int64 >( reinterpret_cast< - uno_Environment * >(pEnv)->pContext ), 16 ); - // process;good guid - oid.append( unoenv_getStaticOIdPart() ); - OUString aStr( oid.makeStringAndClear() ); + uno_Environment * >(pEnv)->pContext ), 16 ) + // process;good guid + + unoenv_getStaticOIdPart() ); *ppOId = aStr.pData; ::rtl_uString_acquire( *ppOId ); } diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index 6cabae88f0dc..009fe137d550 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -13,6 +13,7 @@ #include <cassert> #include <iostream> #include <mutex> +#include <string_view> #include <vector> #include <com/sun/star/beans/NamedValue.hpp> @@ -1798,7 +1799,7 @@ cppuhelper::ServiceManager::findServiceImplementation( /// Make a simpler unique name for preload / progress reporting. #ifndef DISABLE_DYNLOADING -static OUString simplifyModule(const OUString &uri) +static OUString simplifyModule(std::u16string_view uri) { sal_Int32 nIdx; OUStringBuffer edit(uri); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index b702d9133f94..ad20bb0bb616 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -498,11 +498,8 @@ void SAL_CALL ODocumentDefinition::getFastPropertyValue( Any& o_rValue, sal_Int3 OUString sPersistentPath; if ( !m_pImpl->m_aProps.sPersistentName.isEmpty() ) { - OUStringBuffer aBuffer; - aBuffer.append( ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) ); - aBuffer.append( '/' ); - aBuffer.append( m_pImpl->m_aProps.sPersistentName ); - sPersistentPath = aBuffer.makeStringAndClear(); + sPersistentPath = ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) + + "/" + m_pImpl->m_aProps.sPersistentName; } o_rValue <<= sPersistentPath; return; diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index 36c5486a7b40..79fb78c0b9ba 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -20,7 +20,6 @@ #include <dp_platform.hxx> #include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> #include <rtl/instance.hxx> #include <rtl/bootstrap.hxx> #include <osl/diagnose.h> @@ -54,11 +53,7 @@ namespace struct StrPlatform : public rtl::StaticWithInit< OUString, StrPlatform> { OUString operator () () { - OUStringBuffer buf; - buf.append( StrOperatingSystem::get() ); - buf.append( '_' ); - buf.append( StrCPU::get() ); - return buf.makeStringAndClear(); + return StrOperatingSystem::get() + "_" + StrCPU::get(); } }; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index ac859a3d946f..218093c3587a 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -83,18 +83,16 @@ bool jarManifestHeaderPresent( OUString const & url, OUString const & name, Reference<XCommandEnvironment> const & xCmdEnv ) { - OUStringBuffer buf; - buf.append( "vnd.sun.star.zip://" ); - buf.append( - ::rtl::Uri::encode( + OUString buf = "vnd.sun.star.zip://" + + ::rtl::Uri::encode( url, rtl_UriCharClassRegName, rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); - buf.append( "/META-INF/MANIFEST.MF" ); + RTL_TEXTENCODING_UTF8 ) + + "/META-INF/MANIFEST.MF"; ::ucbhelper::Content manifestContent; OUString line; return create_ucb_content( - &manifestContent, buf.makeStringAndClear(), xCmdEnv, + &manifestContent, buf, xCmdEnv, false /* no throw */ ) && readLine( &line, name, manifestContent, RTL_TEXTENCODING_ASCII_US ); } diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index a061aa4382dc..91db8918e747 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -361,19 +361,16 @@ Reference<deployment::XPackageRegistry> PackageRegistryImpl::create( dp_misc::TRACE("> [dp_registry.cxx] media-type detection:\n\n" ); for (auto const& elem : that->m_filter2mediaType) { - OUStringBuffer buf; - buf.append( "extension \"" ); - buf.append( elem.first ); - buf.append( "\" maps to media-type \"" ); - buf.append( elem.second ); - buf.append( "\" maps to backend " ); const Reference<deployment::XPackageRegistry> xBackend( that->m_mediaType2backend.find( elem.second )->second ); allBackends.insert( xBackend ); - buf.append( Reference<lang::XServiceInfo>( + dp_misc::TRACE( + "extension \"" + elem.first + "\" maps to media-type \"" + elem.second + + "\" maps to backend " + + Reference<lang::XServiceInfo>( xBackend, UNO_QUERY_THROW ) - ->getImplementationName() ); - dp_misc::TRACE( buf.makeStringAndClear() + "\n"); + ->getImplementationName() + + "\n"); } dp_misc::TRACE( "> [dp_registry.cxx] ambiguous backends:\n\n" ); for (auto const& ambiguousBackend : that->m_ambiguousBackends) diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 48bec8498033..c93a8a78f746 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -58,6 +58,7 @@ #include <optional> #include <memory> #include <tuple> +#include <string_view> #include <vector> class EditView; @@ -711,7 +712,7 @@ private: void ImplInitLayoutMode(OutputDevice& rOutDev, sal_Int32 nPara, sal_Int32 nIndex); LanguageType ImplCalcDigitLang(LanguageType eCurLang) const; void ImplInitDigitMode(OutputDevice& rOutDev, LanguageType eLang); - static OUString convertDigits(const OUString &rString, sal_Int32 nStt, sal_Int32 nLen, LanguageType eDigitLang); + static OUString convertDigits(std::u16string_view rString, sal_Int32 nStt, sal_Int32 nLen, LanguageType eDigitLang); EditPaM ReadText( SvStream& rInput, EditSelection aSel ); EditPaM ReadRTF( SvStream& rInput, EditSelection aSel ); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index fb52e1eb984b..884a752218e3 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -4316,7 +4316,7 @@ LanguageType ImpEditEngine::ImplCalcDigitLang(LanguageType eCurLang) const return eLang; } -OUString ImpEditEngine::convertDigits(const OUString &rString, sal_Int32 nStt, sal_Int32 nLen, LanguageType eDigitLang) +OUString ImpEditEngine::convertDigits(std::u16string_view rString, sal_Int32 nStt, sal_Int32 nLen, LanguageType eDigitLang) { OUStringBuffer aBuf(rString); for (sal_Int32 nIdx = nStt, nEnd = nStt + nLen; nIdx < nEnd; ++nIdx) diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx index 67507e4c3a05..ac2dcdec8a10 100644 --- a/filter/source/msfilter/rtfutil.cxx +++ b/filter/source/msfilter/rtfutil.cxx @@ -249,17 +249,10 @@ OString OutStringUpr(const char* pToken, const OUString& rStr, rtl_TextEncoding if (TryOutString(rStr, eDestEnc)) return OString::Concat("{") + pToken + " " + OutString(rStr, eDestEnc) + "}"; - OStringBuffer aRet; - aRet.append("{" OOO_STRING_SVTOOLS_RTF_UPR "{"); - aRet.append(pToken); - aRet.append(" "); - aRet.append(OutString(rStr, eDestEnc, /*bUnicode =*/false)); - aRet.append("}{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_UD "{"); - aRet.append(pToken); - aRet.append(" "); - aRet.append(OutString(rStr, eDestEnc)); - aRet.append("}}}"); - return aRet.makeStringAndClear(); + return OString::Concat("{" OOO_STRING_SVTOOLS_RTF_UPR "{") + pToken + " " + + OutString(rStr, eDestEnc, /*bUnicode =*/false) + + "}{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_UD "{" + pToken + " " + + OutString(rStr, eDestEnc) + "}}}"; } int AsHex(char ch) diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 7dff65c1f8d6..6b9d0cdb8f5b 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -2641,7 +2641,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void ) { // to notify to the SVGActionWriter::ImplWriteText method // that we are dealing with a placeholder shape - OUStringBuffer aRepresentation = sPlaceholderTag; + OUStringBuffer aRepresentation(sPlaceholderTag); if( !mCreateOjectsCurrentMasterPage.is() ) { diff --git a/framework/source/uielement/fontmenucontroller.cxx b/framework/source/uielement/fontmenucontroller.cxx index 9d44fe31803c..0bbc57c85721 100644 --- a/framework/source/uielement/fontmenucontroller.cxx +++ b/framework/source/uielement/fontmenucontroller.cxx @@ -32,7 +32,6 @@ #include <vcl/settings.hxx> #include <vcl/i18nhelp.hxx> #include <tools/urlobj.hxx> -#include <rtl/ustrbuf.hxx> #include <vcl/mnemonic.hxx> #include <osl/mutex.hxx> #include <cppuhelper/supportsservice.hxx> @@ -112,9 +111,7 @@ void FontMenuController::fillPopupMenu( const Sequence< OUString >& rFontNameSeq if ( rName == m_aFontFamilyName ) m_xPopupMenu->checkItem( i+1, true ); // use VCL popup menu pointer to set vital information that are not part of the awt implementation - OUStringBuffer aCommandBuffer( aFontNameCommandPrefix ); - aCommandBuffer.append( INetURLObject::encode( rName, INetURLObject::PART_HTTP_QUERY, INetURLObject::EncodeMechanism::All )); - OUString aFontNameCommand = aCommandBuffer.makeStringAndClear(); + OUString aFontNameCommand = aFontNameCommandPrefix + INetURLObject::encode( rName, INetURLObject::PART_HTTP_QUERY, INetURLObject::EncodeMechanism::All ); pVCLPopupMenu->SetItemCommand( i+1, aFontNameCommand ); // Store font name into item command. } } diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx index 32011eb70df6..e374f8f47b1c 100644 --- a/include/basic/basmgr.hxx +++ b/include/basic/basmgr.hxx @@ -24,6 +24,7 @@ #include <basic/sbstar.hxx> #include <basic/basicdllapi.h> #include <memory> +#include <string_view> #include <vector> namespace com::sun::star::script { class XLibraryContainer; } @@ -191,7 +192,7 @@ public: /// executes a given macro ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ); /// executes a given macro - ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, OUString const& i_commaSeparatedArgs, SbxValue* i_retValue ); + ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, std::u16string_view i_commaSeparatedArgs, SbxValue* i_retValue ); private: BASIC_DLLPRIVATE bool IsReference( sal_uInt16 nLib ); diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx index a238f305fa07..52399b6da8b4 100644 --- a/include/rtl/strbuf.hxx +++ b/include/rtl/strbuf.hxx @@ -137,7 +137,7 @@ public: @param value the initial string value. */ #if defined LIBO_INTERNAL_ONLY - explicit OStringBuffer(std::string_view sv) + OStringBuffer(std::string_view sv) : pData(nullptr) , nCapacity( sv.length() + 16 ) { @@ -146,13 +146,14 @@ public: } rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() ); } -#endif +#else OStringBuffer(const OString& value) : pData(NULL) , nCapacity( value.getLength() + 16 ) { rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() ); } +#endif /** @overload @@ -280,7 +281,7 @@ public: pData->length = n; return *this; } -#endif +#else OStringBuffer & operator =(OString const & string) { sal_Int32 n = string.getLength(); if (n >= nCapacity) { @@ -290,6 +291,7 @@ public: pData->length = n; return *this; } +#endif /** Assign from a string literal. @@ -513,6 +515,7 @@ public: return OString(pData->buffer, pData->length); } +#if !defined LIBO_INTERNAL_ONLY /** Appends the string to this string buffer. @@ -527,6 +530,7 @@ public: { return append( str.getStr(), str.getLength() ); } +#endif /** Appends the string representation of the <code>char</code> array @@ -799,11 +803,12 @@ public: { return insert( offset, str.data(), str.length() ); } -#endif +#else OStringBuffer & insert(sal_Int32 offset, const OString & str) { return insert( offset, str.getStr(), str.getLength() ); } +#endif /** Inserts the string representation of the <code>char</code> array diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index 65762d53960d..2b8288b26b1e 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -138,7 +138,7 @@ public: @param value the initial contents of the buffer. */ #if defined LIBO_INTERNAL_ONLY - explicit OUStringBuffer(std::u16string_view sv) + OUStringBuffer(std::u16string_view sv) : pData(nullptr) , nCapacity( sv.length() + 16 ) { @@ -147,13 +147,14 @@ public: } rtl_uStringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() ); } -#endif +#else OUStringBuffer(const OUString& value) : pData(NULL) , nCapacity( value.getLength() + 16 ) { rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() ); } +#endif template< typename T > OUStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() ) @@ -288,7 +289,7 @@ public: pData->length = n; return *this; } -#endif +#else OUStringBuffer & operator =(OUString const & string) { sal_Int32 n = string.getLength(); if (n >= nCapacity) { @@ -300,6 +301,7 @@ public: pData->length = n; return *this; } +#endif /** Assign from a string literal. @@ -583,12 +585,12 @@ public: @param str a string. @return this string buffer. */ +#if !defined LIBO_INTERNAL_ONLY OUStringBuffer & append(const OUString &str) { return append( str.getStr(), str.getLength() ); } - -#if defined LIBO_INTERNAL_ONLY +#else OUStringBuffer & append(std::u16string_view sv) { if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) { throw std::bad_alloc(); @@ -597,6 +599,7 @@ public: } #endif +#if !defined LIBO_INTERNAL_ONLY /** Appends the content of a stringbuffer to this string buffer. @@ -617,6 +620,7 @@ public: } return *this; } +#endif /** Appends the string representation of the <code>char</code> array @@ -992,11 +996,12 @@ public: { return insert( offset, str.data(), str.length() ); } -#endif +#else OUStringBuffer & insert(sal_Int32 offset, const OUString & str) { return insert( offset, str.getStr(), str.getLength() ); } +#endif /** Inserts the string representation of the <code>char</code> array @@ -1452,7 +1457,7 @@ public: str.data(), str.length() ); return (ret < 0 ? ret : ret+fromIndex); } -#endif +#else sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const { assert( fromIndex >= 0 && fromIndex <= pData->length ); @@ -1460,6 +1465,7 @@ public: str.pData->buffer, str.pData->length ); return (ret < 0 ? ret : ret+fromIndex); } +#endif /** @overload @@ -1528,12 +1534,13 @@ public: return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length, str.data(), str.length() ); } -#endif +#else sal_Int32 lastIndexOf( const OUString & str ) const { return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length, str.pData->buffer, str.pData->length ); } +#endif /** Returns the index within this string of the last occurrence of @@ -1554,12 +1561,21 @@ public: of the first character of the last such substring is returned. Otherwise, -1 is returned. */ +#if defined LIBO_INTERNAL_ONLY + sal_Int32 lastIndexOf( std::u16string_view str, sal_Int32 fromIndex ) const + { + assert( fromIndex >= 0 && fromIndex <= pData->length ); + return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex, + str.data(), str.length() ); + } +#else sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const { assert( fromIndex >= 0 && fromIndex <= pData->length ); return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex, str.pData->buffer, str.pData->length ); } +#endif /** @overload diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx index 667bedbef388..7bb85917f952 100644 --- a/include/tools/urlobj.hxx +++ b/include/tools/urlobj.hxx @@ -297,7 +297,7 @@ public: bool ConcatData(INetProtocol eTheScheme, std::u16string_view rTheUser, std::u16string_view rThePassword, - OUString const & rTheHost, sal_uInt32 nThePort, + std::u16string_view rTheHost, sal_uInt32 nThePort, OUString const & rThePath); // Smart Parsing: @@ -445,7 +445,7 @@ public: sal_uInt32 GetPort() const; - bool SetHost(OUString const & rTheHost) + bool SetHost(std::u16string_view rTheHost) { return setHost(rTheHost, RTL_TEXTENCODING_UTF8); } bool SetPort(sal_uInt32 nThePort); @@ -1045,7 +1045,7 @@ private: bool bNetBiosName, OUStringBuffer* pCanonic); bool setHost( - OUString const & rTheHost, + std::u16string_view rTheHost, rtl_TextEncoding eCharset); // Path: diff --git a/include/unotools/fontcvt.hxx b/include/unotools/fontcvt.hxx index 7fbf2cc9c917..979183746201 100644 --- a/include/unotools/fontcvt.hxx +++ b/include/unotools/fontcvt.hxx @@ -20,6 +20,10 @@ #ifndef INCLUDED_UNOTOOLS_FONTCVT_HXX #define INCLUDED_UNOTOOLS_FONTCVT_HXX +#include <sal/config.h> + +#include <string_view> + #include <unotools/unotoolsdllapi.h> #include <rtl/ustring.hxx> @@ -31,7 +35,7 @@ enum class FontToSubsFontFlags }; typedef void* FontToSubsFontConverter; -UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rFontName, FontToSubsFontFlags nFlags ); +UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter( std::u16string_view rFontName, FontToSubsFontFlags nFlags ); UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar( FontToSubsFontConverter hConverter, sal_Unicode c ); UNOTOOLS_DLLPUBLIC OUString GetFontToSubsFontName( FontToSubsFontConverter hConverter ); diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx index ad1d6726f17e..671fca504d75 100644 --- a/include/unotools/fontdefs.hxx +++ b/include/unotools/fontdefs.hxx @@ -53,7 +53,7 @@ public: sal_Unicode (*mpCvtFunc)( sal_Unicode ); sal_Unicode RecodeChar( sal_Unicode c ) const; void RecodeString( OUString& rStra, sal_Int32 nIndex, sal_Int32 nLen ) const; - static const ConvertChar* GetRecodeData( const OUString& rOrgFontName, const OUString& rMapFontName ); + static const ConvertChar* GetRecodeData( std::u16string_view rOrgFontName, std::u16string_view rMapFontName ); }; @@ -85,7 +85,7 @@ enum class DefaultFontType }; UNOTOOLS_DLLPUBLIC OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex ); -UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName( const OUString& rName ); +UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName( std::u16string_view rName ); /** Strip any "script font suffix" from the font name diff --git a/include/unotools/localedatawrapper.hxx b/include/unotools/localedatawrapper.hxx index 7584055e1751..22cafe581c42 100644 --- a/include/unotools/localedatawrapper.hxx +++ b/include/unotools/localedatawrapper.hxx @@ -33,6 +33,7 @@ #include <unotools/unotoolsdllapi.h> #include <memory> #include <map> +#include <string_view> namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::i18n { class XLocaleData5; } @@ -372,7 +373,7 @@ public: /** Append locale info to string, used with locale data checking. A string similar to "de_DE requested\n en_US loaded" is appended. */ - OUString appendLocaleInfo(const OUString& rDebugMsg) const; + OUString appendLocaleInfo(std::u16string_view rDebugMsg) const; /** Output a message during locale data checking. The (UTF-8) string is written to stderr and in a non-product build or if DBG_UTIL is enabled diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 504438bdab40..4aeca1459f25 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -398,7 +398,7 @@ namespace BuilderUtils VCL_DLLPUBLIC void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps); //Convert _ gtk markup to ~ vcl markup - VCL_DLLPUBLIC OUString convertMnemonicMarkup(const OUString &rIn); + VCL_DLLPUBLIC OUString convertMnemonicMarkup(std::u16string_view rIn); VCL_DLLPUBLIC OUString extractCustomProperty(VclBuilder::stringmap &rMap); diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 50ee0324af3d..6f85e0d51fef 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -63,6 +63,7 @@ #include <com/sun/star/awt/DeviceInfo.hpp> #include <memory> +#include <string_view> #include <vector> struct ImplOutDevData; @@ -1111,7 +1112,7 @@ public: FontMetric GetFontMetricFromCollection( int nDevFontIndex ) const; int GetFontFaceCollectionCount() const; - bool IsFontAvailable( const OUString& rFontName ) const; + bool IsFontAvailable( std::u16string_view rFontName ) const; bool AddTempDevFont( const OUString& rFileURL, const OUString& rFontName ); void RefreshFontData( const bool bNewFontLists ); diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx index 9ac458f0dc00..2efab32bad2c 100644 --- a/include/vcl/toolkit/field.hxx +++ b/include/vcl/toolkit/field.hxx @@ -23,6 +23,10 @@ #error "don't use this in new code" #endif +#include <sal/config.h> + +#include <string_view> + #include <config_options.h> #include <tools/date.hxx> #include <tools/fldunit.hxx> @@ -303,14 +307,14 @@ protected: TimeFormatter(Edit* pEdit); - SAL_DLLPRIVATE void ImplTimeReformat( const OUString& rStr, OUString& rOutStr ); + SAL_DLLPRIVATE void ImplTimeReformat( std::u16string_view rStr, OUString& rOutStr ); SAL_DLLPRIVATE void ImplNewFieldValue( const tools::Time& rTime ); SAL_DLLPRIVATE void ImplSetUserTime( const tools::Time& rNewTime, Selection const * pNewSelection = nullptr ); SAL_DLLPRIVATE bool ImplAllowMalformedInput() const; public: static OUString FormatTime(const tools::Time& rNewTime, TimeFieldFormat eFormat, TimeFormat eHourFormat, bool bDuration, const LocaleDataWrapper& rLocaleData); - static bool TextToTime(const OUString& rStr, tools::Time& rTime, TimeFieldFormat eFormat, bool bDuration, const LocaleDataWrapper& rLocaleDataWrapper, bool _bSkipInvalidCharacters = true); + static bool TextToTime(std::u16string_view rStr, tools::Time& rTime, TimeFieldFormat eFormat, bool bDuration, const LocaleDataWrapper& rLocaleDataWrapper, bool _bSkipInvalidCharacters = true); static int GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper); static tools::Time SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat, diff --git a/include/vcl/uitest/logger.hxx b/include/vcl/uitest/logger.hxx index 2500c0d6f58e..c810b7eb7de7 100644 --- a/include/vcl/uitest/logger.hxx +++ b/include/vcl/uitest/logger.hxx @@ -43,7 +43,7 @@ private: public: UITestLogger(); - void logCommand(const OUString& rAction, + void logCommand(std::u16string_view rAction, const css::uno::Sequence<css::beans::PropertyValue>& rArgs); void logAction(VclPtr<Control> const& xUIElement, VclEventId nEvent); diff --git a/jvmfwk/inc/fwkutil.hxx b/jvmfwk/inc/fwkutil.hxx index 60ffa9fe89d0..fdef421f664f 100644 --- a/jvmfwk/inc/fwkutil.hxx +++ b/jvmfwk/inc/fwkutil.hxx @@ -25,7 +25,6 @@ #include <sal/log.hxx> #include <rtl/bootstrap.hxx> #include <rtl/instance.hxx> -#include <rtl/ustrbuf.hxx> #include <rtl/byteseq.hxx> namespace osl { class Mutex; } @@ -44,15 +43,13 @@ OUString getLibraryLocation(); struct Bootstrap : public ::rtl::StaticWithInit< const rtl::Bootstrap *, Bootstrap > { const rtl::Bootstrap * operator () () { - OUStringBuffer buf(256); - buf.append(getLibraryLocation()); + OUString sIni = getLibraryLocation() + #ifdef MACOSX - // For some reason the jvmfwk3rc file is traditionally in - // LIBO_URE_ETC_FOLDER - buf.append( "/../" LIBO_URE_ETC_FOLDER ); + // For some reason the jvmfwk3rc file is traditionally in + // LIBO_URE_ETC_FOLDER + "/../" LIBO_URE_ETC_FOLDER #endif - buf.append(SAL_CONFIGFILE("/jvmfwk3")); - OUString sIni = buf.makeStringAndClear(); + SAL_CONFIGFILE("/jvmfwk3"); ::rtl::Bootstrap * bootstrap = new ::rtl::Bootstrap(sIni); SAL_INFO("jfw.level2", "Using configuration file " << sIni); return bootstrap; diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index e935ab4831f8..dfe013cb9b7c 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -17,6 +17,7 @@ #include <vector> #include <string> +#include <string_view> #include <po.hxx> #include <helper.hxx> @@ -50,7 +51,7 @@ public: bool isFuzzy() const { return m_bFuzzy; } bool isNull() const { return m_bNull; } - void setExtractCom(const OString& rExtractCom) + void setExtractCom(std::string_view rExtractCom) { m_sExtractCom = rExtractCom; } @@ -274,9 +275,9 @@ PoEntry::PoEntry( } m_pGenPo->setMsgCtxt(sMsgCtxt); m_pGenPo->setMsgId(rText); - m_pGenPo->setExtractCom( + m_pGenPo->setExtractCom(OStringConcatenation( ( !rHelpText.isEmpty() ? rHelpText + "\n" : OString()) + - genKeyId( m_pGenPo->getReference().front() + rGroupId + rLocalId + rResType + rText ) ); + genKeyId( m_pGenPo->getReference().front() + rGroupId + rLocalId + rResType + rText ) )); m_bIsInitialized = true; } @@ -441,7 +442,7 @@ PoHeader::PoHeader( std::string_view rExtSrc, const OString& rPoHeaderMsgStr ) : m_pGenPo( new GenPoEntry() ) , m_bIsInitialized( false ) { - m_pGenPo->setExtractCom(OString::Concat("extracted from ") + rExtSrc); + m_pGenPo->setExtractCom(OStringConcatenation(OString::Concat("extracted from ") + rExtSrc)); m_pGenPo->setMsgStr(rPoHeaderMsgStr); m_bIsInitialized = true; } @@ -450,7 +451,7 @@ PoHeader::PoHeader( std::string_view rExtSrc ) : m_pGenPo( new GenPoEntry() ) , m_bIsInitialized( false ) { - m_pGenPo->setExtractCom(OString::Concat("extracted from ") + rExtSrc); + m_pGenPo->setExtractCom(OStringConcatenation(OString::Concat("extracted from ") + rExtSrc)); m_pGenPo->setMsgStr( "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?" diff --git a/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx b/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx index e150e436b958..b85f2d6dc473 100644 --- a/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx +++ b/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx @@ -68,7 +68,7 @@ XFSvgPathEntry::XFSvgPathEntry() OUString XFSvgPathEntry::ToString() { assert(!m_strCommand.isEmpty()); - OUStringBuffer str = m_strCommand; + OUStringBuffer str(m_strCommand); for (auto const& point : m_aPoints) { diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx index e8f8a2b1f8dc..af0e268957d5 100644 --- a/reportdesign/source/ui/dlg/Navigator.cxx +++ b/reportdesign/source/ui/dlg/Navigator.cxx @@ -75,7 +75,7 @@ static OUString lcl_getName(const uno::Reference< beans::XPropertySet>& _xElemen OSL_ENSURE(_xElement.is(),"Found report element which is NULL!"); OUString sTempName; _xElement->getPropertyValue(PROPERTY_NAME) >>= sTempName; - OUStringBuffer sName = sTempName; + OUStringBuffer sName(sTempName); uno::Reference< report::XFixedText> xFixedText(_xElement,uno::UNO_QUERY); uno::Reference< report::XReportControlModel> xReportModel(_xElement,uno::UNO_QUERY); if ( xFixedText.is() ) diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 38911878c437..2baabb533382 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -631,7 +631,7 @@ public: @param nSepCount Specifies how often cSep is inserted between two tokens. @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */ SC_DLLPUBLIC static OUString addToken( - const OUString& rTokenList, std::u16string_view rToken, + std::u16string_view rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount = 1, bool bForceSep = false ); diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx index ff024e4621ea..4bf519a9fbc6 100644 --- a/sc/inc/postit.hxx +++ b/sc/inc/postit.hxx @@ -26,6 +26,7 @@ #include <memory> #include <optional> +#include <string_view> class EditTextObject; class OutlinerParaObject; @@ -283,7 +284,7 @@ public: /** Creates and returns a caption object for a temporary caption. */ static ScCaptionPtr CreateTempCaption( ScDocument& rDoc, const ScAddress& rPos, - SdrPage& rDrawPage, const OUString& rUserText, + SdrPage& rDrawPage, std::u16string_view rUserText, const tools::Rectangle& rVisRect, bool bTailFront ); /** Creates a cell note using the passed caption drawing object. diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx index 0f5083f810df..ac1dcca65eeb 100644 --- a/sc/source/core/data/dputil.cxx +++ b/sc/source/core/data/dputil.cxx @@ -140,9 +140,7 @@ OUString ScDPUtil::getDateGroupName( case sheet::DataPilotFieldGroupBy::MINUTES: case sheet::DataPilotFieldGroupBy::SECONDS: { - OUStringBuffer aBuf(ScGlobal::getLocaleData().getTimeSep()); - aBuf.append(getTwoDigitString(nValue)); - return aBuf.makeStringAndClear(); + return ScGlobal::getLocaleData().getTimeSep() + getTwoDigitString(nValue); } break; default: diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index e795912dd2e3..8706a0017c1b 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -654,11 +654,11 @@ const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr, return nullptr; } -OUString ScGlobal::addToken(const OUString& rTokenList, std::u16string_view rToken, +OUString ScGlobal::addToken(std::u16string_view rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount, bool bForceSep) { OUStringBuffer aBuf(rTokenList); - if( bForceSep || (!rToken.empty() && !rTokenList.isEmpty()) ) + if( bForceSep || (!rToken.empty() && !rTokenList.empty()) ) comphelper::string::padToLength(aBuf, aBuf.getLength() + nSepCount, cSep); aBuf.append(rToken); return aBuf.makeStringAndClear(); diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 12b5778aead2..ef7ff3bc4725 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -1160,7 +1160,7 @@ void ScPostIt::RemoveCaption() ScCaptionPtr ScNoteUtil::CreateTempCaption( ScDocument& rDoc, const ScAddress& rPos, SdrPage& rDrawPage, - const OUString& rUserText, const tools::Rectangle& rVisRect, bool bTailFront ) + std::u16string_view rUserText, const tools::Rectangle& rVisRect, bool bTailFront ) { OUStringBuffer aBuffer( rUserText ); // add plain text of invisible (!) cell note (no formatting etc.) @@ -1193,7 +1193,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption( SdrCaptionObj* pCaption = aCreator.GetCaption().get(); // just for ease of use // clone the edit text object, unless user text is present, then set this text - if( pNoteCaption && rUserText.isEmpty() ) + if( pNoteCaption && rUserText.empty() ) { if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() ) pCaption->SetOutlinerParaObject( *pOPO ); diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 2fe2fa211e85..150a5d187d2a 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -297,8 +297,8 @@ bool ScValidationData::DoMacro( const ScAddress& rPos, const OUString& rInput, { SbModule* pModule = pMethod->GetModule(); SbxObject* pObject = pModule->GetParent(); - OUStringBuffer aMacroStr = pObject->GetName(); - aMacroStr.append('.').append(pModule->GetName()).append('.').append(pMethod->GetName()); + OUString aMacroStr( + pObject->GetName() + "." + pModule->GetName() + "." + pMethod->GetName()); OUString aBasicStr; // the distinction between document- and app-basic has to be done @@ -344,7 +344,7 @@ bool ScValidationData::DoMacro( const ScAddress& rPos, const OUString& rInput, if ( pCell ) pDocument->LockTable( rPos.Tab() ); SbxVariableRef refRes = new SbxVariable; - ErrCode eRet = pDocSh->CallBasic( aMacroStr.makeStringAndClear(), aBasicStr, refPar.get(), refRes.get() ); + ErrCode eRet = pDocSh->CallBasic( aMacroStr, aBasicStr, refPar.get(), refRes.get() ); if ( pCell ) pDocument->UnlockTable( rPos.Tab() ); diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index 242b4b539bc4..13e5df2501ad 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -340,15 +340,12 @@ std::unique_ptr<ScMemChart> ScChartArray::CreateMemChartMulti() if (aString.isEmpty()) { - OUStringBuffer aBuf(ScResId(STR_COLUMN)); - aBuf.append(' '); if ( pPos ) nPosCol = pPos->Col() + 1; else nPosCol++; ScAddress aPos( nPosCol - 1, 0, 0 ); - aBuf.append(aPos.Format(ScRefFlags::COL_VALID)); - aString = aBuf.makeStringAndClear(); + aString = ScResId(STR_COLUMN) + " " + aPos.Format(ScRefFlags::COL_VALID); } pMemChart->SetColText( nCol, aString); } diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index b3a1a64e8653..3583fb28f549 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -2079,11 +2079,7 @@ void ScChangeTrack::Init() bTimeNanoSeconds = true; const SvtUserOptions& rUserOpt = SC_MOD()->GetUserOptions(); - OUStringBuffer aBuf; - aBuf.append(rUserOpt.GetFirstName()); - aBuf.append(' '); - aBuf.append(rUserOpt.GetLastName()); - maUser = aBuf.makeStringAndClear(); + maUser = rUserOpt.GetFirstName() + " " + rUserOpt.GetLastName(); maUserCollection.insert(maUser); } @@ -2184,11 +2180,7 @@ void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, Config const SvtUserOptions& rUserOptions = SC_MOD()->GetUserOptions(); size_t nOldCount = maUserCollection.size(); - OUStringBuffer aBuf; - aBuf.append(rUserOptions.GetFirstName()); - aBuf.append(' '); - aBuf.append(rUserOptions.GetLastName()); - SetUser(aBuf.makeStringAndClear()); + SetUser(rUserOptions.GetFirstName() + " " + rUserOptions.GetLastName()); if ( maUserCollection.size() != nOldCount ) { diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 1477eaaab424..e7030950030f 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2307,15 +2307,12 @@ void ScInterpreter::ScCell() SfxObjectShell* pShell = mrDoc.GetDocumentShell(); if( pShell && pShell->GetMedium() ) { - OUStringBuffer aBuf; - aBuf.append('\''); const INetURLObject& rURLObj = pShell->GetMedium()->GetURLObject(); - aBuf.append(rURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous)); - aBuf.append("'#$"); OUString aTabName; mrDoc.GetName( nTab, aTabName ); - aBuf.append(aTabName); - aFuncResult = aBuf.makeStringAndClear(); + aFuncResult = "'" + + rURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous) + + "'#$" + aTabName; } } } diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 0cf6fb125971..883c77beaf0c 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -4276,7 +4276,7 @@ void XclImpSheetDrawing::ReadNote3( XclImpStream& rStrm ) return; sal_uInt16 nPartLen = ::std::min( nTotalLen, static_cast< sal_uInt16 >( rStrm.GetRecLeft() ) ); - OUStringBuffer aNoteText = rStrm.ReadRawByteString( nPartLen ); + OUStringBuffer aNoteText(rStrm.ReadRawByteString( nPartLen )); nTotalLen = nTotalLen - nPartLen; while (true) { diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index 82c5c0449b25..3c6989af81fd 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -494,16 +494,12 @@ OUString XclTools::GetXclBuiltInDefName( sal_Unicode cBuiltIn ) OUString XclTools::GetBuiltInDefName( sal_Unicode cBuiltIn ) { - OUStringBuffer aBuf(maDefNamePrefix); - aBuf.append(GetXclBuiltInDefName(cBuiltIn)); - return aBuf.makeStringAndClear(); + return maDefNamePrefix + GetXclBuiltInDefName(cBuiltIn); } OUString XclTools::GetBuiltInDefNameXml( sal_Unicode cBuiltIn ) { - OUStringBuffer aBuf(maDefNamePrefixXml); - aBuf.append(GetXclBuiltInDefName(cBuiltIn)); - return aBuf.makeStringAndClear(); + return maDefNamePrefixXml + GetXclBuiltInDefName(cBuiltIn); } sal_Unicode XclTools::GetBuiltInDefNameIndex( const OUString& rDefName ) diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx index a219fdfcbcd1..af8230604b75 100644 --- a/sc/source/filter/oox/numberformatsbuffer.cxx +++ b/sc/source/filter/oox/numberformatsbuffer.cxx @@ -1915,7 +1915,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode ) sal_Int32 nPosEscape = 0; sal_Int32 nErase = 0; sal_Int32 nLastIndex = rFmtCode.getLength() - 1; - OUStringBuffer sFormat = rFmtCode; + OUStringBuffer sFormat(rFmtCode); while ( ( nPosEscape = lclPosToken( rFmtCode, u"\\ ", nPosEscape ) ) > 0 ) { diff --git a/sc/source/filter/oox/worksheetbuffer.cxx b/sc/source/filter/oox/worksheetbuffer.cxx index 94e93dbfd1a1..c4daa9cd98bd 100644 --- a/sc/source/filter/oox/worksheetbuffer.cxx +++ b/sc/source/filter/oox/worksheetbuffer.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <worksheetbuffer.hxx> #include <com/sun/star/container/XIndexAccess.hpp> @@ -159,7 +163,7 @@ OUString WorksheetBuffer::getCalcSheetName( const OUString& rWorksheetName ) con namespace { -OUString lclQuoteName( const OUString& rName ) +OUString lclQuoteName( std::u16string_view rName ) { OUStringBuffer aBuffer( rName ); // duplicate all quote characters diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 4fd91a3451ce..7556ac5e4737 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -1344,7 +1344,7 @@ void ScCheckListMenuControl::getResult(ResultType& rResult) { if ( maMembers[i].mbLeaf ) { - OUStringBuffer aLabel = maMembers[i].maName; + OUStringBuffer aLabel(maMembers[i].maName); if (aLabel.isEmpty()) aLabel = ScResId(STR_EMPTYDATA); diff --git a/sc/source/ui/dataprovider/datatransformation.cxx b/sc/source/ui/dataprovider/datatransformation.cxx index 4039f336be80..14351d7c2004 100644 --- a/sc/source/ui/dataprovider/datatransformation.cxx +++ b/sc/source/ui/dataprovider/datatransformation.cxx @@ -131,7 +131,7 @@ void MergeColumnTransformation::Transform(ScDocument& rDoc) const for (SCROW nRow = 0; nRow <= nMaxRow; ++nRow) { - OUStringBuffer aStr = rDoc.GetString(nTargetCol, nRow, 0); + OUStringBuffer aStr(rDoc.GetString(nTargetCol, nRow, 0)); for (auto& itr : maColumns) { if (itr != nTargetCol) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index f33098bbb353..8f4a0c14eb36 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1830,7 +1830,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co if ( nRepeatCount > 1 ) { OUString aCellStr = aVars.GetString(); - OUStringBuffer aRepeated = aCellStr; + OUStringBuffer aRepeated(aCellStr); for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ ) aRepeated.append(aCellStr); aVars.SetAutoText( aRepeated.makeStringAndClear() ); @@ -2998,7 +2998,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) tools::Long nRepeatCount = nAvailable / nRepeatSize; if ( nRepeatCount > 1 ) { - OUStringBuffer aRepeated = aCellStr; + OUStringBuffer aRepeated(aCellStr); for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ ) aRepeated.append(aCellStr); @@ -3376,7 +3376,7 @@ void ScOutputData::DrawEditBottomTop(DrawEditParam& rParam) const tools::Long nRepeatCount = nAvailable / nRepeatSize; if ( nRepeatCount > 1 ) { - OUStringBuffer aRepeated = aCellStr; + OUStringBuffer aRepeated(aCellStr); for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ ) aRepeated.append(aCellStr); @@ -3620,7 +3620,7 @@ void ScOutputData::DrawEditTopBottom(DrawEditParam& rParam) const tools::Long nRepeatCount = nAvailable / nRepeatSize; if ( nRepeatCount > 1 ) { - OUStringBuffer aRepeated = aCellStr; + OUStringBuffer aRepeated(aCellStr); for ( tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ ) aRepeated.append(aCellStr); diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 2bd1d11c5e53..e357bba348a6 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -2492,21 +2492,17 @@ bool HtmlExport::CreateNavBarFrames() // the navigation bar outliner closed... if(bOk) { - OUStringBuffer aStr(gaHTMLHeader); - aStr.append(CreateMetaCharset()); - aStr.append(" <title>"); - aStr.append(StringToHTMLString(maPageNames[0])); - aStr.append("</title>\r\n</head>\r\n"); - aStr.append(CreateBodyTag()); - aButton = SdResId(STR_HTMLEXP_OUTLINE); if(mnButtonThema != -1) aButton = CreateImage(GetButtonName(BTN_MORE), aButton); - aStr.append(CreateLink(u"JavaScript:parent.ExpandOutline()", aButton)); - aStr.append("</body>\r\n</html>"); - - bOk = WriteHtml("navbar3", true, aStr.makeStringAndClear()); + bOk = WriteHtml( + "navbar3", true, + OUStringConcatenation( + gaHTMLHeader + CreateMetaCharset() + " <title>" + + StringToHTMLString(maPageNames[0]) + "</title>\r\n</head>\r\n" + CreateBodyTag() + + CreateLink(u"JavaScript:parent.ExpandOutline()", aButton) + + "</body>\r\n</html>")); if (mpProgress) mpProgress->SetState(++mnPagesWritten); @@ -2515,21 +2511,17 @@ bool HtmlExport::CreateNavBarFrames() // ... and the outliner open if( bOk ) { - OUStringBuffer aStr(gaHTMLHeader); - aStr.append(CreateMetaCharset()); - aStr.append(" <title>"); - aStr.append(StringToHTMLString(maPageNames[0])); - aStr.append("</title>\r\n</head>\r\n"); - aStr.append(CreateBodyTag()); - aButton = SdResId(STR_HTMLEXP_NOOUTLINE); if(mnButtonThema != -1) aButton = CreateImage(GetButtonName(BTN_LESS), aButton); - aStr.append(CreateLink(u"JavaScript:parent.CollapseOutline()", aButton)); - aStr.append("</body>\r\n</html>"); - - bOk = WriteHtml("navbar4", true, aStr.makeStringAndClear()); + bOk = WriteHtml( + "navbar4", true, + OUStringConcatenation( + gaHTMLHeader + CreateMetaCharset() + " <title>" + + StringToHTMLString(maPageNames[0]) + "</title>\r\n</head>\r\n" + CreateBodyTag() + + CreateLink(u"JavaScript:parent.CollapseOutline()", aButton) + + "</body>\r\n</html>")); if (mpProgress) mpProgress->SetState(++mnPagesWritten); diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index cfce51145f15..2ab7e28dc2d7 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -510,7 +510,8 @@ void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css:: if (!pFile) return; - UITestLogger::getInstance().logCommand("Send UNO Command (\"" + rURL.Complete + "\") ", rArgs); + UITestLogger::getInstance().logCommand( + OUStringConcatenation("Send UNO Command (\"" + rURL.Complete + "\") "), rArgs); } } diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index dedd6532f8a5..0d7ba20396b8 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -1158,11 +1158,8 @@ void SmXMLExport::ExportFont(const SmNode* pNode, int nLevel) case TDVIPSNAMESCOL: case TICONICCOL: { - OUStringBuffer sStrBuf(7); - sStrBuf.append('#'); nc = pNode->GetToken().cMathChar.toUInt32(16); - sStrBuf.append(Color(ColorTransparency, nc).AsRGBHEXString()); - OUString ssStr(sStrBuf.makeStringAndClear()); + OUString ssStr("#" + Color(ColorTransparency, nc).AsRGBHEXString()); AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, ssStr); } break; diff --git a/starmath/source/parse5.cxx b/starmath/source/parse5.cxx index d629fd36ddb1..2fc1395ebf8d 100644 --- a/starmath/source/parse5.cxx +++ b/starmath/source/parse5.cxx @@ -2662,13 +2662,11 @@ std::unique_ptr<SmExpressionNode> SmParser5::DoError(SmParseError eError) DepthProtect aDepthGuard(m_nParseDepth); // Identify error message - OUStringBuffer sStrBuf(128); - sStrBuf.append(SmResId(RID_ERR_IDENT)); - sStrBuf.append(starmathdatabase::getParseErrorDesc(eError)); + OUString sStrBuf(SmResId(RID_ERR_IDENT) + starmathdatabase::getParseErrorDesc(eError)); // Generate error node m_aCurToken.eType = TERROR; - m_aCurToken.cMathChar = sStrBuf.makeStringAndClear(); + m_aCurToken.cMathChar = sStrBuf; auto xSNode = std::make_unique<SmExpressionNode>(m_aCurToken); SmErrorNode* pErr(new SmErrorNode(m_aCurToken)); pErr->SetSelection(m_aCurESelection); diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index 86e523e5a9fe..987b07ed8997 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -311,17 +311,11 @@ FilePermission::FilePermission( if ( m_url == "*" ) { - OUStringBuffer buf( 64 ); - buf.append( getWorkingDir() ); - buf.append( "/*" ); - m_url = buf.makeStringAndClear(); + m_url = getWorkingDir() + "/*"; } else if ( m_url == "-" ) { - OUStringBuffer buf( 64 ); - buf.append( getWorkingDir() ); - buf.append( "/-" ); - m_url = buf.makeStringAndClear(); + m_url = getWorkingDir() + "/-"; } else if (!m_url.startsWith("file:///")) { @@ -401,15 +395,11 @@ bool FilePermission::implies( Permission const & perm ) const OUString FilePermission::toString() const { - OUStringBuffer buf( 48 ); - // url - buf.append( "com.sun.star.io.FilePermission (url=\"" ); - buf.append( m_url ); - // actions - buf.append( "\", actions=\"" ); - buf.append( makeStrings( m_actions, s_actions ) ); - buf.append( "\")" ); - return buf.makeStringAndClear(); + return + // url + "com.sun.star.io.FilePermission (url=\"" + m_url + // actions + + "\", actions=\"" + makeStrings( m_actions, s_actions ) + "\")"; } namespace { diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 6ecf548c0863..ed3499210e02 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1082,7 +1082,7 @@ sal_uInt32 SvNumberFormatter::ImpGenerateCL( LanguageType eLnge ) const LanguageTag& rLoadedLocale = xLocaleData->getLoadedLanguageTag(); if ( !rLoadedLocale.equals( maLanguageTag ) ) { - LocaleDataWrapper::outputCheckMessage( xLocaleData->appendLocaleInfo( "SvNumberFormatter::ImpGenerateCL: locales don't match:" )); + LocaleDataWrapper::outputCheckMessage( xLocaleData->appendLocaleInfo( u"SvNumberFormatter::ImpGenerateCL: locales don't match:" )); } // test XML locale data FormatElement entries { @@ -2468,7 +2468,7 @@ void SvNumberFormatter::ImpAdjustFormatCodeDefault( aMsg.append("\nXML locale data FormatElement group of: "); OUString aUMsg(OStringToOUString(aMsg.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US)); LocaleDataWrapper::outputCheckMessage( - xLocaleData->appendLocaleInfo(aUMsg + pFormatArr[0].NameID)); + xLocaleData->appendLocaleInfo(OUStringConcatenation(aUMsg + pFormatArr[0].NameID))); } } // find the default (medium preferred, then long) and reset all other defaults @@ -2583,7 +2583,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio if (LocaleDataWrapper::areChecksEnabled() && pStdFormat->GetType() != SvNumFormatType::NUMBER) { LocaleDataWrapper::outputCheckMessage( xLocaleData-> - appendLocaleInfo( "SvNumberFormatter::ImpGenerateFormats: General format not NUMBER")); + appendLocaleInfo( u"SvNumberFormatter::ImpGenerateFormats: General format not NUMBER")); } pStdFormat->SetType( SvNumFormatType::NUMBER ); pStdFormat->SetStandard(); @@ -2594,7 +2594,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio if (LocaleDataWrapper::areChecksEnabled()) { LocaleDataWrapper::outputCheckMessage( xLocaleData-> - appendLocaleInfo( "SvNumberFormatter::ImpGenerateFormats: General format not insertable, nothing will work")); + appendLocaleInfo( u"SvNumberFormatter::ImpGenerateFormats: General format not insertable, nothing will work")); } } @@ -3226,7 +3226,7 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex, } else if (eType == SvNumFormatType::SCIENTIFIC) { - OUStringBuffer sOldFormatString = pFormat->GetFormatstring(); + OUStringBuffer sOldFormatString(pFormat->GetFormatstring()); sal_Int32 nIndexE = ImpPosToken( sOldFormatString, 'E' ); if (nIndexE > -1) { @@ -4059,7 +4059,7 @@ void SvNumberFormatter::GetCompatibilityCurrency( OUString& rSymbol, OUString& r if (LocaleDataWrapper::areChecksEnabled()) { LocaleDataWrapper::outputCheckMessage( xLocaleData-> - appendLocaleInfo( "GetCompatibilityCurrency: none?")); + appendLocaleInfo( u"GetCompatibilityCurrency: none?")); } rSymbol = xLocaleData->getCurrSymbol(); rAbbrev = xLocaleData->getCurrBankSymbol(); diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index 5cacc8037bda..96b81ed13abb 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -21,6 +21,7 @@ #include <memory> #include <string.h> +#include <string_view> #include <tools/debug.hxx> #include <tools/fract.hxx> @@ -567,7 +568,7 @@ OUString FontList::GetFontMapText( const FontMetric& rInfo ) const namespace { - FontMetric makeMissing(ImplFontListFontMetric const * pFontNameInfo, const OUString &rName, + FontMetric makeMissing(ImplFontListFontMetric const * pFontNameInfo, std::u16string_view rName, FontWeight eWeight, FontItalic eItalic) { FontMetric aInfo; @@ -583,7 +584,7 @@ namespace //If this is a known but uninstalled symbol font which we can remap to //OpenSymbol then toggle its charset to be a symbol font - if (ConvertChar::GetRecodeData(rName, "OpenSymbol")) + if (ConvertChar::GetRecodeData(rName, u"OpenSymbol")) aInfo.SetCharSet(RTL_TEXTENCODING_SYMBOL); return aInfo; diff --git a/svx/inc/DescriptionGenerator.hxx b/svx/inc/DescriptionGenerator.hxx index 8b3ac3f5cac2..b696cc33e1cd 100644 --- a/svx/inc/DescriptionGenerator.hxx +++ b/svx/inc/DescriptionGenerator.hxx @@ -19,6 +19,10 @@ #pragma once +#include <sal/config.h> + +#include <string_view> + #include <com/sun/star/uno/Reference.hxx> #include <rtl/ustrbuf.hxx> #include <unotools/resmgr.hxx> @@ -67,7 +71,7 @@ public: An introductory description of the shape that is made more specific by later calls to <member>addProperty</member>. */ - void Initialize(const OUString& sPrefix); + void Initialize(std::u16string_view sPrefix); /** Initialize the description with the specified string from the resource followed by the shape style in parentheses and a colon. diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx index ef04fcb8625f..94e3aab617fe 100644 --- a/svx/source/accessibility/AccessibleControlShape.cxx +++ b/svx/source/accessibility/AccessibleControlShape.cxx @@ -341,7 +341,7 @@ OUString break; default: - aDG.Initialize ("Unknown accessible control shape"); + aDG.Initialize (u"Unknown accessible control shape"); if (mxShape.is()) { aDG.AppendString (u"service name="); diff --git a/svx/source/accessibility/DescriptionGenerator.cxx b/svx/source/accessibility/DescriptionGenerator.cxx index 430f22c98c01..fe410914910f 100644 --- a/svx/source/accessibility/DescriptionGenerator.cxx +++ b/svx/source/accessibility/DescriptionGenerator.cxx @@ -57,7 +57,7 @@ void DescriptionGenerator::Initialize(TranslateId pResourceId) Initialize(sPrefix); } -void DescriptionGenerator::Initialize(const OUString& sPrefix) +void DescriptionGenerator::Initialize(std::u16string_view sPrefix) { msDescription = sPrefix; if (!mxSet.is()) diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index ff42f94a770d..3b5a070e4dee 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -1410,7 +1410,7 @@ void FmXFormShell::ExecuteSearch_Lock() FmFormArray().swap(m_aSearchForms); ::std::vector< OUString > aContextNames; impl_collectFormSearchContexts_nothrow_Lock( - m_pShell->GetCurPage()->GetForms(), OUString(), + m_pShell->GetCurPage()->GetForms(), u"", m_aSearchForms, aContextNames); if ( m_aSearchForms.size() != aContextNames.size() ) @@ -2841,7 +2841,7 @@ Reference< XControl> FmXFormShell::impl_getControl_Lock(const Reference<XControl // note: _out_rForms is a member so needs lock void FmXFormShell::impl_collectFormSearchContexts_nothrow_Lock( const Reference<XInterface>& _rxStartingPoint, - const OUString& _rCurrentLevelPrefix, FmFormArray& _out_rForms, ::std::vector< OUString >& _out_rNames ) + std::u16string_view _rCurrentLevelPrefix, FmFormArray& _out_rForms, ::std::vector< OUString >& _out_rNames ) { try { @@ -2867,14 +2867,14 @@ void FmXFormShell::impl_collectFormSearchContexts_nothrow_Lock( const Reference< // the name of the current form OUString sCompleteCurrentName( sCurrentFormName ); - if ( !_rCurrentLevelPrefix.isEmpty() ) + if ( !_rCurrentLevelPrefix.empty() ) { - sCompleteCurrentName += " (" + _rCurrentLevelPrefix + ")"; + sCompleteCurrentName += OUString::Concat(" (") + _rCurrentLevelPrefix + ")"; } // the prefix for the next level aNextLevelPrefix = _rCurrentLevelPrefix; - if ( !_rCurrentLevelPrefix.isEmpty() ) + if ( !_rCurrentLevelPrefix.empty() ) aNextLevelPrefix.append( '/' ); aNextLevelPrefix.append( sCurrentFormName ); diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx index e98da0466786..678e00052de3 100644 --- a/svx/source/form/formcontrolfactory.cxx +++ b/svx/source/form/formcontrolfactory.cxx @@ -680,7 +680,7 @@ namespace svxform } - OUString FormControlFactory::getUniqueName( const Reference< XNameAccess >& _rxContainer, const OUString& _rBaseName ) + OUString FormControlFactory::getUniqueName( const Reference< XNameAccess >& _rxContainer, std::u16string_view _rBaseName ) { sal_Int32 n = 0; OUString sName; diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 4d3c55bc8aa1..4c511897babc 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -330,7 +330,7 @@ private: // collects in strNames the names of all forms SAL_DLLPRIVATE static void impl_collectFormSearchContexts_nothrow_Lock( const css::uno::Reference< css::uno::XInterface>& _rxStartingPoint, - const OUString& _rCurrentLevelPrefix, + std::u16string_view _rCurrentLevelPrefix, FmFormArray& _out_rForms, ::std::vector< OUString >& _out_rNames ); diff --git a/svx/source/inc/formcontrolfactory.hxx b/svx/source/inc/formcontrolfactory.hxx index 2ca1d6d066c0..27320cac54d5 100644 --- a/svx/source/inc/formcontrolfactory.hxx +++ b/svx/source/inc/formcontrolfactory.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <memory> +#include <string_view> class SdrUnoObj; namespace tools { class Rectangle; } @@ -91,7 +92,7 @@ namespace svxform static OUString getUniqueName( const css::uno::Reference< css::container::XNameAccess >& _rxContainer, - const OUString& _rBaseName + std::u16string_view _rBaseName ); private: diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx index 24675f30c924..06888a8a3954 100644 --- a/sw/qa/extras/rtfexport/rtfexport2.cxx +++ b/sw/qa/extras/rtfexport/rtfexport2.cxx @@ -392,7 +392,7 @@ DECLARE_RTFEXPORT_TEST(testFdo38786, "fdo38786.rtf") DECLARE_RTFEXPORT_TEST(testN757651, "n757651.rtf") { // The bug was that due to buggy layout the text expanded to two pages. - if (Application::GetDefaultDevice()->IsFontAvailable("Times New Roman")) + if (Application::GetDefaultDevice()->IsFontAvailable(u"Times New Roman")) CPPUNIT_ASSERT_EQUAL(1, getPages()); } diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx index 229e6c96154c..fe591d11a6e8 100644 --- a/sw/source/core/fields/chpfld.cxx +++ b/sw/source/core/fields/chpfld.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <com/sun/star/text/ChapterFormat.hpp> #include <osl/diagnose.h> #include <doc.hxx> @@ -35,7 +39,7 @@ using namespace ::com::sun::star; namespace { -OUString removeControlChars(const OUString& sIn) +OUString removeControlChars(std::u16string_view sIn) { OUStringBuffer aBuf(sIn); aBuf = aBuf.replace('\n', ' ').replace('\t', ' '); diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 671d1b85356f..8f0941261cef 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -427,16 +427,14 @@ void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const tools::Rectangl break; case ESCHER_Prop_fillBlip: { - OStringBuffer aBuf; - aBuf.append("{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP - SAL_NEWLINE_STRING); int nHeaderSize = 25; // The first bytes are WW8-specific, we're only interested in the PNG - aBuf.append(msfilter::rtfutil::WriteHex(rOpt.nProp.data() + nHeaderSize, - rOpt.nProp.size() - nHeaderSize)); - aBuf.append('}'); - m_aShapeProps.insert( - std::pair<OString, OString>("fillBlip", aBuf.makeStringAndClear())); + OString aBuf = "{" OOO_STRING_SVTOOLS_RTF_PICT OOO_STRING_SVTOOLS_RTF_PNGBLIP + SAL_NEWLINE_STRING + + msfilter::rtfutil::WriteHex(rOpt.nProp.data() + nHeaderSize, + rOpt.nProp.size() - nHeaderSize) + + "}"; + m_aShapeProps.insert(std::pair<OString, OString>("fillBlip", aBuf)); } break; default: diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index c17ce9219a84..93e12e965261 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -2823,7 +2823,7 @@ bool INetURLObject::parseHostOrNetBiosName( return true; } -bool INetURLObject::setHost(OUString const & rTheHost, +bool INetURLObject::setHost(std::u16string_view rTheHost, rtl_TextEncoding eCharset) { if (!getSchemeInfo().m_bHost) @@ -3691,7 +3691,7 @@ bool INetURLObject::operator ==(INetURLObject const & rObject) const bool INetURLObject::ConcatData(INetProtocol eTheScheme, std::u16string_view rTheUser, std::u16string_view rThePassword, - OUString const & rTheHost, + std::u16string_view rTheHost, sal_uInt32 nThePort, OUString const & rThePath) { @@ -3799,7 +3799,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme, } } } - else if (!rTheHost.isEmpty() || nThePort != 0) + else if (!rTheHost.empty() || nThePort != 0) { setInvalid(); return false; @@ -4024,12 +4024,11 @@ bool INetURLObject::setName(std::u16string_view rTheName, EncodeMechanism eMecha while (p != pSegEnd && *p != ';') ++p; - OUStringBuffer aNewPath(256); - aNewPath.append(pPathBegin, pSegBegin - pPathBegin); - aNewPath.append(encodeText(rTheName, PART_PCHAR, eMechanism, eCharset, true)); - aNewPath.append(p, pPathEnd - p); - - return setPath(aNewPath.makeStringAndClear(), EncodeMechanism::NotCanonical, + return setPath( + std::u16string_view(pPathBegin, pSegBegin - pPathBegin) + + encodeText(rTheName, PART_PCHAR, eMechanism, eCharset, true) + + std::u16string_view(p, pPathEnd - p), + EncodeMechanism::NotCanonical, RTL_TEXTENCODING_UTF8); } @@ -4102,13 +4101,11 @@ bool INetURLObject::setBase(std::u16string_view rTheBase, sal_Int32 nIndex, if (!pExtension) pExtension = p; - OUStringBuffer aNewPath; - aNewPath.append(pPathBegin, pSegBegin - pPathBegin); - aNewPath.append(encodeText(rTheBase, PART_PCHAR, - eMechanism, eCharset, true)); - aNewPath.append(pExtension, pPathEnd - pExtension); - - return setPath(aNewPath.makeStringAndClear(), EncodeMechanism::NotCanonical, + return setPath( + std::u16string_view(pPathBegin, pSegBegin - pPathBegin) + + encodeText(rTheBase, PART_PCHAR, eMechanism, eCharset, true) + + std::u16string_view(pExtension, pPathEnd - pExtension), + EncodeMechanism::NotCanonical, RTL_TEXTENCODING_UTF8); } @@ -4164,14 +4161,11 @@ bool INetURLObject::setExtension(std::u16string_view rTheExtension, if (!pExtension) pExtension = p; - OUStringBuffer aNewPath(128); - aNewPath.append(pPathBegin, pExtension - pPathBegin); - aNewPath.append('.'); - aNewPath.append(encodeText(rTheExtension, PART_PCHAR, - EncodeMechanism::WasEncoded, eCharset, true)); - aNewPath.append(p, pPathEnd - p); - - return setPath(aNewPath.makeStringAndClear(), EncodeMechanism::NotCanonical, + return setPath( + OUString::Concat(std::u16string_view(pPathBegin, pExtension - pPathBegin)) + "." + + encodeText(rTheExtension, PART_PCHAR, EncodeMechanism::WasEncoded, eCharset, true) + + std::u16string_view(p, pPathEnd - p), + EncodeMechanism::NotCanonical, RTL_TEXTENCODING_UTF8); } diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 0209fa4fdffa..f1b50e46b009 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/ucb/XDynamicResultSet.hpp> #include <com/sun/star/deployment/PackageInformationProvider.hpp> +#include <o3tl/string_view.hxx> #include <ucbhelper/propertyvalueset.hxx> #include <ucbhelper/cancelcommandexecution.hxx> #include <ucbhelper/content.hxx> @@ -43,6 +44,7 @@ #include <sal/log.hxx> #include <algorithm> +#include <string_view> namespace ucb::ucp::ext @@ -81,12 +83,12 @@ namespace ucb::ucp::ext namespace { - OUString lcl_compose( const OUString& i_rBaseURL, const OUString& i_rRelativeURL ) + OUString lcl_compose( std::u16string_view i_rBaseURL, const OUString& i_rRelativeURL ) { - ENSURE_OR_RETURN( !i_rBaseURL.isEmpty(), "illegal base URL", i_rRelativeURL ); + ENSURE_OR_RETURN( !i_rBaseURL.empty(), "illegal base URL", i_rRelativeURL ); OUStringBuffer aComposer( i_rBaseURL ); - if ( !i_rBaseURL.endsWith("/") ) + if ( !o3tl::ends_with(i_rBaseURL, u"/") ) aComposer.append( '/' ); aComposer.append( i_rRelativeURL ); return aComposer.makeStringAndClear(); diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx index beb9e3066d15..8d505c94f7dd 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/deployment/PackageInformationProvider.hpp> #include <com/sun/star/ucb/IllegalIdentifierException.hpp> #include <com/sun/star/ucb/ResultSetException.hpp> +#include <o3tl/string_view.hxx> #include <ucbhelper/contentidentifier.hxx> #include <ucbhelper/providerhelper.hxx> #include <ucbhelper/content.hxx> @@ -34,6 +35,7 @@ #include <sal/log.hxx> #include <memory> +#include <string_view> namespace ucb::ucp::ext @@ -59,12 +61,12 @@ namespace ucb::ucp::ext namespace { - OUString lcl_compose( const OUString& i_rBaseURL, const OUString& i_rRelativeURL ) + OUString lcl_compose( std::u16string_view i_rBaseURL, const OUString& i_rRelativeURL ) { - ENSURE_OR_RETURN( !i_rBaseURL.isEmpty(), "illegal base URL", i_rRelativeURL ); + ENSURE_OR_RETURN( !i_rBaseURL.empty(), "illegal base URL", i_rRelativeURL ); OUStringBuffer aComposer( i_rBaseURL ); - if ( !i_rBaseURL.endsWith("/") ) + if ( !o3tl::ends_with(i_rBaseURL, u"/") ) aComposer.append( '/' ); aComposer.append( i_rRelativeURL ); return aComposer.makeStringAndClear(); diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx index 5a1335e1efc9..da4058ff0d69 100644 --- a/ucb/source/ucp/tdoc/tdoc_content.cxx +++ b/ucb/source/ucp/tdoc/tdoc_content.cxx @@ -693,12 +693,11 @@ Content::makeNewIdentifier( const OUString& rTitle ) // Assemble new content identifier... Uri aUri( m_xIdentifier->getContentIdentifier() ); - OUStringBuffer aNewURL = aUri.getParentUri(); - aNewURL.append( ::ucb_impl::urihelper::encodeSegment( rTitle ) ); + OUString aNewURL = aUri.getParentUri() + ::ucb_impl::urihelper::encodeSegment( rTitle ); return uno::Reference< ucb::XContentIdentifier >( - new ::ucbhelper::ContentIdentifier( aNewURL.makeStringAndClear() ) ); + new ::ucbhelper::ContentIdentifier( aNewURL ) ); } @@ -1531,9 +1530,7 @@ void Content::insert( const uno::Reference< io::XInputStream >& xData, m_aProps.setTitle( aUri.getDecodedName() ); } - OUStringBuffer aNewURL = aUri.getParentUri(); - aNewURL.append( m_aProps.getTitle() ); - Uri aNewUri( aNewURL.makeStringAndClear() ); + Uri aNewUri( aUri.getParentUri() + m_aProps.getTitle() ); // Handle possible name clash... switch ( nNameClashResolve ) @@ -1565,7 +1562,7 @@ void Content::insert( const uno::Reference< io::XInputStream >& xData, do { - OUStringBuffer aNew = aNewUri.getUri(); + OUStringBuffer aNew(aNewUri.getUri()); aNew.append( "_" ); aNew.append( ++nTry ); aNewUri.setUri( aNew.makeStringAndClear() ); @@ -1585,7 +1582,7 @@ void Content::insert( const uno::Reference< io::XInputStream >& xData, } else { - OUStringBuffer aNewTitle = m_aProps.getTitle(); + OUStringBuffer aNewTitle(m_aProps.getTitle()); aNewTitle.append( "_" ); aNewTitle.append( ++nTry ); m_aProps.setTitle( aNewTitle.makeStringAndClear() ); diff --git a/unotools/qa/unit/testGetEnglishSearchName.cxx b/unotools/qa/unit/testGetEnglishSearchName.cxx index 84feb67b97ae..f20f9c8d46fb 100644 --- a/unotools/qa/unit/testGetEnglishSearchName.cxx +++ b/unotools/qa/unit/testGetEnglishSearchName.cxx @@ -27,18 +27,18 @@ public: void Test::testSingleElement() { // lowercase - OUString test1 = GetEnglishSearchFontName( "SYMBOL" ); + OUString test1 = GetEnglishSearchFontName( u"SYMBOL" ); CPPUNIT_ASSERT_EQUAL( OUString("symbol"),test1); //trailing whitespaces - test1 = GetEnglishSearchFontName( "Symbol " ); + test1 = GetEnglishSearchFontName( u"Symbol " ); CPPUNIT_ASSERT_EQUAL(OUString("symbol"),test1); //no longer remove script suffixes - test1 = GetEnglishSearchFontName( "Symbol(SIP)" ); + test1 = GetEnglishSearchFontName( u"Symbol(SIP)" ); CPPUNIT_ASSERT_EQUAL(OUString("symbol(sip)"),test1); - test1 = GetEnglishSearchFontName( "CM Roman CE" ); + test1 = GetEnglishSearchFontName( u"CM Roman CE" ); CPPUNIT_ASSERT_EQUAL( OUString("cmromance"),test1); //remove special characters; leave semicolon, numbers - test1 = GetEnglishSearchFontName( "sy;mb?=ol129" ); + test1 = GetEnglishSearchFontName( u"sy;mb?=ol129" ); CPPUNIT_ASSERT_EQUAL( OUString("sy;mbol129"),test1); //transformation diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index e30c7d30f558..9d67f1913887 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -118,7 +118,7 @@ void LocaleDataWrapper::loadData() { if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getCurrSymbolsImpl: no default currency" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getCurrSymbolsImpl: no default currency" ) ); } pCurr = aCurrSeq.begin(); } @@ -547,7 +547,7 @@ void LocaleDataWrapper::loadCurrencyFormats() { // bad luck if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getCurrFormatsImpl: no currency formats" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getCurrFormatsImpl: no currency formats" ) ); } nCurrPositiveFormat = nCurrNegativeFormat = nCurrFormatDefault; return; @@ -591,7 +591,7 @@ void LocaleDataWrapper::loadCurrencyFormats() scanCurrFormatImpl( pFormatArr[nElem].Code, 0, nSign, nPar, nNum, nBlank, nSym ); if (areChecksEnabled() && (nNum == -1 || nSym == -1)) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getCurrFormatsImpl: CurrPositiveFormat?" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getCurrFormatsImpl: CurrPositiveFormat?" ) ); } if (nBlank == -1) { @@ -618,7 +618,7 @@ void LocaleDataWrapper::loadCurrencyFormats() scanCurrFormatImpl( rCode, nDelim+1, nSign, nPar, nNum, nBlank, nSym ); if (areChecksEnabled() && (nNum == -1 || nSym == -1 || (nPar == -1 && nSign == -1))) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getCurrFormatsImpl: CurrNegativeFormat?" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getCurrFormatsImpl: CurrNegativeFormat?" ) ); } // NOTE: one of nPar or nSign are allowed to be -1 if (nBlank == -1) @@ -738,7 +738,7 @@ LongDateOrder LocaleDataWrapper::scanDateOrderImpl( const OUString& rCode ) cons { if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::scanDateOrder: not all DMY present" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::scanDateOrder: not all DMY present" ) ); } if (nDay == -1) nDay = rCode.getLength(); @@ -761,7 +761,7 @@ LongDateOrder LocaleDataWrapper::scanDateOrderImpl( const OUString& rCode ) cons { if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::scanDateOrder: no magic applicable" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::scanDateOrder: no magic applicable" ) ); } return LongDateOrder::DMY; } @@ -796,7 +796,7 @@ void LocaleDataWrapper::loadDateOrders() { // bad luck if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getDateOrdersImpl: no date formats" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getDateOrdersImpl: no date formats" ) ); } nDateOrder = DateOrder::DMY; nLongDateOrder = LongDateOrder::DMY; @@ -840,13 +840,13 @@ void LocaleDataWrapper::loadDateOrders() { if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getDateOrdersImpl: no edit" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getDateOrdersImpl: no edit" ) ); } if ( nDef == -1 ) { if (areChecksEnabled()) { - outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getDateOrdersImpl: no default" ) ); + outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::getDateOrdersImpl: no default" ) ); } if ( nMedium != -1 ) nDef = nMedium; @@ -1463,16 +1463,11 @@ LanguageTag LocaleDataWrapper::getLoadedLanguageTag() const return LanguageTag( lang::Locale( aLCInfo.Language, aLCInfo.Country, aLCInfo.Variant )); } -OUString LocaleDataWrapper::appendLocaleInfo(const OUString& rDebugMsg) const +OUString LocaleDataWrapper::appendLocaleInfo(std::u16string_view rDebugMsg) const { - OUStringBuffer aDebugMsg(rDebugMsg); - aDebugMsg.append('\n'); - aDebugMsg.append(maLanguageTag.getBcp47()); - aDebugMsg.append(" requested\n"); LanguageTag aLoaded = getLoadedLanguageTag(); - aDebugMsg.append(aLoaded.getBcp47()); - aDebugMsg.append(" loaded"); - return aDebugMsg.makeStringAndClear(); + return OUString::Concat(rDebugMsg) + "\n" + maLanguageTag.getBcp47() + " requested\n" + + aLoaded.getBcp47() + " loaded"; } // static diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx index b4bd2c45c852..736632f86c75 100644 --- a/unotools/source/misc/fontcvt.cxx +++ b/unotools/source/misc/fontcvt.cxx @@ -1344,7 +1344,7 @@ const RecodeTable aAppleSymbolRecodeTable[] = { static ConvertChar aImplStarSymbolCvt = { nullptr, "StarBats", ImplStarSymbolToStarBats }; -const ConvertChar* ConvertChar::GetRecodeData( const OUString& rOrgFontName, const OUString& rMapFontName ) +const ConvertChar* ConvertChar::GetRecodeData( std::u16string_view rOrgFontName, std::u16string_view rMapFontName ) { const ConvertChar* pCvt = nullptr; @@ -1391,7 +1391,7 @@ const ConvertChar* ConvertChar::GetRecodeData( const OUString& rOrgFontName, con return pCvt; } -FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rOrgName, FontToSubsFontFlags nFlags ) +FontToSubsFontConverter CreateFontToSubsFontConverter( std::u16string_view rOrgName, FontToSubsFontFlags nFlags ) { const ConvertChar* pCvt = nullptr; diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx index 214c8946e553..66bd91363be7 100644 --- a/unotools/source/misc/fontdefs.cxx +++ b/unotools/source/misc/fontdefs.cxx @@ -225,7 +225,7 @@ OUString StripScriptFromName(const OUString& _aName) return aName; } -OUString GetEnglishSearchFontName(const OUString& rInName) +OUString GetEnglishSearchFontName(std::u16string_view rInName) { OUStringBuffer rName(rInName); bool bNeedTranslation = false; diff --git a/uui/source/iahndl-errorhandler.cxx b/uui/source/iahndl-errorhandler.cxx index c41625522f32..c03d518108f3 100644 --- a/uui/source/iahndl-errorhandler.cxx +++ b/uui/source/iahndl-errorhandler.cxx @@ -37,6 +37,7 @@ #include "iahndl.hxx" #include <memory> +#include <string_view> using namespace com::sun::star; @@ -55,14 +56,14 @@ DialogMask executeErrorDialog( weld::Window* pParent, task::InteractionClassification eClassification, - OUString const & rContext, + std::u16string_view rContext, std::u16string_view rMessage, MessageBoxStyle nButtonMask) { SolarMutexGuard aGuard; OUStringBuffer aText(rContext); - if (!rContext.isEmpty() && !rMessage.empty()) + if (!rContext.empty() && !rMessage.empty()) aText.append(":\n"); //TODO! must be internationalized aText.append(rMessage); diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx index 79af305653ff..601796e656a5 100644 --- a/uui/source/secmacrowarnings.cxx +++ b/uui/source/secmacrowarnings.cxx @@ -179,7 +179,7 @@ void MacroWarning::SetStorage( const css::uno::Reference < css::embed::XStorage mpInfos = &rInfos; OUString aCN_Id("CN"); - OUStringBuffer s = GetContentPart( rInfos[ 0 ].Signer->getSubjectName(), aCN_Id ); + OUStringBuffer s(GetContentPart( rInfos[ 0 ].Signer->getSubjectName(), aCN_Id )); for( sal_Int32 i = 1 ; i < nCnt ; ++i ) { diff --git a/vcl/inc/font/DirectFontSubstitution.hxx b/vcl/inc/font/DirectFontSubstitution.hxx index 7c2840bb4cad..4abfb8832ea7 100644 --- a/vcl/inc/font/DirectFontSubstitution.hxx +++ b/vcl/inc/font/DirectFontSubstitution.hxx @@ -28,13 +28,14 @@ #include <font/fontsubstitution.hxx> #include <string> +#include <string_view> #include <vector> namespace vcl::font { struct FontSubstEntry { - FontSubstEntry(OUString const& rFontName, OUString const& rSubstFontName, + FontSubstEntry(std::u16string_view rFontName, std::u16string_view rSubstFontName, AddFontSubstituteFlags nSubstFlags) : maSearchName(GetEnglishSearchFontName(rFontName)) , maSearchReplaceName(GetEnglishSearchFontName(rSubstFontName)) diff --git a/vcl/inc/font/PhysicalFontCollection.hxx b/vcl/inc/font/PhysicalFontCollection.hxx index 5cad84ca15f7..c73be7075ca5 100644 --- a/vcl/inc/font/PhysicalFontCollection.hxx +++ b/vcl/inc/font/PhysicalFontCollection.hxx @@ -28,6 +28,7 @@ #include "PhysicalFontFamily.hxx" #include <array> +#include <string_view> #define MAX_GLYPHFALLBACK 16 @@ -55,7 +56,7 @@ public: int Count() const { return maPhysicalFontFamilies.size(); } // find the device font family - vcl::font::PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const; + vcl::font::PhysicalFontFamily* FindFontFamily( std::u16string_view rFontName ) const; vcl::font::PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName ); vcl::font::PhysicalFontFamily* FindFontFamily( vcl::font::FontSelectPattern& ) const; vcl::font::PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const; diff --git a/vcl/qa/cppunit/physicalfontcollection.cxx b/vcl/qa/cppunit/physicalfontcollection.cxx index ea76fde542e8..7a261268119a 100644 --- a/vcl/qa/cppunit/physicalfontcollection.cxx +++ b/vcl/qa/cppunit/physicalfontcollection.cxx @@ -68,12 +68,12 @@ void VclPhysicalFontCollectionTest::testShouldFindFontFamily() { // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor) vcl::font::PhysicalFontCollection aFontCollection; - aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName("Test Font Family Name")); + aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name")); vcl::font::PhysicalFontFamily* pFontFamily - = aFontCollection.FindFontFamily("Test Font Family Name"); + = aFontCollection.FindFontFamily(u"Test Font Family Name"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name correct", - GetEnglishSearchFontName("Test Font Family Name"), + GetEnglishSearchFontName(u"Test Font Family Name"), pFontFamily->GetSearchName()); } @@ -81,25 +81,25 @@ void VclPhysicalFontCollectionTest::testShouldNotFindFontFamily() { // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor) vcl::font::PhysicalFontCollection aFontCollection; - aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName("Test Font Family Name")); + aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name")); - CPPUNIT_ASSERT(!aFontCollection.FindFontFamily("blah")); + CPPUNIT_ASSERT(!aFontCollection.FindFontFamily(u"blah")); } void VclPhysicalFontCollectionTest::testShouldFindFontFamilyByTokenNames() { // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor) vcl::font::PhysicalFontCollection aFontCollection; - aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName("Test Font Family Name")); + aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name")); - OUString sTokenNames(GetEnglishSearchFontName("Test Font Family Name;")); - sTokenNames += GetEnglishSearchFontName("Test 2"); + OUString sTokenNames(GetEnglishSearchFontName(u"Test Font Family Name;")); + sTokenNames += GetEnglishSearchFontName(u"Test 2"); vcl::font::PhysicalFontFamily* pFontFamily = aFontCollection.FindFontFamilyByTokenNames("Test Font Family Name"); CPPUNIT_ASSERT_MESSAGE("Found the font family", pFontFamily); CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name correct", - GetEnglishSearchFontName("Test Font Family Name"), + GetEnglishSearchFontName(u"Test Font Family Name"), pFontFamily->GetSearchName()); } @@ -107,7 +107,7 @@ void VclPhysicalFontCollectionTest::testShouldFindNoFamilyWithWorthlessAttribute { // note: you must normalize the search family name (first parameter of PhysicalFontFamily constructor) vcl::font::PhysicalFontCollection aFontCollection; - aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName("Test Font Family Name")); + aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"Test Font Family Name")); CPPUNIT_ASSERT(!aFontCollection.FindFontFamilyByAttributes(ImplFontAttrs::None, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE, "")); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 5490ae34c6d5..3af74c6d92b9 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -227,13 +227,13 @@ static bool ImplCommaPointCharEqual( sal_Unicode c1, sal_Unicode c2 ) static OUString ImplPatternReformat( const OUString& rStr, const OString& rEditMask, - const OUString& rLiteralMask, + std::u16string_view rLiteralMask, sal_uInt16 nFormatFlags ) { if (rEditMask.isEmpty()) return rStr; - OUStringBuffer aOutStr = rLiteralMask; + OUStringBuffer aOutStr(rLiteralMask); sal_Unicode cTempChar; sal_Unicode cChar; sal_Unicode cLiteral; @@ -366,7 +366,7 @@ static void ImplPatternMaxPos( const OUString& rStr, const OString& rEditMask, static OUString ImplPatternProcessStrictModify(const OUString& rText, const OString& rEditMask, - const OUString& rLiteralMask, + std::u16string_view rLiteralMask, bool bSameMask) { OUString aText(rText); @@ -395,7 +395,7 @@ static OUString ImplPatternProcessStrictModify(const OUString& rText, static void ImplPatternProcessStrictModify( Edit* pEdit, const OString& rEditMask, - const OUString& rLiteralMask, + std::u16string_view rLiteralMask, bool bSameMask ) { OUString aText = pEdit->GetText(); @@ -429,7 +429,7 @@ static void ImplPatternProcessStrictModify( Edit* pEdit, static void ImplPatternProcessStrictModify( weld::Entry& rEntry, const OString& rEditMask, - const OUString& rLiteralMask, + std::u16string_view rLiteralMask, bool bSameMask ) { OUString aText = rEntry.get_text(); @@ -724,7 +724,7 @@ static bool ImplPatternProcessKeyInput( IEditImplementation& rEdit, const KeyEve cChar = 0; if ( cChar ) { - OUStringBuffer aStr = rEdit.GetText(); + OUStringBuffer aStr(rEdit.GetText()); bool bError = false; if ( bSameMask && rEdit.IsInsertMode() ) { @@ -2292,7 +2292,7 @@ static bool ImplTimeProcessKeyInput( const KeyEvent& rKEvt, } } -static bool ImplIsOnlyDigits( const OUStringBuffer& _rStr ) +static bool ImplIsOnlyDigits( const OUString& _rStr ) { const sal_Unicode* _pChr = _rStr.getStr(); for ( sal_Int32 i = 0; i < _rStr.getLength(); ++i, ++_pChr ) @@ -2303,7 +2303,7 @@ static bool ImplIsOnlyDigits( const OUStringBuffer& _rStr ) return true; } -static bool ImplIsValidTimePortion( bool _bSkipInvalidCharacters, const OUStringBuffer& _rStr ) +static bool ImplIsValidTimePortion( bool _bSkipInvalidCharacters, const OUString& _rStr ) { if ( !_bSkipInvalidCharacters ) { @@ -2328,17 +2328,18 @@ static bool ImplCutTimePortion( OUStringBuffer& _rStr, sal_Int32 _nSepPos, bool return true; } -bool TimeFormatter::TextToTime(const OUString& rStr, tools::Time& rTime, TimeFieldFormat eFormat, +bool TimeFormatter::TextToTime(std::u16string_view rStr, tools::Time& rTime, + TimeFieldFormat eFormat, bool bDuration, const LocaleDataWrapper& rLocaleDataWrapper, bool _bSkipInvalidCharacters) { - OUStringBuffer aStr = rStr; + OUStringBuffer aStr(rStr); short nHour = 0; short nMinute = 0; short nSecond = 0; sal_Int64 nNanoSec = 0; tools::Time aTime( 0, 0, 0 ); - if ( rStr.isEmpty() ) + if ( rStr.empty() ) return false; // Search for separators @@ -2521,7 +2522,7 @@ bool TimeFormatter::TextToTime(const OUString& rStr, tools::Time& rTime, TimeFie return true; } -void TimeFormatter::ImplTimeReformat( const OUString& rStr, OUString& rOutStr ) +void TimeFormatter::ImplTimeReformat( std::u16string_view rStr, OUString& rOutStr ) { tools::Time aTime( 0, 0, 0 ); if ( !TextToTime( rStr, aTime, GetFormat(), IsDuration(), ImplGetLocaleDataWrapper() ) ) diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index 8750ef96f191..4a9c86187677 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -70,7 +70,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if ( rNumber.IsNeg() ) aFraction *= -1; - OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( static_cast<tools::Long>(aFraction), nDigits, rCurrSymbol, bShowThousandSep ); + OUStringBuffer aTemplate(rLocaleDataWrapper.getCurr( static_cast<tools::Long>(aFraction), nDigits, rCurrSymbol, bShowThousandSep )); while( !aInteger.IsZero() ) { aFraction = aInteger; diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index bbccffc0b23c..0cb503a7df54 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -303,7 +303,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySearchName(const return pFoundData; } -PhysicalFontFamily* PhysicalFontCollection::FindFontFamily(OUString const& rFontName) const +PhysicalFontFamily* PhysicalFontCollection::FindFontFamily(std::u16string_view rFontName) const { return ImplFindFontFamilyBySearchName( GetEnglishSearchFontName( rFontName ) ); } diff --git a/vcl/source/font/fontcache.cxx b/vcl/source/font/fontcache.cxx index bdc474223008..b98d1bb644cc 100644 --- a/vcl/source/font/fontcache.cxx +++ b/vcl/source/font/fontcache.cxx @@ -166,7 +166,7 @@ rtl::Reference<LogicalFontInstance> ImplFontCache::GetFontInstance( PhysicalFont aFontSelData.maTargetName.equalsIgnoreAsciiCase("symbol") && aFontSelData.maSearchName.equalsIgnoreAsciiCase("symbol")) { - pFontInstance->mpConversion = ConvertChar::GetRecodeData( "Symbol", "AppleSymbol" ); + pFontInstance->mpConversion = ConvertChar::GetRecodeData( u"Symbol", u"AppleSymbol" ); } #endif @@ -222,7 +222,7 @@ rtl::Reference<LogicalFontInstance> ImplFontCache::GetGlyphFallbackFont( Physica //sufficient heavy-weight code that's likely to undo the value of the //optimization if (nFallbackLevel == 1) - pFallbackData = pFontCollection->FindFontFamily("EUDC"); + pFallbackData = pFontCollection->FindFontFamily(u"EUDC"); if (!pFallbackData) pFallbackData = pFontCollection->GetGlyphFallbackFont(rFontSelData, pFontInstance, rMissingCodes, nFallbackLevel-1); // escape when there are no font candidates diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 9ac3d7492307..5139f1fc03a4 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -126,7 +126,7 @@ int OutputDevice::GetFontFaceCollectionCount() const return mpFontFaceCollection->Count(); } -bool OutputDevice::IsFontAvailable( const OUString& rFontName ) const +bool OutputDevice::IsFontAvailable( std::u16string_view rFontName ) const { ImplInitFontList(); vcl::font::PhysicalFontFamily* pFound = mxFontCollection->FindFontFamily( rFontName ); diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx index 00d98a6cf779..9b6719411e98 100644 --- a/vcl/source/uitest/logger.cxx +++ b/vcl/source/uitest/logger.cxx @@ -79,7 +79,7 @@ UITestLogger::UITestLogger() } } -void UITestLogger::logCommand(const OUString& rAction, +void UITestLogger::logCommand(std::u16string_view rAction, const css::uno::Sequence<css::beans::PropertyValue>& rArgs) { if (!mbValid) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 190c0e0bcad1..ec8c4a99dad1 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2222,7 +2222,7 @@ namespace BuilderUtils } } - OUString convertMnemonicMarkup(const OUString &rIn) + OUString convertMnemonicMarkup(std::u16string_view rIn) { OUStringBuffer aRet(rIn); for (sal_Int32 nI = 0; nI < aRet.getLength(); ++nI) diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 3c2ae8ea7a61..7ba2c127fb3b 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1692,7 +1692,7 @@ sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c ) sal_Unicode cNew = c; if( !mpImpl->hBatsFontConv ) { - mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( "StarBats", + mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( u"StarBats", FontToSubsFontFlags::IMPORT ); SAL_WARN_IF( !mpImpl->hBatsFontConv, "xmloff.core", "Got no symbol font converter" ); } @@ -1709,7 +1709,7 @@ sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c ) sal_Unicode cNew = c; if( !mpImpl->hMathFontConv ) { - mpImpl->hMathFontConv = CreateFontToSubsFontConverter( "StarMath", + mpImpl->hMathFontConv = CreateFontToSubsFontConverter( u"StarMath", FontToSubsFontFlags::IMPORT ); SAL_WARN_IF( !mpImpl->hMathFontConv, "xmloff.core", "Got no symbol font converter" ); } diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 39d6c2763c6a..823cdf79e904 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -1027,7 +1027,7 @@ void SvXMLNumFmtElementContext::endFastElement(sal_Int32 ) // add integer part only if min-integer-digits attribute is there aNumInfo.nDecimals = 0; rParent.AddNumber( aNumInfo ); // number without decimals - OUStringBuffer sIntegerFractionDelimiter = aNumInfo.aIntegerFractionDelimiter; + OUStringBuffer sIntegerFractionDelimiter(aNumInfo.aIntegerFractionDelimiter); lcl_EnquoteIfNecessary( sIntegerFractionDelimiter, rParent ); rParent.AddToCode( sIntegerFractionDelimiter.makeStringAndClear() ); // default is ' ' } @@ -1704,8 +1704,8 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo ) bGrouping = false; // grouping and embedded characters can't be used together sal_uInt32 nStdIndex = pFormatter->GetStandardIndex( nFormatLang ); - OUStringBuffer aNumStr = pFormatter->GenerateFormat( nStdIndex, nFormatLang, - bGrouping, false, nGenPrec, nLeading ); + OUStringBuffer aNumStr(pFormatter->GenerateFormat( nStdIndex, nFormatLang, + bGrouping, false, nGenPrec, nLeading )); if ( rInfo.nExpDigits >= 0 && nLeading == 0 && !bGrouping && nEmbeddedCount == 0 ) { diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index bc99e1cc3750..35dcd65b5528 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -864,12 +864,11 @@ bool XMLVariableDeclImportContext::FindFieldMaster( xFactory(rImport.GetModel(),UNO_QUERY); if( xFactory.is() ) { - OUStringBuffer sService; - sService.append(sAPI_fieldmaster_prefix); - sService.append((eVarType==VarTypeUserField) ? + OUString sService = sAPI_fieldmaster_prefix + + ((eVarType==VarTypeUserField) ? OUString(sAPI_user) : OUString(sAPI_set_expression)); Reference<XInterface> xIfc = - xFactory->createInstance( sService.makeStringAndClear() ); + xFactory->createInstance( sService ); if (xIfc.is()) { Reference<XPropertySet> xTmp( xIfc, UNO_QUERY ); xMaster = xTmp; |