new loplugin:bufferadd

look for OUStringBuffer append sequences that can be turned
into creating an OUString with + operations

Change-Id: Ica840dc096000307b4a105fb4d9ec7588a15ade6
Reviewed-on: https://gerrit.libreoffice.org/80809
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2019-10-14 14:27:57 +02:00
parent 9270f74466
commit f13c6ad5f0
126 changed files with 1022 additions and 856 deletions

View File

@ -67,15 +67,12 @@ void EnableTest::testDimEnable()
void EnableTest::testWin64()
{
OUStringBuffer aSource1(" #If Win64\n");
aSource1.append("Declare PtrSafe Function aht_apiGetOpenFileName Lib ");
aSource1.append('"');
aSource1.append("comdlg32.dll");
aSource1.append('"');
aSource1.append("\n");
aSource1.append("#End if\n");
OUString aSource1 = " #If Win64\n"
"Declare PtrSafe Function aht_apiGetOpenFileName Lib \"comdlg32.dll\""
"\n"
"#End if\n";
MacroSnippet myMacro(aSource1.toString());
MacroSnippet myMacro(aSource1);
myMacro.Compile();
CPPUNIT_ASSERT_MESSAGE("#if Win64 Declare PtrSafe causes compile error", !myMacro.HasError() );
}

View File

@ -567,13 +567,10 @@ OUString ObjectIdentifier::createParticleForAxis(
sal_Int32 nDimensionIndex
, sal_Int32 nAxisIndex )
{
OUStringBuffer aRet("Axis=");
aRet.append( OUString::number( nDimensionIndex ) );
aRet.append(",");
aRet.append( OUString::number( nAxisIndex ) );
return aRet.makeStringAndClear();
return "Axis=" +
OUString::number( nDimensionIndex ) +
"," +
OUString::number( nAxisIndex );
}
OUString ObjectIdentifier::createParticleForGrid(

View File

@ -0,0 +1,416 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef LO_CLANG_SHARED_PLUGINS
#include <cassert>
#include <string>
#include <iostream>
#include <unordered_set>
#include "plugin.hxx"
#include "check.hxx"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/StmtVisitor.h"
/**
Look for *StringBuffer append sequences which can be converted to *String + sequences.
*/
namespace
{
class BufferAdd : public loplugin::FilteringPlugin<BufferAdd>
{
public:
explicit BufferAdd(loplugin::InstantiationData const& data)
: FilteringPlugin(data)
{
}
bool preRun() override
{
std::string fn(handler.getMainFileName());
loplugin::normalizeDotDotInFilePath(fn);
if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/oustring/"))
return false;
if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/oustringbuffer/"))
return false;
if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/strings/"))
return false;
if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/OStringBuffer/"))
return false;
// some false +
if (loplugin::isSamePathname(fn, SRCDIR "/unoidl/source/sourcetreeprovider.cxx"))
return false;
if (loplugin::isSamePathname(fn, SRCDIR "/writerfilter/source/dmapper/StyleSheetTable.cxx"))
return false;
if (loplugin::isSamePathname(fn, SRCDIR "/writerfilter/source/dmapper/GraphicImport.cxx"))
return false;
return true;
}
virtual void run() override
{
if (!preRun())
return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
for (auto const& pair : goodMap)
if (!isa<ParmVarDecl>(pair.first) &&
// reference types have slightly weird behaviour
!pair.first->getType()->isReferenceType()
&& badMap.find(pair.first) == badMap.end())
report(DiagnosticsEngine::Warning,
"convert this append sequence into a *String + sequence",
compat::getBeginLoc(pair.first))
<< pair.first->getSourceRange();
}
bool VisitStmt(Stmt const*);
bool VisitCallExpr(CallExpr const*);
bool VisitCXXConstructExpr(CXXConstructExpr const*);
bool VisitUnaryOperator(UnaryOperator const*);
private:
void findBufferAssignOrAdd(const Stmt* parentStmt, Stmt const*);
Expr const* ignore(Expr const*);
bool isSideEffectFree(Expr const*);
bool isMethodOkToMerge(CXXMemberCallExpr const*);
void addToGoodMap(const VarDecl* varDecl, const Stmt* parentStmt);
std::unordered_map<const VarDecl*, const Stmt*> goodMap;
std::unordered_set<const VarDecl*> badMap;
};
bool BufferAdd::VisitStmt(Stmt const* stmt)
{
if (ignoreLocation(stmt))
return true;
if (!isa<CompoundStmt>(stmt) && !isa<CXXCatchStmt>(stmt) && !isa<CXXForRangeStmt>(stmt)
&& !isa<CXXTryStmt>(stmt) && !isa<DoStmt>(stmt) && !isa<ForStmt>(stmt) && !isa<IfStmt>(stmt)
&& !isa<SwitchStmt>(stmt) && !isa<WhileStmt>(stmt))
return true;
for (auto it = stmt->child_begin(); it != stmt->child_end(); ++it)
if (*it)
findBufferAssignOrAdd(stmt, *it);
return true;
}
bool BufferAdd::VisitCallExpr(CallExpr const* callExpr)
{
if (ignoreLocation(callExpr))
return true;
for (unsigned i = 0; i != callExpr->getNumArgs(); ++i)
{
auto a = ignore(callExpr->getArg(i));
if (auto declRefExpr = dyn_cast<DeclRefExpr>(a))
if (auto varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl()))
badMap.insert(varDecl);
}
return true;
}
bool BufferAdd::VisitCXXConstructExpr(CXXConstructExpr const* callExpr)
{
if (ignoreLocation(callExpr))
return true;
for (unsigned i = 0; i != callExpr->getNumArgs(); ++i)
{
auto a = ignore(callExpr->getArg(i));
if (auto declRefExpr = dyn_cast<DeclRefExpr>(a))
if (auto varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl()))
badMap.insert(varDecl);
}
return true;
}
bool BufferAdd::VisitUnaryOperator(const UnaryOperator* unaryOp)
{
if (ignoreLocation(unaryOp))
return true;
if (unaryOp->getOpcode() != UO_AddrOf)
return true;
auto a = ignore(unaryOp->getSubExpr());
if (auto declRefExpr = dyn_cast<DeclRefExpr>(a))
if (auto varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl()))
badMap.insert(varDecl);
return true;
}
void BufferAdd::findBufferAssignOrAdd(const Stmt* parentStmt, Stmt const* stmt)
{
if (auto exprCleanup = dyn_cast<ExprWithCleanups>(stmt))
stmt = exprCleanup->getSubExpr();
if (auto switchCase = dyn_cast<SwitchCase>(stmt))
stmt = switchCase->getSubStmt();
if (auto declStmt = dyn_cast<DeclStmt>(stmt))
{
if (declStmt->isSingleDecl())
if (auto varDeclLHS = dyn_cast_or_null<VarDecl>(declStmt->getSingleDecl()))
{
auto tc = loplugin::TypeCheck(varDeclLHS->getType());
if (!tc.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()
&& !tc.Class("OStringBuffer").Namespace("rtl").GlobalNamespace())
return;
if (varDeclLHS->getStorageDuration() == SD_Static)
return;
if (!varDeclLHS->hasInit())
return;
auto cxxConstructExpr = dyn_cast<CXXConstructExpr>(ignore(varDeclLHS->getInit()));
if (cxxConstructExpr)
{
if (cxxConstructExpr->getNumArgs() == 0)
{
addToGoodMap(varDeclLHS, parentStmt);
return;
}
auto tc2 = loplugin::TypeCheck(cxxConstructExpr->getArg(0)->getType());
if (cxxConstructExpr->getArg(0)->getType()->isBuiltinType()
|| tc2.LvalueReference().Class("OUStringBuffer")
|| tc2.LvalueReference().Class("OStringBuffer")
|| tc2.Class("OUStringBuffer") || tc2.Class("OStringBuffer"))
{
badMap.insert(varDeclLHS);
return;
}
}
if (!isSideEffectFree(varDeclLHS->getInit()))
badMap.insert(varDeclLHS);
else
addToGoodMap(varDeclLHS, parentStmt);
}
return;
}
// check for single calls to buffer method
if (auto memberCallExpr = dyn_cast<CXXMemberCallExpr>(stmt))
{
if (auto declRefExprLHS
= dyn_cast<DeclRefExpr>(ignore(memberCallExpr->getImplicitObjectArgument())))
{
auto methodDecl = memberCallExpr->getMethodDecl();
if (methodDecl && methodDecl->getIdentifier())
if (auto varDeclLHS = dyn_cast<VarDecl>(declRefExprLHS->getDecl()))
{
auto tc = loplugin::TypeCheck(varDeclLHS->getType());
if (tc.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()
|| tc.Class("OStringBuffer").Namespace("rtl").GlobalNamespace())
{
if (isMethodOkToMerge(memberCallExpr))
addToGoodMap(varDeclLHS, parentStmt);
else
badMap.insert(varDeclLHS);
}
}
return;
}
}
// now check for chained append calls
auto expr = dyn_cast<Expr>(stmt);
if (!expr)
return;
auto tc = loplugin::TypeCheck(expr->getType());
if (!tc.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()
&& !tc.Class("OStringBuffer").Namespace("rtl").GlobalNamespace())
return;
// unwrap the chain (which runs from right to left)
const VarDecl* varDeclLHS = nullptr;
bool good = true;
while (true)
{
auto memberCallExpr = dyn_cast<CXXMemberCallExpr>(expr);
if (!memberCallExpr)
break;
good &= isMethodOkToMerge(memberCallExpr);
if (auto declRefExprLHS
= dyn_cast<DeclRefExpr>(ignore(memberCallExpr->getImplicitObjectArgument())))
{
varDeclLHS = dyn_cast<VarDecl>(declRefExprLHS->getDecl());
break;
}
expr = memberCallExpr->getImplicitObjectArgument();
}
if (varDeclLHS)
{
if (good)
addToGoodMap(varDeclLHS, parentStmt);
else
badMap.insert(varDeclLHS);
}
}
void BufferAdd::addToGoodMap(const VarDecl* varDecl, const Stmt* parentStmt)
{
// check that vars are all inside the same compoundstmt, if they are not, we cannot combine them
auto it = goodMap.find(varDecl);
if (it != goodMap.end())
{
if (it->second == parentStmt)
return;
// don't treat these as parents, otherwise we eliminate .append.append sequences
if (isa<MemberExpr>(parentStmt))
return;
if (isa<CXXMemberCallExpr>(parentStmt))
return;
badMap.insert(varDecl);
}
else
goodMap.emplace(varDecl, parentStmt);
}
bool BufferAdd::isMethodOkToMerge(CXXMemberCallExpr const* memberCall)
{
auto methodDecl = memberCall->getMethodDecl();
if (methodDecl->getNumParams() == 0)
return true;
auto tc2 = loplugin::TypeCheck(methodDecl->getParamDecl(0)->getType());
if (tc2.LvalueReference().Class("OUStringBuffer")
|| tc2.LvalueReference().Class("OStringBuffer"))
return false;
auto name = methodDecl->getName();
if (name == "appendUninitialized" || name == "setLength" || name == "remove" || name == "insert"
|| name == "appendAscii" || name == "appendUtf32")
return false;
auto rhs = memberCall->getArg(0);
if (loplugin::TypeCheck(memberCall->getType())
.Class("OStringBuffer")
.Namespace("rtl")
.GlobalNamespace())
{
// because we have no OStringLiteral1
if (tc2.Char())
return false;
// Can't see how to make the call to append(sal_Unicode*pStart, sal_Unicode*pEnd) work
if (memberCall->getNumArgs() == 2 && loplugin::TypeCheck(rhs->getType()).Pointer())
return false;
}
if (loplugin::TypeCheck(memberCall->getType())
.Class("OUStringBuffer")
.Namespace("rtl")
.GlobalNamespace())
{
// character literals we do with OUStringBuffer, not variables of type sal_Unicode/char
if (tc2.Typedef("sal_Unicode").GlobalNamespace() && !isa<CharacterLiteral>(rhs))
return false;
// Can't see how to make the call to append(sal_Unicode*pStart, sal_Unicode*pEnd) work
if (memberCall->getNumArgs() == 2
&& loplugin::TypeCheck(memberCall->getArg(0)->getType()).Pointer())
return false;
}
if (!isSideEffectFree(rhs))
return false;
return true;
}
Expr const* BufferAdd::ignore(Expr const* expr)
{
return compat::IgnoreImplicit(compat::IgnoreImplicit(expr)->IgnoreParens());
}
bool BufferAdd::isSideEffectFree(Expr const* expr)
{
expr = ignore(expr);
// I don't think the OUStringAppend functionality can handle this efficiently
if (isa<ConditionalOperator>(expr))
return false;
// Multiple statements have a well defined evaluation order (sequence points between them)
// but a single expression may be evaluated in arbitrary order;
// if there are side effects in one of the sub-expressions that have an effect on another subexpression,
// the result may be incorrect, and you don't necessarily notice in tests because the order is compiler-dependent.
// for example see commit afd743141f7a7dd05914d0872c9afe079f16fe0c where such a refactoring introduced such a bug.
// So only consider simple RHS expressions.
if (!expr->HasSideEffects(compiler.getASTContext()))
return true;
// check for chained adds which are side-effect free
if (auto operatorCall = dyn_cast<CXXOperatorCallExpr>(expr))
{
auto op = operatorCall->getOperator();
if (op == OO_PlusEqual || op == OO_Plus)
if (isSideEffectFree(operatorCall->getArg(0))
&& isSideEffectFree(operatorCall->getArg(1)))
return true;
}
if (auto callExpr = dyn_cast<CallExpr>(expr))
{
// check for calls through OUString::number/OUString::unacquired
if (auto calleeMethodDecl = dyn_cast_or_null<CXXMethodDecl>(callExpr->getCalleeDecl()))
if (calleeMethodDecl && calleeMethodDecl->getIdentifier())
{
auto name = calleeMethodDecl->getName();
if (name == "number" || name == "unacquired")
{
auto tc = loplugin::TypeCheck(calleeMethodDecl->getParent());
if (tc.Class("OUString") || tc.Class("OString"))
{
if (isSideEffectFree(callExpr->getArg(0)))
return true;
}
}
}
if (auto calleeFunctionDecl = dyn_cast_or_null<FunctionDecl>(callExpr->getCalleeDecl()))
if (calleeFunctionDecl && calleeFunctionDecl->getIdentifier())
{
auto name = calleeFunctionDecl->getName();
// check for calls through OUStringToOString
if (name == "OUStringToOString" || name == "OStringToOUString")
if (isSideEffectFree(callExpr->getArg(0)))
return true;
// whitelist some known-safe methods
if (name.endswith("ResId") || name == "GetXMLToken")
if (isSideEffectFree(callExpr->getArg(0)))
return true;
}
}
// sometimes we have a constructor call on the RHS
if (auto constructExpr = dyn_cast<CXXConstructExpr>(expr))
{
auto dc = loplugin::DeclCheck(constructExpr->getConstructor());
if (dc.MemberFunction().Class("OUString") || dc.MemberFunction().Class("OString")
|| dc.MemberFunction().Class("OUStringBuffer")
|| dc.MemberFunction().Class("OStringBuffer"))
if (constructExpr->getNumArgs() == 0 || isSideEffectFree(constructExpr->getArg(0)))
return true;
// Expr::HasSideEffects does not like stuff that passes through OUStringLiteral
auto dc2 = loplugin::DeclCheck(constructExpr->getConstructor()->getParent());
if (dc2.Struct("OUStringLiteral").Namespace("rtl").GlobalNamespace())
return true;
}
// when adding literals, we sometimes get this
if (auto functionalCastExpr = dyn_cast<CXXFunctionalCastExpr>(expr))
{
auto tc = loplugin::TypeCheck(functionalCastExpr->getType());
if (tc.Struct("OUStringLiteral").Namespace("rtl").GlobalNamespace())
return isSideEffectFree(functionalCastExpr->getSubExpr());
}
return false;
}
loplugin::Plugin::Registration<BufferAdd> bufferadd("bufferadd");
}
#endif // LO_CLANG_SHARED_PLUGINS
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <rtl/strbuf.hxx>
#include <rtl/string.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
// ---------------------------------------------------------------
// replaceing OUStringBuffer.append sequences to OUString+
namespace test1
{
void f1()
{
// expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
OUStringBuffer v;
v.append("xxx");
v.append("xxx");
}
void f2()
{
// expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
OUStringBuffer v;
v.append("xxx").append("aaaa");
}
}
namespace test2
{
void f2()
{
// no warning expected
OUStringBuffer v;
v.append("xxx");
if (true)
v.append("yyyy");
}
void appendTo(OUStringBuffer&);
void f3()
{
// no warning expected
OUStringBuffer v;
appendTo(v);
v.append("xxx");
}
void f4()
{
// no warning expected
OUStringBuffer v;
v.append("xxx");
v.setLength(0);
}
void f5()
{
// no warning expected
OUStringBuffer v;
v.append("xxx");
v[1] = 'x';
}
void f6()
{
// no warning expected
OUStringBuffer noel1("xxx");
while (true)
noel1.append("ffff").append("aaa");
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@ -154,10 +154,7 @@ OUString Data::fullTemplateName(
"bad component/name pair containing colon " + component + "/" +
name);
}
OUStringBuffer buf(component);
buf.append(':');
buf.append(name);
return buf.makeStringAndClear();
return component + ":" + name;
}
bool Data::equalTemplateNames(

View File

@ -316,13 +316,11 @@ namespace connectivity { namespace hsqldb
xProvider.set( GraphicProvider::create(m_xContext) );
// assemble the image URL
OUStringBuffer aImageURL;
OUString sImageURL =
// load the graphic from the global graphic repository
aImageURL.append( "private:graphicrepository/" );
"private:graphicrepository/"
// the relative path within the images.zip
aImageURL.append( LINKED_TEXT_TABLE_IMAGE_RESOURCE );
// the name of the graphic to use
OUString sImageURL( aImageURL.makeStringAndClear() );
LINKED_TEXT_TABLE_IMAGE_RESOURCE;
// ask the provider to obtain a graphic
Sequence< PropertyValue > aMediaProperties( 1 );

View File

@ -102,18 +102,13 @@ namespace connectivity { namespace hsqldb
try
{
// drop the existing view
OUStringBuffer aCommand;
aCommand.append( "DROP VIEW " );
aCommand.append ( sQualifiedName );
xStatement->execute( aCommand.makeStringAndClear() );
OUString aCommand ="DROP VIEW " + sQualifiedName;
xStatement->execute( aCommand );
bDropSucceeded = true;
// create a new one with the same name
aCommand.append( "CREATE VIEW " );
aCommand.append ( sQualifiedName );
aCommand.append( " AS " );
aCommand.append ( _rNewCommand );
xStatement->execute( aCommand.makeStringAndClear() );
aCommand = "CREATE VIEW " + sQualifiedName + " AS " + _rNewCommand;
xStatement->execute( aCommand );
}
catch( const SQLException& )
{

View File

@ -280,12 +280,11 @@ void Columns::refresh()
{
if (isLog(m_pSettings, LogLevel::Info))
{
OStringBuffer buf;
buf.append( "sdbcx.Columns get refreshed for table " );
buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) );
buf.append( "." );
buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) );
log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() );
OString buf = "sdbcx.Columns get refreshed for table " +
OUStringToOString( m_schemaName, ConnectionSettings::encoding ) +
"." +
OUStringToOString( m_tableName, ConnectionSettings::encoding );
log( m_pSettings, LogLevel::Info, buf.getStr() );
}
osl::MutexGuard guard( m_xMutex->GetMutex() );

