summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-12-23 13:16:31 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-12-26 14:51:15 +0100
commita3d0091d185f39eddabf4d372ebe0ac3061dbb89 (patch)
tree4d70cedc274972ccc21b6b8e7105f042090cf5d6 /xmloff
parentaf791fb775e35c11ad01c42a7085dd121ab9c7a6 (diff)
New loplugin:stringliteralvar
See the comment at the top of compilerplugins/clang/stringliteralvar.cxx for details. (Turned some affected variables in included files into inline variables, to avoid GCC warnings about unused variables.) Change-Id: Ie77219e6adfdaaceaa8b4e590b08971f2f04c83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/qa/unit/draw.cxx2
-rw-r--r--xmloff/qa/unit/style.cxx2
-rw-r--r--xmloff/qa/unit/text.cxx2
-rw-r--r--xmloff/source/chart/SchXMLTableContext.cxx2
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx18
-rw-r--r--xmloff/source/forms/elementimport.cxx2
-rw-r--r--xmloff/source/meta/xmlversion.cxx2
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx8
-rw-r--r--xmloff/source/text/XMLTextListBlockContext.cxx2
-rw-r--r--xmloff/source/text/XMLTextMarkImportContext.cxx2
-rw-r--r--xmloff/source/text/txtfldi.cxx57
-rw-r--r--xmloff/source/text/txtimp.cxx32
-rw-r--r--xmloff/source/text/txtvfldi.cxx22
13 files changed, 78 insertions, 75 deletions
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index 8365b463efc6..4128e33b96f2 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -20,7 +20,7 @@
using namespace ::com::sun::star;
-char const DATA_DIRECTORY[] = "/xmloff/qa/unit/data/";
+OUStringLiteral const DATA_DIRECTORY = u"/xmloff/qa/unit/data/";
/// Covers xmloff/source/draw/ fixes.
class XmloffDrawTest : public test::BootstrapFixture, public unotest::MacrosTest
diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx
index 4a5b7af616c1..d9511e3e2a8a 100644
--- a/xmloff/qa/unit/style.cxx
+++ b/xmloff/qa/unit/style.cxx
@@ -15,7 +15,7 @@
using namespace ::com::sun::star;
-char const DATA_DIRECTORY[] = "/xmloff/qa/unit/data/";
+OUStringLiteral const DATA_DIRECTORY = u"/xmloff/qa/unit/data/";
/// Covers xmloff/source/style/ fixes.
class XmloffStyleTest : public test::BootstrapFixture, public unotest::MacrosTest
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 3d1873d02e83..de2f718f53dc 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -14,7 +14,7 @@
using namespace ::com::sun::star;
-char const DATA_DIRECTORY[] = "/xmloff/qa/unit/data/";
+OUStringLiteral const DATA_DIRECTORY = u"/xmloff/qa/unit/data/";
/// Covers xmloff/source/text/ fixes.
class XmloffStyleTest : public test::BootstrapFixture, public unotest::MacrosTest
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index ac5bcdbc2515..15de497408aa 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -55,7 +55,7 @@ using ::com::sun::star::uno::Reference;
namespace
{
-const char aCategoriesRange[] = "categories";
+const OUStringLiteral aCategoriesRange = u"categories";
typedef ::std::multimap< OUString, OUString >
lcl_tOriginalRangeToInternalRangeMap;
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index c7a6b44401aa..dac4db9eb464 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include <xmloff/autolayout.hxx>
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
#include <xmloff/namespacemap.hxx>
@@ -1313,7 +1317,7 @@ void SdXMLExport::ImpPrepDrawPageInfos()
}
}
-static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, const char* pPrefix )
+static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, std::u16string_view pPrefix )
{
// search rVector if there is already a string that equals rText
auto aIter = std::find(rVector.begin(), rVector.end(), rText);
@@ -1325,10 +1329,10 @@ static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUStri
// create a reference string with pPrefix and the index of the
// found or created rText
- return OUString::createFromAscii( pPrefix ) + OUString::number( nIndex );
+ return pPrefix + OUString::number( nIndex );
}
-static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, bool bFixed, sal_Int32 nFormat, const char* pPrefix )
+static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, bool bFixed, sal_Int32 nFormat, std::u16string_view pPrefix )
{
// search rVector if there is already a DateTimeDeclImpl with rText,bFixed and nFormat
auto aIter = std::find_if(rVector.begin(), rVector.end(),
@@ -1351,12 +1355,12 @@ static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, cons
// create a reference string with pPrefix and the index of the
// found or created DateTimeDeclImpl
- return OUString::createFromAscii( pPrefix ) + OUString::number( nIndex );
+ return pPrefix + OUString::number( nIndex );
}
-const char gpStrHeaderTextPrefix[] = "hdr";
-const char gpStrFooterTextPrefix[] = "ftr";
-const char gpStrDateTimeTextPrefix[] = "dtd";
+const OUStringLiteral gpStrHeaderTextPrefix = u"hdr";
+const OUStringLiteral gpStrFooterTextPrefix = u"ftr";
+const OUStringLiteral gpStrDateTimeTextPrefix = u"dtd";
HeaderFooterPageSettingsImpl SdXMLExport::ImpPrepDrawPageHeaderFooterDecls( const Reference<XDrawPage>& xDrawPage )
{
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index 6f892de8ca09..79bc77a71e89 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -442,7 +442,7 @@ namespace xmloff
{
// no optimization here. If this method gets called, the XML stream did not contain a name for the
// element, which is a heavy error. So in this case we don't care for performance
- static const char sUnnamedName[] = "unnamed";
+ static const OUStringLiteral sUnnamedName = u"unnamed";
OSL_ENSURE(m_xParentContainer.is(), "OElementImport::implGetDefaultName: no parent container!");
if (!m_xParentContainer.is())
return sUnnamedName;
diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx
index 76fe43b5d2fb..2aa1100e5b21 100644
--- a/xmloff/source/meta/xmlversion.cxx
+++ b/xmloff/source/meta/xmlversion.cxx
@@ -40,7 +40,7 @@ using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-const char XMLN_VERSIONSLIST[] = "VersionList.xml";
+const OUStringLiteral XMLN_VERSIONSLIST = u"VersionList.xml";
XMLVersionListExport::XMLVersionListExport(
const css::uno::Reference< css::uno::XComponentContext >& rContext,
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index 7c028bd1ef63..d06bc3cde711 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -1226,10 +1226,10 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
const OUString& rTargetFrameName,
bool bMap )
{
- static const char s_HyperLinkURL[] = "HyperLinkURL";
- static const char s_HyperLinkName[] = "HyperLinkName";
- static const char s_HyperLinkTarget[] = "HyperLinkTarget";
- static const char s_ServerMap[] = "ServerMap";
+ static const OUStringLiteral s_HyperLinkURL = u"HyperLinkURL";
+ static const OUStringLiteral s_HyperLinkName = u"HyperLinkName";
+ static const OUStringLiteral s_HyperLinkTarget = u"HyperLinkTarget";
+ static const OUStringLiteral s_ServerMap = u"ServerMap";
if( !xPropSet.is() )
return;
diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx
index 9240413a004b..b7a55c2ac80b 100644
--- a/xmloff/source/text/XMLTextListBlockContext.cxx
+++ b/xmloff/source/text/XMLTextListBlockContext.cxx
@@ -55,7 +55,7 @@ XMLTextListBlockContext::XMLTextListBlockContext(
, msListId()
, msContinueListId()
{
- static const char s_PropNameDefaultListId[] = "DefaultListId";
+ static const OUStringLiteral s_PropNameDefaultListId = u"DefaultListId";
{
// get the parent list block context (if any); this is a bit ugly...
XMLTextListBlockContext * pLB(nullptr);
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index b81152a3c211..e48159449f02 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -241,7 +241,7 @@ static auto PopFieldmark(XMLTextImportHelper & rHelper) -> void
void XMLTextMarkImportContext::endFastElement(sal_Int32 nElement)
{
- static const char sAPI_bookmark[] = "com.sun.star.text.Bookmark";
+ static const OUStringLiteral sAPI_bookmark = u"com.sun.star.text.Bookmark";
lcl_MarkType nTmp{};
if (!SvXMLUnitConverter::convertEnum(nTmp, SvXMLImport::getNameFromToken(nElement), lcl_aMarkTypeMap))
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index 0c65d17b1d67..e813d4a725f7 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -86,39 +86,39 @@ using namespace ::xmloff::token;
// service prefix and service names
-constexpr char16_t sAPI_textfield_prefix[] = u"com.sun.star.text.TextField.";
+constexpr OUStringLiteral sAPI_textfield_prefix = u"com.sun.star.text.TextField.";
constexpr char16_t sAPI_fieldmaster_prefix[] = u"com.sun.star.text.FieldMaster.";
const char sAPI_presentation_prefix[] = "com.sun.star.presentation.TextField.";
-const char sAPI_date_time[] = "DateTime";
-const char sAPI_page_number[] = "PageNumber";
-const char sAPI_docinfo_change_date_time[] = "DocInfo.ChangeDateTime";
-const char sAPI_docinfo_create_date_time[] = "DocInfo.CreateDateTime";
-const char sAPI_docinfo_custom[] = "DocInfo.Custom";
-const char sAPI_docinfo_print_date_time[] = "DocInfo.PrintDateTime";
-const char sAPI_dde[] = "DDE";
-const char sAPI_url[] = "URL";
+const OUStringLiteral sAPI_date_time = u"DateTime";
+const OUStringLiteral sAPI_page_number = u"PageNumber";
+const OUStringLiteral sAPI_docinfo_change_date_time = u"DocInfo.ChangeDateTime";
+const OUStringLiteral sAPI_docinfo_create_date_time = u"DocInfo.CreateDateTime";
+const OUStringLiteral sAPI_docinfo_custom = u"DocInfo.Custom";
+const OUStringLiteral sAPI_docinfo_print_date_time = u"DocInfo.PrintDateTime";
+const OUStringLiteral sAPI_dde = u"DDE";
+const OUStringLiteral sAPI_url = u"URL";
// property names
-const char sAPI_is_fixed[] = "IsFixed";
-const char sAPI_content[] = "Content";
-const char sAPI_author[] = "Author";
-const char sAPI_hint[] = "Hint";
-const char sAPI_name[] = "Name";
-const char sAPI_sub_type[] = "SubType";
-const char sAPI_date_time_value[] = "DateTimeValue";
-const char sAPI_number_format[] = "NumberFormat";
-const char sAPI_numbering_type[] = "NumberingType";
-const char sAPI_offset[] = "Offset";
-const char sAPI_condition[] = "Condition";
-const char sAPI_set_number[] = "SetNumber";
-const char sAPI_file_format[] = "FileFormat";
-const char sAPI_is_date[] = "IsDate";
-const char sAPI_current_presentation[] = "CurrentPresentation";
-const char sAPI_is_hidden[] = "IsHidden";
-const char sAPI_is_fixed_language[] = "IsFixedLanguage";
-
-const char sAPI_true[] = "TRUE";
+const OUStringLiteral sAPI_is_fixed = u"IsFixed";
+const OUStringLiteral sAPI_content = u"Content";
+const OUStringLiteral sAPI_author = u"Author";
+const OUStringLiteral sAPI_hint = u"Hint";
+const OUStringLiteral sAPI_name = u"Name";
+const OUStringLiteral sAPI_sub_type = u"SubType";
+const OUStringLiteral sAPI_date_time_value = u"DateTimeValue";
+const OUStringLiteral sAPI_number_format = u"NumberFormat";
+const OUStringLiteral sAPI_numbering_type = u"NumberingType";
+const OUStringLiteral sAPI_offset = u"Offset";
+const OUStringLiteral sAPI_condition = u"Condition";
+const OUStringLiteral sAPI_set_number = u"SetNumber";
+const OUStringLiteral sAPI_file_format = u"FileFormat";
+const OUStringLiteral sAPI_is_date = u"IsDate";
+const OUStringLiteral sAPI_current_presentation = u"CurrentPresentation";
+const OUStringLiteral sAPI_is_hidden = u"IsHidden";
+const OUStringLiteral sAPI_is_fixed_language = u"IsFixedLanguage";
+
+const OUStringLiteral sAPI_true = u"TRUE";
XMLTextFieldImportContext::XMLTextFieldImportContext(
@@ -1537,7 +1537,6 @@ OUString XMLSimpleDocInfoImportContext::MapTokenToServiceName(
case XML_ELEMENT(TEXT, XML_TITLE):
pServiceName = "DocInfo.Title";
break;
-
default:
XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken);
assert(false);
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 6585a4b25517..e32c02d8ca1b 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -405,7 +405,7 @@ XMLTextImportHelper::XMLTextImportHelper(
bProgress, bBlockMode, bOrganizerMode) )
, m_xBackpatcherImpl( MakeBackpatcherImpl() )
{
- static const char s_PropNameDefaultListId[] = "DefaultListId";
+ static const OUStringLiteral s_PropNameDefaultListId = u"DefaultListId";
Reference< XChapterNumberingSupplier > xCNSupplier( rModel, UNO_QUERY );
@@ -1013,14 +1013,14 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
bool bSetListAttrs,
bool bOutlineContentVisible)
{
- static const char s_NumberingRules[] = "NumberingRules";
- static const char s_NumberingIsNumber[] = "NumberingIsNumber";
- static const char s_NumberingLevel[] = "NumberingLevel";
- static const char s_ParaIsNumberingRestart[] = "ParaIsNumberingRestart";
- static const char s_NumberingStartValue[] = "NumberingStartValue";
- static const char s_PropNameListId[] = "ListId";
- static const char s_PageDescName[] = "PageDescName";
- static const char s_OutlineLevel[] = "OutlineLevel";
+ static const OUStringLiteral s_NumberingRules = u"NumberingRules";
+ static const OUStringLiteral s_NumberingIsNumber = u"NumberingIsNumber";
+ static const OUStringLiteral s_NumberingLevel = u"NumberingLevel";
+ static const OUStringLiteral s_ParaIsNumberingRestart = u"ParaIsNumberingRestart";
+ static const OUStringLiteral s_NumberingStartValue = u"NumberingStartValue";
+ static const OUStringLiteral s_PropNameListId = u"ListId";
+ static const OUStringLiteral s_PageDescName = u"PageDescName";
+ static const OUStringLiteral s_OutlineLevel = u"OutlineLevel";
const XmlStyleFamily nFamily = bPara ? XmlStyleFamily::TEXT_PARAGRAPH
: XmlStyleFamily::TEXT_TEXT;
@@ -1619,12 +1619,12 @@ void XMLTextImportHelper::SetHyperlink(
const OUString& rVisitedStyleName,
XMLEventsImportContext* pEvents)
{
- static const char s_HyperLinkURL[] = "HyperLinkURL";
- static const char s_HyperLinkName[] = "HyperLinkName";
- static const char s_HyperLinkTarget[] = "HyperLinkTarget";
- static const char s_UnvisitedCharStyleName[] = "UnvisitedCharStyleName";
- static const char s_VisitedCharStyleName[] = "VisitedCharStyleName";
- static const char s_HyperLinkEvents[] = "HyperLinkEvents";
+ static const OUStringLiteral s_HyperLinkURL = u"HyperLinkURL";
+ static const OUStringLiteral s_HyperLinkName = u"HyperLinkName";
+ static const OUStringLiteral s_HyperLinkTarget = u"HyperLinkTarget";
+ static const OUStringLiteral s_UnvisitedCharStyleName = u"UnvisitedCharStyleName";
+ static const OUStringLiteral s_VisitedCharStyleName = u"VisitedCharStyleName";
+ static const OUStringLiteral s_HyperLinkEvents = u"HyperLinkEvents";
Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
Reference < XPropertySetInfo > xPropSetInfo(
@@ -2212,7 +2212,7 @@ void XMLTextImportHelper::ConnectFrameChains(
bool XMLTextImportHelper::IsInFrame() const
{
- static const char s_TextFrame[] = "TextFrame";
+ static const OUStringLiteral s_TextFrame = u"TextFrame";
bool bIsInFrame = false;
diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx
index 790844cef1bd..f6fdcaee02c4 100644
--- a/xmloff/source/text/txtvfldi.cxx
+++ b/xmloff/source/text/txtvfldi.cxx
@@ -54,17 +54,17 @@
// service names
constexpr char16_t sAPI_fieldmaster_prefix[] = u"com.sun.star.text.FieldMaster.";
-const char sAPI_get_expression[] = "GetExpression";
-const char sAPI_set_expression[] = "SetExpression";
-const char sAPI_user[] = "User";
-const char sAPI_database[] = "com.sun.star.text.TextField.Database";
+const OUStringLiteral sAPI_get_expression = u"GetExpression";
+const OUStringLiteral sAPI_set_expression = u"SetExpression";
+const OUStringLiteral sAPI_user = u"User";
+const OUStringLiteral sAPI_database = u"com.sun.star.text.TextField.Database";
// property names
-const char sAPI_content[] = "Content";
-const char sAPI_sub_type[] = "SubType";
-const char sAPI_number_format[] = "NumberFormat";
-const char sAPI_is_visible[] = "IsVisible";
-const char sAPI_current_presentation[] = "CurrentPresentation";
+const OUStringLiteral sAPI_content = u"Content";
+const OUStringLiteral sAPI_sub_type = u"SubType";
+const OUStringLiteral sAPI_number_format = u"NumberFormat";
+const OUStringLiteral sAPI_is_visible = u"IsVisible";
+const OUStringLiteral sAPI_current_presentation = u"CurrentPresentation";
using namespace ::com::sun::star;
@@ -866,8 +866,8 @@ bool XMLVariableDeclImportContext::FindFieldMaster(
OUStringBuffer sService;
sService.append(sAPI_fieldmaster_prefix);
- sService.appendAscii((eVarType==VarTypeUserField) ?
- sAPI_user : sAPI_set_expression);
+ sService.append((eVarType==VarTypeUserField) ?
+ OUString(sAPI_user) : OUString(sAPI_set_expression));
Reference<XInterface> xIfc =
xFactory->createInstance( sService.makeStringAndClear() );
if (xIfc.is()) {