Some loplugin:conststringvar/stringconstant improvements: xmloff

Change-Id: I05e03936d9e5518fa7ba4d9c72d5b8e241e32526
This commit is contained in:
Stephan Bergmann
2017-01-11 11:25:42 +01:00
parent 5088b20666
commit 15f84c9cd4
3 changed files with 13 additions and 17 deletions

View File

@@ -50,8 +50,7 @@ private:
}; };
lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo() : lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo() :
// note: length of FillColor and LineColor is 9 m_aColorPropName( "FillColor" ),
m_aColorPropName( "FillColor", 9, RTL_TEXTENCODING_ASCII_US ),
m_aColorProp( m_aColorPropName, -1, m_aColorProp( m_aColorPropName, -1,
cppu::UnoType<sal_Int32>::get(), 0) cppu::UnoType<sal_Int32>::get(), 0)
{} {}
@@ -85,8 +84,7 @@ namespace chart
{ {
ColorPropertySet::ColorPropertySet( sal_Int32 nColor ) : ColorPropertySet::ColorPropertySet( sal_Int32 nColor ) :
// note: length of FillColor and LineColor is 9 m_aColorPropName( "FillColor" ),
m_aColorPropName( "FillColor", 9, RTL_TEXTENCODING_ASCII_US ),
m_nColor( nColor ), m_nColor( nColor ),
m_nDefaultColor( 0x0099ccff ) // blue 8 m_nDefaultColor( 0x0099ccff ) // blue 8
{} {}

View File

@@ -105,7 +105,7 @@ static ::rtl::OUString
lcl_GetMediaReference(SvXMLImport const& rImport, ::rtl::OUString const& rURL) lcl_GetMediaReference(SvXMLImport const& rImport, ::rtl::OUString const& rURL)
{ {
if (rImport.IsPackageURL(rURL)) if (rImport.IsPackageURL(rURL))
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.Package:")) + rURL; return "vnd.sun.star.Package:" + rURL;
return rImport.GetAbsoluteReference(rURL); return rImport.GetAbsoluteReference(rURL);
} }

View File

@@ -295,10 +295,10 @@ void SvXMLMetaExport::MExport_()
} }
} }
static const char * const s_xmlns = "xmlns"; static const char s_xmlns[] = "xmlns";
static const char * const s_xmlns2 = "xmlns:"; static const char s_xmlns2[] = "xmlns:";
static const char * const s_meta = "meta:"; static const char s_meta[] = "meta:";
static const char * const s_href = "xlink:href"; static const char s_href[] = "xlink:href";
SvXMLMetaExport::SvXMLMetaExport( SvXMLMetaExport::SvXMLMetaExport(
SvXMLExport& i_rExp, SvXMLExport& i_rExp,
@@ -326,11 +326,9 @@ void SvXMLMetaExport::Export()
key != USHRT_MAX; key = rNsMap.GetNextKey(key)) { key != USHRT_MAX; key = rNsMap.GetNextKey(key)) {
beans::StringPair ns; beans::StringPair ns;
const OUString attrname = rNsMap.GetAttrNameByKey(key); const OUString attrname = rNsMap.GetAttrNameByKey(key);
if (attrname.matchAsciiL(s_xmlns2, strlen(s_xmlns2))) { if (!attrname.startsWith(s_xmlns2, &ns.First)
ns.First = attrname.copy(strlen(s_xmlns2)); || attrname == s_xmlns) // default initialized empty string
} else if (attrname.equalsAsciiL(s_xmlns, strlen(s_xmlns))) { {
// default initialized empty string
} else {
assert(!"namespace attribute not starting with xmlns unexpected"); assert(!"namespace attribute not starting with xmlns unexpected");
} }
ns.Second = rNsMap.GetNameByKey(key); ns.Second = rNsMap.GetNameByKey(key);
@@ -376,7 +374,7 @@ SvXMLMetaExport::startElement(const OUString & i_rName,
const sal_Int16 nCount = i_xAttribs->getLength(); const sal_Int16 nCount = i_xAttribs->getLength();
for (sal_Int16 i = 0; i < nCount; ++i) { for (sal_Int16 i = 0; i < nCount; ++i) {
const OUString name(i_xAttribs->getNameByIndex(i)); const OUString name(i_xAttribs->getNameByIndex(i));
if (name.matchAsciiL(s_xmlns, strlen(s_xmlns))) { if (name.startsWith(s_xmlns)) {
bool found(false); bool found(false);
const SvXMLNamespaceMap & rNsMap(mrExport.GetNamespaceMap()); const SvXMLNamespaceMap & rNsMap(mrExport.GetNamespaceMap());
for (sal_uInt16 key = rNsMap.GetFirstKey(); for (sal_uInt16 key = rNsMap.GetFirstKey();
@@ -419,14 +417,14 @@ SvXMLMetaExport::startElement(const OUString & i_rName,
} }
// attach the attributes // attach the attributes
if (i_rName.matchAsciiL(s_meta, strlen(s_meta))) { if (i_rName.startsWith(s_meta)) {
// special handling for all elements that may have // special handling for all elements that may have
// xlink:href attributes; these must be made relative // xlink:href attributes; these must be made relative
const sal_Int16 nLength = i_xAttribs->getLength(); const sal_Int16 nLength = i_xAttribs->getLength();
for (sal_Int16 i = 0; i < nLength; ++i) { for (sal_Int16 i = 0; i < nLength; ++i) {
const OUString name (i_xAttribs->getNameByIndex (i)); const OUString name (i_xAttribs->getNameByIndex (i));
OUString value(i_xAttribs->getValueByIndex(i)); OUString value(i_xAttribs->getValueByIndex(i));
if (name.matchAsciiL(s_href, strlen(s_href))) { if (name.startsWith(s_href)) {
value = mrExport.GetRelativeReference(value); value = mrExport.GetRelativeReference(value);
} }
mrExport.AddAttribute(name, value); mrExport.AddAttribute(name, value);