View File

@ -104,10 +104,9 @@ void IndexColumns::refresh()
{
if (isLog(m_pSettings, LogLevel::Info))
{
OStringBuffer buf;
buf.append( "sdbcx.IndexColumns get refreshed for index " );
buf.append( OUStringToOString( m_indexName, ConnectionSettings::encoding ) );
log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() );
OString buf = "sdbcx.IndexColumns get refreshed for index " +
OUStringToOString( m_indexName, ConnectionSettings::encoding );
log( m_pSettings, LogLevel::Info, buf.getStr() );
}
osl::MutexGuard guard( m_xMutex->GetMutex() );

View File

@ -96,12 +96,11 @@ void Indexes::refresh()
{
if (isLog(m_pSettings, LogLevel::Info))
{
OStringBuffer buf;
buf.append( "sdbcx.Indexes get refreshed for table " );
buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) );
buf.append( "." );
buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) );
log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() );
OString buf = "sdbcx.Indexes get refreshed for table " +
OUStringToOString( m_schemaName, ConnectionSettings::encoding ) +
"." +
OUStringToOString( m_tableName, ConnectionSettings::encoding );
log( m_pSettings, LogLevel::Info, buf.getStr() );
}
osl::MutexGuard guard( m_xMutex->GetMutex() );

View File

@ -92,12 +92,11 @@ void KeyColumns::refresh()
{
if (isLog(m_pSettings, LogLevel::Info))
{
OStringBuffer buf;
buf.append( "sdbcx.KeyColumns get refreshed for table " );
buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) );
buf.append( "." );
buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) );
log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() );
OString buf = "sdbcx.KeyColumns get refreshed for table " +
OUStringToOString( m_schemaName, ConnectionSettings::encoding ) +
"." +
OUStringToOString( m_tableName, ConnectionSettings::encoding );
log( m_pSettings, LogLevel::Info, buf.getStr() );
}
osl::MutexGuard guard( m_xMutex->GetMutex() );

View File

@ -60,13 +60,11 @@ extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
SAL_THROW_EXTERN_C()
{
OUStringBuffer buf;
buf.append( "Cannot extract an Any(" );
buf.append( OUString::unacquired(&pAny->pType->pTypeName) );
buf.append( ") to " );
buf.append( OUString::unacquired(&pType->pTypeName) );
buf.append( '!' );
const OUString ret( buf.makeStringAndClear() );
OUString ret = "Cannot extract an Any(" +
OUString::unacquired(&pAny->pType->pTypeName) +
") to " +
OUString::unacquired(&pType->pTypeName) +
"!";
rtl_uString_acquire( ret.pData );
return ret.pData;
}

View File

@ -1006,14 +1006,13 @@ extern "C" void SAL_CALL typelib_typedescription_newMIInterface(
for (sal_Int32 j = 0; j < pBase->nMembers; ++j) {
typelib_TypeDescriptionReference const * pDirectBaseMember
= pDirectBase->ppAllMembers[rEntry.directBaseMemberOffset + j];
OUStringBuffer aBuf(pDirectBaseMember->pTypeName);
aBuf.append(":@");
aBuf.append(rEntry.directBaseIndex);
aBuf.append(',');
aBuf.append(rEntry.memberOffset + j);
aBuf.append(':');
aBuf.append(pITD->aBase.pTypeName);
OUString aName(aBuf.makeStringAndClear());
OUString aName = OUString::unacquired(&pDirectBaseMember->pTypeName) +
":@" +
OUString::number(rEntry.directBaseIndex) +
"," +
OUString::number(rEntry.memberOffset + j) +
":" +
OUString::unacquired(&pITD->aBase.pTypeName);
typelib_TypeDescriptionReference * pDerivedMember = nullptr;
typelib_typedescriptionreference_new(
&pDerivedMember, pDirectBaseMember->eTypeClass,

View File

@ -32,15 +32,15 @@ namespace cppu { namespace detail {
#ifndef DISABLE_DYNLOADING
bool loadModule(osl::Module& rModule, OUString const & name) {
OUStringBuffer b;
OUString b =
#if defined SAL_DLLPREFIX
b.append(SAL_DLLPREFIX);
SAL_DLLPREFIX +
#endif
b.append(name);
b.append(SAL_DLLEXTENSION);
name +
SAL_DLLEXTENSION;
return rModule.loadRelative(
reinterpret_cast< oslGenericFunction >(&loadModule),
b.makeStringAndClear(),
b,
SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY);
}

View File

@ -91,9 +91,7 @@ static OUString getAppNameRegistryPath()
eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
OUString sAppName(lcl_getAppName(eApp));
OUStringBuffer sPath("org.openoffice.Office.UI.ToolbarMode/Applications/");
sPath.append(sAppName);
return sPath.makeStringAndClear();
return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName;
}
static OUString customizedUIPathBuffer()

View File

@ -136,11 +136,7 @@ ObjectType OViewContainer::appendObject( const OUString& _rForName, const Refere
OUString sCommand;
descriptor->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
OUStringBuffer aSQL;
aSQL.append( "CREATE VIEW " );
aSQL.append ( sComposedName );
aSQL.append( " AS " );
aSQL.append ( sCommand );
OUString aSQL = "CREATE VIEW " + sComposedName + " AS " + sCommand;
Reference<XConnection> xCon = m_xConnection;
OSL_ENSURE(xCon.is(),"Connection is null!");
@ -148,7 +144,7 @@ ObjectType OViewContainer::appendObject( const OUString& _rForName, const Refere
{
::utl::SharedUNOComponent< XStatement > xStmt( xCon->createStatement() );
if ( xStmt.is() )
xStmt->execute( aSQL.makeStringAndClear() );
xStmt->execute( aSQL );
}
}

View File

@ -91,11 +91,7 @@ public:
OUString lcl_createAlterForeign(const OUString& sForeignPart, const OUString& sTableName)
{
OUStringBuffer sBuff("ALTER TABLE ");
sBuff.append(sTableName);
sBuff.append(" ADD ");
sBuff.append(sForeignPart);
return sBuff.makeStringAndClear();
return "ALTER TABLE " + sTableName + " ADD " + sForeignPart;
}
} // anonymous namespace

View File

@ -50,10 +50,7 @@ OUString getIdentifier(
}
OUString generateLegacyIdentifier(OUString const & fileName) {
OUStringBuffer b;
b.append("org.openoffice.legacy.");
b.append(fileName);
return b.makeStringAndClear();
return "org.openoffice.legacy." + fileName;
}
}

View File

@ -229,9 +229,9 @@ BackendImpl::BackendImpl(
}
catch (const Exception &e)
{
OUStringBuffer aStr( "Exception loading legacy package database: '" );
aStr.append( e.Message );
aStr.append( "' - ignoring file, please remove it.\n" );
OUString aStr = "Exception loading legacy package database: '" +
e.Message +
"' - ignoring file, please remove it.\n";
dp_misc::writeConsole( aStr.getStr() );
}
}

View File

@ -5127,10 +5127,10 @@ static void force_c_locale()
static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
{
OStringBuffer aBuffer("Unexpected dialog: ");
aBuffer.append(OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US));
aBuffer.append(" Error: ");
aBuffer.append(OUStringToOString(rError, RTL_TEXTENCODING_ASCII_US));
OString aBuffer = "Unexpected dialog: " +
OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US) +
" Error: " +
OUStringToOString(rError, RTL_TEXTENCODING_ASCII_US);
fprintf(stderr, "Unexpected basic error dialog '%s'\n", aBuffer.getStr());
}

