[Libreoffice-commits] core.git: 25 commits - basctl/source basic/source compilerplugins/clang connectivity/source cppuhelper/source cppu/source cui/source dbaccess/source editeng/source extensions/source filter/source framework/inc framework/source i18npool/qa include/comphelper include/rtl oox/source sal/qa sc/source sd/source svtools/source svx/source sw/qa sw/source ucb/source unotools/source vcl/source xmloff/source
Stephan Bergmann
sbergman at redhat.com
Thu Jun 25 03:39:21 PDT 2015
basctl/source/basicide/brkdlg.cxx | 2
basic/source/comp/codegen.cxx | 2
compilerplugins/clang/stringconstant.cxx | 133 +++++++
connectivity/source/drivers/evoab2/NStatement.cxx | 4
cppu/source/typelib/typelib.cxx | 3
cppuhelper/source/factory.cxx | 3
cui/source/options/optpath.cxx | 2
dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 4
dbaccess/source/ui/app/AppController.cxx | 2
dbaccess/source/ui/browser/unodatbr.cxx | 4
dbaccess/source/ui/control/opendoccontrols.cxx | 2
dbaccess/source/ui/dlg/DbAdminImpl.cxx | 4
editeng/source/editeng/impedit.cxx | 2
extensions/source/propctrlr/selectlabeldialog.cxx | 4
filter/source/graphic/GraphicExportFilter.cxx | 8
filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx | 2
filter/source/xsltdialog/xmlfilterjar.cxx | 2
framework/inc/queries.h | 38 +-
framework/source/accelerators/storageholder.cxx | 4
i18npool/qa/cppunit/test_breakiterator.cxx | 4
include/comphelper/string.hxx | 2
include/rtl/strbuf.hxx | 28 +
include/rtl/string.hxx | 130 +++++--
include/rtl/stringconcat.hxx | 13
include/rtl/stringutils.hxx | 87 ++++
include/rtl/ustrbuf.hxx | 49 +-
include/rtl/ustring.hxx | 305 +++++++++--------
oox/source/export/chartexport.cxx | 2
oox/source/export/vmlexport.cxx | 2
sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 14
sc/source/core/tool/compiler.cxx | 4
sc/source/ui/docshell/impex.cxx | 12
sc/source/ui/view/gridwin5.cxx | 4
sc/source/ui/view/tabvwshe.cxx | 2
sd/source/filter/eppt/pptexanimations.cxx | 2
sd/source/filter/html/htmlex.cxx | 4
svtools/source/misc/ehdl.cxx | 9
svx/source/form/navigatortree.cxx | 6
sw/qa/core/uwriter.cxx | 8
sw/source/core/access/acccontext.cxx | 4
sw/source/core/fields/dbfld.cxx | 2
sw/source/core/fields/ddefld.cxx | 2
sw/source/core/tox/tox.cxx | 2
sw/source/filter/ww8/docxexport.cxx | 4
sw/source/filter/ww8/ww8par5.cxx | 4
sw/source/uibase/dbui/mmconfigitem.cxx | 4
sw/source/uibase/docvw/edtwin2.cxx | 4
sw/source/uibase/fldui/fldmgr.cxx | 8
sw/source/uibase/utlui/initui.cxx | 4
ucb/source/ucp/hierarchy/hierarchyuri.cxx | 4
ucb/source/ucp/webdav-neon/NeonSession.cxx | 3
ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx | 3
unotools/source/config/bootstrap.cxx | 4
unotools/source/config/dynamicmenuoptions.cxx | 2
unotools/source/config/pathoptions.cxx | 4
vcl/source/control/field2.cxx | 2
xmloff/source/chart/SchXMLExport.cxx | 2
57 files changed, 664 insertions(+), 310 deletions(-)
New commits:
commit af333e81037b106702fc4c4d68b0653f80d2fb1b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:38:02 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I47726315f12ef05714bea248d79cc503fb99b23c
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index 12bf173..9c86921 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -98,6 +98,9 @@ private:
std::string const & qname, std::string const & replacement,
TreatEmpty treatEmpty);
+ void handleOUStringCtor(
+ CallExpr const * expr, unsigned arg, std::string const & qname);
+
std::stack<Expr const *> calls_;
};
@@ -292,6 +295,68 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
TreatEmpty::Error);
return true;
}
+ if (qname == "rtl::OUString::reverseCompareTo"
+ && fdecl->getNumParams() == 1)
+ {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::equalsIgnoreAsciiCase"
+ && fdecl->getNumParams() == 1)
+ {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::match" && fdecl->getNumParams() == 2) {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::matchIgnoreAsciiCase"
+ && fdecl->getNumParams() == 2)
+ {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::startsWith" && fdecl->getNumParams() == 2) {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::startsWithIgnoreAsciiCase"
+ && fdecl->getNumParams() == 2)
+ {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::endsWith" && fdecl->getNumParams() == 2) {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::endsWithIgnoreAsciiCase"
+ && fdecl->getNumParams() == 2)
+ {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::indexOf" && fdecl->getNumParams() == 2) {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::lastIndexOf" && fdecl->getNumParams() == 1) {
+ handleOUStringCtor(expr, 0, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::replaceFirst" && fdecl->getNumParams() == 3) {
+ handleOUStringCtor(expr, 0, qname);
+ handleOUStringCtor(expr, 1, qname);
+ return true;
+ }
+ if (qname == "rtl::OUString::replaceAll"
+ && (fdecl->getNumParams() == 2 || fdecl->getNumParams() == 3))
+ {
+ handleOUStringCtor(expr, 0, qname);
+ handleOUStringCtor(expr, 1, qname);
+ return true;
+ }
if (qname == "rtl::OUString::equals" && fdecl->getNumParams() == 1) {
unsigned n;
bool non;
@@ -451,6 +516,7 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
<< expr->getSourceRange();
return true;
}
+ return true;
}
return true;
}
@@ -1089,6 +1155,73 @@ void StringConstant::handleCharLen(
reportChange(expr, ChangeKind::CharLen, qname, repl, PassThrough::No);
}
+void StringConstant::handleOUStringCtor(
+ CallExpr const * expr, unsigned arg, std::string const & qname)
+{
+ auto e0 = expr->getArg(arg)->IgnoreParenImpCasts();
+ auto e1 = dyn_cast<CXXFunctionalCastExpr>(e0);
+ if (e1 != nullptr) {
+ e0 = e1->getSubExpr()->IgnoreParenImpCasts();
+ }
+ auto e2 = dyn_cast<CXXBindTemporaryExpr>(e0);
+ if (e2 == nullptr) {
+ return;
+ }
+ auto e3 = dyn_cast<CXXConstructExpr>(
+ e2->getSubExpr()->IgnoreParenImpCasts());
+ if (e3 == nullptr) {
+ return;
+ }
+ if (e3->getConstructor()->getQualifiedNameAsString()
+ != "rtl::OUString::OUString")
+ {
+ return;
+ }
+ if (e3->getNumArgs() == 0) {
+ report(
+ DiagnosticsEngine::Warning,
+ ("in call of %0, replace default-constructed OUString with an empty"
+ " string literal"),
+ e3->getExprLoc())
+ << qname << expr->getSourceRange();
+ return;
+ }
+ APSInt res;
+ if (e3->getNumArgs() == 1
+ && e3->getArg(0)->IgnoreParenImpCasts()->isIntegerConstantExpr(
+ res, compiler.getASTContext()))
+ {
+ if (res > 0 && res <= 127) {
+ report(
+ DiagnosticsEngine::Warning,
+ ("in call of %0, replace OUString constructed from a (non-NUL)"
+ " ASCII char constant with a string literal"),
+ e3->getExprLoc())
+ << qname << expr->getSourceRange();
+ }
+ return;
+ }
+ if (e3->getNumArgs() != 2) {
+ return;
+ }
+ unsigned n;
+ bool non;
+ bool emb;
+ bool trm;
+ if (!isStringConstant(
+ e3->getArg(0)->IgnoreParenImpCasts(), &n, &non, &emb, &trm))
+ {
+ return;
+ }
+ //TODO: non, emb, trm
+ report(
+ DiagnosticsEngine::Warning,
+ ("in call of %0, replace OUString constructed from a string literal"
+ " directly with the string literal"),
+ e3->getExprLoc())
+ << qname << expr->getSourceRange();
+}
+
loplugin::Plugin::Registration< StringConstant > X("stringconstant");
}
commit 94c1ea92ce7653f3cf91cfd0efe9546bbdb47ad3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:38 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I81a60eb512356d19cb746145fdf0dc1a3c676ba1
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 7f42635..08f1c53 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -627,7 +627,7 @@ uno::Sequence< OUString > lcl_DataSequenceToStringSequence(
{
OUString aRole;
xProp->getPropertyValue("Role") >>= aRole;
- if( aRole.match( OUString( "values-x" ) ) )
+ if( aRole.match("values-x") )
{
//lcl_clearIfNoValuesButTextIsContained - replace by indices if the values are not appropriate
bool bHasValue=false;
commit 0c526c668391faec7fdfbab7d0210210c7a2a32e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:34 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I918023aa2e14d0913e6e05129ceb0c528b6cfd96
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 3f343b2..6f093e6 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -948,7 +948,7 @@ static sal_uInt16 ImplCutNumberFromString( OUString& rStr )
static bool ImplCutMonthName( OUString& rStr, const OUString& _rLookupMonthName )
{
sal_Int32 index = 0;
- rStr = rStr.replaceFirst(_rLookupMonthName, OUString(), &index);
+ rStr = rStr.replaceFirst(_rLookupMonthName, "", &index);
return index >= 0;
}
commit 495b6575f8b9a19f1c72184d56eacb590aeab739
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:29 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I45fcbcdf15134585443e528e8af2c9486d0b3bbe
diff --git a/unotools/source/config/bootstrap.cxx b/unotools/source/config/bootstrap.cxx
index 020c8463..2fb514d 100644
--- a/unotools/source/config/bootstrap.cxx
+++ b/unotools/source/config/bootstrap.cxx
@@ -199,7 +199,7 @@ bool implNormalizeURL(OUString & _sURL, osl::DirectoryItem& aDirItem)
// #109863# sal/osl returns final slash for file URLs contradicting
// the URL/URI RFCs.
- if ( !aNormalizedURL.endsWith(OUString(cURLSeparator)) )
+ if ( !aNormalizedURL.endsWith(OUStringLiteral1<cURLSeparator>()) )
_sURL = aNormalizedURL;
else
_sURL = aNormalizedURL.copy( 0, aNormalizedURL.getLength()-1 );
@@ -312,7 +312,7 @@ PathStatus getDerivedPath(
// do we have a base path ?
if (!_aBaseURL.isEmpty())
{
- OSL_PRECOND(!_aBaseURL.endsWith(OUString(cURLSeparator)), "Unexpected: base URL ends in slash");
+ OSL_PRECOND(!_aBaseURL.endsWith(OUStringLiteral1<cURLSeparator>()), "Unexpected: base URL ends in slash");
sDerivedURL = OUStringBuffer(_aBaseURL).append(cURLSeparator).append(_sRelativeURL).makeStringAndClear();
diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx
index cf706c4..6a8659e 100644
--- a/unotools/source/config/dynamicmenuoptions.cxx
+++ b/unotools/source/config/dynamicmenuoptions.cxx
@@ -59,7 +59,7 @@ using namespace ::com::sun::star::beans;
#define OFFSET_IMAGEIDENTIFIER 2
#define OFFSET_TARGETNAME 3
-#define PATHPREFIX_SETUP OUString("m")
+#define PATHPREFIX_SETUP "m"
/*-****************************************************************************************************************
@descr struct to hold information about one menu entry.
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 23f062c..46bada4 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -58,8 +58,8 @@ using namespace com::sun::star::util;
using namespace com::sun::star::lang;
#define SEARCHPATH_DELIMITER ';'
-#define SIGN_STARTVARIABLE OUString( "$(" )
-#define SIGN_ENDVARIABLE OUString( ")" )
+#define SIGN_STARTVARIABLE "$("
+#define SIGN_ENDVARIABLE ")"
// Supported variables by the old SvtPathOptions implementation
#define SUBSTITUTE_INSTPATH "$(instpath)"
commit 69acf266801246d0099d02de57db332fbe167c72
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:25 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I5bd4f30d7b614af34b5ca2edca06bab9350ca206
diff --git a/ucb/source/ucp/hierarchy/hierarchyuri.cxx b/ucb/source/ucp/hierarchy/hierarchyuri.cxx
index 0c4b259..03c10dc 100644
--- a/ucb/source/ucp/hierarchy/hierarchyuri.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchyuri.cxx
@@ -123,9 +123,7 @@ void HierarchyUri::init() const
}
// Empty path segments?
- if ( m_aUri.indexOf(
- OUString("//"),
- nStart ) != -1 )
+ if ( m_aUri.indexOf("//", nStart) != -1 )
{
// error, but remember that we did a init().
m_aPath = "/";
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index d13e843..5c90ae2 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -720,8 +720,7 @@ void NeonSession::Init()
// Register the session with the lock store
m_aNeonLockStore.registerSession( m_pHttpSession );
- if ( m_aScheme.equalsIgnoreAsciiCase(
- OUString( "https" ) ) )
+ if ( m_aScheme.equalsIgnoreAsciiCase("https") )
{
// Set a failure callback for certificate check
ne_ssl_set_verify(
diff --git a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
index a737766..047b018 100644
--- a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
+++ b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
@@ -376,8 +376,7 @@ bool UCBDeadPropertyValue::createFromXML( const OString & rInData,
}
else if ( aCtx.pType->equalsIgnoreAsciiCase( aTypeBoolean ) )
{
- if ( aStringValue.equalsIgnoreAsciiCase(
- OUString("true") ) )
+ if ( aStringValue.equalsIgnoreAsciiCase("true") )
rOutData <<= true;
else
rOutData <<= false;
commit 8918eaf6d6b3de149e77ade965ab46694972b985
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:22 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: Idd767eb9e2d2e101a77a19cd5617f479eb9fd2aa
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index f4e03a0..849ce1b 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -823,7 +823,7 @@ void SwDocTest::testSwScanner()
aDocStat.Reset();
m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint());
- m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" = ")));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll("X", " = "));
pTextNode = aPaM.GetNode().GetTextNode();
pTextNode->CountWords(aDocStat, 0, pTextNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 5 &&
@@ -832,7 +832,7 @@ void SwDocTest::testSwScanner()
aDocStat.Reset();
m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint());
- m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" _ ")));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll("X", " _ "));
pTextNode = aPaM.GetNode().GetTextNode();
pTextNode->CountWords(aDocStat, 0, pTextNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 5 &&
@@ -841,7 +841,7 @@ void SwDocTest::testSwScanner()
aDocStat.Reset();
m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint());
- m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" -- ")));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll("X", " -- "));
pTextNode = aPaM.GetNode().GetTextNode();
pTextNode->CountWords(aDocStat, 0, pTextNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 5 &&
@@ -908,7 +908,7 @@ void SwDocTest::testSwScanner()
const sal_Unicode aChunk[] = {' ', 0x2013, ' '};
OUString sChunk(aChunk, SAL_N_ELEMENTS(aChunk));
m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint());
- m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), sChunk));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll("X", sChunk));
pTextNode = aPaM.GetNode().GetTextNode();
pTextNode->CountWords(aDocStat, 0, pTextNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 4 &&
diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
index 09e5372..b99ec62 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -1405,11 +1405,11 @@ OUString SwAccessibleContext::GetResource( sal_uInt16 nResId,
if( pArg1 )
{
- sStr = sStr.replaceFirst( OUString("$(ARG1)"), *pArg1 );
+ sStr = sStr.replaceFirst( "$(ARG1)", *pArg1 );
}
if( pArg2 )
{
- sStr = sStr.replaceFirst( OUString("$(ARG2)"), *pArg2 );
+ sStr = sStr.replaceFirst( "$(ARG2)", *pArg2 );
}
return sStr;
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index fa8969e..919ca20 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -46,7 +46,7 @@ using namespace ::com::sun::star;
/// replace database separator by dots for display
static OUString lcl_DBTrennConv(const OUString& aContent)
{
- return aContent.replaceAll(OUString(DB_DELIM), OUString('.'));
+ return aContent.replaceAll(OUString(DB_DELIM), ".");
}
// database field type
diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx
index de9d827..34e6fa8 100644
--- a/sw/source/core/fields/ddefld.cxx
+++ b/sw/source/core/fields/ddefld.cxx
@@ -385,7 +385,7 @@ SwDDEField::~SwDDEField()
OUString SwDDEField::Expand() const
{
OUString aStr = static_cast<SwDDEFieldType*>(GetTyp())->GetExpansion();
- aStr = aStr.replaceAll("\r", OUString());
+ aStr = aStr.replaceAll("\r", "");
aStr = aStr.replaceAll("\t", " ");
aStr = aStr.replaceAll("\n", "|");
if (aStr.endsWith("|"))
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 0b6a852..6490ae8 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -627,7 +627,7 @@ OUString SwFormToken::GetString() const
break;
case TOKEN_TEXT:
sData += OUStringLiteral1<TOX_STYLE_DELIMITER>()
- + sText.replaceAll(OUString(TOX_STYLE_DELIMITER), OUString())
+ + sText.replaceAll(OUStringLiteral1<TOX_STYLE_DELIMITER>(), "")
+ OUStringLiteral1<TOX_STYLE_DELIMITER>();
break;
case TOKEN_AUTHORITY:
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 855be57..e91bea8 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1244,9 +1244,9 @@ void DocxExport::WriteEmbeddings()
embeddingsList[j].Value >>= embeddingsStream;
OUString contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- if (embeddingPath.endsWith(OUString(".xlsm")))
+ if (embeddingPath.endsWith(".xlsm"))
contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
- else if (embeddingPath.endsWith(OUString(".bin")))
+ else if (embeddingPath.endsWith(".bin"))
contentType = "application/vnd.openxmlformats-officedocument.oleObject";
if ( embeddingsStream.is() )
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index b7c1e2e..03e5181 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -249,8 +249,8 @@ long SwWW8ImplReader::Read_AtnBook(WW8PLCFManResult*)
OUString SwWW8ImplReader::ConvertFFileName(const OUString& rOrg)
{
OUString aName = rOrg;
- aName = aName.replaceAll("\\\\", OUString('\\'));
- aName = aName.replaceAll("%20", OUString(' '));
+ aName = aName.replaceAll("\\\\", "\\");
+ aName = aName.replaceAll("%20", " ");
// remove attached quotation marks
if (aName.endsWith("\""))
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index c5bc58e..d765dc0f 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -388,7 +388,7 @@ static OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments )
static void lcl_ConvertToNumbers(OUString& rBlock, const ResStringArray& rHeaders )
{
//convert the strings used for UI to numbers used for the configuration
- OUString sBlock(rBlock.replaceAll("\n", OUString("\\n")));
+ OUString sBlock(rBlock.replaceAll("\n", "\\n"));
for(sal_uInt32 i = 0; i < rHeaders.Count(); ++i)
{
OUString sHeader = "<" + rHeaders.GetString( i ) + ">";
@@ -402,7 +402,7 @@ static void lcl_ConvertFromNumbers(OUString& rBlock, const ResStringArray& rHead
{
//convert the numbers used for the configuration to strings used for UI to numbers
//doesn't use ReplaceAll to prevent expansion of numbers inside of the headers
- OUString sBlock(rBlock.replaceAll("\\n", OUString('\n')));
+ OUString sBlock(rBlock.replaceAll("\\n", "\n"));
SwAddressIterator aGreetingIter(sBlock);
sBlock.clear();
while(aGreetingIter.HasMore())
diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx
index dd78039..4f06e6f 100644
--- a/sw/source/uibase/docvw/edtwin2.cxx
+++ b/sw/source/uibase/docvw/edtwin2.cxx
@@ -236,8 +236,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
vcl::KeyCode aCode( KEY_SPACE );
vcl::KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
OUString aModStr( aModifiedCode.GetName() );
- aModStr = aModStr.replaceFirst(aCode.GetName(), OUString());
- aModStr = aModStr.replaceAll("+", OUString());
+ aModStr = aModStr.replaceFirst(aCode.GetName(), "");
+ aModStr = aModStr.replaceAll("+", "");
sText = SW_RESSTR(STR_SMARTTAG_CLICK).replaceAll("%s", aModStr);
}
break;
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 9cc7533d..48c0ca8 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -954,10 +954,10 @@ bool SwFieldMgr::InsertField(
//JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
// That's not yet considered here.
sal_Int32 nIndex = 0;
- OUString sCmd = rData.m_sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex);
+ OUString sCmd = rData.m_sPar2.replaceFirst(" ", OUString(sfx2::cTokenSeparator), &nIndex);
if (nIndex>=0 && ++nIndex<sCmd.getLength())
{
- sCmd = sCmd.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex);
+ sCmd = sCmd.replaceFirst(" ", OUString(sfx2::cTokenSeparator), &nIndex);
}
SwDDEFieldType aType( rData.m_sPar1, sCmd, static_cast<SfxLinkUpdateMode>(nFormatId) );
@@ -1401,10 +1401,10 @@ void SwFieldMgr::UpdateCurField(sal_uLong nFormat,
// DDE-Topics/-Items can have blanks in their names!
// That's not yet considered here!
sal_Int32 nIndex = 0;
- sPar2 = sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex );
+ sPar2 = sPar2.replaceFirst(" ", OUString(sfx2::cTokenSeparator), &nIndex );
if (nIndex>=0 && ++nIndex<sPar2.getLength())
{
- sPar2 = sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex);
+ sPar2 = sPar2.replaceFirst(" ", OUString(sfx2::cTokenSeparator), &nIndex);
}
break;
}
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index 99acee2..0b5730c 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -218,8 +218,8 @@ ShellResource::ShellResource()
vcl::KeyCode aCode( KEY_SPACE );
vcl::KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
OUString aModStr( aModifiedCode.GetName() );
- aModStr = aModStr.replaceFirst(aCode.GetName(), OUString());
- aModStr = aModStr.replaceAll("+", OUString());
+ aModStr = aModStr.replaceFirst(aCode.GetName(), "");
+ aModStr = aModStr.replaceAll("+", "");
aLinkCtrlClick = aLinkCtrlClick.replaceAll("%s", aModStr);
for(sal_uInt16 i = 0; i < nCount; ++i)
commit 94ca2679eee35dddd099de29dab571eff919a0f3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:18 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I2b3e3fedeb9b824f43208a5d4066c9278231dcba
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index 86d96be..a5895e1 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -438,7 +438,7 @@ namespace svxform
case SID_FM_NEW_FORM:
{
OUString aStr(SVX_RESSTR(RID_STR_FORM));
- OUString aUndoStr = SVX_RESSTR(RID_STR_UNDO_CONTAINER_INSERT).replaceAll(OUString('#'), aStr);
+ OUString aUndoStr = SVX_RESSTR(RID_STR_UNDO_CONTAINER_INSERT).replaceAll("#", aStr);
pFormModel->BegUndo(aUndoStr);
// slot was only available, if there is only one selected entry,
@@ -450,7 +450,7 @@ namespace svxform
case SID_FM_NEW_HIDDEN:
{
OUString aStr(SVX_RESSTR(RID_STR_CONTROL));
- OUString aUndoStr = SVX_RESSTR(RID_STR_UNDO_CONTAINER_INSERT).replaceAll(OUString('#'), aStr);
+ OUString aUndoStr = SVX_RESSTR(RID_STR_UNDO_CONTAINER_INSERT).replaceAll("#", aStr);
pFormModel->BegUndo(aUndoStr);
// slot was valid for (exactly) one selected form
@@ -969,7 +969,7 @@ namespace svxform
if (pFormModel)
{
OUString aStr(SVX_RESSTR(RID_STR_CONTROL));
- OUString aUndoStr = SVX_RESSTR(RID_STR_UNDO_CONTAINER_INSERT).replaceAll(OUString('#'), aStr);
+ OUString aUndoStr = SVX_RESSTR(RID_STR_UNDO_CONTAINER_INSERT).replaceAll("#", aStr);
pFormModel->BegUndo(aUndoStr);
}
commit 0c7cf7229f065c0f328077d4b148242696a2baeb
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:15 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I3c7b73ebb50c464e6bca816444324e100bd89d23
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
index 8ac1174..397ba40 100644
--- a/svtools/source/misc/ehdl.cxx
+++ b/svtools/source/misc/ehdl.cxx
@@ -190,8 +190,7 @@ bool SfxErrorHandler::CreateString(
const StringErrorInfo *pStringInfo = PTR_CAST(StringErrorInfo,pErr);
if(pStringInfo)
{
- rStr = rStr.replaceAll(OUString("$(ARG1)"),
- pStringInfo->GetErrorString());
+ rStr = rStr.replaceAll("$(ARG1)", pStringInfo->GetErrorString());
}
else
{
@@ -347,7 +346,7 @@ bool SfxErrorHandler::GetErrorString(
sal_uInt16 nResFlags = aErrorString.GetFlags();
if ( nResFlags )
nFlags = nResFlags;
- rStr = rStr.replaceAll(OUString("$(ERROR)"), aErrorString.GetString());
+ rStr = rStr.replaceAll("$(ERROR)", aErrorString.GetString());
bRet = true;
}
else
@@ -415,7 +414,7 @@ bool SfxErrorContext::GetString(sal_uLong nErrId, OUString &rStr)
if ( aTestEr )
{
rStr = static_cast<ResString>(aTestEr).GetString();
- rStr = rStr.replaceAll(OUString("$(ARG1)"), aArg1 );
+ rStr = rStr.replaceAll("$(ARG1)", aArg1);
bRet = true;
}
else
@@ -429,7 +428,7 @@ bool SfxErrorContext::GetString(sal_uLong nErrId, OUString &rStr)
sal_uInt16 nId = ( nErrId & ERRCODE_WARNING_MASK ) ? ERRCTX_WARNING : ERRCTX_ERROR;
ResId aSfxResId( RID_ERRCTX, *pMgr );
ErrorResource_Impl aEr( aSfxResId, nId );
- rStr = rStr.replaceAll( OUString("$(ERR)"), static_cast<ResString>(aEr).GetString() );
+ rStr = rStr.replaceAll("$(ERR)", static_cast<ResString>(aEr).GetString());
}
}
commit ca30ba7a390e770d4b420ce02ae769f54a682404
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:12 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I397db197dfa3108ee3c025a60dd9e437dd05a95d
diff --git a/sd/source/filter/eppt/pptexanimations.cxx b/sd/source/filter/eppt/pptexanimations.cxx
index b629df7..272916d 100644
--- a/sd/source/filter/eppt/pptexanimations.cxx
+++ b/sd/source/filter/eppt/pptexanimations.cxx
@@ -920,7 +920,7 @@ sal_uInt32 AnimationExporter::GetPresetID( const OUString& rPreset, sal_uInt32 n
sal_uInt32 nPresetId = 0;
bPresetId = false;
- if ( rPreset.match( OUString( "ppt_" ), 0 ) )
+ if ( rPreset.match("ppt_", 0) )
{
sal_Int32 nLast = rPreset.lastIndexOf( '_' );
if ( ( nLast != -1 ) && ( ( nLast + 1 ) < rPreset.getLength() ) )
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index e815e07..f1bc794 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -3255,8 +3255,8 @@ bool HtmlErrorContext::GetString( sal_uLong, OUString& rCtxStr )
rCtxStr = SdResId( mnResId ).toString();
- rCtxStr = rCtxStr.replaceAll( OUString("$(URL1)"), maURL1 );
- rCtxStr = rCtxStr.replaceAll( OUString("$(URL2)"), maURL2 );
+ rCtxStr = rCtxStr.replaceAll( "$(URL1)", maURL1 );
+ rCtxStr = rCtxStr.replaceAll( "$(URL2)", maURL2 );
return true;
}
commit cb0a4a43a52b2f9230dc676e8ffc8700d006ec0c
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:08 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: Icdd850336caf998e62cdb5a90fc3683eddd04a3e
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 764db1f..11aa239 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3547,13 +3547,13 @@ void ScCompiler::AutoCorrectParsedSymbol()
if ( comphelper::string::getTokenCount(aCorrectedSymbol, cx) > 1 )
{ // x => *
sal_Unicode c = mxSymbols->getSymbolChar(ocMul);
- aCorrectedSymbol = aCorrectedSymbol.replaceAll(OUString(cx), OUString(c));
+ aCorrectedSymbol = aCorrectedSymbol.replaceAll(OUStringLiteral1<cx>(), OUString(c));
bCorrected = true;
}
if ( comphelper::string::getTokenCount(aCorrectedSymbol, cX) > 1 )
{ // X => *
sal_Unicode c = mxSymbols->getSymbolChar(ocMul);
- aCorrectedSymbol = aCorrectedSymbol.replaceAll(OUString(cX), OUString(c));
+ aCorrectedSymbol = aCorrectedSymbol.replaceAll(OUStringLiteral1<cX>(), OUString(c));
bCorrected = true;
}
}
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index a213ddf..1b46428 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -695,11 +695,11 @@ static void lcl_UnescapeSylk( OUString & rString, SylkVersion eVersion )
// Older versions quoted the string and doubled embedded quotes, but not
// the semicolons, which was plain wrong.
if (eVersion >= SYLK_OOO32)
- rString = rString.replaceAll( OUString(DOUBLE_SEMICOLON), OUString(';') );
+ rString = rString.replaceAll(OUString(DOUBLE_SEMICOLON), ";");
else
- rString = rString.replaceAll( OUString(DOUBLE_DOUBLEQUOTE), OUString('"') );
+ rString = rString.replaceAll(OUString(DOUBLE_DOUBLEQUOTE), "\"");
- rString = rString.replaceAll( OUString(SYLK_LF), OUString('\n') );
+ rString = rString.replaceAll(OUString(SYLK_LF), "\n");
}
static const sal_Unicode* lcl_ScanSylkString( const sal_Unicode* p,
@@ -1497,7 +1497,7 @@ void ScImportExport::EmbeddedNullTreatment( OUString & rStr )
sal_Unicode cNull = 0;
if (rStr.indexOf( cNull) >= 0)
{
- rStr = rStr.replaceAll( OUString( &cNull, 1), OUString());
+ rStr = rStr.replaceAll( OUString( &cNull, 1), "");
}
}
@@ -1909,7 +1909,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
// unescape doubled semicolons
aCode = aCode.replaceAll(";;", ";");
// get rid of Xcl escape characters
- aCode = aCode.replaceAll(OUString(static_cast<sal_Unicode>(0x1b)), OUString());
+ aCode = aCode.replaceAll("\x1b", "");
sal_Int32 nCheckPos;
short nType;
sal_uInt32 nKey;
@@ -2002,7 +2002,7 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm )
case CELLTYPE_EDIT:
hasstring:
aCellStr = pDoc->GetString(nCol, nRow, aRange.aStart.Tab());
- aCellStr = aCellStr.replaceAll( OUString('\n'), OUString(SYLK_LF) );
+ aCellStr = aCellStr.replaceAll("\n", OUString(SYLK_LF));
aBufStr = "C;X";
aBufStr += OUString::number( c );
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index 2e20954..d5b55d6 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -248,8 +248,8 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
vcl::KeyCode aCode( KEY_SPACE );
vcl::KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
OUString aModStr( aModifiedCode.GetName() );
- aModStr = aModStr.replaceFirst(aCode.GetName(), OUString());
- aModStr = aModStr.replaceAll("+", OUString());
+ aModStr = aModStr.replaceFirst(aCode.GetName(), "");
+ aModStr = aModStr.replaceAll("+", "");
OUString aCtrlClickHlinkStr = ScGlobal::GetRscString( STR_CTRLCLICKHYPERLINK );
aCtrlClickHlinkStr = aCtrlClickHlinkStr.replaceAll("%s", aModStr);
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index d2298c2..d26475c 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -107,7 +107,7 @@ OUString ScTabViewShell::GetSelectionText( bool bWholeWord )
if ( bInFormatDialog || bWholeWord || aRange.aEnd.Row() == aRange.aStart.Row() )
{
- aStrSelection = aStrSelection.replaceAll(OUString(CHAR_CR), " ");
+ aStrSelection = aStrSelection.replaceAll(OUStringLiteral1<CHAR_CR>(), " ");
aStrSelection = aStrSelection.replaceAll("\t", " ");
aStrSelection = comphelper::string::stripEnd(aStrSelection, ' ');
}
commit 327001c7575661a6dd2968a7375dc1eeed58ab2a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:37:04 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I5bb3493e3d27bd348f58cd4f858f34becf761cd0
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index fb27c77..77b4b2b 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -821,7 +821,7 @@ void ChartExport::exportExternalData( Reference< css::chart::XChartDocument > xC
}
FSHelperPtr pFS = GetFS();
OUString type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
- if (relationPath.endsWith(OUString(".bin")))
+ if (relationPath.endsWith(".bin"))
type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
OUString sRelId = GetFB()->addRelation(pFS->getOutputStream(),
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 7161a2f..9b42d2c 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -197,7 +197,7 @@ bool VMLExport::IsWaterMarkShape(const OUString& rStr)
{
if (rStr.isEmpty() ) return false;
- if (rStr.match(OUString("PowerPlusWaterMarkObject")) || rStr.match(OUString("WordPictureWatermark")))
+ if (rStr.match("PowerPlusWaterMarkObject") || rStr.match("WordPictureWatermark"))
return true;
else
return false;
commit 346938fa26343314a0836bf3347a48fe3342fd74
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:59 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I7ef1dc1d42237ef101731b363359801d9e1e9db6
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index e0a797b..d06c2b2 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -342,7 +342,7 @@ void TestBreakIterator::testWordBoundaries()
const sal_Int32 aSinglePositions[] = {0, 1, 3, 4, 6, 7, 9, 10};
for (size_t j = 1; j < SAL_N_ELEMENTS(aTests); ++j)
{
- OUString aTest = aBase.replaceAll(OUString("xx"), OUString(aTests[j]));
+ OUString aTest = aBase.replaceAll("xx", OUString(aTests[j]));
sal_Int32 nPos = -1;
size_t i = 0;
do
@@ -365,7 +365,7 @@ void TestBreakIterator::testWordBoundaries()
const sal_Int32 aSingleQuotePositions[] = {0, 1, 9, 10};
CPPUNIT_ASSERT(aTests[0] == '\'');
{
- OUString aTest = aBase.replaceAll(OUString("xx"), OUString(aTests[0]));
+ OUString aTest = aBase.replaceAll("xx", OUString(aTests[0]));
sal_Int32 nPos = -1;
size_t i = 0;
do
commit 995296ea1d48636363a3a80068ceeb002b8bedb8
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:54 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I63f1b54cc9ef49a83800b671a60ea25df7fc2121
diff --git a/framework/inc/queries.h b/framework/inc/queries.h
index 6311bc6..8e0abff 100644
--- a/framework/inc/queries.h
+++ b/framework/inc/queries.h
@@ -33,16 +33,16 @@ namespace framework{
They are used by our FilterFactory or our TypeDetection to return
subsets of our cached configuration.
*//*-*************************************************************************************************************/
-#define BASE_QUERY_ALL DECLARE_ASCII("_query_all" )
-#define BASE_QUERY_WRITER DECLARE_ASCII("_query_Writer" )
-#define BASE_QUERY_WEB DECLARE_ASCII("_query_web" )
-#define BASE_QUERY_GLOBAL DECLARE_ASCII("_query_global" )
-#define BASE_QUERY_CHART DECLARE_ASCII("_query_chart" )
-#define BASE_QUERY_CALC DECLARE_ASCII("_query_calc" )
-#define BASE_QUERY_IMPRESS DECLARE_ASCII("_query_impress" )
-#define BASE_QUERY_DRAW DECLARE_ASCII("_query_draw" )
-#define BASE_QUERY_MATH DECLARE_ASCII("_query_math" )
-#define BASE_QUERY_GRAPHICS DECLARE_ASCII("_query_graphics")
+#define BASE_QUERY_ALL "_query_all"
+#define BASE_QUERY_WRITER "_query_Writer"
+#define BASE_QUERY_WEB "_query_web"
+#define BASE_QUERY_GLOBAL "_query_global"
+#define BASE_QUERY_CHART "_query_chart"
+#define BASE_QUERY_CALC "_query_calc"
+#define BASE_QUERY_IMPRESS "_query_impress"
+#define BASE_QUERY_DRAW "_query_draw"
+#define BASE_QUERY_MATH "_query_math"
+#define BASE_QUERY_GRAPHICS "_query_graphics"
/*-************************************************************************************************************
@short These parameters can be used in combination with BASE_QUERY_... defines to
@@ -63,17 +63,17 @@ namespace framework{
#define SEPARATOR_QUERYPARAM ((sal_Unicode)':')
#define SEPARATOR_QUERYPARAMVALUE ((sal_Unicode)'=')
-#define QUERYPARAM_IFLAGS DECLARE_ASCII("iflags" )
-#define QUERYPARAM_EFLAGS DECLARE_ASCII("eflags" )
-#define QUERYPARAM_SORT_PROP DECLARE_ASCII("sort_prop" )
+#define QUERYPARAM_IFLAGS "iflags"
+#define QUERYPARAM_EFLAGS "eflags"
+#define QUERYPARAM_SORT_PROP "sort_prop"
-#define QUERYPARAM_DESCENDING DECLARE_ASCII("descending" )
-#define QUERYPARAM_USE_ORDER DECLARE_ASCII("use_order" )
-#define QUERYPARAM_DEFAULT_FIRST DECLARE_ASCII("default_first" )
-#define QUERYPARAM_CASE_SENSITIVE DECLARE_ASCII("case_sensitive" )
+#define QUERYPARAM_DESCENDING "descending"
+#define QUERYPARAM_USE_ORDER "use_order"
+#define QUERYPARAM_DEFAULT_FIRST "default_first"
+#define QUERYPARAM_CASE_SENSITIVE "case_sensitive"
-#define QUERYPARAMVALUE_SORT_PROP_NAME DECLARE_ASCII("name" )
-#define QUERYPARAMVALUE_SORT_PROP_UINAME DECLARE_ASCII("uiname" )
+#define QUERYPARAMVALUE_SORT_PROP_NAME "name"
+#define QUERYPARAMVALUE_SORT_PROP_UINAME "uiname"
/*-************************************************************************************************************
@short Helper class to support easy building of a query statements.
diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index 2dc2731..e22d9e6 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -494,7 +494,7 @@ OUString StorageHolder::impl_st_normPath(const OUString& sPath)
OUString sNormedPath = sPath;
// "/bla" => "bla" && "/" => "" (!)
- if (sNormedPath.startsWith(PATH_SEPARATOR))
+ if (sNormedPath.startsWith(PATH_SEPARATOR_ASCII))
sNormedPath += sNormedPath.copy(1);
// "/" => "" || "" => "" ?
@@ -502,7 +502,7 @@ OUString StorageHolder::impl_st_normPath(const OUString& sPath)
return OUString();
// "bla" => "bla/"
- if (sNormedPath.lastIndexOf(PATH_SEPARATOR) != (sNormedPath.getLength()-1))
+ if (sNormedPath.lastIndexOf(PATH_SEPARATOR_UNICODE) != (sNormedPath.getLength()-1))
sNormedPath += PATH_SEPARATOR;
return sNormedPath;
commit db081acb013666a84f0ae30c3c3132835d2638db
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:47 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I7d8b0ab33980726ffb4887b1f19797702d224191
diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx
index 2f4caba..5797013 100644
--- a/filter/source/graphic/GraphicExportFilter.cxx
+++ b/filter/source/graphic/GraphicExportFilter.cxx
@@ -44,10 +44,10 @@ void GraphicExportFilter::gatherProperties( const Sequence<PropertyValue>& rProp
if ( aProperty.Name == "FilterName" )
{
aProperty.Value >>= aInternalFilterName;
- aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "draw_" ), OUString() );
- aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "impress_" ), OUString() );
- aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "calc_" ), OUString() );
- aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "writer_" ), OUString() );
+ aInternalFilterName = aInternalFilterName.replaceFirst("draw_", "");
+ aInternalFilterName = aInternalFilterName.replaceFirst("impress_", "");
+ aInternalFilterName = aInternalFilterName.replaceFirst("calc_", "");
+ aInternalFilterName = aInternalFilterName.replaceFirst("writer_", "");
}
else if ( aProperty.Name == "FilterData" )
{
diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
index aa09f59..7aee584 100644
--- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
+++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
@@ -141,7 +141,7 @@ bool SAL_CALL XmlFilterAdaptor::importImpl( const Sequence< ::com::sun::star::be
Sequence<com::sun::star::beans::PropertyValue> pValue=xstyleLoader->getStyleLoaderOptions();
//Load the Styles from the Template URL Supplied in the TypeDetection file
- if(msTemplateName.indexOf(OUString( "file:" ))==-1)
+ if(msTemplateName.indexOf("file:")==-1)
{
SvtPathOptions aOptions;
OUString PathString = aOptions.SubstituteVariable(OUString("$(progurl)"));
diff --git a/filter/source/xsltdialog/xmlfilterjar.cxx b/filter/source/xsltdialog/xmlfilterjar.cxx
index c14917b..ce6ddba 100644
--- a/filter/source/xsltdialog/xmlfilterjar.cxx
+++ b/filter/source/xsltdialog/xmlfilterjar.cxx
@@ -123,7 +123,7 @@ void XMLFilterJarHelper::addFile( Reference< XInterface > xRootFolder, Reference
{
OUString aFileURL( rSourceFile );
- if( !aFileURL.matchIgnoreAsciiCase( OUString("file://") ) )
+ if( !aFileURL.matchIgnoreAsciiCase("file://") )
{
aFileURL = URIHelper::SmartRel2Abs( INetURLObject(sProgPath), aFileURL, Link<OUString *, bool>(), false );
}
commit 768abe343c9c596a4f11e58b98d7871e4172758d
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:42 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: Ia4f844e0e9249f54d134fbbde11aa1f7e250e8af
diff --git a/extensions/source/propctrlr/selectlabeldialog.cxx b/extensions/source/propctrlr/selectlabeldialog.cxx
index 0d5b30d..e9acfb1 100644
--- a/extensions/source/propctrlr/selectlabeldialog.cxx
+++ b/extensions/source/propctrlr/selectlabeldialog.cxx
@@ -75,10 +75,10 @@ namespace pcr
if (::comphelper::hasProperty(PROPERTY_CLASSID, m_xControlModel))
nClassID = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID));
- sDescription = sDescription.replaceAll(OUString("$controlclass$"),
+ sDescription = sDescription.replaceAll("$controlclass$",
GetUIHeadlineName(nClassID, makeAny(m_xControlModel)));
OUString sName = ::comphelper::getString(m_xControlModel->getPropertyValue(PROPERTY_NAME));
- sDescription = sDescription.replaceAll(OUString("$controlname$"), sName);
+ sDescription = sDescription.replaceAll("$controlname$", sName);
m_pMainDesc->SetText(sDescription);
// search for the root of the form hierarchy
commit 8987a2920cc638939c3d5beb0f80c9bd6a13f3d5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:36 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: Ie217f99961c6f2c224d1c01beaf0146a4ea3e0c2
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 484ba38..6037249 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1418,7 +1418,7 @@ void ImpEditView::Paste( ::com::sun::star::uno::Reference< ::com::sun::star::dat
OUString aTmpText;
aData >>= aTmpText;
OUString aText(convertLineEnd(aTmpText, LINEEND_LF));
- aText = aText.replaceAll( OUString(LINE_SEP), " " );
+ aText = aText.replaceAll( OUStringLiteral1<LINE_SEP>(), " " );
aSel = pEditEngine->InsertText(aSel, aText);
}
catch( ... )
commit 68c09b05f00a224872b8ce962f144bf6d8ccbe78
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:31 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: Ifd804fb45fb032dddbf2ba3643ec0964e0e24724
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 6be7270..a2bae59 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -449,7 +449,7 @@ OUString OSingleSelectQueryComposer::impl_getColumnRealName_throw(const Referenc
)
{
OUString sError(DBACORE_RESSTRING(RID_STR_COLUMN_UNKNOWN_PROP));
- SQLException aErr(sError.replaceAll("%value", OUString(PROPERTY_NAME)),*this,SQLSTATE_GENERAL,1000,Any() );
+ SQLException aErr(sError.replaceAll("%value", PROPERTY_NAME),*this,SQLSTATE_GENERAL,1000,Any() );
throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) );
}
@@ -519,7 +519,7 @@ OUString OSingleSelectQueryComposer::impl_getColumnName_throw(const Reference< X
)
{
OUString sError(DBACORE_RESSTRING(RID_STR_COLUMN_UNKNOWN_PROP));
- SQLException aErr(sError.replaceAll("%value", OUString(PROPERTY_NAME)),*this,SQLSTATE_GENERAL,1000,Any() );
+ SQLException aErr(sError.replaceAll("%value", PROPERTY_NAME),*this,SQLSTATE_GENERAL,1000,Any() );
throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) );
}
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index c07b651..50731ed 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -2160,7 +2160,7 @@ void OApplicationController::renameEntry()
{
OUString sStatus("S1000");
OUString sMsg = OUString( ModuleRes( STR_NAME_ALREADY_EXISTS ) );
- showError(SQLExceptionInfo(SQLException(sMsg.replaceAll(OUString('#'), e.Message), e.Context, sStatus, 0, Any())));
+ showError(SQLExceptionInfo(SQLException(sMsg.replaceAll("#", e.Message), e.Context, sStatus, 0, Any())));
}
catch(const Exception& )
{
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 9d34932..e593add 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1805,7 +1805,7 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
xProp->getPropertyValue(PROPERTY_COMMAND) >>= aName;
OUString sObject(aName);
- aReturn.sTitle = sTitle.replaceFirst(OUString('#'), sObject);
+ aReturn.sTitle = sTitle.replaceFirst("#", sObject);
aReturn.bEnabled = true;
}
break;
@@ -2672,7 +2672,7 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
OUString sFilter = " WHERE ";
sFilter = sFilter + xAnalyzer->getFilter();
OUString sReplace(sSql);
- sReplace = sReplace.replaceFirst(sFilter,OUString());
+ sReplace = sReplace.replaceFirst(sFilter, "");
xAnalyzer->setQuery(sReplace);
Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY);
xComposer->setFilter(OUString("0=1"));
diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx
index 7eb8ef0..05d9480 100644
--- a/dbaccess/source/ui/control/opendoccontrols.cxx
+++ b/dbaccess/source/ui/control/opendoccontrols.cxx
@@ -171,7 +171,7 @@ namespace dbaui
// our label should equal the UI text of the "Open" command
OUString sLabel(GetCommandText(".uno:Open", m_sModule));
- SetText(" " + sLabel.replaceAll("~", OUString()));
+ SetText(" " + sLabel.replaceAll("~", ""));
// Place icon left of text and both centered in the button.
SetModeImage( GetCommandIcon( ".uno:Open", m_sModule ) );
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index c4de3e5..ece6bea 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -256,9 +256,9 @@ bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< PropertyVal
sLoginRequest = sLoginRequest.replaceAll("$name$", sName);
else
{
- sLoginRequest = sLoginRequest.replaceAll("\"$name$\"", OUString());
+ sLoginRequest = sLoginRequest.replaceAll("\"$name$\"", "");
// ensure that in other languages the string will be deleted
- sLoginRequest = sLoginRequest.replaceAll("$name$", OUString());
+ sLoginRequest = sLoginRequest.replaceAll("$name$", "");
}
// the request
commit 90dfd9d87ad93525dd815e1e5d047045fd7628b0
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:27 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I0749564ce91cb6ad5ca58cc6432ff3cd4b2f579b
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 6bebf7f..06f6fee 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -66,7 +66,7 @@ using namespace svx;
#define POSTFIX_INTERNAL OUString("_internal")
#define POSTFIX_USER OUString("_user")
#define POSTFIX_WRITABLE OUString("_writable")
-#define VAR_ONE OUString("%1")
+#define VAR_ONE "%1"
#define IODLG_CONFIGNAME OUString("FilePicker_Save")
// struct OptPath_Impl ---------------------------------------------------
commit 6ce8ae5f0ca3cda17a1e708a273419f46bd0e8b0
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:23 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I5fe4002c3c0065dfe93be0d8f47df90d57af898b
diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx
index f7f79007..6040cf6 100644
--- a/cppuhelper/source/factory.cxx
+++ b/cppuhelper/source/factory.cxx
@@ -782,8 +782,7 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
aLocation = xLocationKey->getAsciiValue();
// search protocol delimiter
- sal_Int32 nPos = aLocation.indexOf(
- OUString("://") );
+ sal_Int32 nPos = aLocation.indexOf("://");
if( nPos != -1 )
{
aActivatorName = aLocation.copy( 0, nPos );
commit 472c0a3dcc8dd146e584c4b677a63854b8642f35
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:19 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I36ae4b57049fe4deabe785ccfecf78608461086f
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 740b9bc..129b2c0 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -1974,8 +1974,7 @@ extern "C" void SAL_CALL typelib_typedescription_getByName(
if (0 == *ppRet)
{
// Check for derived interface member type:
- sal_Int32 i1 = name.lastIndexOf(
- rtl::OUString(":@"));
+ sal_Int32 i1 = name.lastIndexOf(":@");
if (i1 >= 0) {
sal_Int32 i2 = i1 + RTL_CONSTASCII_LENGTH(":@");
sal_Int32 i3 = name.indexOf(',', i2);
commit 33be6e79a0ffd7823721ebe96784a5a68fe78f51
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:14 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I9a10663f1b428d3f6a6a6d5187b5774076aef75b
diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx
index 94b3c81..79c6a2f 100644
--- a/connectivity/source/drivers/evoab2/NStatement.cxx
+++ b/connectivity/source/drivers/evoab2/NStatement.cxx
@@ -388,7 +388,7 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree )
}
else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) )
{ // One occurrence of '%' matches...
- if ( aMatchString.startsWith( OUString(WILDCARD) ) )
+ if ( aMatchString.startsWith(OUStringLiteral1<WILDCARD>()) )
pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) );
else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 )
pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) );
@@ -396,7 +396,7 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree )
m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD,*this);
}
else if( aMatchString.getLength() >= 3 &&
- aMatchString.startsWith( OUString(WILDCARD) ) &&
+ aMatchString.startsWith(OUStringLiteral1<WILDCARD>()) &&
aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) {
// one '%' at the start and another at the end
pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) );
commit 2434f2983894a1577080be6ea1881cc6afcafcf9
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:36:00 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I0e2e161a29b653cf16b2e3a6ddeb89567b5342c8
diff --git a/include/comphelper/string.hxx b/include/comphelper/string.hxx
index 5bf8296..0609e62 100644
--- a/include/comphelper/string.hxx
+++ b/include/comphelper/string.hxx
@@ -83,7 +83,7 @@ inline OString remove(const OString &rIn,
*/
inline OUString remove(const OUString &rIn,
sal_Unicode c)
-{ return rIn.replaceAll(OUString(c), OUString()); }
+{ return rIn.replaceAll(OUString(c), ""); }
/** Removes all occurrences of a character from within the source string
commit 687ab37853be1adaf84a78a6a5b1c947ea0608fc
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:35:50 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: Ie6ca3065ee60fb2ad75f3bab53059046a981da8d
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index 81f9de2..08b695a 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -194,7 +194,7 @@ void SbiCodeGen::Save()
sal_uInt16 nPassCount = 1;
if( nIfaceCount )
{
- int nPropPrefixFound = aProcName.indexOf(OUString("Property "));
+ int nPropPrefixFound = aProcName.indexOf("Property ");
OUString aPureProcName = aProcName;
OUString aPropPrefix;
if( nPropPrefixFound == 0 )
commit fce88d8ff087bdc6b14649e15e1123892c5d414f
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 12:35:44 2015 +0200
loplugin:stringconstant: Flag more inefficiencies
Change-Id: I7c79445bfa1536706561752da107090599ef26a2
diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx
index eff2c10..4c50b69 100644
--- a/basctl/source/basicide/brkdlg.cxx
+++ b/basctl/source/basicide/brkdlg.cxx
@@ -43,7 +43,7 @@ bool lcl_ParseText(OUString const &rText, size_t& rLineNr )
// number n. (Maybe it would be better to ignore all whitespace instead
// of just spaces.)
OUString aText(
- rText.replaceAll(" ", OUString()));
+ rText.replaceAll(" ", ""));
if (aText.isEmpty())
return false;
sal_Unicode cFirst = aText[0];
commit 8007417c318140d74b87ec5abcf835f4a2ba9682
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Jun 25 10:15:34 2015 +0200
Revert "Revert "Generalize OUStringLiteral1""
This reverts commit 5cba714b4d03ed54debf71534ad8c8edc383a01e, now including a
workaround for <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53658> "internal
compiler error -- segmentation fault."
Change-Id: I31f6d9ddcb0b884134703df2b9dc1800ba0a84be
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 81773b4..3071103 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -170,10 +170,14 @@ public:
template< typename T >
OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
: pData(NULL)
- , nCapacity( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
- {
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_string_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
+ , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
+ {
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_string_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
#ifdef RTL_STRING_UNITTEST
rtl_string_unittest_const_literal = true;
#endif
@@ -453,8 +457,12 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_stringbuffer_insert(
+ &pData, &nCapacity, getLength(),
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return *this;
}
@@ -708,8 +716,12 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_stringbuffer_insert( &pData, &nCapacity, offset, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_stringbuffer_insert(
+ &pData, &nCapacity, offset,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return *this;
}
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 56cbf93..e3237ff2 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -181,12 +181,18 @@ public:
template< typename T >
OString( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
pData = 0;
- if( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
- rtl_string_new( &pData );
- else
- rtl_string_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+ if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
+ rtl_string_new(&pData);
+ } else {
+ rtl_string_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
+ }
#ifdef RTL_STRING_UNITTEST
rtl_string_unittest_const_literal = true;
#endif
@@ -278,11 +284,17 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, OString& >::Type operator=( T& literal )
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- if( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
- rtl_string_new( &pData );
- else
- rtl_string_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
+ rtl_string_new(&pData);
+ } else {
+ rtl_string_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
+ }
return *this;
}
@@ -543,11 +555,17 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- if ( pData->length != libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 )
- return false;
- return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
- literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ (pData->length
+ == libreoffice_internal::ConstCharArrayDetector<T>::length)
+ && (rtl_str_compareIgnoreAsciiCase_WithLength(
+ pData->buffer, pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0);
}
/**
@@ -608,10 +626,16 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rtl_str_shortenedCompare_WithLength(
- pData->buffer + fromIndex, pData->length - fromIndex,
- literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ rtl_str_shortenedCompare_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length,
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0;
}
/**
@@ -681,9 +705,16 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
- literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
+ pData->buffer+fromIndex, pData->length-fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length,
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0;
}
/**
@@ -720,7 +751,8 @@ public:
RTL_STRING_CONST_FUNCTION
bool b = match(literal, 0);
if (b && rest != 0) {
- *rest = copy(libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ *rest = copy(
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
return b;
}
@@ -758,14 +790,21 @@ public:
T & literal, OString * rest = 0) const
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= getLength()
- && match(literal, getLength() - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ));
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ bool b
+ = (libreoffice_internal::ConstCharArrayDetector<T>::length
+ <= sal_uInt32(getLength()))
+ && match(
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ (getLength()
+ - libreoffice_internal::ConstCharArrayDetector<T>::length));
if (b && rest != 0) {
*rest = copy(
0,
(getLength()
- - (libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)));
+ - libreoffice_internal::ConstCharArrayDetector<T>::length));
}
return b;
}
@@ -834,10 +873,17 @@ public:
friend typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr, T& literal )
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rStr.getLength() == libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1
- && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ (rStr.getLength()
+ == libreoffice_internal::ConstCharArrayDetector<T>::length)
+ && (rtl_str_compare_WithLength(
+ rStr.pData->buffer, rStr.pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0);
}
/**
@@ -849,10 +895,17 @@ public:
friend typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OString& rStr )
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rStr.getLength() == libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1
- && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ (rStr.getLength()
+ == libreoffice_internal::ConstCharArrayDetector<T>::length)
+ && (rtl_str_compare_WithLength(
+ rStr.pData->buffer, rStr.pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0);
}
template< typename T >
@@ -994,9 +1047,12 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
{
RTL_STRING_CONST_FUNCTION
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
sal_Int32 n = rtl_str_indexOfStr_WithLength(
- pData->buffer + fromIndex, pData->length - fromIndex, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ pData->buffer + fromIndex, pData->length - fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return n < 0 ? n : n + fromIndex;
}
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
index a74dd77..7ef9e11 100644
--- a/include/rtl/stringconcat.hxx
+++ b/include/rtl/stringconcat.hxx
@@ -141,6 +141,19 @@ struct ToStringHelper< const char[ N ] >
static const bool allowOUStringConcat = true;
};
+#if defined LIBO_INTERNAL_ONLY
+template<char C> struct ToStringHelper<OUStringLiteral1_<C>> {
+ static int length(OUStringLiteral1_<C>) { return 1; }
+ static char * addData(char * buffer, OUStringLiteral1_<C> literal)
+ { return addDataHelper(buffer, &literal.c, 1); }
+ static sal_Unicode * addData(
+ sal_Unicode * buffer, OUStringLiteral1_<C> literal)
+ { return addDataLiteral(buffer, &literal.c, 1); }
+ static bool const allowOStringConcat = false;
+ static bool const allowOUStringConcat = true;
+};
+#endif
+
/**
@internal
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
index fb11545..ff25d4d 100644
--- a/include/rtl/stringutils.hxx
+++ b/include/rtl/stringutils.hxx
@@ -11,6 +11,10 @@
#define INCLUDED_RTL_STRINGUTILS_HXX
#include <sal/config.h>
+
+#include <cstddef>
+#include <cstring>
+
#include <sal/types.h>
// The unittest uses slightly different code to help check that the proper
@@ -29,6 +33,60 @@ namespace rtl
#undef rtl
#endif
+#if defined LIBO_INTERNAL_ONLY
+/// @cond INTERNAL
+
+/** A simple wrapper around an ASCII character literal.
+
+ Can be useful to pass a char constant with ASCII value into a
+ OUString-related function that is optimized for ASCII string literal
+ arguments. That is, instead of
+
+ char const WILDCARD = '%';
+ ...
+ if (s[i] == WILDCARD) ...
+ ...
+ if (s.endsWith(OUString(WILDCARD))) ...
+
+ use
+
+ char const WILDCARD = '%';
+ ...
+ if (s[i] == WILDCARD) ...
+ ...
+ if (s.endsWith(OUStringLiteral1<WILDCARD>())) ...
+
+ to avoid creating a temporary OUString instance, and instead pick the
+ endsWith overload actually designed to take an argument of type
+ char const[N].
+
+ Instances of OUStringLiteral1 need to be const, as those literal-optimized
+ functions take the literal argument by non-const lvalue reference, for
+ technical reasons. Except with MSVC, at least up to Visual Studio 2013:
+ For one, it fails to take that const-ness into account when trying to match
+ "OUStringLiteral1_<C> const" against T in a "T & literal" parameter of a
+ function template. But for another, as a language extension, it allows to
+ bind non-const temporary OUStringLiteral1_ instances to non-const lvalue
+ references, but also with a warning that thus needs to be disabled.
+
+ @since LibreOffice 5.0
+*/
+template<char C> struct SAL_WARN_UNUSED OUStringLiteral1_ {
+ static_assert(
+ static_cast<unsigned char>(C) < 0x80,
+ "non-ASCII character in OUStringLiteral1");
+ char const c = C;
+};
+#if defined _MSC_VER && _MSC_VER <= 1800 // Visual Studio 2013
+template<char C> using OUStringLiteral1 = OUStringLiteral1_<C>;
+#pragma warning(disable: 4239)
+#else
+template<char C> using OUStringLiteral1 = OUStringLiteral1_<C> const;
+#endif
+
+/// @endcond
+#endif
+
namespace libreoffice_internal
{
/*
@@ -102,13 +160,34 @@ struct ConstCharArrayDetector
{
static const bool ok = false;
};
-template< int N, typename T >
+template< std::size_t N, typename T >
struct ConstCharArrayDetector< const char[ N ], T >
{
typedef T Type;
- static const int size = N;
+ static const std::size_t length = N - 1;
static const bool ok = true;
+ static bool isValid(char const (& literal)[N])
+ { return std::strlen(literal) == length; }
+ static char const * toPointer(char const (& literal)[N]) { return literal; }
};
+#if defined LIBO_INTERNAL_ONLY
+template<char C, typename T> struct ConstCharArrayDetector<
+#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8 \
+ && !defined __clang__
+ OUStringLiteral1_<C> const,
+#else
+ OUStringLiteral1<C>,
+#endif
+ T>
+{
+ typedef T Type;
+ static const std::size_t length = 1;
+ static const bool ok = true;
+ static bool isValid(OUStringLiteral1_<C>) { return true; }
+ static char const * toPointer(OUStringLiteral1_<C> const & literal)
+ { return &literal.c; }
+};
+#endif
// this one is used to rule out only const char[N]
template< typename T >
@@ -137,6 +216,10 @@ template< int N >
struct ExceptCharArrayDetector< const char[ N ] >
{
};
+#if defined LIBO_INTERNAL_ONLY && defined _MSC_VER && _MSC_VER <= 1800
+ // Visual Studio 2013
+template<char C> struct ExceptCharArrayDetector<OUStringLiteral1<C>> {};
+#endif
template< typename T1, typename T2 = void >
struct SalUnicodePtrDetector
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index 04ac8a6..fe64ebe 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -132,10 +132,14 @@ public:
template< typename T >
OUStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
: pData(NULL)
- , nCapacity( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
- {
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_uString_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
+ , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
+ {
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uString_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
#ifdef RTL_STRING_UNITTEST
rtl_string_unittest_const_literal = true;
#endif
@@ -470,9 +474,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uStringbuffer_insert_ascii(
+ &pData, &nCapacity, getLength(),
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return *this;
}
@@ -813,9 +820,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uStringbuffer_insert_ascii(
+ &pData, &nCapacity, offset,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
return *this;
}
@@ -1199,11 +1209,13 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
- pData->buffer + fromIndex, pData->length - fromIndex, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
- return ret < 0 ? ret : ret + fromIndex;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
+ return n < 0 ? n : n + fromIndex;
}
/**
@@ -1263,9 +1275,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
return rtl_ustr_lastIndexOfAscii_WithLength(
- pData->buffer, pData->length, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ pData->buffer, pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
/**
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 1e9bfa8..387a6e8 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -73,17 +73,6 @@ struct SAL_WARN_UNUSED OUStringLiteral
const char* data;
};
-/** A simple wrapper around an ASCII character literal, for use in certain
- OUString functions designed for efficient processing of string literals.
-
- @since LibreOffice 5.0
-*/
-template<char C> struct SAL_WARN_UNUSED OUStringLiteral1 {
- static_assert(
- static_cast<unsigned char>(C) < 0x80,
- "non-ASCII character in OUStringLiteral1");
-};
-
/// @endcond
#endif
@@ -226,12 +215,18 @@ public:
template< typename T >
OUString( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
pData = 0;
- if( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
- rtl_uString_new( &pData );
- else
- rtl_uString_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
+ if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
+ rtl_uString_new(&pData);
+ } else {
+ rtl_uString_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
+ }
#ifdef RTL_STRING_UNITTEST
rtl_string_unittest_const_literal = true;
#endif
@@ -404,27 +399,19 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- if( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
- rtl_uString_new( &pData );
- else
- rtl_uString_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
- return *this;
- }
-
-#if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
- /// @cond INTERNAL
- /** Assign a new string from a single ASCII character literal.
-
- @since LibreOffice 5.0
- */
- template<char C> OUString & operator =(OUStringLiteral1<C>) {
- sal_Unicode const c = C;
- rtl_uString_newFromStr_WithLength(&pData, &c, 1);
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
+ rtl_uString_new(&pData);
+ } else {
+ rtl_uString_newFromLiteral(
+ &pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
+ }
return *this;
}
- /// @endcond
-#endif
/**
Append a string to this string.
@@ -578,9 +565,12 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
- literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return rtl_ustr_asciil_reverseCompare_WithLength(
+ pData->buffer, pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
/**
@@ -658,11 +648,16 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- if ( pData->length != libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 )
- return false;
-
- return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, literal ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ (pData->length
+ == libreoffice_internal::ConstCharArrayDetector<T>::length)
+ && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
+ pData->buffer, pData->length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal))
+ == 0);
}
/**
@@ -694,9 +689,15 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
- literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ rtl_ustr_ascii_shortenedCompare_WithLength(
+ pData->buffer+fromIndex, pData->length-fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0;
}
/**
@@ -732,9 +733,15 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
- literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return
+ rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+ pData->buffer+fromIndex, pData->length-fromIndex,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0;
}
/**
@@ -1039,12 +1046,19 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(
T & literal, OUString * rest = 0) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
- && rtl_ustr_asciil_reverseEquals_WithLength( pData->buffer, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ bool b
+ = (libreoffice_internal::ConstCharArrayDetector<T>::length
+ <= sal_uInt32(pData->length))
+ && rtl_ustr_asciil_reverseEquals_WithLength(
+ pData->buffer,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
if (b && rest != 0) {
- *rest = copy(libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ *rest = copy(
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
return b;
}
@@ -1088,14 +1102,19 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
startsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- bool b = (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
- pData->buffer,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)
- == 0);
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ bool b
+ = (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ pData->buffer,
+ libreoffice_internal::ConstCharArrayDetector<T>::length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
+ == 0);
if (b && rest != 0) {
- *rest = copy(libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ *rest = copy(
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
return b;
}
@@ -1132,16 +1151,22 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
endsWith(T & literal, OUString * rest = 0) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ bool b
+ = (libreoffice_internal::ConstCharArrayDetector<T>::length
+ <= sal_uInt32(pData->length))
&& rtl_ustr_asciil_reverseEquals_WithLength(
- pData->buffer + pData->length - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ), literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
+ (pData->buffer + pData->length
+ - libreoffice_internal::ConstCharArrayDetector<T>::length),
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
if (b && rest != 0) {
*rest = copy(
0,
(getLength()
- - (libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)));
+ - libreoffice_internal::ConstCharArrayDetector<T>::length));
}
return b;
}
@@ -1205,18 +1230,24 @@ public:
typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
endsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ bool b
+ = (libreoffice_internal::ConstCharArrayDetector<T>::length
+ <= sal_uInt32(pData->length))
&& (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
- pData->buffer + pData->length - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ),
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)
+ (pData->buffer + pData->length
+ - libreoffice_internal::ConstCharArrayDetector<T>::length),
+ libreoffice_internal::ConstCharArrayDetector<T>::length,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
+ literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length)
== 0);
if (b && rest != 0) {
*rest = copy(
0,
(getLength()
- - (libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)));
+ - libreoffice_internal::ConstCharArrayDetector<T>::length));
}
return b;
}
@@ -1274,8 +1305,11 @@ public:
template< typename T >
friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return string.equalsAsciiL(
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
/**
* Compare string to an ASCII string literal.
@@ -1287,8 +1321,11 @@ public:
template< typename T >
friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return string.equalsAsciiL(
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
/**
* Compare string to an ASCII string literal.
@@ -1300,8 +1337,11 @@ public:
template< typename T >
friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return !string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return !string.equalsAsciiL(
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
/**
* Compare string to an ASCII string literal.
@@ -1313,8 +1353,11 @@ public:
template< typename T >
friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- return !string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ return !string.equalsAsciiL(
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
}
#if defined LIBO_INTERNAL_ONLY
@@ -1492,11 +1535,13 @@ public:
template< typename T >
typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
{
- assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
- sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
- pData->buffer + fromIndex, pData->length - fromIndex, literal,
- libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
- return ret < 0 ? ret : ret + fromIndex;
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list