summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-04-15 09:39:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-15 13:54:53 +0200
commit46ce0d28b4c765076c7871358375c4e85e44534b (patch)
treeb17378d5258a51185001eac455a764897e6dda11 /sw
parent00f7309fb786efcc0bbca04fb29de80f275a16ba (diff)
loplugin:stringliteralvar look for assignments
to O[U]String from char array literals, we can convert the char literals to O[U]StringLiteral and avoid a runtime allocation Change-Id: I15d8dddb2cd428b90740e39f20daf98e0941aa6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114125 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/access/accpara.cxx2
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx52
-rw-r--r--sw/source/core/unocore/unoidx.cxx4
-rw-r--r--sw/source/core/unocore/unosett.cxx2
-rw-r--r--sw/source/core/unocore/unotext.cxx2
-rw-r--r--sw/source/ui/vba/vbalisthelper.cxx16
6 files changed, 39 insertions, 39 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index e4008dc10a41..3939e274021e 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1599,7 +1599,7 @@ uno::Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes(
_getDefaultAttributesImpl( aRequestedAttributes, aDefAttrSeq );
// #i92233#
- static const char sMMToPixelRatio[] = "MMToPixelRatio";
+ constexpr OUStringLiteral sMMToPixelRatio = u"MMToPixelRatio";
bool bProvideMMToPixelRatio( !aRequestedAttributes.hasElements() ||
(comphelper::findValue(aRequestedAttributes, sMMToPixelRatio) != -1) );
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 51785be1a1c4..088f21c00b10 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -136,36 +136,36 @@ const char aQuotation[] = "Quotation";
const char aSourceText[] = "Source Text";
// PDF Tag Names:
-const char aDocumentString[] = "Document";
-const char aDivString[] = "Div";
-const char aSectString[] = "Sect";
-const char aHString[] = "H";
-const char aH1String[] = "H1";
-const char aH2String[] = "H2";
-const char aH3String[] = "H3";
-const char aH4String[] = "H4";
-const char aH5String[] = "H5";
-const char aH6String[] = "H6";
+constexpr OUStringLiteral aDocumentString = u"Document";
+constexpr OUStringLiteral aDivString = u"Div";
+constexpr OUStringLiteral aSectString = u"Sect";
+constexpr OUStringLiteral aHString = u"H";
+constexpr OUStringLiteral aH1String = u"H1";
+constexpr OUStringLiteral aH2String = u"H2";
+constexpr OUStringLiteral aH3String = u"H3";
+constexpr OUStringLiteral aH4String = u"H4";
+constexpr OUStringLiteral aH5String = u"H5";
+constexpr OUStringLiteral aH6String = u"H6";
constexpr OUStringLiteral aListString = u"L";
constexpr OUStringLiteral aListItemString = u"LI";
constexpr OUStringLiteral aListBodyString = u"LBody";
-const char aBlockQuoteString[] = "BlockQuote";
-const char aCaptionString[] = "Caption";
-const char aIndexString[] = "Index";
-const char aTOCString[] = "TOC";
+constexpr OUStringLiteral aBlockQuoteString = u"BlockQuote";
+constexpr OUStringLiteral aCaptionString = u"Caption";
+constexpr OUStringLiteral aIndexString = u"Index";
+constexpr OUStringLiteral aTOCString = u"TOC";
constexpr OUStringLiteral aTOCIString = u"TOCI";
-const char aTableString[] = "Table";
-const char aTRString[] = "TR";
-const char aTDString[] = "TD";
-const char aTHString[] = "TH";
-const char aBibEntryString[] = "BibEntry";
-const char aQuoteString[] = "Quote";
-const char aSpanString[] = "Span";
-const char aCodeString[] = "Code";
-const char aFigureString[] = "Figure";
-const char aFormulaString[] = "Formula";
-const char aLinkString[] = "Link";
-const char aNoteString[] = "Note";
+constexpr OUStringLiteral aTableString = u"Table";
+constexpr OUStringLiteral aTRString = u"TR";
+constexpr OUStringLiteral aTDString = u"TD";
+constexpr OUStringLiteral aTHString = u"TH";
+constexpr OUStringLiteral aBibEntryString = u"BibEntry";
+constexpr OUStringLiteral aQuoteString = u"Quote";
+constexpr OUStringLiteral aSpanString = u"Span";
+constexpr OUStringLiteral aCodeString = u"Code";
+constexpr OUStringLiteral aFigureString = u"Figure";
+constexpr OUStringLiteral aFormulaString = u"Formula";
+constexpr OUStringLiteral aLinkString = u"Link";
+constexpr OUStringLiteral aNoteString = u"Note";
// returns true if first paragraph in cell frame has 'table heading' style
bool lcl_IsHeadlineCell( const SwCellFrame& rCellFrame )
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index c916dca531de..697f57358d5c 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -119,7 +119,7 @@ lcl_ReAssignTOXType(SwDoc& rDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
rTOXBase.RegisterToTOXType( *const_cast<SwTOXType*>(pNewType) );
}
-const char cUserDefined[] = "User-Defined";
+constexpr OUStringLiteral cUserDefined = u"User-Defined";
const char cUserSuffix[] = " (user)";
#define USER_LEN 12
#define USER_AND_SUFFIXLEN 19
@@ -152,7 +152,7 @@ lcl_ConvertTOUNameToUserName(OUString& rTmp)
USER_AND_SUFFIXLEN == rTmp.getLength())
{
//make sure that in non-English versions the " (user)" suffix is removed
- if (rTmp.matchAsciiL(cUserDefined, sizeof(cUserDefined)) &&
+ if (rTmp.match(cUserDefined) &&
rTmp.matchAsciiL(cUserSuffix, sizeof(cUserSuffix), USER_LEN))
{
rTmp = cUserDefined;
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 61d081918736..a79e4d57e62f 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1003,7 +1003,7 @@ void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString& /*
OSL_FAIL("not implemented");
}
-const char16_t aInvalidStyle[] = u"__XXX___invalid";
+constexpr OUStringLiteral aInvalidStyle = u"__XXX___invalid";
class SwXNumberingRules::Impl
: public SvtListener
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 1857706ca06e..6542d96ca277 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -73,7 +73,7 @@
using namespace ::com::sun::star;
-const char cInvalidObject[] = "this object is invalid";
+constexpr OUStringLiteral cInvalidObject = u"this object is invalid";
class SwXText::Impl
{
diff --git a/sw/source/ui/vba/vbalisthelper.cxx b/sw/source/ui/vba/vbalisthelper.cxx
index a6597a539145..fa7d69a23d20 100644
--- a/sw/source/ui/vba/vbalisthelper.cxx
+++ b/sw/source/ui/vba/vbalisthelper.cxx
@@ -38,14 +38,14 @@ constexpr OUStringLiteral UNO_NAME_CHAR_STYLE_NAME = u"CharStyleName";
constexpr OUStringLiteral UNO_NAME_NUMBERING_TYPE = u"NumberingType";
constexpr OUStringLiteral UNO_NAME_BULLET_CHAR = u"BulletChar";
-const sal_Unicode CHAR_CLOSED_DOT[] = u"\u2022";
-const char CHAR_EMPTY_DOT[] = "o";
-const sal_Unicode CHAR_SQUARE[] = u"\u2540";
-const sal_Unicode CHAR_STAR_SYMBOL[] = u"\u272A";
-const sal_Unicode CHAR_FOUR_DIAMONDS[] = u"\u2756";
-const sal_Unicode CHAR_DIAMOND[] = u"\u2726";
-const sal_Unicode CHAR_ARROW[] = u"\u27A2";
-const sal_Unicode CHAR_CHECK_MARK[] = u"\u2713";
+constexpr OUStringLiteral CHAR_CLOSED_DOT = u"\u2022";
+constexpr OUStringLiteral CHAR_EMPTY_DOT = u"o";
+constexpr OUStringLiteral CHAR_SQUARE = u"\u2540";
+constexpr OUStringLiteral CHAR_STAR_SYMBOL = u"\u272A";
+constexpr OUStringLiteral CHAR_FOUR_DIAMONDS = u"\u2756";
+constexpr OUStringLiteral CHAR_DIAMOND = u"\u2726";
+constexpr OUStringLiteral CHAR_ARROW = u"\u27A2";
+constexpr OUStringLiteral CHAR_CHECK_MARK = u"\u2713";
SwVbaListHelper::SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) : mxTextDocument( xTextDoc ), mnGalleryType( nGalleryType ), mnTemplateType( nTemplateType )
{