View File

@ -356,12 +356,9 @@ Reference<XComponentContext> connectToOffice(
bool verbose )
{
OUString pipeId( ::dp_misc::generateRandomPipeId() );
OUStringBuffer buf;
buf.append( "--accept=pipe,name=" );
buf.append( pipeId );
buf.append( ";urp;" );
OUString acceptArg = "--accept=pipe,name=" + pipeId + ";urp;";
Sequence<OUString> args { "--nologo", "--nodefault", buf.makeStringAndClear() };
Sequence<OUString> args { "--nologo", "--nodefault", acceptArg };
OUString appURL( getExecutableDir() + "/soffice" );
if (verbose)
@ -377,13 +374,10 @@ Reference<XComponentContext> connectToOffice(
if (verbose)
dp_misc::writeConsole("OK. Connecting...");
OSL_ASSERT( buf.isEmpty() );
buf.append( "uno:pipe,name=" );
buf.append( pipeId );
buf.append( ";urp;StarOffice.ComponentContext" );
OUString sUnoUrl = "uno:pipe,name=" + pipeId + ";urp;StarOffice.ComponentContext";
Reference<XComponentContext> xRet(
::dp_misc::resolveUnoURL(
buf.makeStringAndClear(), xLocalComponentContext ),
sUnoUrl, xLocalComponentContext ),
UNO_QUERY_THROW );
if (verbose)
dp_misc::writeConsole("OK.\n");

View File

@ -108,11 +108,7 @@ namespace logging
::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 ) );
OUString sTime = OUString::createFromAscii( buffer );
OUStringBuffer aBuff;
aBuff.append( sDate );
aBuff.append( '.' );
aBuff.append( sTime );
OUString sDateTime = aBuff.makeStringAndClear();
OUString sDateTime = sDate + "." + sTime;
oslProcessIdentifier aProcessId = 0;
oslProcessInfo info;

View File

@ -61,18 +61,17 @@ namespace logging
OUString SAL_CALL PlainTextFormatter::getHead( )
{
OUStringBuffer aHeader;
aHeader.append( " event no" ); // column 1: the event number
aHeader.append( " " );
aHeader.append( "thread " ); // column 2: the thread ID
aHeader.append( " " );
aHeader.append( "date " ); // column 3: date
aHeader.append( " " );
aHeader.append( "time " ); // column 4: time
aHeader.append( " " );
aHeader.append( "(class/method:) message" ); // column 5: class/method/message
aHeader.append( "\n" );
return aHeader.makeStringAndClear();
return
" event no" // column 1: the event number
" "
"thread " // column 2: the thread ID
" "
"date " // column 3: date
" "
"time " // column 4: time
" "
"(class/method:) message" // column 5: class/method/message
"\n";
}

View File

@ -250,13 +250,11 @@ namespace pcr
OUString sLocation = aScriptEvent.ScriptCode.copy( 0, nPrefixLen );
OUString sMacroPath = aScriptEvent.ScriptCode.copy( nPrefixLen + 1 );
OUStringBuffer aNewStyleSpec;
aNewStyleSpec.append( "vnd.sun.star.script:" );
aNewStyleSpec.append ( sMacroPath );
aNewStyleSpec.append( "?language=Basic&location=" );
aNewStyleSpec.append ( sLocation );
aScriptEvent.ScriptCode = aNewStyleSpec.makeStringAndClear();
aScriptEvent.ScriptCode =
"vnd.sun.star.script:" +
sMacroPath +
"?language=Basic&location=" +
sLocation;
// also, this new-style spec requires the script code to be "Script" instead of "StarBasic"
aScriptEvent.ScriptType = "Script";
@ -1080,11 +1078,10 @@ namespace pcr
Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW );
Reference< XNameContainer > xEvents( xEventsSupplier->getEvents(), UNO_SET_THROW );
OUStringBuffer aCompleteName;
aCompleteName.append( _rScriptEvent.ListenerType );
aCompleteName.append( "::" );
aCompleteName.append( _rScriptEvent.EventMethod );
OUString sCompleteName( aCompleteName.makeStringAndClear() );
OUString sCompleteName =
_rScriptEvent.ListenerType +
"::" +
_rScriptEvent.EventMethod;
bool bExists = xEvents->hasByName( sCompleteName );

View File

@ -668,14 +668,10 @@ namespace pcr
xPSI = xSet->getPropertySetInfo();
if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_LABEL ) )
{
OUStringBuffer aValue;
aValue.append( '<' );
OUString sLabel;
if( ! (xSet->getPropertyValue( PROPERTY_LABEL) >>= sLabel) )
SAL_WARN("extensions.propctrlr", "convertToPropertyValue: unable to get property " PROPERTY_LABEL);
aValue.append( sLabel );
aValue.append( '>' );
sControlValue = aValue.makeStringAndClear();
sControlValue = "<" + sLabel + ">";
}
aControlValue <<= sControlValue;

View File

@ -1367,9 +1367,8 @@ void SaneDlg::SaveState()
bool bValue;
if( mrSane.GetOptionValue( nOption, bValue ) )
{
OStringBuffer aString("BOOL=");
aString.append(static_cast<sal_Int32>(bValue));
aConfig.WriteKey(aOption, aString.makeStringAndClear());
OString aString = "BOOL=" + OString::number(static_cast<sal_Int32>(bValue));
aConfig.WriteKey(aOption, aString);
}
}
break;
@ -1378,9 +1377,8 @@ void SaneDlg::SaveState()
OString aValue;
if( mrSane.GetOptionValue( nOption, aValue ) )
{
OStringBuffer aString("STRING=");
aString.append(aValue);
aConfig.WriteKey( aOption, aString.makeStringAndClear() );
OString aString = "STRING=" + aValue;
aConfig.WriteKey( aOption, aString );
}
}
break;

View File

@ -132,16 +132,15 @@ checkForUpdates(
if ( !aUpdateInfoEnumeration.is() )
return false; // something went wrong ..
OUStringBuffer aBuffer;
aBuffer.append("/child::inst:description[inst:os=\'");
aBuffer.append( rOS );
aBuffer.append("\' and inst:arch=\'");
aBuffer.append( rArch );
aBuffer.append("\' and inst:gitid!=\'");
aBuffer.append( rGitID );
aBuffer.append("\']");
OUString aXPathExpression =
"/child::inst:description[inst:os=\'"+
rOS +
"\' and inst:arch=\'"+
rArch +
"\' and inst:gitid!=\'"+
rGitID +
"\']";
OUString aXPathExpression = aBuffer.makeStringAndClear();
while( aUpdateInfoEnumeration->hasMoreElements() )
{

View File

@ -63,24 +63,20 @@ void PriorityFilterTest::testPriority()
OUString aTypeName = xDetection->queryTypeByURL(aURL);
OUString aFormatCorrect = OUString::createFromAscii(aToCheck[i].pFormat);
OUStringBuffer aMsg("Mis-matching formats ");
aMsg.append("'");
aMsg.append(aTypeName);
aMsg.append("' should be '");
aMsg.append(aFormatCorrect);
aMsg.append("'");
CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aMsg.makeStringAndClear(),
OUString aMsg = "Mis-matching formats "
"'" +
aTypeName +
"' should be '" +
aFormatCorrect +
"'";
CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aMsg,
RTL_TEXTENCODING_UTF8).getStr(),
aFormatCorrect, aTypeName);
}
catch (const uno::Exception &e)
{
OUStringBuffer aMsg("Exception querying for type: ");
aMsg.append("'");
aMsg.append(e.Message);
aMsg.append("'");
CPPUNIT_FAIL(OUStringToOString(aMsg.makeStringAndClear(),
RTL_TEXTENCODING_UTF8).getStr());
OUString aMsg = "Exception querying for type: '" + e.Message + "'";
CPPUNIT_FAIL(OUStringToOString(aMsg, RTL_TEXTENCODING_UTF8).getStr());
}
}
}

View File

@ -925,11 +925,8 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const OUString& rN
// Header
//TODO: Encode rName into a properly formatted Content-Disposition header
// field as per RFC 2231:
OUStringBuffer aContentDisp;
aContentDisp.append("form-data; name=\"");
aContentDisp.append(rName);
aContentDisp.append('\"');
pChild->SetContentDisposition(aContentDisp.makeStringAndClear());
OUString aContentDisp = "form-data; name=\"" + rName + "\"";
pChild->SetContentDisposition(aContentDisp);
rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding();
const sal_Char* pBestMatchingEncoding = rtl_getBestMimeCharsetFromTextEncoding( eSystemEncoding );
@ -989,14 +986,14 @@ void ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
// Header
//TODO: Encode rName and aFileName into a properly formatted
// Content-Disposition header field as per RFC 2231:
OUStringBuffer aContentDisp;
aContentDisp.append("form-data; name=\"");
aContentDisp.append(rName);
aContentDisp.append('\"');
aContentDisp.append("; filename=\"");
aContentDisp.append(aFileName);
aContentDisp.append('\"');
pChild->SetContentDisposition(aContentDisp.makeStringAndClear());
OUString aContentDisp =
"form-data; name=\"" +
rName +
"\""
"; filename=\"" +
aFileName +
"\"";
pChild->SetContentDisposition(aContentDisp);
pChild->SetContentType( aContentType );
pChild->SetContentTransferEncoding("8bit");

View File

@ -226,11 +226,7 @@ void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir )
namespace {
OUString lcl_DecoratedFilter( const OUString& _rOriginalFilter )
{
OUStringBuffer aDecoratedFilter;
aDecoratedFilter.append('<');
aDecoratedFilter.append(_rOriginalFilter);
aDecoratedFilter.append('>');
return aDecoratedFilter.makeStringAndClear();
return "<" + _rOriginalFilter + ">";
}
}

View File

@ -885,10 +885,9 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
OUString aImagesItemNode( aAddonImagesNode + aAddonImagesNodeSeq[n] );
// Create sequence for data access
OUStringBuffer aBuffer( aImagesItemNode );
aBuffer.append( m_aPathDelimiter );
aBuffer.append( m_aPropNames[ OFFSET_MENUITEM_URL ] );
aAddonImageItemNodePropNames[0] = aBuffer.makeStringAndClear();
aAddonImageItemNodePropNames[0] = aImagesItemNode +
m_aPathDelimiter +
m_aPropNames[ OFFSET_MENUITEM_URL ];
Sequence< Any > aAddonImageItemNodeValues = GetProperties( aAddonImageItemNodePropNames );
@ -898,11 +897,10 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
!aURL.isEmpty() &&
!HasAssociatedImages( aURL ))
{
OUStringBuffer aBuf( aImagesItemNode );
aBuf.append( m_aPathDelimiter );
aBuf.append( IMAGES_NODENAME );
aBuf.append( m_aPathDelimiter );
OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear();
OUString aImagesUserDefinedItemNode = aImagesItemNode +
m_aPathDelimiter +
IMAGES_NODENAME +
m_aPathDelimiter;
// Read a user-defined images data
std::unique_ptr<ImageEntry> pImageEntry = ReadImageData( aImagesUserDefinedItemNode );
@ -1074,10 +1072,8 @@ void AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstruction
bool AddonsOptions_Impl::ReadMergeToolbarData( const OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems )
{
OUStringBuffer aBuffer( aMergeAddonInstructionBase );
aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] );
OUString aMergeToolbarBaseNode = aBuffer.makeStringAndClear();
OUString aMergeToolbarBaseNode = aMergeAddonInstructionBase +
m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ];
return ReadToolBarItemSet( aMergeToolbarBaseNode, rMergeToolbarItems );
}
@ -1158,10 +1154,8 @@ bool AddonsOptions_Impl::ReadMergeNotebookBarData(
const OUString& aMergeAddonInstructionBase,
Sequence<Sequence<PropertyValue>>& rMergeNotebookBarItems)
{
OUStringBuffer aBuffer(aMergeAddonInstructionBase);
aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBARITEMS]);
OUString aMergeNotebookBarBaseNode = aBuffer.makeStringAndClear();
OUString aMergeNotebookBarBaseNode = aMergeAddonInstructionBase +
m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBARITEMS];
return ReadNotebookBarItemSet(aMergeNotebookBarBaseNode, rMergeNotebookBarItems);
}
@ -1233,9 +1227,8 @@ bool AddonsOptions_Impl::ReadMergeStatusbarData(
{
sal_uInt32 nStatusbarItemCount = rMergeStatusbarItems.getLength();
OUStringBuffer aBuffer( aMergeAddonInstructionBase );
aBuffer.append( m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_STATUSBARITEMS ] );
OUString aMergeStatusbarBaseNode = aBuffer.makeStringAndClear();
OUString aMergeStatusbarBaseNode = aMergeAddonInstructionBase +
m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_STATUSBARITEMS ];
OUString aAddonStatusbarItemSetNode( aMergeStatusbarBaseNode + m_aPathDelimiter );
Sequence< OUString > aAddonStatusbarItemSetNodeSeq = GetNodeNames( aMergeStatusbarBaseNode );

View File

