diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-16 16:57:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-22 13:31:57 +0200 |
commit | 60bc26354763fa3461db49a3e827da552484150d (patch) | |
tree | 5c66cee43f76f556f9a086a67fa8a6e88750c5d5 /comphelper | |
parent | 7867e1f1cdd726cb98a236245e3d08557cc3a313 (diff) |
new loplugin:conststringfield
Look for const string fields which can be static, and
mostly convert them to OUStringLiteral
And add a getLength() method to OUStringLiteral to make
the transition easier.
Remove dead code in XclExpRoot::GenerateDefaultEncryptionData,
default password is never empty.
Change-Id: Iae75514d9dbb87289fd5b016222f640abe755091
Reviewed-on: https://gerrit.libreoffice.org/59204
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
4 files changed, 49 insertions, 62 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index d47c9904c696..7e5a76983e43 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -545,16 +545,16 @@ namespace typedef std::vector< ExtensionInfoEntry > ExtensionInfoEntryVector; + static const OUStringLiteral gaRegPath { "/registry/com.sun.star.comp.deployment.bundle.PackageRegistryBackend/backenddb.xml" }; + class ExtensionInfo { private: ExtensionInfoEntryVector maEntries; - OUString const maRegPath; public: ExtensionInfo() - : maEntries(), - maRegPath("/registry/com.sun.star.comp.deployment.bundle.PackageRegistryBackend/backenddb.xml") + : maEntries() { } @@ -677,19 +677,19 @@ namespace public: void createUserExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) { - const OUString aPath(rUserConfigWorkURL + "/uno_packages/cache" + maRegPath); + const OUString aPath(rUserConfigWorkURL + "/uno_packages/cache" + gaRegPath); createExtensionRegistryEntriesFromXML(aPath); } void createSharedExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) { - const OUString aPath(rUserConfigWorkURL + "/extensions/shared" + maRegPath); + const OUString aPath(rUserConfigWorkURL + "/extensions/shared" + gaRegPath); createExtensionRegistryEntriesFromXML(aPath); } void createBundledExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) { - const OUString aPath(rUserConfigWorkURL + "/extensions/bundled" + maRegPath); + const OUString aPath(rUserConfigWorkURL + "/extensions/bundled" + gaRegPath); createExtensionRegistryEntriesFromXML(aPath); } diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx index a1850d4b6fc8..1323f79a22de 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx @@ -75,11 +75,12 @@ static bool makeCanonicalFileURL( OUString & rURL ) namespace comphelper { +static OUString const g_aOfficeBrandDirMacro("$(brandbaseurl)"); +static OUString const g_aUserDirMacro("$(userdataurl)"); + OfficeInstallationDirectories::OfficeInstallationDirectories( const uno::Reference< uno::XComponentContext > & xCtx ) -: m_aOfficeBrandDirMacro( "$(brandbaseurl)" ), - m_aUserDirMacro( "$(userdataurl)" ), - m_xCtx( xCtx ), +: m_xCtx( xCtx ), m_pOfficeBrandDir( nullptr ), m_pUserDir( nullptr ) { @@ -131,7 +132,7 @@ OfficeInstallationDirectories::makeRelocatableURL( const OUString& URL ) return aCanonicalURL.replaceAt( nIndex, m_pOfficeBrandDir->getLength(), - m_aOfficeBrandDirMacro ); + g_aOfficeBrandDirMacro ); } else { @@ -141,7 +142,7 @@ OfficeInstallationDirectories::makeRelocatableURL( const OUString& URL ) return aCanonicalURL.replaceAt( nIndex, m_pUserDir->getLength(), - m_aUserDirMacro ); + g_aUserDirMacro ); } } } @@ -155,26 +156,26 @@ OfficeInstallationDirectories::makeAbsoluteURL( const OUString& URL ) { if ( !URL.isEmpty() ) { - sal_Int32 nIndex = URL.indexOf( m_aOfficeBrandDirMacro ); + sal_Int32 nIndex = URL.indexOf( g_aOfficeBrandDirMacro ); if ( nIndex != -1 ) { initDirs(); return URL.replaceAt( nIndex, - m_aOfficeBrandDirMacro.getLength(), + g_aOfficeBrandDirMacro.getLength(), *m_pOfficeBrandDir ); } else { - nIndex = URL.indexOf( m_aUserDirMacro ); + nIndex = URL.indexOf( g_aUserDirMacro ); if ( nIndex != -1 ) { initDirs(); return URL.replaceAt( nIndex, - m_aUserDirMacro.getLength(), + g_aUserDirMacro.getLength(), *m_pUserDir ); } } diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx index e2b04a7687fb..bfcde8d72876 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx @@ -69,8 +69,6 @@ public: private: void initDirs(); - OUString const m_aOfficeBrandDirMacro; - OUString const m_aUserDirMacro; css::uno::Reference< css::uno::XComponentContext > m_xCtx; std::unique_ptr<OUString> m_pOfficeBrandDir; std::unique_ptr<OUString> m_pUserDir; diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx index 62cd50aba2ca..4a2bf122b39e 100644 --- a/comphelper/source/xml/ofopxmlhelper.cxx +++ b/comphelper/source/xml/ofopxmlhelper.cxx @@ -47,22 +47,6 @@ class OFOPXMLHelper_Impl { sal_uInt16 const m_nFormat; // which format to parse - // Relations info related strings - OUString const m_aRelListElement; - OUString const m_aRelElement; - OUString const m_aIDAttr; - OUString const m_aTypeAttr; - OUString const m_aTargetModeAttr; - OUString const m_aTargetAttr; - - // ContentType related strings - OUString const m_aTypesElement; - OUString const m_aDefaultElement; - OUString const m_aOverrideElement; - OUString const m_aExtensionAttr; - OUString const m_aPartNameAttr; - OUString const m_aContentTypeAttr; - css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > m_aResultSeq; std::vector< OUString > m_aElementsSeq; // stack of elements being parsed @@ -284,20 +268,24 @@ uno::Sequence< uno::Sequence< beans::StringPair > > ReadSequence_Impl( } // namespace OFOPXMLHelper +// Relations info related strings +static OUString const g_aRelListElement("Relationships"); +static OUString const g_aRelElement( "Relationship" ); +static OUString const g_aIDAttr( "Id" ); +static OUString const g_aTypeAttr( "Type" ); +static OUString const g_aTargetModeAttr( "TargetMode" ); +static OUString const g_aTargetAttr( "Target" ); + +// ContentType related strings +static OUString const g_aTypesElement( "Types" ); +static OUString const g_aDefaultElement( "Default" ); +static OUString const g_aOverrideElement( "Override" ); +static OUString const g_aExtensionAttr( "Extension" ); +static OUString const g_aPartNameAttr( "PartName" ); +static OUString const g_aContentTypeAttr( "ContentType" ); + OFOPXMLHelper_Impl::OFOPXMLHelper_Impl( sal_uInt16 nFormat ) : m_nFormat( nFormat ) -, m_aRelListElement( "Relationships" ) -, m_aRelElement( "Relationship" ) -, m_aIDAttr( "Id" ) -, m_aTypeAttr( "Type" ) -, m_aTargetModeAttr( "TargetMode" ) -, m_aTargetAttr( "Target" ) -, m_aTypesElement( "Types" ) -, m_aDefaultElement( "Default" ) -, m_aOverrideElement( "Override" ) -, m_aExtensionAttr( "Extension" ) -, m_aPartNameAttr( "PartName" ) -, m_aContentTypeAttr( "ContentType" ) { } @@ -324,7 +312,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno { if ( m_nFormat == RELATIONINFO_FORMAT ) { - if ( aName == m_aRelListElement ) + if ( aName == g_aRelListElement ) { sal_Int32 nNewLength = m_aElementsSeq.size() + 1; @@ -335,7 +323,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno return; // nothing to do } - else if ( aName == m_aRelElement ) + else if ( aName == g_aRelElement ) { sal_Int32 nNewLength = m_aElementsSeq.size() + 1; if ( nNewLength != 2 ) @@ -348,32 +336,32 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno sal_Int32 nAttrNum = 0; m_aResultSeq[nNewEntryNum-1].realloc( 4 ); // the maximal expected number of arguments is 4 - OUString aIDValue = xAttribs->getValueByName( m_aIDAttr ); + OUString aIDValue = xAttribs->getValueByName( g_aIDAttr ); if ( aIDValue.isEmpty() ) throw css::xml::sax::SAXException(); // TODO: the ID value must present - OUString aTypeValue = xAttribs->getValueByName( m_aTypeAttr ); - OUString aTargetValue = xAttribs->getValueByName( m_aTargetAttr ); - OUString aTargetModeValue = xAttribs->getValueByName( m_aTargetModeAttr ); + OUString aTypeValue = xAttribs->getValueByName( g_aTypeAttr ); + OUString aTargetValue = xAttribs->getValueByName( g_aTargetAttr ); + OUString aTargetModeValue = xAttribs->getValueByName( g_aTargetModeAttr ); - m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = m_aIDAttr; + m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aIDAttr; m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aIDValue; if ( !aTypeValue.isEmpty() ) { - m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = m_aTypeAttr; + m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aTypeAttr; m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aTypeValue; } if ( !aTargetValue.isEmpty() ) { - m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = m_aTargetAttr; + m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aTargetAttr; m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aTargetValue; } if ( !aTargetModeValue.isEmpty() ) { - m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = m_aTargetModeAttr; + m_aResultSeq[nNewEntryNum-1][++nAttrNum - 1].First = g_aTargetModeAttr; m_aResultSeq[nNewEntryNum-1][nAttrNum - 1].Second = aTargetModeValue; } @@ -384,7 +372,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno } else if ( m_nFormat == CONTENTTYPE_FORMAT ) { - if ( aName == m_aTypesElement ) + if ( aName == g_aTypesElement ) { sal_Int32 nNewLength = m_aElementsSeq.size() + 1; @@ -398,7 +386,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno return; // nothing to do } - else if ( aName == m_aDefaultElement ) + else if ( aName == g_aDefaultElement ) { sal_Int32 nNewLength = m_aElementsSeq.size() + 1; if ( nNewLength != 2 ) @@ -412,11 +400,11 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno if ( m_aResultSeq.getLength() != 2 ) throw uno::RuntimeException(); - const OUString aExtensionValue = xAttribs->getValueByName( m_aExtensionAttr ); + const OUString aExtensionValue = xAttribs->getValueByName( g_aExtensionAttr ); if ( aExtensionValue.isEmpty() ) throw css::xml::sax::SAXException(); // TODO: the Extension value must present - const OUString aContentTypeValue = xAttribs->getValueByName( m_aContentTypeAttr ); + const OUString aContentTypeValue = xAttribs->getValueByName( g_aContentTypeAttr ); if ( aContentTypeValue.isEmpty() ) throw css::xml::sax::SAXException(); // TODO: the ContentType value must present @@ -426,7 +414,7 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno m_aResultSeq[0][nNewResultLen-1].First = aExtensionValue; m_aResultSeq[0][nNewResultLen-1].Second = aContentTypeValue; } - else if ( aName == m_aOverrideElement ) + else if ( aName == g_aOverrideElement ) { sal_Int32 nNewLength = m_aElementsSeq.size() + 1; if ( nNewLength != 2 ) @@ -440,11 +428,11 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno if ( m_aResultSeq.getLength() != 2 ) throw uno::RuntimeException(); - OUString aPartNameValue = xAttribs->getValueByName( m_aPartNameAttr ); + OUString aPartNameValue = xAttribs->getValueByName( g_aPartNameAttr ); if ( aPartNameValue.isEmpty() ) throw css::xml::sax::SAXException(); // TODO: the PartName value must present - OUString aContentTypeValue = xAttribs->getValueByName( m_aContentTypeAttr ); + OUString aContentTypeValue = xAttribs->getValueByName( g_aContentTypeAttr ); if ( aContentTypeValue.isEmpty() ) throw css::xml::sax::SAXException(); // TODO: the ContentType value must present |