summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-12-15 09:38:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-15 10:50:28 +0100
commita79e6a7cf1ce3be46e4339a54b013ddaa534dd39 (patch)
tree3de6cf2d804dfe0e929f999103fa1c2c01b9ec53 /dbaccess
parent15e4427e8fb56a143caa28b8a3120f3761fc77a5 (diff)
use views to parse rather than allocating OUString
Change-Id: If0a848c64ce8077d1681661873629c83307cf8b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107736 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/filter/xml/xmlColumn.cxx22
-rw-r--r--dbaccess/source/filter/xml/xmlComponent.cxx11
-rw-r--r--dbaccess/source/filter/xml/xmlConnectionResource.cxx7
-rw-r--r--dbaccess/source/filter/xml/xmlDataSource.cxx37
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceInfo.cxx4
-rw-r--r--dbaccess/source/filter/xml/xmlDataSourceSetting.cxx10
-rw-r--r--dbaccess/source/filter/xml/xmlHierarchyCollection.cxx4
-rw-r--r--dbaccess/source/filter/xml/xmlLogin.cxx11
-rw-r--r--dbaccess/source/filter/xml/xmlQuery.cxx6
9 files changed, 46 insertions, 66 deletions
diff --git a/dbaccess/source/filter/xml/xmlColumn.cxx b/dbaccess/source/filter/xml/xmlColumn.cxx
index 9d8560cf1364..198a92f76fa4 100644
--- a/dbaccess/source/filter/xml/xmlColumn.cxx
+++ b/dbaccess/source/filter/xml/xmlColumn.cxx
@@ -48,38 +48,36 @@ OXMLColumn::OXMLColumn( ODBFilter& rImport
OUString sType;
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
switch( aIter.getToken() & TOKEN_MASK )
{
case XML_NAME:
- m_sName = sValue;
+ m_sName = aIter.toString();
break;
case XML_STYLE_NAME:
- m_sStyleName = sValue;
+ m_sStyleName = aIter.toString();
break;
case XML_HELP_MESSAGE:
- m_sHelpMessage = sValue;
+ m_sHelpMessage = aIter.toString();
break;
case XML_VISIBILITY:
- m_bHidden = sValue != "visible";
+ m_bHidden = aIter.toView() != "visible";
break;
case XML_TYPE_NAME:
- sType = sValue;
+ sType = aIter.toString();
OSL_ENSURE(!sType.isEmpty(),"No type name set");
break;
case XML_DEFAULT_VALUE:
- if ( !(sValue.isEmpty() || sType.isEmpty()) )
- m_aDefaultValue <<= sValue;
+ if ( !(aIter.isEmpty() || sType.isEmpty()) )
+ m_aDefaultValue <<= aIter.toString();
break;
case XML_VISIBLE:
- m_bHidden = sValue == "false";
+ m_bHidden = aIter.toView() == "false";
break;
case XML_DEFAULT_CELL_STYLE_NAME:
- m_sCellStyleName = sValue;
+ m_sCellStyleName = aIter.toString();
break;
default:
- XMLOFF_WARN_UNKNOWN_ATTR("dbaccess", aIter.getToken(), aIter.toString());
+ XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
}
}
}
diff --git a/dbaccess/source/filter/xml/xmlComponent.cxx b/dbaccess/source/filter/xml/xmlComponent.cxx
index 144eb4ec9234..a9ba7a708842 100644
--- a/dbaccess/source/filter/xml/xmlComponent.cxx
+++ b/dbaccess/source/filter/xml/xmlComponent.cxx
@@ -44,19 +44,16 @@ OXMLComponent::OXMLComponent( ODBFilter& rImport
OUString sName;
OUString sHREF;
bool bAsTemplate(false);
- static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
switch( aIter.getToken() )
{
case XML_ELEMENT(XLINK, XML_HREF):
- sHREF = sValue;
+ sHREF = aIter.toString();
break;
case XML_ELEMENT(DB, XML_NAME):
case XML_ELEMENT(DB_OASIS, XML_NAME):
- sName = sValue;
+ sName = aIter.toString();
// sanitize the name. Previously, we allowed to create forms/reports/queries which contain
// a / in their name, which nowadays is forbidden. To not lose such objects if they're contained
// in older files, we replace the slash with something less offending.
@@ -64,10 +61,10 @@ OXMLComponent::OXMLComponent( ODBFilter& rImport
break;
case XML_ELEMENT(DB, XML_AS_TEMPLATE):
case XML_ELEMENT(DB_OASIS, XML_AS_TEMPLATE):
- bAsTemplate = sValue == s_sTRUE;
+ bAsTemplate = IsXMLToken(aIter, XML_TRUE);
break;
default:
- XMLOFF_WARN_UNKNOWN_ATTR("dbaccess", aIter.getToken(), aIter.toString());
+ XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
}
}
if ( !(!sHREF.isEmpty() && !sName.isEmpty() && _xParentContainer.is()) )
diff --git a/dbaccess/source/filter/xml/xmlConnectionResource.cxx b/dbaccess/source/filter/xml/xmlConnectionResource.cxx
index 70f7fe210415..e5d92a8d0a8e 100644
--- a/dbaccess/source/filter/xml/xmlConnectionResource.cxx
+++ b/dbaccess/source/filter/xml/xmlConnectionResource.cxx
@@ -42,7 +42,6 @@ OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport,
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
aProperty.Name.clear();
aProperty.Value = Any();
@@ -51,7 +50,7 @@ OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport,
case XML_ELEMENT(XLINK, XML_HREF):
try
{
- xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue));
+ xDataSource->setPropertyValue(PROPERTY_URL,makeAny(aIter.toString()));
}
catch(const Exception&)
{
@@ -68,12 +67,12 @@ OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport,
aProperty.Name = "Actuate";
break;
default:
- XMLOFF_WARN_UNKNOWN_ATTR("dbaccess", aIter.getToken(), aIter.toString());
+ XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
}
if ( !aProperty.Name.isEmpty() )
{
if ( !aProperty.Value.hasValue() )
- aProperty.Value <<= sValue;
+ aProperty.Value <<= aIter.toString();
rImport.addInfo(aProperty);
}
}
diff --git a/dbaccess/source/filter/xml/xmlDataSource.cxx b/dbaccess/source/filter/xml/xmlDataSource.cxx
index c179cb23ded9..e133d09cbc29 100644
--- a/dbaccess/source/filter/xml/xmlDataSource.cxx
+++ b/dbaccess/source/filter/xml/xmlDataSource.cxx
@@ -49,13 +49,10 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport,
bool bFoundAppendTableAliasName = false;
bool bFoundSuppressVersionColumns = false;
- static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
if (xDataSource.is())
{
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
aProperty.Name.clear();
aProperty.Value = Any();
@@ -64,7 +61,7 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport,
case XML_CONNECTION_RESOURCE:
try
{
- xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue));
+ xDataSource->setPropertyValue(PROPERTY_URL,makeAny(aIter.toString()));
}
catch(const Exception&)
{
@@ -74,7 +71,7 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport,
case XML_SUPPRESS_VERSION_COLUMNS:
try
{
- xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(sValue == s_sTRUE));
+ xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(IsXMLToken(aIter, XML_TRUE)));
bFoundSuppressVersionColumns = true;
}
catch(const Exception&)
@@ -90,15 +87,15 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport,
break;
case XML_IS_FIRST_ROW_HEADER_LINE:
aProperty.Name = INFO_TEXTFILEHEADER;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
break;
case XML_SHOW_DELETED:
aProperty.Name = INFO_SHOWDELETEDROWS;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
break;
case XML_IS_TABLE_NAME_LENGTH_LIMITED:
aProperty.Name = INFO_ALLOWLONGTABLENAMES;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
bFoundTableNameLengthLimited = true;
break;
case XML_SYSTEM_DRIVER_SETTINGS:
@@ -106,54 +103,54 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport,
break;
case XML_ENABLE_SQL92_CHECK:
aProperty.Name = PROPERTY_ENABLESQL92CHECK;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
break;
case XML_APPEND_TABLE_ALIAS_NAME:
aProperty.Name = INFO_APPEND_TABLE_ALIAS;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
bFoundAppendTableAliasName = true;
break;
case XML_PARAMETER_NAME_SUBSTITUTION:
aProperty.Name = INFO_PARAMETERNAMESUBST;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
bFoundParamNameSubstitution = true;
break;
case XML_IGNORE_DRIVER_PRIVILEGES:
aProperty.Name = INFO_IGNOREDRIVER_PRIV;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
break;
case XML_BOOLEAN_COMPARISON_MODE:
aProperty.Name = PROPERTY_BOOLEANCOMPARISONMODE;
- if ( sValue == "equal-integer" )
+ if ( aIter.toView() == "equal-integer" )
aProperty.Value <<= sal_Int32(0);
- else if ( sValue == "is-boolean" )
+ else if ( aIter.toView() == "is-boolean" )
aProperty.Value <<= sal_Int32(1);
- else if ( sValue == "equal-boolean" )
+ else if ( aIter.toView() == "equal-boolean" )
aProperty.Value <<= sal_Int32(2);
- else if ( sValue == "equal-use-only-zero" )
+ else if ( aIter.toView() == "equal-use-only-zero" )
aProperty.Value <<= sal_Int32(3);
break;
case XML_USE_CATALOG:
aProperty.Name = INFO_USECATALOG;
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
break;
case XML_BASE_DN:
aProperty.Name = INFO_CONN_LDAP_BASEDN;
break;
case XML_MAX_ROW_COUNT:
aProperty.Name = INFO_CONN_LDAP_ROWCOUNT;
- aProperty.Value <<= sValue.toInt32();
+ aProperty.Value <<= aIter.toInt32();
break;
case XML_JAVA_CLASSPATH:
aProperty.Name = "JavaDriverClassPath";
break;
default:
- XMLOFF_WARN_UNKNOWN_ATTR("dbaccess", aIter.getToken(), aIter.toString());
+ XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
}
if ( !aProperty.Name.isEmpty() )
{
if ( !aProperty.Value.hasValue() )
- aProperty.Value <<= sValue;
+ aProperty.Value <<= aIter.toString();
rImport.addInfo(aProperty);
}
}
diff --git a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx
index ec1a42d6e9af..e7362ca5ba77 100644
--- a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx
+++ b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx
@@ -39,8 +39,6 @@ OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport
bool bFoundField = false,bFoundThousand = false, bFoundCharset = false;
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
aProperty.Name.clear();
switch( aIter.getToken() & TOKEN_MASK )
@@ -76,7 +74,7 @@ OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport
}
if ( !aProperty.Name.isEmpty() )
{
- aProperty.Value <<= sValue;
+ aProperty.Value <<= aIter.toString();
rImport.addInfo(aProperty);
}
}
diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
index f709757a5f7d..525162664865 100644
--- a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
+++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
@@ -47,12 +47,10 @@ OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
switch( aIter.getToken() & TOKEN_MASK )
{
case XML_DATA_SOURCE_SETTING_IS_LIST:
- m_bIsList = sValue == "true";
+ m_bIsList = aIter.toView() == "true";
break;
case XML_DATA_SOURCE_SETTING_TYPE:
{
@@ -71,17 +69,17 @@ OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport
return tmp;
}();
- const std::map< OUString, css::uno::Type >::const_iterator aTypePos = s_aTypeNameMap.find(sValue);
+ const std::map< OUString, css::uno::Type >::const_iterator aTypePos = s_aTypeNameMap.find(aIter.toString());
OSL_ENSURE(s_aTypeNameMap.end() != aTypePos, "OXMLDataSourceSetting::OXMLDataSourceSetting: invalid type!");
if (s_aTypeNameMap.end() != aTypePos)
m_aPropType = aTypePos->second;
}
break;
case XML_DATA_SOURCE_SETTING_NAME:
- m_aSetting.Name = sValue;
+ m_aSetting.Name = aIter.toString();
break;
default:
- XMLOFF_WARN_UNKNOWN_ATTR("dbaccess", aIter.getToken(), aIter.toString());
+ XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
}
}
diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx
index 7b2a8cc54e6b..879575482b54 100644
--- a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx
+++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx
@@ -50,12 +50,10 @@ OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport
OUString sName;
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
switch( aIter.getToken() & TOKEN_MASK )
{
case XML_NAME:
- sName = sValue;
+ sName = aIter.toString();
break;
default:
XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
diff --git a/dbaccess/source/filter/xml/xmlLogin.cxx b/dbaccess/source/filter/xml/xmlLogin.cxx
index a30988098595..cc7502301233 100644
--- a/dbaccess/source/filter/xml/xmlLogin.cxx
+++ b/dbaccess/source/filter/xml/xmlLogin.cxx
@@ -36,15 +36,12 @@ OXMLLogin::OXMLLogin( ODBFilter& rImport,
{
Reference<XPropertySet> xDataSource(rImport.getDataSource());
- static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
bool bUserFound = false;
if (!xDataSource.is())
return;
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
try
{
switch( aIter.getToken() & TOKEN_MASK )
@@ -55,7 +52,7 @@ OXMLLogin::OXMLLogin( ODBFilter& rImport,
bUserFound = true;
try
{
- xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue));
+ xDataSource->setPropertyValue(PROPERTY_USER,makeAny(aIter.toString()));
}
catch(const Exception&)
{
@@ -66,7 +63,7 @@ OXMLLogin::OXMLLogin( ODBFilter& rImport,
case XML_IS_PASSWORD_REQUIRED:
try
{
- xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny(sValue == s_sTRUE));
+ xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny(IsXMLToken(aIter, XML_TRUE)));
}
catch(const Exception&)
{
@@ -79,14 +76,14 @@ OXMLLogin::OXMLLogin( ODBFilter& rImport,
bUserFound = true;
PropertyValue aProperty;
aProperty.Name = "UseSystemUser";
- aProperty.Value <<= (sValue == s_sTRUE);
+ aProperty.Value <<= IsXMLToken(aIter, XML_TRUE);
rImport.addInfo(aProperty);
}
break;
case XML_LOGIN_TIMEOUT:
try
{
- Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(sValue.toInt32());
+ Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(aIter.toInt32());
}
catch(const Exception&)
{
diff --git a/dbaccess/source/filter/xml/xmlQuery.cxx b/dbaccess/source/filter/xml/xmlQuery.cxx
index 722e650c3b58..8f91145d72e9 100644
--- a/dbaccess/source/filter/xml/xmlQuery.cxx
+++ b/dbaccess/source/filter/xml/xmlQuery.cxx
@@ -44,15 +44,13 @@ OXMLQuery::OXMLQuery( ODBFilter& rImport
{
for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
{
- OUString sValue = aIter.toString();
-
switch( aIter.getToken() & TOKEN_MASK )
{
case XML_COMMAND:
- m_sCommand = sValue;
+ m_sCommand = aIter.toString();
break;
case XML_ESCAPE_PROCESSING:
- m_bEscapeProcessing = sValue == "true";
+ m_bEscapeProcessing = aIter.toView() == "true";
break;
default:
XMLOFF_WARN_UNKNOWN("dbaccess", aIter);