@ -2001,10 +2001,7 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn
css::uno::Reference< css::container::XNameContainer > xModify(xCheck, css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::lang::XSingleServiceFactory > xCreate(xCheck, css::uno::UNO_QUERY_THROW);
OUStringBuffer sIDBuf;
sIDBuf.append(RECOVERY_ITEM_BASE_IDENTIFIER);
sIDBuf.append(rInfo.ID);
OUString sID = sIDBuf.makeStringAndClear();
OUString sID = RECOVERY_ITEM_BASE_IDENTIFIER + OUString::number(rInfo.ID);
// remove
if (bRemoveIt)
@ -4176,11 +4173,7 @@ void AutoRecovery::st_impl_removeLockFile()
OUString sUserURL;
::utl::Bootstrap::locateUserInstallation( sUserURL );
OUStringBuffer sLockURLBuf;
sLockURLBuf.append (sUserURL);
sLockURLBuf.append("/.lock");
OUString sLockURL = sLockURLBuf.makeStringAndClear();
OUString sLockURL = sUserURL + "/.lock";
AutoRecovery::st_impl_removeFile(sLockURL);
}
catch(const css::uno::Exception&)

View File

@ -261,9 +261,7 @@ sal_Bool SAL_CALL URLTransformer::assemble( css::util::URL& aURL )
else if ( !aURL.Protocol.isEmpty() )
{
// Minimal support for unknown protocols
OUStringBuffer aBuffer( aURL.Protocol );
aBuffer.append( aURL.Path );
aURL.Complete = aBuffer.makeStringAndClear();
aURL.Complete = aURL.Protocol + aURL.Path;
aURL.Main = aURL.Complete;
return true;
}

View File

@ -240,12 +240,10 @@ void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent
OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId ));
{
OUStringBuffer aBuf(".uno:Notebookbar?File:string=");
aBuf.append( aCmd );
URL aTargetURL;
Sequence<PropertyValue> aArgs;
aTargetURL.Complete = aBuf.makeStringAndClear();
aTargetURL.Complete = ".uno:Notebookbar?File:string=" + aCmd;
xURLTransformer->parseStrict( aTargetURL );
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
if ( xDispatchProvider.is() )
@ -261,12 +259,10 @@ void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent
}
}
OUStringBuffer aBuf(".uno:ToolbarMode?Mode:string=");
aBuf.append( aCmd );
URL aTargetURL;
Sequence<PropertyValue> aArgs;
aTargetURL.Complete = aBuf.makeStringAndClear();
aTargetURL.Complete = ".uno:ToolbarMode?Mode:string=" + aCmd;
xURLTransformer->parseStrict( aTargetURL );
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
if ( xDispatchProvider.is() )

View File

@ -47,10 +47,7 @@ namespace framework
{
static OUString getHashKeyFromStrings( const OUString& aCommandURL, const OUString& aModuleName )
{
OUStringBuffer aKey( aCommandURL );
aKey.append( "-" );
aKey.append( aModuleName );
return aKey.makeStringAndClear();
return aCommandURL + "-" + aModuleName;
}
// XInterface, XTypeProvider

View File

@ -134,18 +134,18 @@ void SvIdlParser::ReadInclude( SvMetaModule& rModule )
osl::FileBase::RC searchError = osl::File::searchFileURL(aFullName, rBase.GetPath(), aFullName);
if( osl::FileBase::E_None != searchError )
{
OStringBuffer aStr("cannot find file:");
aStr.append(OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8));
throw SvParseException(aStr.makeStringAndClear(), rInStm.GetToken());
OString aStr = "cannot find file:" +
OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8);
throw SvParseException(aStr, rInStm.GetToken());
}
osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
rBase.AddDepFile( aFullName );
SvTokenStream aTokStm( aFullName );
if( ERRCODE_NONE != aTokStm.GetStream().GetError() )
{
OStringBuffer aStr("cannot open file: ");
aStr.append(OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8));
throw SvParseException(aStr.makeStringAndClear(), rInStm.GetToken());
OString aStr = "cannot open file: " +
OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8);
throw SvParseException(aStr, rInStm.GetToken());
}
// rescue error from old file
SvIdlError aOldErr = rBase.GetError();

View File

@ -95,8 +95,8 @@ static OUString tempFileHelper(OUString const & fname)
}
else
{
OStringBuffer aStr("invalid filename: ");
aStr.append(OUStringToOString(fname, RTL_TEXTENCODING_UTF8));
OString aStr = "invalid filename: " +
OUStringToOString(fname, RTL_TEXTENCODING_UTF8);
fprintf(stderr, "%s\n", aStr.getStr());
}
return aTmpFile;
@ -134,8 +134,8 @@ int main ( int argc, char ** argv)
if( !pDataBase->WriteSfx( aOutStm ) )
{
nExit = -1;
OStringBuffer aStr("cannot write slotmap file: ");
aStr.append(OUStringToOString(aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8));
OString aStr = "cannot write slotmap file: " +
OUStringToOString(aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8);
fprintf(stderr, "%s\n", aStr.getStr());
}
}
@ -181,12 +181,10 @@ int main ( int argc, char ** argv)
if( bErr )
{
nExit = -1;
OStringBuffer aStr("cannot move file from: ");
aStr.append(OUStringToOString(aErrFile2,
RTL_TEXTENCODING_UTF8));
aStr.append("\n to file: ");
aStr.append(OUStringToOString(aErrFile,
RTL_TEXTENCODING_UTF8));
OString aStr = "cannot move file from: " +
OUStringToOString(aErrFile2, RTL_TEXTENCODING_UTF8) +
"\n to file: " +
OUStringToOString(aErrFile, RTL_TEXTENCODING_UTF8);
fprintf( stderr, "%s\n", aStr.getStr() );
}
else

View File

