diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-07 08:46:27 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-09 07:08:24 +0200 |
commit | 4d82c1d8a3160719f694df98a4db6b9b8c7664bd (patch) | |
tree | 2e0fd754bd15d74171f07b77dbd4a00612d13f7c /xmloff | |
parent | a5ba8d94e6c36a7d79276416cc5acad9a1f6e54e (diff) |
Simplify SvXMLExport::AddAttribute overloads
Remove overloads taking const char* which were not needed, because
every their use eventually took a string literal convertible to
OUString directly.
Many other literals were converted to OUStringLiterals.
Change-Id: Ia1e742a8087776cd20bf5094dc415dafd9a8834a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123155
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 35 | ||||
-rw-r--r-- | xmloff/source/forms/elementexport.cxx | 8 | ||||
-rw-r--r-- | xmloff/source/forms/formattributes.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/forms/formattributes.hxx | 12 | ||||
-rw-r--r-- | xmloff/source/forms/layerimport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.cxx | 22 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.hxx | 19 |
7 files changed, 37 insertions, 75 deletions
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index c64fb6052d45..0a29e8bf9449 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -924,49 +924,24 @@ SvXMLExport::EnsureNamespace(OUString const & i_rNamespace) return sPrefix; } -void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey, - const char *pName, - const char *pValue ) -{ - OUString sName( OUString::createFromAscii( pName ) ); - OUString sValue( OUString::createFromAscii( pValue ) ); - - mxAttrList->AddAttribute( - GetNamespaceMap_().GetQNameByKey( nPrefixKey, sName ), sValue ); -} - -void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const char *pName, - const OUString& rValue ) -{ - OUString sName( OUString::createFromAscii( pName ) ); - - mxAttrList->AddAttribute( - GetNamespaceMap_().GetQNameByKey( nPrefixKey, sName ), rValue ); -} - void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName, const OUString& rValue ) { - mxAttrList->AddAttribute( - GetNamespaceMap_().GetQNameByKey( nPrefixKey, rName ), rValue ); + AddAttribute(GetNamespaceMap_().GetQNameByKey(nPrefixKey, rName), rValue); } void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, enum XMLTokenEnum eName, const OUString& rValue ) { - mxAttrList->AddAttribute( - GetNamespaceMap_().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ), - rValue ); + AddAttribute(nPrefixKey, GetXMLToken(eName), rValue); } void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, enum XMLTokenEnum eName, enum XMLTokenEnum eValue) { - mxAttrList->AddAttribute( - GetNamespaceMap_().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ), - GetXMLToken(eValue) ); + AddAttribute(nPrefixKey, eName, GetXMLToken(eValue)); } void SvXMLExport::AddAttribute( const OUString& rQName, @@ -980,9 +955,7 @@ void SvXMLExport::AddAttribute( const OUString& rQName, void SvXMLExport::AddAttribute( const OUString& rQName, enum ::xmloff::token::XMLTokenEnum eValue ) { - mxAttrList->AddAttribute( - rQName, - GetXMLToken(eValue) ); + AddAttribute(rQName, GetXMLToken(eValue)); } void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc, diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 02632fa08c8b..72cb6e0ef35c 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -742,7 +742,7 @@ namespace xmloff // add the attributes if necessary and possible if (pCurrentValuePropertyName && (CCAFlags::CurrentValue & m_nIncludeCommon)) { - static const char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentValue); + static const OUString pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentValue); // don't export the current-value if this value originates from a data binding // #i26944# if ( controlHasActiveDataBinding() ) @@ -760,7 +760,7 @@ namespace xmloff if (pValuePropertyName && (CCAFlags::Value & m_nIncludeCommon)) { - static const char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Value); + static const OUString pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Value); static const sal_uInt16 nValueAttributeNamespaceKey = OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Value); exportGenericPropertyAttribute( nValueAttributeNamespaceKey, @@ -1164,8 +1164,8 @@ namespace xmloff "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!"); // add the two attributes - static const char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MinValue); - static const char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MaxValue); + static const OUString pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MinValue); + static const OUString pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MaxValue); static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MinValue); static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MaxValue); diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx index c8cccb55b3cb..6b7b3fb9f099 100644 --- a/xmloff/source/forms/formattributes.cxx +++ b/xmloff/source/forms/formattributes.cxx @@ -34,7 +34,7 @@ namespace xmloff using namespace ::com::sun::star::beans; //= OAttributeMetaData - const char* OAttributeMetaData::getCommonControlAttributeName(CCAFlags _nId) + OUString OAttributeMetaData::getCommonControlAttributeName(CCAFlags _nId) { switch (_nId) { @@ -115,7 +115,7 @@ namespace xmloff return XML_NAMESPACE_FORM; } - const char* OAttributeMetaData::getFormAttributeName(FormAttributes _eAttrib) + OUString OAttributeMetaData::getFormAttributeName(FormAttributes _eAttrib) { switch (_eAttrib) { @@ -181,7 +181,7 @@ namespace xmloff return XML_NAMESPACE_FORM; } - const char* OAttributeMetaData::getDatabaseAttributeName(DAFlags _nId) + OUString OAttributeMetaData::getDatabaseAttributeName(DAFlags _nId) { switch (_nId) { @@ -213,7 +213,7 @@ namespace xmloff return XML_NONE; } - const char* OAttributeMetaData::getBindingAttributeName(BAFlags _nId) + OUString OAttributeMetaData::getBindingAttributeName(BAFlags _nId) { switch (_nId) { @@ -239,7 +239,7 @@ namespace xmloff return XML_UNKNOWN; } - const char* OAttributeMetaData::getSpecialAttributeName(SCAFlags _nId) + OUString OAttributeMetaData::getSpecialAttributeName(SCAFlags _nId) { switch (_nId) { @@ -305,7 +305,7 @@ namespace xmloff return XML_NAMESPACE_FORM; } - const char* OAttributeMetaData::getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib) + OUString OAttributeMetaData::getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib) { switch (_eAttrib) { diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx index 19a71132f0aa..ae36fd65dcd6 100644 --- a/xmloff/source/forms/formattributes.hxx +++ b/xmloff/source/forms/formattributes.hxx @@ -182,7 +182,7 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the CCA_* constants. */ - static const char* getCommonControlAttributeName(CCAFlags _nId); + static OUString getCommonControlAttributeName(CCAFlags _nId); /** calculates the xml attribute representation of a common control attribute. @param _nId @@ -200,7 +200,7 @@ namespace xmloff @param _eAttrib enum value specifying the attribute */ - static const char* getFormAttributeName(FormAttributes _eAttrib); + static OUString getFormAttributeName(FormAttributes _eAttrib); /** retrieves the name of an attribute of a form xml representation @param _eAttrib @@ -218,7 +218,7 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the DA_* constants. */ - static const char* getDatabaseAttributeName(DAFlags _nId); + static OUString getDatabaseAttributeName(DAFlags _nId); /** calculates the xml attribute representation of a database attribute. @param _nId @@ -240,7 +240,7 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the SCA_* constants. */ - static const char* getSpecialAttributeName(SCAFlags _nId); + static OUString getSpecialAttributeName(SCAFlags _nId); /** calculates the xml attribute representation of a special attribute. @param _nId @@ -252,7 +252,7 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the BA_* constants. */ - static const char* getBindingAttributeName(BAFlags _nId); + static OUString getBindingAttributeName(BAFlags _nId); /** calculates the xml attribute representation of a binding attribute. @param _nId @@ -280,7 +280,7 @@ namespace xmloff @param _nId the id of the attribute */ - static const char* getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib); + static OUString getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib); static xmloff::token::XMLTokenEnum getOfficeFormsAttributeToken(OfficeFormsAttributes _eAttrib); /** calculates the xml namedspace key of an attribute of the office:forms element diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index 40845d735a64..b879ed8518e3 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -91,7 +91,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) // properties not added because they're already present in another form OSL_ENSURE( - OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCAFlags::TargetLocation)).equalsAscii( + OAttributeMetaData::getCommonControlAttributeName(CCAFlags::TargetLocation).equals( OAttributeMetaData::getFormAttributeName(faAction)), "OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl: invalid attribute names (1)!"); // if this fails, we would have to add a translation from faAction->PROPERTY_TARGETURL @@ -99,7 +99,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) // and CCAFlags::TargetLocation and faAction should be represented by the same attribute OSL_ENSURE( - OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Name)).equalsAscii( + OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Name).equals( OAttributeMetaData::getFormAttributeName(faName)), "OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl: invalid attribute names (2)!"); // the same for faName, CCAFlags::Name and PROPERTY_NAME diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index de9ee4ec27a4..91bf65072359 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -235,7 +235,7 @@ namespace xmloff } } - void OPropertyExport::exportStringPropertyAttribute( const sal_uInt16 _nNamespaceKey, const char* _pAttributeName, + void OPropertyExport::exportStringPropertyAttribute( const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName, const OUString& _rPropertyName ) { DBG_CHECK_PROPERTY( _rPropertyName, OUString ); @@ -257,7 +257,7 @@ namespace xmloff exportedProperty( _rPropertyName ); } - void OPropertyExport::exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const char* _pAttributeName, + void OPropertyExport::exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName, const OUString& _rPropertyName, const BoolAttrFlags _nBooleanAttributeFlags) { DBG_CHECK_PROPERTY_NO_TYPE( _rPropertyName ); @@ -295,7 +295,7 @@ namespace xmloff exportedProperty( _rPropertyName ); } - void OPropertyExport::exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const char* _pAttributeName, + void OPropertyExport::exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName, const OUString& _rPropertyName, const sal_Int16 _nDefault, bool force) { DBG_CHECK_PROPERTY( _rPropertyName, sal_Int16 ); @@ -315,7 +315,7 @@ namespace xmloff exportedProperty( _rPropertyName ); } - void OPropertyExport::exportInt32PropertyAttribute( const sal_uInt16 _nNamespaceKey, const char* _pAttributeName, + void OPropertyExport::exportInt32PropertyAttribute( const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName, const OUString& _rPropertyName, const sal_Int32 _nDefault ) { DBG_CHECK_PROPERTY( _rPropertyName, sal_Int32 ); @@ -336,7 +336,7 @@ namespace xmloff } void OPropertyExport::exportEnumPropertyAttributeImpl( - const sal_uInt16 _nNamespaceKey, const char* _pAttributeName, + const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName, const OUString &rPropertyName, const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap, const sal_uInt16 _nDefault, const bool _bVoidDefault) { @@ -444,7 +444,7 @@ namespace xmloff } void OPropertyExport::exportGenericPropertyAttribute( - const sal_uInt16 _nAttributeNamespaceKey, const char* _pAttributeName, const char* _pPropertyName) + const sal_uInt16 _nAttributeNamespaceKey, const OUString& _pAttributeName, const char* _pPropertyName) { DBG_CHECK_PROPERTY_ASCII_NO_TYPE( _pPropertyName ); @@ -471,7 +471,7 @@ namespace xmloff AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sValue); } - void OPropertyExport::exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const char* _pAttributeName, + void OPropertyExport::exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const OUString& _pAttributeName, const OUString& _rPropertyName) { const sal_Unicode _aListSeparator = ','; @@ -628,14 +628,6 @@ namespace xmloff } #ifdef DBG_UTIL - void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, const char* _pName, const OUString& _rValue) - { - OSL_ENSURE(m_rContext.getGlobalContext().GetXAttrList()->getValueByName(OUString::createFromAscii(_pName)).isEmpty(), - "OPropertyExport::AddAttribute: already have such an attribute"); - - m_rContext.getGlobalContext().AddAttribute(_nPrefix, _pName, _rValue); - } - void OPropertyExport::AddAttribute( sal_uInt16 _nPrefix, const OUString& _rName, const OUString& _rValue ) { OSL_ENSURE(m_rContext.getGlobalContext().GetXAttrList()->getValueByName( _rName ).isEmpty(), diff --git a/xmloff/source/forms/propertyexport.hxx b/xmloff/source/forms/propertyexport.hxx index 6a972fefe818..b848ab6e47bc 100644 --- a/xmloff/source/forms/propertyexport.hxx +++ b/xmloff/source/forms/propertyexport.hxx @@ -129,7 +129,7 @@ namespace xmloff */ void exportStringPropertyAttribute( const sal_uInt16 _nNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName ); @@ -147,7 +147,7 @@ namespace xmloff */ void exportBooleanPropertyAttribute( const sal_uInt16 _nNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName, const BoolAttrFlags _nBooleanAttributeFlags); @@ -170,7 +170,7 @@ namespace xmloff */ void exportInt16PropertyAttribute( const sal_uInt16 _nNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName, const sal_Int16 _nDefault, const bool force = false); @@ -190,7 +190,7 @@ namespace xmloff */ void exportInt32PropertyAttribute( const sal_uInt16 _nNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName, const sal_Int32 _nDefault); @@ -212,7 +212,7 @@ namespace xmloff template<typename EnumT> void exportEnumPropertyAttribute( const sal_uInt16 _nNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName, const SvXMLEnumMapEntry<EnumT>* _pValueMap, const EnumT _nDefault, @@ -224,7 +224,7 @@ namespace xmloff } void exportEnumPropertyAttributeImpl( const sal_uInt16 _nNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName, const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap, const sal_uInt16 _nDefault, @@ -291,7 +291,7 @@ namespace xmloff */ void exportGenericPropertyAttribute( const sal_uInt16 _nAttributeNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const char* _pPropertyName); /** exports a property value, which is a string sequence, as attribute @@ -315,7 +315,7 @@ namespace xmloff */ void exportStringSequenceAttribute( const sal_uInt16 _nAttributeNamespaceKey, - const char* _pAttributeName, + const OUString& _pAttributeName, const OUString& _rPropertyName); /** determines whether the given property is to be exported @@ -354,14 +354,11 @@ namespace xmloff static ::xmloff::token::XMLTokenEnum implGetPropertyXMLType(const css::uno::Type& _rType); #ifdef DBG_UTIL - void AddAttribute(sal_uInt16 _nPrefix, const char* _pName, const OUString& _rValue); void AddAttribute( sal_uInt16 _nPrefix, const OUString& _rName, const OUString& _rValue ); void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const OUString& _rValue); void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, ::xmloff::token::XMLTokenEnum _eValue ); #else // in the product version, inline this, so it does not cost us extra time calling into our method - void AddAttribute(sal_uInt16 _nPrefix, const char* _pName, const OUString& _rValue) - { m_rContext.getGlobalContext().AddAttribute(_nPrefix, _pName, _rValue); } void AddAttribute( sal_uInt16 _nPrefix, const OUString& _rName, const OUString& _rValue ) { m_rContext.getGlobalContext().AddAttribute( _nPrefix, _rName, _rValue ); } void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const OUString& _rValue) |