@ -72,9 +72,7 @@ void TextContext::onCharacters( const OUString& rChars )
if( isCurrentElement( C_TOKEN( v ) ) )
{
// Static text is stored as a single string formula token for Excel document.
OUStringBuffer aBuf;
aBuf.append('"').append(rChars).append('"');
mrModel.mxDataSeq.create().maFormula = aBuf.makeStringAndClear();
mrModel.mxDataSeq.create().maFormula = "\"" + rChars + "\"";
// Also store it as a single element type for non-Excel document.
mrModel.mxDataSeq->maData[0] <<= rChars;

View File

@ -1181,15 +1181,15 @@ sal_Int32 VMLExport::StartShape()
nShapeElement = XML_shape;
if ( !m_aShapeTypeWritten[ m_nShapeType ] )
{
OStringBuffer sShapeType;
sShapeType.append("<v:shapetype id=\"shapetype_").append(OString::number(m_nShapeType)).
append("\" coordsize=\"21600,21600\" o:spt=\"").append(OString::number(m_nShapeType)).
append("\" path=\"m,l,21600l21600,21600l21600,xe\">\n").
append("<v:stroke joinstyle=\"miter\"/>\n"
OString sShapeType =
"<v:shapetype id=\"shapetype_" + OString::number(m_nShapeType) +
"\" coordsize=\"21600,21600\" o:spt=\"" + OString::number(m_nShapeType) +
"\" path=\"m,l,21600l21600,21600l21600,xe\">\n"
"<v:stroke joinstyle=\"miter\"/>\n"
"<v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/>\n"
"<o:lock v:ext=\"edit\" shapetype=\"t\"/>\n"
"</v:shapetype>");
m_pSerializer->write(sShapeType.makeStringAndClear());
"</v:shapetype>";
m_pSerializer->write(sShapeType);
m_aShapeTypeWritten[ m_nShapeType ] = true;
}
break;
@ -1202,11 +1202,11 @@ sal_Int32 VMLExport::StartShape()
nShapeElement = XML_shape;
if ( !m_aShapeTypeWritten[ m_nShapeType ] )
{
OStringBuffer sShapeType;
sShapeType.append("<v:shapetype id=\"shapetype_").append(OString::number(m_nShapeType)).
append("\" coordsize=\"21600,21600\" o:spt=\"").append(OString::number(m_nShapeType)).
append("\" o:preferrelative=\"t\" path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">\n").
append("<v:stroke joinstyle=\"miter\"/>\n"
OString sShapeType =
"<v:shapetype id=\"shapetype_" + OString::number(m_nShapeType) +
"\" coordsize=\"21600,21600\" o:spt=\"" + OString::number(m_nShapeType) +
"\" o:preferrelative=\"t\" path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">\n"
"<v:stroke joinstyle=\"miter\"/>\n"
"<v:formulas>\n"
"<v:f eqn=\"if lineDrawn pixelLineWidth 0\"/>\n"
"<v:f eqn=\"sum @0 1 0\"/>\n"
@ -1223,8 +1223,8 @@ sal_Int32 VMLExport::StartShape()
"</v:formulas>\n"
"<v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n"
"<o:lock v:ext=\"edit\" aspectratio=\"t\"/>\n"
"</v:shapetype>");
m_pSerializer->write(sShapeType.makeStringAndClear());
"</v:shapetype>";
m_pSerializer->write(sShapeType);
m_aShapeTypeWritten[ m_nShapeType ] = true;
}
break;

View File

@ -346,9 +346,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
{
sal_Int64 nSize = 0;
rValue.Value >>= nSize;
OUStringBuffer aBuffer;
aBuffer.append ( nSize );
pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, OUString::number( nSize ) );
}
else if (rValue.Name == sInitialisationVectorProperty )
pVector = &rValue.Value;

View File

@ -93,16 +93,14 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
return "void";
OUStringBuffer buf( 64 );
buf.append( '(' );
buf.append( pTypeRef->pTypeName );
buf.append( ')' );
buf.append( "(" + OUString::unacquired(&pTypeRef->pTypeName) + ")" );
switch (pTypeRef->eTypeClass)
{
case typelib_TypeClass_INTERFACE:
{
buf.append( "0x" );
buf.append( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 );
buf.append( "0x" +
OUString::number( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 ));
if( VAL2STR_MODE_DEEP == mode )
{
buf.append( "{" ); Reference< XInterface > r = *static_cast<Reference< XInterface > const *>(pVal);
@ -164,8 +162,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos )
{
buf.append( ppMemberNames[nPos] );
buf.append( " = " );
buf.append( OUString::unacquired(&ppMemberNames[nPos]) + " = " );
typelib_TypeDescription * pMemberType = nullptr;
TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
buf.append( val2str( static_cast<char const *>(pVal) + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) );
@ -222,9 +219,9 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( (*static_cast<typelib_TypeDescriptionReference * const *>(pVal))->pTypeName );
break;
case typelib_TypeClass_STRING:
buf.append( '\"' );
buf.append( *static_cast<rtl_uString * const *>(pVal) );
buf.append( '\"' );
buf.append( "\"" +
OUString::unacquired(&*static_cast<rtl_uString * const *>(pVal)) +
"\"" );
break;
case typelib_TypeClass_ENUM:
{
@ -264,24 +261,24 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( *static_cast<double const *>(pVal) );
break;
case typelib_TypeClass_BYTE:
buf.append( "0x" );
buf.append( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 );
buf.append( "0x" +
OUString::number( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_SHORT:
buf.append( "0x" );
buf.append( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 );
buf.append( "0x" +
OUString::number( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_UNSIGNED_SHORT:
buf.append( "0x" );
buf.append( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 );
buf.append( "0x" +
OUString::number( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_LONG:
buf.append( "0x" );
buf.append( *static_cast<sal_Int32 const *>(pVal), 16 );
buf.append( "0x" +
OUString::number( *static_cast<sal_Int32 const *>(pVal), 16 ));
break;
case typelib_TypeClass_UNSIGNED_LONG:
buf.append( "0x" );
buf.append( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 );
buf.append( "0x" +
OUString::number( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 ));
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
@ -464,15 +461,14 @@ PyObject *PyUNO_str( PyObject * self )
{
PyUNO *me = reinterpret_cast<PyUNO *>(self);
OStringBuffer buf;
OString buf;
{
PyThreadDetach antiguard;
buf.append( "pyuno object " );
OUString s = val2str( me->members->wrappedObject.getValue(),
me->members->wrappedObject.getValueType().getTypeLibType() );
buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) );
buf = "pyuno object " + OUStringToOString(s,RTL_TEXTENCODING_ASCII_US);
}
return PyStr_FromString( buf.getStr() );

View File

@ -47,15 +47,11 @@ void raisePyExceptionWithAny( const css::uno::Any &anyExc )
css::uno::Exception e;
anyExc >>= e;
OUStringBuffer buf;
buf.append( "Couldn't convert uno exception to a python exception (" );
buf.append(anyExc.getValueType().getTypeName());
buf.append( ": " );
buf.append(e.Message );
buf.append( ")" );
OUString buf = "Couldn't convert uno exception to a python exception (" +
anyExc.getValueType().getTypeName() + ": " + e.Message + ")";
PyErr_SetString(
PyExc_SystemError,
OUStringToOString(buf.makeStringAndClear(),RTL_TEXTENCODING_ASCII_US).getStr() );
OUStringToOString(buf,RTL_TEXTENCODING_ASCII_US).getStr() );
}
}
catch(const css::lang::IllegalArgumentException & e)

View File

@ -113,13 +113,10 @@ public:
if (initialised[key])
{
OUStringBuffer buf;
buf.append( "pyuno._createUnoStructHelper: member '");
buf.append(key);
buf.append( "'");
buf.append( "pyuno._createUnoStructHelper: member '" + key + "'");
if ( pos >= 0 )
{
buf.append( " at position ");
buf.append(pos);
buf.append( " at position " + OUString::number(pos));
}
buf.append( " initialised multiple times.");
throw RuntimeException(buf.makeStringAndClear());
@ -191,13 +188,12 @@ void fillStruct(
const OUString memberName (pCompType->ppMemberNames[i]);
if ( ! state.isInitialised( memberName ) )
{
OUStringBuffer buf;
buf.append( "pyuno._createUnoStructHelper: member '");
buf.append(memberName);
buf.append( "' of struct type '");
buf.append(pCompType->aBase.pTypeName);
buf.append( "' not given a value.");
throw RuntimeException(buf.makeStringAndClear());
OUString buf = "pyuno._createUnoStructHelper: member '" +
memberName +
"' of struct type '" +
OUString::unacquired(&pCompType->aBase.pTypeName) +
"' not given a value.";
throw RuntimeException(buf);
}
}
}
@ -223,12 +219,11 @@ OUString getLibDir()
void raisePySystemException( const char * exceptionType, const OUString & message )
{
OStringBuffer buf;
buf.append( "Error during bootstrapping uno (");
buf.append( exceptionType );
buf.append( "):" );
buf.append( OUStringToOString( message, osl_getThreadTextEncoding() ) );
PyErr_SetString( PyExc_SystemError, buf.makeStringAndClear().getStr() );
OString buf = OStringLiteral("Error during bootstrapping uno (") +
exceptionType +
"):" +
OUStringToOString( message, osl_getThreadTextEncoding() );
PyErr_SetString( PyExc_SystemError, buf.getStr() );
}
extern "C" {
@ -250,7 +245,6 @@ static PyObject* getComponentContext(
}
else
{
OUString iniFile;
if( path.isEmpty() )
{
PyErr_SetString(
@ -259,14 +253,11 @@ static PyObject* getComponentContext(
return nullptr;
}
OUStringBuffer iniFileName;
iniFileName.append( path );
OUString iniFile = path +
#ifdef MACOSX
iniFileName.append( "/../" LIBO_ETC_FOLDER );
"/../" LIBO_ETC_FOLDER
#endif
iniFileName.append( "/" );
iniFileName.append( SAL_CONFIGFILE( "pyuno" ) );
iniFile = iniFileName.makeStringAndClear();
"/" SAL_CONFIGFILE( "pyuno" );
osl::DirectoryItem item;
if( osl::DirectoryItem::get( iniFile, item ) == osl::FileBase::E_None )
{
@ -395,16 +386,14 @@ PyObject * extractOneStringArg( PyObject *args, char const *funcName )
{
if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 )
{
OStringBuffer buf;
buf.append( funcName ).append( ": expecting one string argument" );
OString buf = funcName + OStringLiteral(": expecting one string argument");
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
PyObject *obj = PyTuple_GetItem( args, 0 );
if (!PyStr_Check(obj) && !PyUnicode_Check(obj))
{
OStringBuffer buf;
buf.append( funcName ).append( ": expecting one string argument" );
OString buf = funcName + OStringLiteral(": expecting one string argument");
PyErr_SetString( PyExc_TypeError, buf.getStr());
return nullptr;
}
@ -515,8 +504,7 @@ static PyObject *getTypeByName(
}
else
{
OStringBuffer buf;
buf.append( "Type " ).append(name).append( " is unknown" );
OString buf = OStringLiteral("Type ") + name + " is unknown";
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
}
}
@ -577,8 +565,7 @@ static PyObject *checkType( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 )
{
OStringBuffer buf;
buf.append( "pyuno.checkType : expecting one uno.Type argument" );
OString buf = "pyuno.checkType : expecting one uno.Type argument";
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
@ -601,8 +588,7 @@ static PyObject *checkEnum( SAL_UNUSED_PARAMETER PyObject *, PyObject *args )
{
if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 )
{
OStringBuffer buf;
buf.append( "pyuno.checkType : expecting one uno.Type argument" );
OString buf = "pyuno.checkType : expecting one uno.Type argument";
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}
@ -684,14 +670,13 @@ static PyObject *systemPathToFileUrl(
if( e != osl::FileBase::E_None )
{
OUStringBuffer buf;
buf.append( "Couldn't convert " );
buf.append( sysPath );
buf.append( " to a file url for reason (" );
buf.append( static_cast<sal_Int32>(e) );
buf.append( ")" );
OUString buf = "Couldn't convert " +
sysPath +
" to a file url for reason (" +
OUString::number( static_cast<sal_Int32>(e) ) +
")";
raisePyExceptionWithAny(
makeAny( RuntimeException( buf.makeStringAndClear() )));
makeAny( RuntimeException( buf )));
return nullptr;
}
return ustring2PyUnicode( url ).getAcquired();
@ -710,14 +695,13 @@ static PyObject * fileUrlToSystemPath(
if( e != osl::FileBase::E_None )
{
OUStringBuffer buf;
buf.append( "Couldn't convert file url " );
buf.append( sysPath );
buf.append( " to a system path for reason (" );
buf.append( static_cast<sal_Int32>(e) );
buf.append( ")" );
OUString buf = "Couldn't convert file url " +
sysPath +
" to a system path for reason (" +
OUString::number( static_cast<sal_Int32>(e) ) +
")";
raisePyExceptionWithAny(
makeAny( RuntimeException( buf.makeStringAndClear() )));
makeAny( RuntimeException( buf )));
return nullptr;
}
return ustring2PyUnicode( sysPath ).getAcquired();
@ -733,18 +717,18 @@ static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args )
oslFileError e = osl_getAbsoluteFileURL( ouPath.pData, ouRel.pData, &(ret.pData) );
if( e != osl_File_E_None )
{
OUStringBuffer buf;
buf.append( "Couldn't absolutize " );
buf.append( ouRel );
buf.append( " using root " );
buf.append( ouPath );
buf.append( " for reason (" );
buf.append( static_cast<sal_Int32>(e) );
buf.append( ")" );
OUString buf =
"Couldn't absolutize " +
ouRel +
" using root " +
ouPath +
" for reason (" +
OUString::number(static_cast<sal_Int32>(e) ) +
")";
PyErr_SetString(
PyExc_OSError,
OUStringToOString(buf.makeStringAndClear(),osl_getThreadTextEncoding()).getStr());
OUStringToOString(buf,osl_getThreadTextEncoding()).getStr());
return nullptr;
}
return ustring2PyUnicode( ret ).getAcquired();
@ -787,9 +771,8 @@ static PyObject * invoke(SAL_UNUSED_PARAMETER PyObject *, PyObject *args)
}
else
{
OStringBuffer buf;
buf.append("uno.invoke expects object, name, (arg1, arg2, ... )\n");
PyErr_SetString(PyExc_RuntimeError, buf.makeStringAndClear().getStr());
OString buf = "uno.invoke expects object, name, (arg1, arg2, ... )\n";
PyErr_SetString(PyExc_RuntimeError, buf.getStr());
}
return ret;
}
@ -841,10 +824,9 @@ static PyObject *setCurrentContext(
}
else
{
OStringBuffer buf;
buf.append( "uno.setCurrentContext expects exactly one argument (the current Context)\n" );
OString buf = "uno.setCurrentContext expects exactly one argument (the current Context)\n";
PyErr_SetString(
PyExc_RuntimeError, buf.makeStringAndClear().getStr() );
PyExc_RuntimeError, buf.getStr() );
}
}
catch( const css::uno::Exception & e )

View File

@ -57,7 +57,7 @@ static void PyUNOStruct_del( PyObject* self )
static PyObject *PyUNOStruct_str( PyObject *self )
{
PyUNO *me = reinterpret_cast<PyUNO*>( self );
OStringBuffer buf;
OString buf;
Reference<XMaterialHolder> rHolder( me->members->xInvocation,UNO_QUERY );
if( rHolder.is() )
@ -65,7 +65,7 @@ static PyObject *PyUNOStruct_str( PyObject *self )
PyThreadDetach antiguard;
Any a = rHolder->getMaterial();
OUString s = val2str( a.getValue(), a.getValueType().getTypeLibType() );
buf.append( OUStringToOString( s, RTL_TEXTENCODING_ASCII_US ) );
buf = OUStringToOString( s, RTL_TEXTENCODING_ASCII_US );
}
return PyStr_FromString( buf.getStr());

View File

@ -232,9 +232,7 @@ static PyObject* callCtor( const Runtime &r , const char * clazz, const PyRef &
PyRef code( PyDict_GetItemString( r.getImpl()->cargo->getUnoModule().get(), clazz ) );
if( ! code.is() )
{
OStringBuffer buf;
buf.append( "couldn't access uno." );
buf.append( clazz );
OString buf = OStringLiteral("couldn't access uno.") + clazz;
PyErr_SetString( PyExc_RuntimeError, buf.getStr() );
return nullptr;
}

View File

@ -161,9 +161,7 @@ void logException( RuntimeCargo *cargo, const char *intro,
OUStringBuffer buf( 128 );
buf.appendAscii( intro );
appendPointer(buf, ptr);
buf.append( "]." );
buf.append( aFunctionName );
buf.append( " = " );
buf.append( "]." + aFunctionName + " = " );
buf.append(
val2str( data, type.getTypeLibType(), VAL2STR_MODE_SHALLOW ) );
log( cargo,LogLevel::CALL, buf.makeStringAndClear() );
@ -182,9 +180,7 @@ void logReply(
OUStringBuffer buf( 128 );
buf.appendAscii( intro );
appendPointer(buf, ptr);
buf.append( "]." );
buf.append( aFunctionName );
buf.append( "()=" );
buf.append( "]." + aFunctionName + "()=" );
if( isLog( cargo, LogLevel::ARGS ) )
{
buf.append(
@ -207,9 +203,7 @@ void logCall( RuntimeCargo *cargo, const char *intro,
OUStringBuffer buf( 128 );
buf.appendAscii( intro );
appendPointer(buf, ptr);
buf.append( "]." );
buf.append( aFunctionName );
buf.append( "(" );
buf.append( "]." + aFunctionName + "(" );
if( isLog( cargo, LogLevel::ARGS ) )
{
for( int i = 0; i < aParams.getLength() ; i ++ )

View File

@ -58,12 +58,7 @@ namespace rptui
case Field:
{
OUStringBuffer aBuffer;
aBuffer.append( sFieldPrefix );
aBuffer.append( "[" );
aBuffer.append( _rFieldOrExpression );
aBuffer.append( "]" );
m_sCompleteFormula = aBuffer.makeStringAndClear();
m_sCompleteFormula = sFieldPrefix + OUStringLiteral("[") + _rFieldOrExpression + "]";
}
break;
default:

View File

@ -49,12 +49,11 @@ static void lcl_exportPrettyPrinting(const uno::Reference< xml::sax::XDocumentHa
OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute)
{
OUStringBuffer sQName;
return
// ...if it's in our map, make the prefix
sQName.append ( xmloff::token::GetXMLToken(_eNamespace) );
sQName.append ( ':' );
sQName.append ( xmloff::token::GetXMLToken(_eAttribute) );
return sQName.makeStringAndClear();
xmloff::token::GetXMLToken(_eNamespace) +
":" +
xmloff::token::GetXMLToken(_eAttribute);
}
static void lcl_correctCellAddress(const OUString & _sName, const uno::Reference< xml::sax::XAttributeList > & xAttribs)

View File

@ -90,10 +90,7 @@ namespace rptui
OUString sLabel = m_rReportController.getColumnLabel_throw(sColumnName);
if ( !sLabel.isEmpty() )
{
OUStringBuffer aBuffer;
aBuffer.append( "=" );
aBuffer.append( sLabel );
sDataField = aBuffer.makeStringAndClear();
sDataField = "=" + sLabel;
bSet = false;
}
}

View File

@ -129,13 +129,12 @@ namespace osl_Security
OUString strID;
bRes = aSec.getUserIdent( strID );
OStringBuffer aMessage;
aMessage.append("strUserID: ");
aMessage.append(OUStringToOString(strUserID, osl_getThreadTextEncoding()));
aMessage.append(", strID: ");
aMessage.append(OUStringToOString(strID, osl_getThreadTextEncoding()));
aMessage.append(", bRes: ");
aMessage.append(bRes);
OString aMessage = "strUserID: " +
OUStringToOString(strUserID, osl_getThreadTextEncoding()) +
", strID: " +
OUStringToOString(strID, osl_getThreadTextEncoding()) +
", bRes: " +
OString::boolean(bRes);
CPPUNIT_ASSERT_EQUAL_MESSAGE( aMessage.getStr(), strUserID, strID );
CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), bRes );

View File

@ -44,7 +44,6 @@ void Test::test_Uri() {
rtl_UriCharClass const eFirstCharClass = rtl_UriCharClassNone;
rtl_UriCharClass const eLastCharClass = rtl_UriCharClassUnoParamValue;
OUStringBuffer aBuffer;
OUString aText1;
OUString aText2;
@ -182,12 +181,11 @@ void Test::test_Uri() {
// Check surrogate handling:
aBuffer.append(u'\xD800'); // %ED%A0%80
aBuffer.append(u'\xD800'); // %F0%90%8F%BF
aBuffer.append(u'\xDFFF');
aBuffer.append(u'\xDFFF'); // %ED%BF%BF
aBuffer.append('A'); // A
aText1 = aBuffer.makeStringAndClear();
aText1 = OUStringLiteral1(u'\xD800') + // %ED%A0%80
OUStringLiteral1(u'\xD800') + // %F0%90%8F%BF
OUStringLiteral1(u'\xDFFF') +
OUStringLiteral1(u'\xDFFF') + // %ED%BF%BF
"A"; // A
aText2 = "%ED%A0%80" "%F0%90%8F%BF" "%ED%BF%BF" "A";
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"failure 11",
@ -209,12 +207,11 @@ void Test::test_Uri() {
RTL_TEXTENCODING_UTF8));
aText1 = "%ed%a0%80" "%f0%90%8f%bf" "%ed%bf%bf" "A";
aBuffer.append("%ED%A0%80");
aBuffer.append(u'\xD800');
aBuffer.append(u'\xDFFF');
aBuffer.append("%ED%BF%BF");
aBuffer.append('A');
aText2 = aBuffer.makeStringAndClear();
aText2 = "%ED%A0%80" +
OUStringLiteral1(u'\xD800') +
OUStringLiteral1(u'\xDFFF') +
"%ED%BF%BF"
"A";
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"failure 14",
aText2,
@ -250,9 +247,8 @@ void Test::test_Uri() {
// Check IURI handling:
aText1 = "%30%C3%BF";
aBuffer.append("%30");
aBuffer.append(u'\x00FF');
aText2 = aBuffer.makeStringAndClear();
aText2 = "%30" +
OUStringLiteral1(u'\x00FF');
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"failure 18",
aText2,

View File

@ -39,13 +39,12 @@ inline OUString getConditionalFormatString(ScDocument* pDoc, SCCOL nCol, SCROW n
inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab)
{
OStringBuffer aString("Error in Table: ");
aString.append(static_cast<sal_Int32>(nTab));
aString.append(" Column: ");
aString.append(static_cast<sal_Int32>(nCol));
aString.append(" Row: ");
aString.append(nRow);
return aString.makeStringAndClear();
return "Error in Table: " +
OString::number(static_cast<sal_Int32>(nTab)) +
" Column: " +
OString::number(static_cast<sal_Int32>(nCol)) +
" Row: " +
OString::number(nRow);
}
inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rExpectedString, const OUString& rString)

View File

@ -117,8 +117,7 @@ void loadFile(const OUString& aFileName, std::string& aContent)
std::ifstream aFile(aOFileName.getStr());
OStringBuffer aErrorMsg("Could not open csv file: ");
aErrorMsg.append(aOFileName);
OString aErrorMsg = "Could not open csv file: " + aOFileName;
CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), aFile);
std::ostringstream aOStream;
aOStream << aFile.rdbuf();

View File

@ -708,17 +708,16 @@ void ScFiltersTest::testCachedFormulaResultsODS()
{
for(SCROW nRow = 0; nRow < 2; ++nRow)
{
OUStringBuffer aIsErrorFormula("=ISERROR(");
aIsErrorFormula.append(static_cast<char>('A'+nCol)).append(OUString::number(nRow));
aIsErrorFormula.append(")");
OUString aFormula = aIsErrorFormula.makeStringAndClear();
OUString aFormula = "=ISERROR(" +
OUStringLiteral1(static_cast<char>('A'+nCol)) + OUString::number(nRow) +
")";
rDoc.SetString(nCol, nRow + 2, 2, aFormula);
CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), OUString("TRUE"), rDoc.GetString(nCol, nRow +2, 2));
OUStringBuffer aIsTextFormula("=ISTEXT(");
aIsTextFormula.append(static_cast<char>('A'+nCol)).append(OUString::number(nRow));
aIsTextFormula.append(")");
rDoc.SetString(nCol, nRow + 4, 2, aIsTextFormula.makeStringAndClear());
OUString aIsTextFormula = "=ISTEXT(" +
OUString::number(static_cast<char>('A'+nCol))+ OUString::number(nRow) +
")";
rDoc.SetString(nCol, nRow + 4, 2, aIsTextFormula);
CPPUNIT_ASSERT_EQUAL(OUString("FALSE"), rDoc.GetString(nCol, nRow +4, 2));
}
}
@ -1285,9 +1284,8 @@ void checkValiditationEntries( const ValDataTestParams& rVDTParams )
sal_Int32 nCol( static_cast<sal_Int32>(rVDTParams.aPosition.Col()) );
sal_Int32 nRow( static_cast<sal_Int32>(rVDTParams.aPosition.Row()) );
sal_Int32 nTab( static_cast<sal_Int32>(rVDTParams.aPosition.Tab()) );
OStringBuffer sMsg("Data Validation Entry with base-cell-address: (");
sMsg.append(nCol).append(",").append(nRow).append(",").append(nTab).append(") ");
OString aMsgPrefix = sMsg.makeStringAndClear();
OString aMsgPrefix = "Data Validation Entry with base-cell-address: (" +
OString::number(nCol) + "," + OString::number(nRow) + "," + OString::number(nTab) + ") ";
OString aMsg = aMsgPrefix + "did not get imported at all.";
CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), pValDataTest);
@ -1323,11 +1321,13 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co
sal_Int32 nCol = static_cast<sal_Int32>(i);
sal_Int32 nRow = static_cast<sal_Int32>(j);
sal_Int32 nTab32 = static_cast<sal_Int32>(nTab);
OStringBuffer sMsg("\nData validation entry base-cell-address: (");
sMsg.append( static_cast<sal_Int32>(nBCol) ).append(",");
sMsg.append( static_cast<sal_Int32>(nBRow) ).append(",");
sMsg.append( nTab32 ).append(")\n");
sMsg.append("Cell: (").append(nCol).append(",").append(nRow).append(",").append(nTab32).append(")");
OString sMsg = "\nData validation entry base-cell-address: (" +
OString::number( static_cast<sal_Int32>(nBCol) ) + "," +
OString::number( static_cast<sal_Int32>(nBRow) ) + "," +
OString::number( nTab32 ) + ")\n"
"Cell: (" + OString::number(nCol) + "," +
OString::number(nRow) + "," +
OString::number(nTab32) + ")";
sal_uInt32 expectedKey(pValData->GetKey());
sal_uInt32 actualKey(0);
if(pValDataTest)

View File

@ -843,13 +843,12 @@ void ScDocument::UpdateExternalRefLinks(weld::Window* pWin)
INetURLObject aUrl(aFile,INetURLObject::EncodeMechanism::WasEncoded);
aFile = aUrl.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
OUStringBuffer aBuf;
aBuf.append(ScResId(SCSTR_EXTDOC_NOT_LOADED));
aBuf.append("\n\n");
aBuf.append(aFile);
OUString sMessage = ScResId(SCSTR_EXTDOC_NOT_LOADED) +
"\n\n" +
aFile;
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin,
VclMessageType::Warning, VclButtonsType::Ok,
aBuf.makeStringAndClear()));
sMessage));
xBox->run();
}

View File

@ -408,10 +408,7 @@ void ScDocument::CreateValidTabName(OUString& rName) const
for ( SCTAB i = static_cast<SCTAB>(maTabs.size())+1; !bOk ; i++ )
{
OUStringBuffer aBuf;
aBuf.append(aStrTable);
aBuf.append(static_cast<sal_Int32>(i));
rName = aBuf.makeStringAndClear();
rName = aStrTable + OUString::number(static_cast<sal_Int32>(i));
if (bPrefix)
bOk = ValidNewTabName( rName );
else

View File

@ -1507,10 +1507,7 @@ OUString lcl_GetDataFieldName( const OUString& rSourceName, sal_Int16 eFunc )
if (!pStrId)
return OUString();
OUStringBuffer aRet(ScResId(pStrId));
aRet.append(" - ");
aRet.append(rSourceName);
return aRet.makeStringAndClear();
return ScResId(pStrId) + " - " + rSourceName;
}
}

View File

@ -374,14 +374,11 @@ std::unique_ptr<ScMemChart> ScChartArray::CreateMemChartMulti()
if (aString.isEmpty())
{
OUStringBuffer aBuf(ScResId(STR_ROW));
aBuf.append(' ');
if ( pPos )
nPosRow = pPos->Row() + 1;
else
nPosRow++;
aBuf.append(static_cast<sal_Int32>(nPosRow));
aString = aBuf.makeStringAndClear();
aString = ScResId(STR_ROW) + " " + OUString::number(static_cast<sal_Int32>(nPosRow));
}
pMemChart->SetRowText( nRow, aString);
}

View File

@ -420,9 +420,7 @@ OUString ScChartListenerCollection::getUniqueName(const OUString& rPrefix) const
{
for (sal_Int32 nNum = 1; nNum < 10000; ++nNum) // arbitrary limit to prevent infinite loop.
{
OUStringBuffer aBuf(rPrefix);
aBuf.append(nNum);
OUString aTestName = aBuf.makeStringAndClear();
OUString aTestName = rPrefix + OUString::number(nNum);
if (m_Listeners.find(aTestName) == m_Listeners.end())
return aTestName;
}

View File

@ -1197,9 +1197,7 @@ void ScChangeActionMove::GetDescription(
aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
}
OUStringBuffer aBuf(rStr); // append to the original string.
aBuf.append(aRsc);
rStr = aBuf.makeStringAndClear();
rStr += aRsc; // append to the original string.
}
void ScChangeActionMove::GetRefString(
@ -1470,9 +1468,7 @@ void ScChangeActionContent::GetDescription(
aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
}
OUStringBuffer aBuf(rStr); // append to the original string.
aBuf.append(aRsc);
rStr = aBuf.makeStringAndClear();
rStr += aRsc; // append to the original string.
}
void ScChangeActionContent::GetRefString(
@ -1502,11 +1498,7 @@ void ScChangeActionContent::GetRefString(
if ( IsDeletedIn() )
{
// Insert the parentheses.
OUStringBuffer aBuf;
aBuf.append('(');
aBuf.append(rStr);
aBuf.append(')');
rStr = aBuf.makeStringAndClear();
rStr = "(" + rStr + ")";
}
}
else

View File

@ -2323,16 +2323,14 @@ void ScInterpreter::ScCell()
else if( aInfoType == "COORD" )
{ // address, lotus 1-2-3 formatted: $TABLE:$COL$ROW
// Yes, passing tab as col is intentional!
OUStringBuffer aFuncResult;
OUString aCellStr =
ScAddress( static_cast<SCCOL>(aCellPos.Tab()), 0, 0 ).Format(
(ScRefFlags::COL_ABS|ScRefFlags::COL_VALID), nullptr, pDok->GetAddressConvention() );
aFuncResult.append(aCellStr);
aFuncResult.append(':');
aCellStr = aCellPos.Format((ScRefFlags::COL_ABS|ScRefFlags::COL_VALID|ScRefFlags::ROW_ABS|ScRefFlags::ROW_VALID),
OUString aCellStr1 =
ScAddress( static_cast<SCCOL>(aCellPos.Tab()), 0, 0 ).Format(
(ScRefFlags::COL_ABS|ScRefFlags::COL_VALID), nullptr, pDok->GetAddressConvention() );
OUString aCellStr2 =
aCellPos.Format((ScRefFlags::COL_ABS|ScRefFlags::COL_VALID|ScRefFlags::ROW_ABS|ScRefFlags::ROW_VALID),
nullptr, pDok->GetAddressConvention());
aFuncResult.append(aCellStr);
PushString( aFuncResult.makeStringAndClear() );
OUString aFuncResult = aCellStr1 + ":" + aCellStr2;
PushString( aFuncResult );
}
// *** CELL PROPERTIES ***
@ -2493,12 +2491,8 @@ void ScInterpreter::ScCellExternal()
return;
}
OUStringBuffer aBuf;
aBuf.append('\'');
aBuf.append(*p);
aBuf.append("'#$");
aBuf.append(aTabName);
PushString(aBuf.makeStringAndClear());
OUString aBuf = "'" + *p + "'#$" + aTabName;
PushString(aBuf);
}
else if ( aInfoType == "CONTENTS" )
{

View File

@ -1168,14 +1168,14 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
XML_showRowStripes, "0", XML_showColStripes, "0",
XML_showLastColumn, "1");
OUStringBuffer aBuf("../pivotCache/pivotCacheDefinition");
aBuf.append(nCacheId);
aBuf.append(".xml");
OUString aBuf = "../pivotCache/pivotCacheDefinition" +
OUString::number(nCacheId) +
".xml";
rStrm.addRelation(
pPivotStrm->getOutputStream(),
CREATE_OFFICEDOC_RELATION_TYPE("pivotCacheDefinition"),
aBuf.makeStringAndClear());
aBuf);
pPivotStrm->endElement(XML_pivotTableDefinition);
}

View File

@ -635,13 +635,12 @@ static const char maCFStyleNamePrefix2[] = "ConditionalStyle_"; /// Prefix for c
OUString XclTools::GetCondFormatStyleName( SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition )
{
OUStringBuffer aBuf(maCFStyleNamePrefix1);
aBuf.append(static_cast<sal_Int32>(nScTab+1));
aBuf.append('_');
aBuf.append(static_cast<sal_Int32>(nFormat+1));
aBuf.append('_');
aBuf.append(static_cast<sal_Int32>(nCondition+1));
return aBuf.makeStringAndClear();
return maCFStyleNamePrefix1 +
OUString::number(static_cast<sal_Int32>(nScTab+1)) +
"_" +
OUString::number(static_cast<sal_Int32>(nFormat+1)) +
"_" +
OUString::number(static_cast<sal_Int32>(nCondition+1));
}
bool XclTools::IsCondFormatStyleName( const OUString& rStyleName )

View File

@ -81,9 +81,8 @@ void QProToSc::DoFunc( DefTokenId eOc, sal_uInt16 nArgs, const sal_Char* pExtStr
bAddIn = true;
if( pExtString )
{
OStringBuffer s("QPRO_");
s.append(pExtString);
nPush = aPool.Store(eOc, OStringToOUString(s.makeStringAndClear(), maIn.GetStreamCharSet()));
OString s = OStringLiteral("QPRO_") + pExtString;
nPush = aPool.Store(eOc, OStringToOUString(s, maIn.GetStreamCharSet()));
aPool << nPush;
}
else

View File

@ -103,10 +103,8 @@ void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange&
if (aParam.bUserDef)
{
OUStringBuffer aBuf;
aBuf.append(SC_USERLIST);
aBuf.append(static_cast<sal_Int32>(aParam.nUserIndex));
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf.makeStringAndClear());
OUString aBuf = SC_USERLIST + OUString::number(static_cast<sal_Int32>(aParam.nUserIndex));
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf);
}
else
{
@ -198,11 +196,10 @@ public:
return;
// name
OUStringBuffer aBuf;
aBuf.append(STR_DB_LOCAL_NONAME);
aBuf.append(static_cast<sal_Int32>(r.first)); // appended number equals sheet index on import.
OUString aBuf = STR_DB_LOCAL_NONAME +
OUString::number(static_cast<sal_Int32>(r.first)); // appended number equals sheet index on import.
write(aBuf.makeStringAndClear(), *r.second);
write(aBuf, *r.second);
}
void operator() (const ScDBData& rData)
@ -639,10 +636,8 @@ private:
if (aParam.bUserDef)
{
OUStringBuffer aBuf;
aBuf.append(SC_USERLIST);
aBuf.append(static_cast<sal_Int32>(aParam.nUserIndex));
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf.makeStringAndClear());
OUString aBuf = SC_USERLIST + OUString::number(static_cast<sal_Int32>(aParam.nUserIndex));
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf);
}
SvXMLElementExport aElemSGs(mrExport, XML_NAMESPACE_TABLE, XML_SORT_GROUPS, true, true);
}

View File

@ -4884,14 +4884,12 @@ void ScXMLExport::WriteExternalRefCaches()
{
if (nRow > 1)
{
OUStringBuffer aVal;
aVal.append(nRow);
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal.makeStringAndClear());
OUString aVal = OUString::number(nRow);
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal);
}
SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
OUStringBuffer aVal;
aVal.append(static_cast<sal_Int32>(nMaxColsUsed));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
OUString aVal = OUString::number(static_cast<sal_Int32>(nMaxColsUsed));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal);
SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
}
}
@ -4902,14 +4900,12 @@ void ScXMLExport::WriteExternalRefCaches()
{
if (nRowGap > 2)
{
OUStringBuffer aVal;
aVal.append(static_cast<sal_Int32>(nRowGap-1));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal.makeStringAndClear());
OUString aVal = OUString::number(static_cast<sal_Int32>(nRowGap-1));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal);
}
SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
OUStringBuffer aVal;
aVal.append(static_cast<sal_Int32>(nMaxColsUsed));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
OUString aVal = OUString::number(static_cast<sal_Int32>(nMaxColsUsed));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal);
SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
}
}
@ -4927,9 +4923,8 @@ void ScXMLExport::WriteExternalRefCaches()
{
if (nCol > 1)
{
OUStringBuffer aVal;
aVal.append(static_cast<sal_Int32>(nCol));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
OUString aVal = OUString::number(static_cast<sal_Int32>(nCol));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal);
}
SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
}
@ -4941,9 +4936,8 @@ void ScXMLExport::WriteExternalRefCaches()
{
if (nColGap > 2)
{
OUStringBuffer aVal;
aVal.append(static_cast<sal_Int32>(nColGap-1));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
OUString aVal = OUString::number(static_cast<sal_Int32>(nColGap-1));
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal);
}
SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
}

View File

@ -1551,11 +1551,8 @@ static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const
if ( pCalc->GetCode()->GetCodeLen() <= 1 )
{ // ==1: Single one is as a Parameter always a Range
// ==0: It might be one, if ...
OUStringBuffer aBraced;
aBraced.append('(');
aBraced.append(rFormula);
aBraced.append(')');
pCalc.reset( new ScSimpleFormulaCalculator( pDoc, rPos, aBraced.makeStringAndClear(), false ) );
OUString aBraced = "(" + rFormula + ")";
pCalc.reset( new ScSimpleFormulaCalculator( pDoc, rPos, aBraced, false ) );
}
else
bColRowName = false;

View File

@ -2028,11 +2028,7 @@ namespace {
OUString createLocalRangeName(const OUString& rName, const OUString& rTableName)
{
OUStringBuffer aString (rName);
aString.append(" (");
aString.append(rTableName);
aString.append(")");
return aString.makeStringAndClear();
return rName + " (" + rTableName + ")";
}
}

View File

@ -41,10 +41,9 @@ ScAbstractDialogFactory* ScAbstractDialogFactory::Create()
#ifndef DISABLE_DYNLOADING
static ::osl::Module aDialogLibrary;
OUStringBuffer aStrBuf;
aStrBuf.append( SVLIBRARY("scui") );
OUString aStrBuf = SVLIBRARY("scui");
if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, aStrBuf.makeStringAndClear(),
if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, aStrBuf,
SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY ) )
fp = reinterpret_cast<ScAbstractDialogFactory* (SAL_CALL*)()>(
aDialogLibrary.getFunctionSymbol( "ScCreateDialogFactory" ));

View File

@ -126,11 +126,8 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet )
theDbName = pDBData->GetName();
}
OUStringBuffer aBuf;
aBuf.append(" (");
aBuf.append(theDbName);
aBuf.append(')');
m_xFtDbArea->set_label(aBuf.makeStringAndClear());
OUString sLabel = " (" + theDbName + ")";
m_xFtDbArea->set_label(sLabel);
}
else
{

View File

@ -193,18 +193,18 @@ bool DocumentLinkManager::updateDdeOrOleOrWebServiceLinks(weld::Window* pWin)
const OUString& aElem = pDdeLink->GetItem();
const OUString& aType = pDdeLink->GetAppl();
OUStringBuffer aBuf;
aBuf.append(ScResId(SCSTR_DDEDOC_NOT_LOADED));
aBuf.append("\n\n");
aBuf.append("Source : ");
aBuf.append(aFile);
aBuf.append("\nElement : ");
aBuf.append(aElem);
aBuf.append("\nType : ");
aBuf.append(aType);
OUString sMessage =
ScResId(SCSTR_DDEDOC_NOT_LOADED) +
"\n\n"
"Source : " +
aFile +
"\nElement : " +
aElem +
"\nType : " +
aType;
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin,
VclMessageType::Warning, VclButtonsType::Ok,
aBuf.makeStringAndClear()));
sMessage));
xBox->run();
}
}

View File

@ -309,12 +309,9 @@ bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult
if ( pFCell->GetCode()->GetCodeLen() <= 1 )
{ // ==1: area
// ==0: would be an area if...
OUStringBuffer aBraced;
aBraced.append('(');
aBraced.append(rStrExp);
aBraced.append(')');
OUString aBraced = "(" + rStrExp + ")";
pFCell.reset( new ScSimpleFormulaCalculator(
m_pDoc, m_CursorPos, aBraced.makeStringAndClear(), bMatrixFormula));
m_pDoc, m_CursorPos, aBraced, bMatrixFormula));
pFCell->SetLimitString(true);
}
else

View File

@ -213,11 +213,11 @@ void ScDataFormDlg::FillCtrls()
if (nCurrentRow <= nEndRow)
{
OUStringBuffer aBuf;
aBuf.append(static_cast<sal_Int32>(nCurrentRow - nStartRow));
aBuf.append(" / ");
aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow));
m_xFixedText->set_label(aBuf.makeStringAndClear());
OUString sLabel =
OUString::number(static_cast<sal_Int32>(nCurrentRow - nStartRow)) +
" / " +
OUString::number(static_cast<sal_Int32>(nEndRow - nStartRow));
m_xFixedText->set_label(sLabel);
}
else
m_xFixedText->set_label(sNewRecord);

View File

@ -863,11 +863,7 @@ namespace {
OUString createLocalRangeName(const OUString& rName, const OUString& rTableName)
{
OUStringBuffer aString (rName);
aString.append(" (");
aString.append(rTableName);
aString.append(")");
return aString.makeStringAndClear();
return rName + " (" + rTableName + ")";
}
}

View File

@ -180,16 +180,15 @@ void ScViewFunc::DetectiveMarkPred()
if (pPath && ScRefTokenHelper::getRangeFromToken(aRange, p, aCurPos, true))
{
OUString aTabName = p->GetString().getString();
OUStringBuffer aBuf;
aBuf.append(*pPath);
aBuf.append('#');
aBuf.append(aTabName);
aBuf.append('.');
OUString aRangeStr(aRange.Format(ScRefFlags::VALID));
aBuf.append(aRangeStr);
OUString sUrl =
*pPath +
"#" +
aTabName +
"." +
aRangeStr;
ScGlobal::OpenURL(aBuf.makeStringAndClear(), OUString());
ScGlobal::OpenURL(sUrl, OUString());
}
return;
}

View File

@ -327,11 +327,8 @@ protected:
uno::Reference< drawing::XShapes > xShapes(xDrawPage, uno::UNO_QUERY_THROW);
OUString aString = XShapeDumper::dump(xShapes);
OStringBuffer aFileNameBuf( OUStringToOString( rShapesDumpFileNameBase, RTL_TEXTENCODING_UTF8 ) );
aFileNameBuf.append(i);
aFileNameBuf.append(".xml");
OString aFileName = aFileNameBuf.makeStringAndClear();
OString aFileName = OUStringToOString( rShapesDumpFileNameBase, RTL_TEXTENCODING_UTF8 ) +
OString::number(i) + ".xml";
if ( bCreate )
{

View File

@ -79,9 +79,7 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
|* Name of the layout of the page
\********************************************************************/
OUString aOldLayoutName(maLayoutName); // memorize
OUStringBuffer aBuf(rLayoutName);
aBuf.append(SD_LT_SEPARATOR).append(STR_LAYOUT_OUTLINE);
maLayoutName = aBuf.makeStringAndClear();
maLayoutName = rLayoutName + SD_LT_SEPARATOR STR_LAYOUT_OUTLINE;
/*********************************************************************
|* search and replace master page if necessary

View File

@ -58,10 +58,9 @@ void Communicator::execute()
pTransmitter->addMessage( "LO_SERVER_SERVER_PAIRED\n\n",
Transmitter::PRIORITY_HIGH );
OStringBuffer aServerInformationBuffer;
aServerInformationBuffer.append( "LO_SERVER_INFO\n" LIBO_VERSION_DOTTED "\n\n" );
OString aServerInformation = "LO_SERVER_INFO\n" LIBO_VERSION_DOTTED "\n\n";
pTransmitter->addMessage( aServerInformationBuffer.makeStringAndClear(), Transmitter::PRIORITY_HIGH );
pTransmitter->addMessage( aServerInformation, Transmitter::PRIORITY_HIGH );
Receiver aReceiver( pTransmitter.get() );
try {

View File

@ -177,18 +177,15 @@ void ImagePreparer::sendNotes( sal_uInt32 aSlideNumber )
return;
// Start the writing
OStringBuffer aBuffer;
aBuffer.append( "slide_notes\n" );
aBuffer.append( static_cast<sal_Int32>(aSlideNumber) );
aBuffer.append( "\n" );
aBuffer.append( "<html><body>" );
aBuffer.append( aNotes );
aBuffer.append( "</body></html>" );
aBuffer.append( "\n\n" );
pTransmitter->addMessage( aBuffer.makeStringAndClear(),
OString aBuffer =
"slide_notes\n" +
OString::number( static_cast<sal_Int32>(aSlideNumber) ) +
"\n"
"<html><body>" +
aNotes +
"</body></html>"
"\n\n";
pTransmitter->addMessage( aBuffer,
Transmitter::PRIORITY_LOW );
}

View File

@ -43,12 +43,11 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon
sal_Int32 aSlides = aController->getSlideCount();
sal_Int32 aCurrentSlide = aController->getCurrentSlideIndex();
OStringBuffer aBuffer;
aBuffer.append( "slideshow_started\n" )
.append( OString::number( aSlides ) ).append("\n")
.append( OString::number( aCurrentSlide ) ).append( "\n\n" );
OString aBuffer = "slideshow_started\n" +
OString::number( aSlides ) + "\n" +
OString::number( aCurrentSlide ) + "\n\n";
pTransmitter->addMessage( aBuffer.makeStringAndClear(),
pTransmitter->addMessage( aBuffer,
Transmitter::PRIORITY_HIGH );
{
@ -98,13 +97,13 @@ void SAL_CALL Listener::slideTransitionStarted()
{
sal_Int32 aSlide = mController->getCurrentSlideIndex();
OStringBuffer aBuilder( "slide_updated\n" );
aBuilder.append( OString::number( aSlide ) );
aBuilder.append( "\n\n" );
OString aBuilder = "slide_updated\n" +
OString::number( aSlide ) +
"\n\n";
if ( pTransmitter )
{
pTransmitter->addMessage( aBuilder.makeStringAndClear(),
pTransmitter->addMessage( aBuilder,
Transmitter::PRIORITY_HIGH );
}
}

View File

@ -1465,14 +1465,13 @@ uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName )
const OUString aModulName = aMacro.getToken(0, '.', nIdx);
const OUString aLibName = aMacro.getToken(0, '.', nIdx);
OUStringBuffer sBuffer;
sBuffer.append( aLibName );
sBuffer.append( '.' );
sBuffer.append( aModulName );
sBuffer.append( '.' );
sBuffer.append( aMacroName );
OUString sBuffer = aLibName +
"." +
aModulName +
"." +
aMacroName;
aAny <<= sBuffer.makeStringAndClear();
aAny <<= sBuffer;
pProperties->Name = gaStrMacroName;
pProperties->Handle = -1;
pProperties->Value = aAny;

View File

@ -2103,11 +2103,8 @@ OUString getPageApiName( SdPage const * pPage )
if( aPageName.isEmpty() )
{
OUStringBuffer sBuffer;
sBuffer.append( sEmptyPageName );
const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1;
sBuffer.append( nPageNum );
aPageName = sBuffer.makeStringAndClear();
aPageName = sEmptyPageName + OUString::number( nPageNum );
}
}
@ -2165,11 +2162,7 @@ OUString getUiNameFromPageApiNameImpl( const OUString& rApiName )
if( nPageNumber != -1)
{
OUStringBuffer sBuffer;
sBuffer.append( SdResId(STR_PAGE) );
sBuffer.append( ' ' );
sBuffer.append( aNumber );
return sBuffer.makeStringAndClear();
return SdResId(STR_PAGE) + " " + aNumber;
}
}

View File

@ -112,12 +112,11 @@ void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL,
if ( nFileSizeSource && nFileSizeDest )
{
OUStringBuffer sBuf( "Your Presentation has been minimized from:" );
sBuf.append( OUString::number( nFileSizeSource >> 10 ) );
sBuf.append( "KB to " );
sBuf.append( OUString::number( nFileSizeDest >> 10 ) );
sBuf.append( "KB." );
OUString sResult( sBuf.makeStringAndClear() );
OUString sResult = "Your Presentation has been minimized from:" +
OUString::number( nFileSizeSource >> 10 ) +
"KB to " +
OUString::number( nFileSizeDest >> 10 ) +
"KB.";
SAL_INFO("sdext.minimizer", sResult );
}
}

View File

@ -56,9 +56,8 @@ OdfEmitter::OdfEmitter( const uno::Reference<io::XOutputStream>& xOutput ) :
OSL_PRECOND(m_xOutput.is(), "OdfEmitter(): invalid output stream");
m_aLineFeed[0] = '\n';
OUStringBuffer aElement;
aElement.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
write(aElement.makeStringAndClear());
OUString aElement = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
write(aElement);
}
void OdfEmitter::beginTag( const char* pTag, const PropertyMap& rProperties )
@ -73,12 +72,12 @@ void OdfEmitter::beginTag( const char* pTag, const PropertyMap& rProperties )
std::vector<OUString> aAttributes;
for( const auto& rCurr : rProperties )
{
OUStringBuffer aAttribute;
aAttribute.append(rCurr.first);
aAttribute.append("=\"");
aAttribute.append(rCurr.second);
aAttribute.append("\" ");
aAttributes.push_back(aAttribute.makeStringAndClear());
OUString aAttribute =
rCurr.first +
"=\"" +
rCurr.second +
"\" ";
aAttributes.push_back(aAttribute);
}
// since the hash map's sorting is undefined (and varies across

View File

@ -263,11 +263,11 @@ static int write_addStreamArray( const char* pOutFile, PDFArray* pStreams, PDFFi
PDFObject* pObject = pPDFFile->findObject( pStreamRef->m_nNumber, pStreamRef->m_nGeneration );
if( pObject )
{
OStringBuffer aOutStream( pOutFile );
aOutStream.append( "_stream_" );
aOutStream.append( sal_Int32(pStreamRef->m_nNumber) );
aOutStream.append( "_" );
aOutStream.append( sal_Int32(pStreamRef->m_nGeneration) );
OString aOutStream = pOutFile +
OStringLiteral("_stream_") +
OString::number( sal_Int32(pStreamRef->m_nNumber) ) +
"_" +
OString::number( sal_Int32(pStreamRef->m_nGeneration) );
FileEmitContext aContext( aOutStream.getStr(), pInFile, pPDFFile );
aContext.m_bDecrypt = pPDFFile->isEncrypted();
pObject->writeStream( aContext, pPDFFile );
@ -406,11 +406,11 @@ static int write_objects( const char* i_pInFile, const char* i_pOutFile, PDFFile
continue;
}
OStringBuffer aOutStream( i_pOutFile );
aOutStream.append( "_stream_" );
aOutStream.append( nObject );
aOutStream.append( "_" );
aOutStream.append( nGeneration );
OString aOutStream = i_pOutFile +
OStringLiteral("_stream_") +
OString::number( nObject ) +
"_" +
OString::number( nGeneration );
FileEmitContext aContext( aOutStream.getStr(), i_pInFile, i_pPDFFile );
aContext.m_bDecrypt = i_pPDFFile->isEncrypted();
pStream->writeStream( aContext, i_pPDFFile );

View File

@ -1377,17 +1377,14 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() )
{
OUStringBuffer aURLBuf( sTemplRepoURL );
aURLBuf.append("?lang=");
// read locale from configuration
OUString sLocale(officecfg::Setup::L10N::ooLocale::get());
if (sLocale.isEmpty())
sLocale = "en-US";
aURLBuf.append( sLocale );
OUString aURLBuf = sTemplRepoURL + "?lang=" + sLocale;
xSystemShell->execute(
aURLBuf.makeStringAndClear(),
aURLBuf,
OUString(),
css::system::SystemShellExecuteFlags::URIS_ONLY );
}

View File

@ -1230,8 +1230,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
continue;
}
OStringBuffer aDbg("Unknown item detected: ");
aDbg.append(static_cast<sal_Int32>(nId));
OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId));
DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr());
}
}

View File

@ -1134,9 +1134,7 @@ OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleName()
if( aRet.isEmpty() )
{
OUStringBuffer aBuffer("Item ");
aBuffer.append(static_cast<sal_Int32>(mpParent->mnId));
aRet = aBuffer.makeStringAndClear();
aRet = "Item " + OUString::number(static_cast<sal_Int32>(mpParent->mnId));
}
}

View File

@ -1527,11 +1527,7 @@ OUString SAL_CALL MetadatableMixin::getLocalName()
ensureMetadataReference(); // N.B.: side effect!
mdref = getMetadataReference();
}
OUStringBuffer buf;
buf.append(mdref.First);
buf.append('#');
buf.append(mdref.Second);
return buf.makeStringAndClear();
return mdref.First + "#" + mdref.Second;
}
OUString SAL_CALL MetadatableMixin::getNamespace()

View File

@ -279,12 +279,11 @@ bool SfxNotebookBar::IsActive()
return false;
OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/");
aPath.append( appName );
OUString aPath = "org.openoffice.Office.UI.ToolbarMode/Applications/" + appName;
const utl::OConfigurationTreeRoot aAppNode(
::comphelper::getProcessComponentContext(),
aPath.makeStringAndClear(),
aPath,
false);
if ( !aAppNode.isValid() )
return false;
@ -378,8 +377,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
{
RemoveListeners(pSysWindow);
OUStringBuffer aBuf(rUIFile);
aBuf.append( sFile );
OUString aBuf = rUIFile + sFile;
//Addons For Notebookbar
std::vector<Image> aImageValues;
@ -390,7 +388,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
aNotebookBarAddonsItem.aImageValues = aImageValues;
// setup if necessary
pSysWindow->SetNotebookBar(aBuf.makeStringAndClear(), xFrame, aNotebookBarAddonsItem , bReloadNotebookbar);
pSysWindow->SetNotebookBar(aBuf, xFrame, aNotebookBarAddonsItem , bReloadNotebookbar);
pNotebookBar = pSysWindow->GetNotebookBar();
pNotebookBar->Show();
pNotebookBar->GetParent()->Resize();

View File

@ -714,12 +714,10 @@ utl::OConfigurationTreeRoot ResourceManager::GetLegacyAddonRootNode (const OUStr
"ooSetupFactoryWindowStateConfigRef",
OUString()));
OUStringBuffer aPathComposer;
aPathComposer.append("org.openoffice.Office.UI.");
aPathComposer.append(sWindowStateRef);
aPathComposer.append("/UIElements/States");
OUString aPathComposer = "org.openoffice.Office.UI." + sWindowStateRef +
"/UIElements/States";
return utl::OConfigurationTreeRoot(xContext, aPathComposer.makeStringAndClear(), false);
return utl::OConfigurationTreeRoot(xContext, aPathComposer, false);
}
catch (const Exception&)
{

View File

@ -35,11 +35,9 @@ namespace slideshow
OUString debugGetNodeName( const BaseNode *pNode )
{
OUStringBuffer aBuf;
aBuf.append(lcl_nOffset);
aBuf.append(" - 0x");
aBuf.append(reinterpret_cast<sal_Int64>(pNode), 16);
return aBuf.makeStringAndClear();
return OUString::number(lcl_nOffset) +
" - 0x" +
OUString::number(reinterpret_cast<sal_Int64>(pNode), 16);
}
void debugNodesShowTree( const BaseNode* pNode )

View File

@ -12,6 +12,7 @@ $(eval $(call gb_CompilerTest_CompilerTest,compilerplugins_clang))
$(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/badstatics \
compilerplugins/clang/test/blockblock \
compilerplugins/clang/test/bufferadd \
compilerplugins/clang/test/buriedassign \
compilerplugins/clang/test/casttovoid \
compilerplugins/clang/test/classmemaccess \

View File

@ -1290,10 +1290,8 @@ Reference<XInterface > ORegistryServiceManager::loadWithImplementationName(
Sequence<OUString> ORegistryServiceManager::getFromServiceName(
const OUString& serviceName ) const
{
OUStringBuffer buf;
buf.append( "/SERVICES/" );
buf.append( serviceName );
return retrieveAsciiValueList( m_xRegistry, buf.makeStringAndClear() );
OUString buf = "/SERVICES/" + serviceName;
return retrieveAsciiValueList( m_xRegistry, buf );
}
/**

View File

@ -42,11 +42,7 @@ namespace
OUString str1("");
OUString str2("a-b--c---");
OUStringBuffer str3Buf;
str3Buf.append(SVT_SOFT_HYPHEN);
str3Buf.append(SVT_HARD_HYPHEN);
str3Buf.append(SVT_HARD_HYPHEN);
OUString str3(str3Buf.makeStringAndClear());
OUString str3 = OUStringLiteral1(SVT_SOFT_HYPHEN) + OUStringLiteral1(SVT_HARD_HYPHEN) + OUStringLiteral1(SVT_HARD_HYPHEN);
OUString str4("asdf");

View File

@ -102,10 +102,7 @@ OUString ColorNameMap::lookUp(long color) const {
return i->second;
}
// Did not find the given color; return its RGB tuple representation:
OUStringBuffer buf;
buf.append('#');
buf.append(color, 16);
return buf.makeStringAndClear();
return "#" + OUString::number(color, 16);
}
struct theColorNameMap: public rtl::Static< ColorNameMap, theColorNameMap > {};

View File

@ -1035,14 +1035,11 @@ namespace svxform
sMacroLocation = "document";
}
OUStringBuffer aScriptURI;
aScriptURI.append( "vnd.sun.star.script:" );
aScriptURI.append( sScriptCode );
aScriptURI.append( "?language=Basic" );
aScriptURI.append( "&location=" );
aScriptURI.append( sMacroLocation );
OUString sScriptURI = "vnd.sun.star.script:" +
sScriptCode +
"?language=Basic&location=" +
sMacroLocation;
const OUString sScriptURI( aScriptURI.makeStringAndClear() );
pScript.reset( new NewStyleUNOScript( *xObjectShell, sScriptURI ) );
}

View File

@ -113,9 +113,8 @@ void SwMacrosTest::testVba()
OUString aFileName;
createFileURL(testInfo[i].sFileBaseName, "doc", aFileName);
uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
OUStringBuffer sMsg( "Failed to load " );
sMsg.append ( aFileName );
CPPUNIT_ASSERT_MESSAGE( OUStringToOString( sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() );
OUString sMsg = "Failed to load " + aFileName;
CPPUNIT_ASSERT_MESSAGE( OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() );
OUString sUrl = testInfo[i].sMacroUrl;
Any aRet;

View File

@ -522,11 +522,10 @@ void SwDocTest::testModelToViewHelperHideInvisibleHideRedlined()
ModelToViewHelper aModelToViewHelper(*pTextNode, nullptr,
ExpandMode::HideInvisible | ExpandMode::HideDeletions);
OUString sViewText = aModelToViewHelper.getViewText();
OUStringBuffer aBuffer;
aBuffer.append("AAAACCCCC ");
aBuffer.append(CH_TXTATR_BREAKWORD);
aBuffer.append(" DDDDD");
CPPUNIT_ASSERT_EQUAL(aBuffer.makeStringAndClear(), sViewText);
OUString aBuffer = "AAAACCCCC " +
OUStringLiteral1(CH_TXTATR_BREAKWORD) +
" DDDDD";
CPPUNIT_ASSERT_EQUAL(aBuffer, sViewText);
}
void SwDocTest::testModelToViewHelperExpandFieldsHideInvisibleHideRedlinedExpandFootnote()

View File

@ -215,7 +215,6 @@ namespace sw { namespace mark
{
static OUString sUniquePostfix;
static sal_Int32 nCount = SAL_MAX_INT32;
OUStringBuffer aResult(rPrefix);
if(nCount == SAL_MAX_INT32)
{
unsigned int const n(comphelper::rng::uniform_uint_distribution(0,
@ -224,7 +223,7 @@ namespace sw { namespace mark
nCount = 0;
}
// putting the counter in front of the random parts will speed up string comparisons
return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear();
return rPrefix + OUString::number(nCount++) + sUniquePostfix;
}
}

Some files were not shown because too many files have changed in this diff Show More