diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-12 20:11:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-13 13:34:15 +0100 |
commit | db6c54b2e93d1cc5c02e7db7b1841fabbc3ef950 (patch) | |
tree | 702b0735606f94719d11ab015fc19aea86b92ec2 /dbaccess | |
parent | 09597ab01d22820137ada0dc08b5a9bf481468a8 (diff) |
convert dbaccess to FastParser APIs
Noting that I use "& TOKEN_MASK" a lot because we can be dealing with
either NAMESPACE_DB or NAMESPACE_DB_OASIS.
Change-Id: I5ca0aac61e37dc903bb998a43b73b48df22e55fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86655
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
41 files changed, 653 insertions, 1104 deletions
diff --git a/dbaccess/source/filter/xml/xmlColumn.cxx b/dbaccess/source/filter/xml/xmlColumn.cxx index fc90f490179c..91dc85582883 100644 --- a/dbaccess/source/filter/xml/xmlColumn.cxx +++ b/dbaccess/source/filter/xml/xmlColumn.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XChild.hpp> #include "xmlStyleImport.hxx" +#include <sal/log.hxx> namespace dbaxml { @@ -42,59 +43,52 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLColumn::OXMLColumn( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XFastAttributeList > & _xAttrList ,const Reference< XNameAccess >& _xParentContainer ,const Reference< XPropertySet >& _xTable ) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + SvXMLImportContext( rImport ) ,m_xParentContainer(_xParentContainer) ,m_xTable(_xTable) ,m_bHidden(false) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetColumnElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; OUString sType; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_COLUMN_NAME: + case XML_NAME: m_sName = sValue; break; - case XML_TOK_COLUMN_STYLE_NAME: + case XML_STYLE_NAME: m_sStyleName = sValue; break; - case XML_TOK_COLUMN_HELP_MESSAGE: + case XML_HELP_MESSAGE: m_sHelpMessage = sValue; break; - case XML_TOK_COLUMN_VISIBILITY: + case XML_VISIBILITY: m_bHidden = sValue != "visible"; break; - case XML_TOK_COLUMN_TYPE_NAME: + case XML_TYPE_NAME: sType = sValue; OSL_ENSURE(!sType.isEmpty(),"No type name set"); break; - case XML_TOK_COLUMN_DEFAULT_VALUE: + case XML_DEFAULT_VALUE: if ( !(sValue.isEmpty() || sType.isEmpty()) ) m_aDefaultValue <<= sValue; break; - case XML_TOK_COLUMN_VISIBLE: + case XML_VISIBLE: m_bHidden = sValue == "false"; break; - case XML_TOK_DEFAULT_CELL_STYLE_NAME: + case XML_DEFAULT_CELL_STYLE_NAME: m_sCellStyleName = sValue; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } } @@ -104,7 +98,7 @@ OXMLColumn::~OXMLColumn() } -void OXMLColumn::EndElement() +void OXMLColumn::endFastElement(sal_Int32 ) { Reference<XDataDescriptorFactory> xFac(m_xParentContainer,UNO_QUERY); if ( xFac.is() && !m_sName.isEmpty() ) diff --git a/dbaccess/source/filter/xml/xmlColumn.hxx b/dbaccess/source/filter/xml/xmlColumn.hxx index 7b319fa4766c..cc242a905fc2 100644 --- a/dbaccess/source/filter/xml/xmlColumn.hxx +++ b/dbaccess/source/filter/xml/xmlColumn.hxx @@ -42,14 +42,14 @@ namespace dbaxml public: OXMLColumn( ODBFilter& rImport - , sal_uInt16 nPrfx - ,const OUString& rLName - ,const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ,const css::uno::Reference< css::beans::XPropertySet >& _xTable ); virtual ~OXMLColumn() override; - virtual void EndElement() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlComponent.cxx b/dbaccess/source/filter/xml/xmlComponent.cxx index 7db3101b679d..dde08cd1fe23 100644 --- a/dbaccess/source/filter/xml/xmlComponent.cxx +++ b/dbaccess/source/filter/xml/xmlComponent.cxx @@ -39,44 +39,39 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLComponent::OXMLComponent( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XFastAttributeList > & _xAttrList ,const Reference< XNameAccess >& _xParentContainer ,const OUString& _sComponentServiceName ) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + SvXMLImportContext( rImport ) ,m_bAsTemplate(false) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() ) { - case XML_TOK_HREF: + case XML_ELEMENT(XLINK, XML_HREF): m_sHREF = sValue; break; - case XML_TOK_COMPONENT_NAME: + case XML_ELEMENT(DB, XML_NAME): + case XML_ELEMENT(DB_OASIS, XML_NAME): m_sName = sValue; // 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. m_sName = m_sName.replace( '/', '_' ); break; - case XML_TOK_AS_TEMPLATE: + case XML_ELEMENT(DB, XML_AS_TEMPLATE): + case XML_ELEMENT(DB_OASIS, XML_AS_TEMPLATE): m_bAsTemplate = sValue == s_sTRUE; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } if ( !m_sHREF.isEmpty() && !m_sName.isEmpty() && _xParentContainer.is() ) diff --git a/dbaccess/source/filter/xml/xmlComponent.hxx b/dbaccess/source/filter/xml/xmlComponent.hxx index cd78d501eca7..5cee3a2c381c 100644 --- a/dbaccess/source/filter/xml/xmlComponent.hxx +++ b/dbaccess/source/filter/xml/xmlComponent.hxx @@ -34,12 +34,12 @@ namespace dbaxml public: OXMLComponent( ODBFilter& rImport - , sal_uInt16 nPrfx - ,const OUString& rLName - ,const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ,const OUString& _sComponentServiceName ); + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual ~OXMLComponent() override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlConnectionData.cxx b/dbaccess/source/filter/xml/xmlConnectionData.cxx index ddef531688c2..c99853543dfb 100644 --- a/dbaccess/source/filter/xml/xmlConnectionData.cxx +++ b/dbaccess/source/filter/xml/xmlConnectionData.cxx @@ -36,9 +36,8 @@ namespace dbaxml using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; -OXMLConnectionData::OXMLConnectionData( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) +OXMLConnectionData::OXMLConnectionData( ODBFilter& rImport) : + SvXMLImportContext( rImport ) ,m_bFoundOne(false) { rImport.setNewFormat(true); @@ -49,37 +48,34 @@ OXMLConnectionData::~OXMLConnectionData() } -SvXMLImportContextRef OXMLConnectionData::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLConnectionData::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_LOGIN: + case XML_LOGIN: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLLogin( GetOwnImport(), nPrefix, rLocalName,xAttrList ); + pContext = new OXMLLogin( GetOwnImport(), xAttrList ); break; - case XML_TOK_DATABASE_DESCRIPTION: + case XML_DATABASE_DESCRIPTION: if ( !m_bFoundOne ) { m_bFoundOne = true; GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDatabaseDescription( GetOwnImport(), nPrefix, rLocalName); + pContext = new OXMLDatabaseDescription( GetOwnImport() ); } break; - case XML_TOK_CONNECTION_RESOURCE: + case XML_CONNECTION_RESOURCE: if ( !m_bFoundOne ) { m_bFoundOne = true; GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLConnectionResource( GetOwnImport(), nPrefix, rLocalName,xAttrList ); + pContext = new OXMLConnectionResource( GetOwnImport(), xAttrList ); } break; - case XML_TOK_COMPOUND_DATABASE: + case XML_COMPOUND_DATABASE: if ( !m_bFoundOne ) { m_bFoundOne = true; diff --git a/dbaccess/source/filter/xml/xmlConnectionData.hxx b/dbaccess/source/filter/xml/xmlConnectionData.hxx index 57d0c07ef9fa..20c552e42fec 100644 --- a/dbaccess/source/filter/xml/xmlConnectionData.hxx +++ b/dbaccess/source/filter/xml/xmlConnectionData.hxx @@ -33,13 +33,13 @@ namespace dbaxml ODBFilter& GetOwnImport(); public: - OXMLConnectionData( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName); + OXMLConnectionData( ODBFilter& rImport ); virtual ~OXMLConnectionData() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlConnectionResource.cxx b/dbaccess/source/filter/xml/xmlConnectionResource.cxx index b1e7e36b6dd8..744345b4c7f9 100644 --- a/dbaccess/source/filter/xml/xmlConnectionResource.cxx +++ b/dbaccess/source/filter/xml/xmlConnectionResource.cxx @@ -34,57 +34,53 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName, - const Reference< XAttributeList > & _xAttrList) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + const Reference< XFastAttributeList > & _xAttrList) : + SvXMLImportContext( rImport ) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap(); - Reference<XPropertySet> xDataSource = rImport.getDataSource(); PropertyValue aProperty; - const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; - for(sal_Int16 i = 0; i < nLength; ++i) + if (xDataSource.is()) { - OUString sLocalName; - const OUString sAttrName = _xAttrList->getNameByIndex( i ); - const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - const OUString sValue = _xAttrList->getValueByIndex( i ); - - aProperty.Name.clear(); - aProperty.Value = Any(); - - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - case XML_TOK_HREF: - try - { - xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue)); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } - break; - case XML_TOK_TYPE: - aProperty.Name = PROPERTY_TYPE; - break; - case XML_TOK_SHOW: - aProperty.Name = "Show"; - break; - case XML_TOK_ACTUATE: - aProperty.Name = "Actuate"; - break; - } - if ( !aProperty.Name.isEmpty() ) - { - if ( !aProperty.Value.hasValue() ) - aProperty.Value <<= sValue; - rImport.addInfo(aProperty); + OUString sValue = aIter.toString(); + aProperty.Name.clear(); + aProperty.Value = Any(); + + switch( aIter.getToken() ) + { + case XML_ELEMENT(XLINK, XML_HREF): + try + { + xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue)); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } + break; + case XML_ELEMENT(XLINK, XML_TYPE): + aProperty.Name = PROPERTY_TYPE; + break; + case XML_ELEMENT(XLINK, XML_SHOW): + aProperty.Name = "Show"; + break; + case XML_ELEMENT(XLINK, XML_ACTUATE): + aProperty.Name = "Actuate"; + break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); + } + if ( !aProperty.Name.isEmpty() ) + { + if ( !aProperty.Value.hasValue() ) + aProperty.Value <<= sValue; + rImport.addInfo(aProperty); + } } } } diff --git a/dbaccess/source/filter/xml/xmlConnectionResource.hxx b/dbaccess/source/filter/xml/xmlConnectionResource.hxx index d5effa9e65fd..7b2bb478f0c4 100644 --- a/dbaccess/source/filter/xml/xmlConnectionResource.hxx +++ b/dbaccess/source/filter/xml/xmlConnectionResource.hxx @@ -30,9 +30,10 @@ namespace dbaxml { public: - OXMLConnectionResource( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList); + OXMLConnectionResource( ODBFilter& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ); + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual ~OXMLConnectionResource() override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlDataSource.cxx b/dbaccess/source/filter/xml/xmlDataSource.cxx index aad160ee9bae..6044ed9d6a34 100644 --- a/dbaccess/source/filter/xml/xmlDataSource.cxx +++ b/dbaccess/source/filter/xml/xmlDataSource.cxx @@ -41,15 +41,11 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLDataSource::OXMLDataSource( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName, - const Reference< XAttributeList > & _xAttrList, const UsedFor _eUsedFor ) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + const css::uno::Reference< css::xml::sax::XFastAttributeList >& _xAttrList, + const UsedFor _eUsedFor ) : + SvXMLImportContext( rImport ) { - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap(); - Reference<XPropertySet> xDataSource = rImport.getDataSource(); PropertyValue aProperty; @@ -58,112 +54,115 @@ OXMLDataSource::OXMLDataSource( ODBFilter& rImport, bool bFoundAppendTableAliasName = false; bool bFoundSuppressVersionColumns = false; - const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); - for(sal_Int16 i = 0; i < nLength; ++i) + if (xDataSource.is()) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) + { + OUString sValue = aIter.toString(); - aProperty.Name.clear(); - aProperty.Value = Any(); + aProperty.Name.clear(); + aProperty.Value = Any(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) - { - case XML_TOK_CONNECTION_RESOURCE: - try - { - xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue)); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } - break; - case XML_TOK_SUPPRESS_VERSION_COLUMNS: - try - { - xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(sValue == s_sTRUE)); - bFoundSuppressVersionColumns = true; - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } - break; - case XML_TOK_JAVA_DRIVER_CLASS: - aProperty.Name = INFO_JDBCDRIVERCLASS; - break; - case XML_TOK_EXTENSION: - aProperty.Name = INFO_TEXTFILEEXTENSION; - break; - case XML_TOK_IS_FIRST_ROW_HEADER_LINE: - aProperty.Name = INFO_TEXTFILEHEADER; - aProperty.Value <<= (sValue == s_sTRUE); - break; - case XML_TOK_SHOW_DELETED: - aProperty.Name = INFO_SHOWDELETEDROWS; - aProperty.Value <<= (sValue == s_sTRUE); - break; - case XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED: - aProperty.Name = INFO_ALLOWLONGTABLENAMES; - aProperty.Value <<= (sValue == s_sTRUE); - bFoundTableNameLengthLimited = true; - break; - case XML_TOK_SYSTEM_DRIVER_SETTINGS: - aProperty.Name = INFO_ADDITIONALOPTIONS; - break; - case XML_TOK_ENABLE_SQL92_CHECK: - aProperty.Name = PROPERTY_ENABLESQL92CHECK; - aProperty.Value <<= (sValue == s_sTRUE); - break; - case XML_TOK_APPEND_TABLE_ALIAS_NAME: - aProperty.Name = INFO_APPEND_TABLE_ALIAS; - aProperty.Value <<= (sValue == s_sTRUE); - bFoundAppendTableAliasName = true; - break; - case XML_TOK_PARAMETER_NAME_SUBSTITUTION: - aProperty.Name = INFO_PARAMETERNAMESUBST; - aProperty.Value <<= (sValue == s_sTRUE); - bFoundParamNameSubstitution = true; - break; - case XML_TOK_IGNORE_DRIVER_PRIVILEGES: - aProperty.Name = INFO_IGNOREDRIVER_PRIV; - aProperty.Value <<= (sValue == s_sTRUE); - break; - case XML_TOK_BOOLEAN_COMPARISON_MODE: - aProperty.Name = PROPERTY_BOOLEANCOMPARISONMODE; - if ( sValue == "equal-integer" ) - aProperty.Value <<= sal_Int32(0); - else if ( sValue == "is-boolean" ) - aProperty.Value <<= sal_Int32(1); - else if ( sValue == "equal-boolean" ) - aProperty.Value <<= sal_Int32(2); - else if ( sValue == "equal-use-only-zero" ) - aProperty.Value <<= sal_Int32(3); - break; - case XML_TOK_USE_CATALOG: - aProperty.Name = INFO_USECATALOG; - aProperty.Value <<= (sValue == s_sTRUE); - break; - case XML_TOK_BASE_DN: - aProperty.Name = INFO_CONN_LDAP_BASEDN; - break; - case XML_TOK_MAX_ROW_COUNT: - aProperty.Name = INFO_CONN_LDAP_ROWCOUNT; - aProperty.Value <<= sValue.toInt32(); - break; - case XML_TOK_JAVA_CLASSPATH: - aProperty.Name = "JavaDriverClassPath"; - break; - } - if ( !aProperty.Name.isEmpty() ) - { - if ( !aProperty.Value.hasValue() ) - aProperty.Value <<= sValue; - rImport.addInfo(aProperty); + switch( aIter.getToken() & TOKEN_MASK ) + { + case XML_CONNECTION_RESOURCE: + try + { + xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue)); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } + break; + case XML_SUPPRESS_VERSION_COLUMNS: + try + { + xDataSource->setPropertyValue(PROPERTY_SUPPRESSVERSIONCL,makeAny(sValue == s_sTRUE)); + bFoundSuppressVersionColumns = true; + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } + break; + case XML_JAVA_DRIVER_CLASS: + aProperty.Name = INFO_JDBCDRIVERCLASS; + break; + case XML_EXTENSION: + aProperty.Name = INFO_TEXTFILEEXTENSION; + break; + case XML_IS_FIRST_ROW_HEADER_LINE: + aProperty.Name = INFO_TEXTFILEHEADER; + aProperty.Value <<= (sValue == s_sTRUE); + break; + case XML_SHOW_DELETED: + aProperty.Name = INFO_SHOWDELETEDROWS; + aProperty.Value <<= (sValue == s_sTRUE); + break; + case XML_IS_TABLE_NAME_LENGTH_LIMITED: + aProperty.Name = INFO_ALLOWLONGTABLENAMES; + aProperty.Value <<= (sValue == s_sTRUE); + bFoundTableNameLengthLimited = true; + break; + case XML_SYSTEM_DRIVER_SETTINGS: + aProperty.Name = INFO_ADDITIONALOPTIONS; + break; + case XML_ENABLE_SQL92_CHECK: + aProperty.Name = PROPERTY_ENABLESQL92CHECK; + aProperty.Value <<= (sValue == s_sTRUE); + break; + case XML_APPEND_TABLE_ALIAS_NAME: + aProperty.Name = INFO_APPEND_TABLE_ALIAS; + aProperty.Value <<= (sValue == s_sTRUE); + bFoundAppendTableAliasName = true; + break; + case XML_PARAMETER_NAME_SUBSTITUTION: + aProperty.Name = INFO_PARAMETERNAMESUBST; + aProperty.Value <<= (sValue == s_sTRUE); + bFoundParamNameSubstitution = true; + break; + case XML_IGNORE_DRIVER_PRIVILEGES: + aProperty.Name = INFO_IGNOREDRIVER_PRIV; + aProperty.Value <<= (sValue == s_sTRUE); + break; + case XML_BOOLEAN_COMPARISON_MODE: + aProperty.Name = PROPERTY_BOOLEANCOMPARISONMODE; + if ( sValue == "equal-integer" ) + aProperty.Value <<= sal_Int32(0); + else if ( sValue == "is-boolean" ) + aProperty.Value <<= sal_Int32(1); + else if ( sValue == "equal-boolean" ) + aProperty.Value <<= sal_Int32(2); + else if ( sValue == "equal-use-only-zero" ) + aProperty.Value <<= sal_Int32(3); + break; + case XML_USE_CATALOG: + aProperty.Name = INFO_USECATALOG; + aProperty.Value <<= (sValue == s_sTRUE); + 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(); + break; + case XML_JAVA_CLASSPATH: + aProperty.Name = "JavaDriverClassPath"; + break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); + } + if ( !aProperty.Name.isEmpty() ) + { + if ( !aProperty.Value.hasValue() ) + aProperty.Value <<= sValue; + rImport.addInfo(aProperty); + } } } if ( rImport.isNewFormat() ) @@ -205,50 +204,48 @@ OXMLDataSource::~OXMLDataSource() } -SvXMLImportContextRef OXMLDataSource::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDataSource::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceElemTokenMap(); - const sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); - switch( nToken ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_LOGIN: + case XML_LOGIN: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLLogin( GetOwnImport(), nPrefix, rLocalName,xAttrList ); + pContext = new OXMLLogin( GetOwnImport(), xAttrList ); break; - case XML_TOK_TABLE_FILTER: - case XML_TOK_TABLE_TYPE_FILTER: + case XML_TABLE_FILTER: + case XML_TABLE_TYPE_FILTER: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName ); + pContext = new OXMLTableFilterList( GetImport() ); break; - case XML_TOK_AUTO_INCREMENT: - case XML_TOK_DELIMITER: - case XML_TOK_FONT_CHARSET: - case XML_TOK_CHARACTER_SET: + case XML_AUTO_INCREMENT: + case XML_DELIMITER: + case XML_FONT_CHARSET: + case XML_CHARACTER_SET: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSourceInfo( GetOwnImport(), nPrefix, rLocalName,xAttrList,nToken); + pContext = new OXMLDataSourceInfo( GetOwnImport(), nElement, xAttrList ); break; - case XML_TOK_DATA_SOURCE_SETTINGS: + case XML_DATA_SOURCE_SETTINGS: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSourceSettings( GetOwnImport(), nPrefix, rLocalName); + pContext = new OXMLDataSourceSettings( GetOwnImport() ); break; - case XML_TOK_CONNECTION_DATA: + case XML_CONNECTION_DATA: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLConnectionData( GetOwnImport(), nPrefix, rLocalName); + pContext = new OXMLConnectionData( GetOwnImport() ); break; - case XML_TOK_DRIVER_SETTINGS: + case XML_DRIVER_SETTINGS: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDriverSettings ); + pContext = new OXMLDataSource( GetOwnImport(), xAttrList, OXMLDataSource::eDriverSettings ); break; - case XML_TOK_APPLICATION_CONNECTION_SETTINGS: + case XML_APPLICATION_CONNECTION_SETTINGS: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eAppSettings ); + pContext = new OXMLDataSource( GetOwnImport(), xAttrList, OXMLDataSource::eAppSettings ); break; + default: + SAL_WARN("dbaccess", "unknown element " << nElement); } return pContext; diff --git a/dbaccess/source/filter/xml/xmlDataSource.hxx b/dbaccess/source/filter/xml/xmlDataSource.hxx index f78b408c5f2e..4b0ba10c900d 100644 --- a/dbaccess/source/filter/xml/xmlDataSource.hxx +++ b/dbaccess/source/filter/xml/xmlDataSource.hxx @@ -37,15 +37,15 @@ namespace dbaxml eAppSettings }; - OXMLDataSource( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, + OXMLDataSource( ODBFilter& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& _xAttrList, const UsedFor _eUsedFor ); virtual ~OXMLDataSource() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx index 5cf4ee184ed5..75e50335dba1 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx +++ b/dbaccess/source/filter/xml/xmlDataSourceInfo.cxx @@ -28,6 +28,7 @@ #include <strings.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <vector> +#include <sal/log.hxx> namespace dbaxml { @@ -35,59 +36,51 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const Reference< XAttributeList > & _xAttrList - ,const sal_uInt16 _nToken) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + ,sal_Int32 nElement + ,const Reference< XFastAttributeList > & _xAttrList) : + SvXMLImportContext( rImport ) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceInfoElemTokenMap(); - PropertyValue aProperty; - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; bool bAutoEnabled = false; bool bFoundField = false,bFoundThousand = false, bFoundCharset = false; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); aProperty.Name.clear(); - sal_uInt16 nToken = rTokenMap.Get( nPrefix, sLocalName ); - switch( nToken ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_ADDITIONAL_COLUMN_STATEMENT: + case XML_ADDITIONAL_COLUMN_STATEMENT: aProperty.Name = PROPERTY_AUTOINCREMENTCREATION; bAutoEnabled = true; break; - case XML_TOK_ROW_RETRIEVING_STATEMENT: + case XML_ROW_RETRIEVING_STATEMENT: aProperty.Name = INFO_AUTORETRIEVEVALUE; bAutoEnabled = true; break; - case XML_TOK_STRING: + case XML_STRING: aProperty.Name = INFO_TEXTDELIMITER; break; - case XML_TOK_FIELD: + case XML_FIELD: aProperty.Name = INFO_FIELDDELIMITER; bFoundField = true; break; - case XML_TOK_DECIMAL: + case XML_DECIMAL: aProperty.Name = INFO_DECIMALDELIMITER; break; - case XML_TOK_THOUSAND: + case XML_THOUSAND: aProperty.Name = INFO_THOUSANDSDELIMITER; bFoundThousand = true; break; - case XML_TOK_ENCODING: + case XML_ENCODING: aProperty.Name = INFO_CHARSET; bFoundCharset = true; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } if ( !aProperty.Name.isEmpty() ) { @@ -103,7 +96,7 @@ OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport } if ( rImport.isNewFormat() ) { - if ( XML_TOK_DELIMITER == _nToken ) + if ( (nElement & TOKEN_MASK) == XML_DELIMITER ) { if ( !bFoundField ) { @@ -118,7 +111,7 @@ OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport rImport.addInfo(aProperty); } } - if ( XML_TOK_FONT_CHARSET == _nToken && !bFoundCharset ) + if ( (nElement & TOKEN_MASK) == XML_FONT_CHARSET && !bFoundCharset ) { aProperty.Name = INFO_CHARSET; aProperty.Value <<= OUString("utf8"); diff --git a/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx b/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx index 1d76aca40017..b0f617a53dc8 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx +++ b/dbaccess/source/filter/xml/xmlDataSourceInfo.hxx @@ -28,10 +28,11 @@ namespace dbaxml { public: - OXMLDataSourceInfo( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList - ,const sal_uInt16 _nToken); + OXMLDataSourceInfo( ODBFilter& rImport, + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList); + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual ~OXMLDataSourceInfo() override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx index a874f14bdffb..bd0506401f14 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx +++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx @@ -40,35 +40,27 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XFastAttributeList > & _xAttrList ,OXMLDataSourceSetting* _pContainer) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + SvXMLImportContext( rImport ) ,m_pContainer(_pContainer) ,m_bIsList(false) { m_aPropType = cppu::UnoType<void>::get(); - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceInfoElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_DATA_SOURCE_SETTING_IS_LIST: + case XML_DATA_SOURCE_SETTING_IS_LIST: m_bIsList = sValue == "true"; break; - case XML_TOK_DATA_SOURCE_SETTING_TYPE: + case XML_DATA_SOURCE_SETTING_TYPE: { // needs to be translated into a css::uno::Type static std::map< OUString, css::uno::Type > s_aTypeNameMap = [&]() @@ -91,9 +83,11 @@ OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport m_aPropType = aTypePos->second; } break; - case XML_TOK_DATA_SOURCE_SETTING_NAME: + case XML_DATA_SOURCE_SETTING_NAME: m_aSetting.Name = sValue; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } @@ -103,30 +97,27 @@ OXMLDataSourceSetting::~OXMLDataSourceSetting() { } -SvXMLImportContextRef OXMLDataSourceSetting::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDataSourceSetting::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceInfoElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_DATA_SOURCE_SETTING: + case XML_DATA_SOURCE_SETTING: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSourceSetting( GetOwnImport(), nPrefix, rLocalName,xAttrList); + pContext = new OXMLDataSourceSetting( GetOwnImport(), xAttrList); break; - case XML_TOK_DATA_SOURCE_SETTING_VALUE: + case XML_DATA_SOURCE_SETTING_VALUE: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSourceSetting( GetOwnImport(), nPrefix, rLocalName,xAttrList,this ); + pContext = new OXMLDataSourceSetting( GetOwnImport(), xAttrList,this ); break; } return pContext; } -void OXMLDataSourceSetting::EndElement() +void OXMLDataSourceSetting::endFastElement(sal_Int32 ) { if ( !m_aSetting.Name.isEmpty() ) { @@ -142,7 +133,7 @@ void OXMLDataSourceSetting::EndElement() } } -void OXMLDataSourceSetting::Characters( const OUString& rChars ) +void OXMLDataSourceSetting::characters( const OUString& rChars ) { if ( m_pContainer ) m_pContainer->addValue(rChars); diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx index 293a9004185b..9f28d3343c83 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx +++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.hxx @@ -38,19 +38,20 @@ namespace dbaxml static css::uno::Any convertString(const css::uno::Type& _rExpectedType, const OUString& _rReadCharacters); public: - OXMLDataSourceSetting( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + OXMLDataSourceSetting( ODBFilter& rImport + ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ,OXMLDataSourceSetting* _pContainer = nullptr); virtual ~OXMLDataSourceSetting() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; - virtual void EndElement() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} - virtual void Characters( const OUString& rChars ) override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; + + virtual void SAL_CALL characters( const OUString& rChars ) override; /** adds value to property @param _sValue diff --git a/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx b/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx index 3ff748158753..eff915c1d62a 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx +++ b/dbaccess/source/filter/xml/xmlDataSourceSettings.cxx @@ -35,10 +35,8 @@ namespace dbaxml using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; -OXMLDataSourceSettings::OXMLDataSourceSettings( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) +OXMLDataSourceSettings::OXMLDataSourceSettings( ODBFilter& rImport ) : + SvXMLImportContext( rImport ) { } @@ -48,19 +46,16 @@ OXMLDataSourceSettings::~OXMLDataSourceSettings() } -SvXMLImportContextRef OXMLDataSourceSettings::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDataSourceSettings::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDataSourceInfoElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_DATA_SOURCE_SETTING: + case XML_DATA_SOURCE_SETTING: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSourceSetting( GetOwnImport(), nPrefix, rLocalName,xAttrList); + pContext = new OXMLDataSourceSetting( GetOwnImport(), xAttrList ); break; } diff --git a/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx b/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx index 1812212479f0..27bd20435fb9 100644 --- a/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx +++ b/dbaccess/source/filter/xml/xmlDataSourceSettings.hxx @@ -29,12 +29,13 @@ namespace dbaxml ODBFilter& GetOwnImport(); public: - OXMLDataSourceSettings( ODBFilter& rImport, sal_uInt16 nPrfx,const OUString& rLName); + OXMLDataSourceSettings( ODBFilter& rImport ); virtual ~OXMLDataSourceSettings() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlDatabase.cxx b/dbaccess/source/filter/xml/xmlDatabase.cxx index d6ca6e6e1d4a..80e929e849c9 100644 --- a/dbaccess/source/filter/xml/xmlDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlDatabase.cxx @@ -40,9 +40,8 @@ namespace dbaxml using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::xml::sax; -OXMLDatabase::OXMLDatabase( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& rLName ) : - SvXMLImportContext( rImport, nPrfx, rLName ) +OXMLDatabase::OXMLDatabase( ODBFilter& rImport ) : + SvXMLImportContext( rImport ) { } @@ -52,21 +51,18 @@ OXMLDatabase::~OXMLDatabase() } -SvXMLImportContextRef OXMLDatabase::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDatabase::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_DATASOURCE: + case XML_DATASOURCE: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource ); + pContext = new OXMLDataSource( GetOwnImport(), xAttrList, OXMLDataSource::eDataSource ); break; - case XML_TOK_FORMS: + case XML_FORMS: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); Any aValue; @@ -77,11 +73,11 @@ SvXMLImportContextRef OXMLDatabase::CreateChildContext( { Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY); if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); + pContext = new OXMLDocuments( GetOwnImport(), xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); } } break; - case XML_TOK_REPORTS: + case XML_REPORTS: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); Any aValue; @@ -92,11 +88,11 @@ SvXMLImportContextRef OXMLDatabase::CreateChildContext( { Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY); if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); + pContext = new OXMLDocuments( GetOwnImport(), xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); } } break; - case XML_TOK_QUERIES: + case XML_QUERIES: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); Any aValue; @@ -107,17 +103,17 @@ SvXMLImportContextRef OXMLDatabase::CreateChildContext( { Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY); if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION); + pContext = new OXMLDocuments( GetOwnImport(), xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION); } } break; - case XML_TOK_TABLES: - case XML_TOK_SCHEMA_DEFINITION: + case XML_TABLE_REPRESENTATIONS: + case XML_SCHEMA_DEFINITION: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY); if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables()); + pContext = new OXMLDocuments( GetOwnImport(), xSup->getTables()); } break; } @@ -130,7 +126,7 @@ ODBFilter& OXMLDatabase::GetOwnImport() return static_cast<ODBFilter&>(GetImport()); } -void OXMLDatabase::EndElement() +void OXMLDatabase::endFastElement(sal_Int32) { GetOwnImport().setPropertyInfo(); } diff --git a/dbaccess/source/filter/xml/xmlDatabase.hxx b/dbaccess/source/filter/xml/xmlDatabase.hxx index 73dd1cfa8de4..d1f87c263c3d 100644 --- a/dbaccess/source/filter/xml/xmlDatabase.hxx +++ b/dbaccess/source/filter/xml/xmlDatabase.hxx @@ -24,20 +24,20 @@ namespace dbaxml { class ODBFilter; - class OXMLDatabase : public SvXMLImportContext + class OXMLDatabase final : public SvXMLImportContext { ODBFilter& GetOwnImport(); public: - OXMLDatabase( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName ); + OXMLDatabase( ODBFilter& rImport ); virtual ~OXMLDatabase() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; - virtual void EndElement() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx b/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx index 3290e3344f8e..c024d99096c1 100644 --- a/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx +++ b/dbaccess/source/filter/xml/xmlDatabaseDescription.cxx @@ -35,9 +35,8 @@ namespace dbaxml using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; -OXMLDatabaseDescription::OXMLDatabaseDescription( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) +OXMLDatabaseDescription::OXMLDatabaseDescription( ODBFilter& rImport ) : + SvXMLImportContext( rImport ) ,m_bFoundOne(false) { } @@ -47,30 +46,27 @@ OXMLDatabaseDescription::~OXMLDatabaseDescription() } -SvXMLImportContextRef OXMLDatabaseDescription::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDatabaseDescription::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseDescriptionElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_FILE_BASED_DATABASE: + case XML_FILE_BASED_DATABASE: if ( !m_bFoundOne ) { m_bFoundOne = true; GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLFileBasedDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList ); + pContext = new OXMLFileBasedDatabase( GetOwnImport(), xAttrList ); } break; - case XML_TOK_SERVER_DATABASE: + case XML_SERVER_DATABASE: if ( !m_bFoundOne ) { m_bFoundOne = true; GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLServerDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList ); + pContext = new OXMLServerDatabase( GetOwnImport(), xAttrList ); } break; } diff --git a/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx b/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx index a95f1f546901..331f98dd832c 100644 --- a/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx +++ b/dbaccess/source/filter/xml/xmlDatabaseDescription.hxx @@ -33,13 +33,13 @@ namespace dbaxml ODBFilter& GetOwnImport(); public: - OXMLDatabaseDescription( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName); + OXMLDatabaseDescription( ODBFilter& rImport); virtual ~OXMLDatabaseDescription() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlDocuments.cxx b/dbaccess/source/filter/xml/xmlDocuments.cxx index 4c58e6fada53..e5fd75d9997b 100644 --- a/dbaccess/source/filter/xml/xmlDocuments.cxx +++ b/dbaccess/source/filter/xml/xmlDocuments.cxx @@ -36,12 +36,10 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLDocuments::OXMLDocuments( ODBFilter& rImport - ,sal_uInt16 nPrfx - , const OUString& rLName ,const Reference< XNameAccess >& _xContainer ,const OUString& _sCollectionServiceName ,const OUString& _sComponentServiceName) : - SvXMLImportContext( rImport, nPrfx, rLName ) + SvXMLImportContext( rImport ) ,m_xContainer(_xContainer) ,m_sCollectionServiceName(_sCollectionServiceName) ,m_sComponentServiceName(_sComponentServiceName) @@ -50,12 +48,10 @@ OXMLDocuments::OXMLDocuments( ODBFilter& rImport } OXMLDocuments::OXMLDocuments( ODBFilter& rImport - ,sal_uInt16 nPrfx - , const OUString& rLName ,const Reference< XNameAccess >& _xContainer ,const OUString& _sCollectionServiceName ) : - SvXMLImportContext( rImport, nPrfx, rLName ) + SvXMLImportContext( rImport ) ,m_xContainer(_xContainer) ,m_sCollectionServiceName(_sCollectionServiceName) { @@ -66,31 +62,29 @@ OXMLDocuments::~OXMLDocuments() } -SvXMLImportContextRef OXMLDocuments::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLDocuments::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDocumentsElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_TABLE: + case XML_TABLE: + case XML_TABLE_REPRESENTATION: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLTable( GetOwnImport(), nPrefix, rLocalName, xAttrList, m_xContainer, "com.sun.star.sdb.TableDefinition"); + pContext = new OXMLTable( GetOwnImport(), xAttrList, m_xContainer, "com.sun.star.sdb.TableDefinition"); break; - case XML_TOK_QUERY: + case XML_QUERY: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLQuery( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer ); + pContext = new OXMLQuery( GetOwnImport(), xAttrList, m_xContainer ); break; - case XML_TOK_COMPONENT: + case XML_COMPONENT: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLComponent( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sComponentServiceName ); + pContext = new OXMLComponent( GetOwnImport(), xAttrList, m_xContainer,m_sComponentServiceName ); break; - case XML_TOK_COMPONENT_COLLECTION: + case XML_COMPONENT_COLLECTION: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName ); + pContext = new OXMLHierarchyCollection( GetOwnImport(), xAttrList, m_xContainer,m_sCollectionServiceName,m_sComponentServiceName ); break; } diff --git a/dbaccess/source/filter/xml/xmlDocuments.hxx b/dbaccess/source/filter/xml/xmlDocuments.hxx index d0141d632550..027274267650 100644 --- a/dbaccess/source/filter/xml/xmlDocuments.hxx +++ b/dbaccess/source/filter/xml/xmlDocuments.hxx @@ -38,25 +38,22 @@ namespace dbaxml // for forms and reports OXMLDocuments( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& rLName ,const css::uno::Reference< css::container::XNameAccess >& _xContainer ,const OUString& _sCollectionServiceName ,const OUString& _sComponentServiceName); // for queries OXMLDocuments( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& rLName ,const css::uno::Reference< css::container::XNameAccess >& _xContainer ,const OUString& _sCollectionServiceName = OUString() ); virtual ~OXMLDocuments() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlEnums.hxx b/dbaccess/source/filter/xml/xmlEnums.hxx index 709536443418..0a52cd22f8bd 100644 --- a/dbaccess/source/filter/xml/xmlEnums.hxx +++ b/dbaccess/source/filter/xml/xmlEnums.hxx @@ -23,12 +23,6 @@ namespace dbaxml { - enum XMLDocTokens - { - XML_TOK_DOC_SETTINGS, - XML_TOK_DOC_STYLES, - XML_TOK_DOC_CONTENT, - }; enum XMLDocContentTokens { XML_TOK_CONTENT_AUTOSTYLES, @@ -36,126 +30,6 @@ namespace dbaxml XML_TOK_CONTENT_SCRIPTS, XML_TOK_CONTENT_BODY, }; - enum XMLDatabaseToken - { - XML_TOK_DATASOURCE, - XML_TOK_FORMS, - XML_TOK_REPORTS, - XML_TOK_QUERIES, - XML_TOK_TABLES, - XML_TOK_SCHEMA_DEFINITION - }; - enum XMLDataSource - { - XML_TOK_CONNECTION_RESOURCE, - XML_TOK_SUPPRESS_VERSION_COLUMNS, - XML_TOK_JAVA_DRIVER_CLASS, - XML_TOK_EXTENSION, - XML_TOK_IS_FIRST_ROW_HEADER_LINE, - XML_TOK_SHOW_DELETED, - XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED, - XML_TOK_SYSTEM_DRIVER_SETTINGS, - XML_TOK_ENABLE_SQL92_CHECK, - XML_TOK_APPEND_TABLE_ALIAS_NAME, - XML_TOK_PARAMETER_NAME_SUBSTITUTION, - XML_TOK_IGNORE_DRIVER_PRIVILEGES, - XML_TOK_BOOLEAN_COMPARISON_MODE, - XML_TOK_USE_CATALOG, - XML_TOK_BASE_DN, - XML_TOK_MAX_ROW_COUNT, - XML_TOK_LOGIN, - XML_TOK_TABLE_FILTER, - XML_TOK_TABLE_TYPE_FILTER, - XML_TOK_AUTO_INCREMENT, - XML_TOK_DELIMITER, - XML_TOK_DATA_SOURCE_SETTINGS, - XML_TOK_FONT_CHARSET, - XML_TOK_DATABASE_DESCRIPTION, - XML_TOK_COMPOUND_DATABASE, - XML_TOK_DB_HREF, - XML_TOK_MEDIA_TYPE, - XML_TOK_DB_TYPE, - XML_TOK_HOSTNAME, - XML_TOK_PORT, - XML_TOK_LOCAL_SOCKET, - XML_TOK_DATABASE_NAME, - XML_TOK_CONNECTION_DATA, - XML_TOK_DRIVER_SETTINGS, - XML_TOK_JAVA_CLASSPATH, - XML_TOK_CHARACTER_SET, - XML_TOK_APPLICATION_CONNECTION_SETTINGS - }; - enum XMLDatabaseDescription - { - XML_TOK_FILE_BASED_DATABASE, - XML_TOK_SERVER_DATABASE - }; - enum XMLLogin - { - XML_TOK_USER_NAME, - XML_TOK_IS_PASSWORD_REQUIRED, - XML_TOK_USE_SYSTEM_USER, - XML_TOK_LOGIN_TIMEOUT - }; - enum XMLDataSourceInfo - { - XML_TOK_STRING, - XML_TOK_FIELD, - XML_TOK_DECIMAL, - XML_TOK_THOUSAND, - XML_TOK_ADDITIONAL_COLUMN_STATEMENT, - XML_TOK_ROW_RETRIEVING_STATEMENT, - XML_TOK_DATA_SOURCE_SETTING, - XML_TOK_DATA_SOURCE_SETTING_VALUE, - XML_TOK_DATA_SOURCE_SETTING_IS_LIST, - XML_TOK_DATA_SOURCE_SETTING_TYPE, - XML_TOK_DATA_SOURCE_SETTING_NAME, - XML_TOK_ENCODING, - }; - enum XMLDocuments - { - XML_TOK_COMPONENT, - XML_TOK_COMPONENT_COLLECTION, - XML_TOK_QUERY_COLLECTION, - XML_TOK_QUERY, - XML_TOK_TABLE, - XML_TOK_COLUMN - }; - enum XMLComponent - { - XML_TOK_HREF , - XML_TOK_TYPE , - XML_TOK_SHOW , - XML_TOK_ACTUATE , - XML_TOK_AS_TEMPLATE , - XML_TOK_COMPONENT_NAME - }; - enum XMLQueryTable - { - XML_TOK_QUERY_NAME, - XML_TOK_COMMAND, - XML_TOK_ESCAPE_PROCESSING, - XML_TOK_FILTER_STATEMENT, - XML_TOK_ORDER_STATEMENT, - XML_TOK_UPDATE_TABLE, - XML_TOK_CATALOG_NAME, - XML_TOK_SCHEMA_NAME, - XML_TOK_STYLE_NAME, - XML_TOK_APPLY_FILTER, - XML_TOK_APPLY_ORDER, - XML_TOK_COLUMNS - }; - enum XMLColumn - { - XML_TOK_COLUMN_NAME, - XML_TOK_COLUMN_STYLE_NAME, - XML_TOK_COLUMN_HELP_MESSAGE, - XML_TOK_COLUMN_VISIBILITY, - XML_TOK_COLUMN_DEFAULT_VALUE, - XML_TOK_COLUMN_TYPE_NAME, - XML_TOK_COLUMN_VISIBLE, - XML_TOK_DEFAULT_CELL_STYLE_NAME - }; } // namespace dbaxml #endif // INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLENUMS_HXX diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx index e81ab45933f3..b4aa35af4a87 100644 --- a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx @@ -36,63 +36,62 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLFileBasedDatabase::OXMLFileBasedDatabase( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName, - const Reference< XAttributeList > & _xAttrList) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + const Reference< XFastAttributeList > & _xAttrList) : + SvXMLImportContext( rImport ) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap(); - Reference<XPropertySet> xDataSource = rImport.getDataSource(); PropertyValue aProperty; - const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; OUString sLocation,sMediaType,sFileTypeExtension; - for(sal_Int16 i = 0; i < nLength; ++i) + if (xDataSource.is()) { - OUString sLocalName; - const OUString sAttrName = _xAttrList->getNameByIndex( i ); - const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - const OUString sValue = _xAttrList->getValueByIndex( i ); + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) + { + OUString sValue = aIter.toString(); - aProperty.Name.clear(); - aProperty.Value = Any(); + aProperty.Name.clear(); + aProperty.Value = Any(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) - { - case XML_TOK_DB_HREF: - { - SvtPathOptions aPathOptions; - OUString sFileName = aPathOptions.SubstituteVariable(sValue); - if ( sValue == sFileName ) + switch( aIter.getToken() ) + { + case XML_ELEMENT(XLINK, XML_HREF): { - const sal_Int32 nFileNameLength = sFileName.getLength(); - if ( sFileName.endsWith("/") ) - sFileName = sFileName.copy( 0, nFileNameLength - 1 ); + SvtPathOptions aPathOptions; + OUString sFileName = aPathOptions.SubstituteVariable(sValue); + if ( sValue == sFileName ) + { + const sal_Int32 nFileNameLength = sFileName.getLength(); + if ( sFileName.endsWith("/") ) + sFileName = sFileName.copy( 0, nFileNameLength - 1 ); - sLocation = ::svt::OFileNotation( rImport.GetAbsoluteReference( sFileName ) ).get( ::svt::OFileNotation::N_SYSTEM ); - } + sLocation = ::svt::OFileNotation( rImport.GetAbsoluteReference( sFileName ) ).get( ::svt::OFileNotation::N_SYSTEM ); + } - if ( sLocation.isEmpty() ) - sLocation = sValue; - } - break; - case XML_TOK_MEDIA_TYPE: - sMediaType = sValue; - break; - case XML_TOK_EXTENSION: - aProperty.Name = INFO_TEXTFILEEXTENSION; - sFileTypeExtension = sValue; - break; - } - if ( !aProperty.Name.isEmpty() ) - { - if ( !aProperty.Value.hasValue() ) - aProperty.Value <<= sValue; - rImport.addInfo(aProperty); + if ( sLocation.isEmpty() ) + sLocation = sValue; + } + break; + case XML_ELEMENT(DB, XML_MEDIA_TYPE): + case XML_ELEMENT(DB_OASIS, XML_MEDIA_TYPE): + sMediaType = sValue; + break; + case XML_ELEMENT(DB, XML_EXTENSION): + case XML_ELEMENT(DB_OASIS, XML_EXTENSION): + aProperty.Name = INFO_TEXTFILEEXTENSION; + sFileTypeExtension = sValue; + break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); + } + if ( !aProperty.Name.isEmpty() ) + { + if ( !aProperty.Value.hasValue() ) + aProperty.Value <<= sValue; + rImport.addInfo(aProperty); + } } } if ( !(sLocation.isEmpty() || sMediaType.isEmpty()) ) diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx index ed8926a96034..6ffcd44dbc92 100644 --- a/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx +++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.hxx @@ -30,9 +30,10 @@ namespace dbaxml { public: - OXMLFileBasedDatabase( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList); + OXMLFileBasedDatabase( ODBFilter& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ); + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual ~OXMLFileBasedDatabase() override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx index 44052a93ed67..3ed0e3aabfaa 100644 --- a/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx +++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <comphelper/propertysequence.hxx> +#include <sal/log.hxx> namespace dbaxml { @@ -40,33 +41,27 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XFastAttributeList > & _xAttrList ,const Reference< XNameAccess >& _xParentContainer ,const OUString& _sCollectionServiceName ,const OUString& _sComponentServiceName) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + SvXMLImportContext( rImport ) ,m_sCollectionServiceName(_sCollectionServiceName) ,m_sComponentServiceName(_sComponentServiceName) { - - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_COMPONENT_NAME: + case XML_NAME: m_sName = sValue; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } if ( !m_sName.isEmpty() && _xParentContainer.is() ) @@ -95,12 +90,10 @@ OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport } OXMLHierarchyCollection::OXMLHierarchyCollection( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName ,const Reference< XNameAccess >& _xContainer ,const Reference< XPropertySet >& _xTable ) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + SvXMLImportContext( rImport ) ,m_xContainer(_xContainer) ,m_xTable(_xTable) { @@ -111,27 +104,24 @@ OXMLHierarchyCollection::~OXMLHierarchyCollection() } -SvXMLImportContextRef OXMLHierarchyCollection::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLHierarchyCollection::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDocumentsElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_COMPONENT: + case XML_COMPONENT: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLComponent( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sComponentServiceName ); + pContext = new OXMLComponent( GetOwnImport(), xAttrList,m_xContainer,m_sComponentServiceName ); break; - case XML_TOK_COLUMN: + case XML_COLUMN: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLColumn( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_xTable); + pContext = new OXMLColumn( GetOwnImport(), xAttrList,m_xContainer,m_xTable); break; - case XML_TOK_COMPONENT_COLLECTION: + case XML_COMPONENT_COLLECTION: GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName); + pContext = new OXMLHierarchyCollection( GetOwnImport(), xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName); break; } diff --git a/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx b/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx index 4552b50b7094..758fc6321926 100644 --- a/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx +++ b/dbaccess/source/filter/xml/xmlHierarchyCollection.hxx @@ -39,24 +39,21 @@ namespace dbaxml public: OXMLHierarchyCollection( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& rLName - ,const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ,const OUString& _sCollectionServiceName ,const OUString& _sComponentServiceName ); OXMLHierarchyCollection( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& rLName ,const css::uno::Reference< css::container::XNameAccess >& _xContainer ,const css::uno::Reference< css::beans::XPropertySet >& _xTable ); virtual ~OXMLHierarchyCollection() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlLogin.cxx b/dbaccess/source/filter/xml/xmlLogin.cxx index d747ef801f55..786be60253b2 100644 --- a/dbaccess/source/filter/xml/xmlLogin.cxx +++ b/dbaccess/source/filter/xml/xmlLogin.cxx @@ -37,80 +37,77 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLLogin::OXMLLogin( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName, - const Reference< XAttributeList > & _xAttrList ) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + const Reference< XFastAttributeList > & _xAttrList ) : + SvXMLImportContext( rImport ) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetLoginElemTokenMap(); - Reference<XPropertySet> xDataSource(rImport.getDataSource()); - const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); bool bUserFound = false; - for(sal_Int16 i = 0; i < nLength; ++i) + if (xDataSource.is()) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); - - try + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + OUString sValue = aIter.toString(); + + try { - case XML_TOK_USER_NAME: - if ( !bUserFound ) - { - bUserFound = true; + switch( aIter.getToken() & TOKEN_MASK ) + { + case XML_USER_NAME: + if ( !bUserFound ) + { + bUserFound = true; + try + { + xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue)); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } + } + break; + case XML_IS_PASSWORD_REQUIRED: try { - xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue)); + xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny(sValue == s_sTRUE)); } catch(const Exception&) { DBG_UNHANDLED_EXCEPTION("dbaccess"); } - } - break; - case XML_TOK_IS_PASSWORD_REQUIRED: - try - { - xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny(sValue == s_sTRUE)); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } - break; - case XML_TOK_USE_SYSTEM_USER: - if ( !bUserFound ) - { - bUserFound = true; - PropertyValue aProperty; - aProperty.Name = "UseSystemUser"; - aProperty.Value <<= (sValue == s_sTRUE); - rImport.addInfo(aProperty); - } - break; - case XML_TOK_LOGIN_TIMEOUT: - try - { - Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(sValue.toInt32()); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } - break; + break; + case XML_USE_SYSTEM_USER: + if ( !bUserFound ) + { + bUserFound = true; + PropertyValue aProperty; + aProperty.Name = "UseSystemUser"; + aProperty.Value <<= (sValue == s_sTRUE); + rImport.addInfo(aProperty); + } + break; + case XML_LOGIN_TIMEOUT: + try + { + Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(sValue.toInt32()); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } + break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); + } + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); } - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); } } } diff --git a/dbaccess/source/filter/xml/xmlLogin.hxx b/dbaccess/source/filter/xml/xmlLogin.hxx index ed47680129fd..50297416d221 100644 --- a/dbaccess/source/filter/xml/xmlLogin.hxx +++ b/dbaccess/source/filter/xml/xmlLogin.hxx @@ -28,9 +28,10 @@ namespace dbaxml { public: - OXMLLogin( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); + OXMLLogin( ODBFilter& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ); + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual ~OXMLLogin() override; }; diff --git a/dbaccess/source/filter/xml/xmlQuery.cxx b/dbaccess/source/filter/xml/xmlQuery.cxx index d41b1929937d..88bc13f74322 100644 --- a/dbaccess/source/filter/xml/xmlQuery.cxx +++ b/dbaccess/source/filter/xml/xmlQuery.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameContainer.hpp> +#include <sal/log.hxx> namespace dbaxml { @@ -39,35 +40,28 @@ namespace dbaxml OXMLQuery::OXMLQuery( ODBFilter& rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const Reference< XAttributeList > & _xAttrList + ,const Reference< XFastAttributeList > & _xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ) : - OXMLTable( rImport, nPrfx, _sLocalName,_xAttrList,_xParentContainer, "com.sun.star.sdb.CommandDefinition" ) + OXMLTable( rImport, _xAttrList,_xParentContainer, "com.sun.star.sdb.CommandDefinition" ) ,m_bEscapeProcessing(true) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetQueryElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_COMMAND: + case XML_COMMAND: m_sCommand = sValue; break; - case XML_TOK_ESCAPE_PROCESSING: + case XML_ESCAPE_PROCESSING: m_bEscapeProcessing = sValue == "true"; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } } @@ -77,19 +71,15 @@ OXMLQuery::~OXMLQuery() } -SvXMLImportContextRef OXMLQuery::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLQuery::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - SvXMLImportContextRef xContext = OXMLTable::CreateChildContext(nPrefix, rLocalName,xAttrList ); + css::uno::Reference< css::xml::sax::XFastContextHandler > xContext = OXMLTable::createFastChildContext(nElement,xAttrList ); if (!xContext) { - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap(); - - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_UPDATE_TABLE: + case XML_UPDATE_TABLE: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); OUString s1; diff --git a/dbaccess/source/filter/xml/xmlQuery.hxx b/dbaccess/source/filter/xml/xmlQuery.hxx index 995d406a9d39..211764b49b1f 100644 --- a/dbaccess/source/filter/xml/xmlQuery.hxx +++ b/dbaccess/source/filter/xml/xmlQuery.hxx @@ -35,16 +35,15 @@ namespace dbaxml public: OXMLQuery( ODBFilter& rImport - , sal_uInt16 nPrfx - ,const OUString& rLName - ,const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + ,const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ); virtual ~OXMLQuery() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlServerDatabase.cxx b/dbaccess/source/filter/xml/xmlServerDatabase.cxx index 6eb9ce76ef12..e231d19f78f1 100644 --- a/dbaccess/source/filter/xml/xmlServerDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlServerDatabase.cxx @@ -34,47 +34,44 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLServerDatabase::OXMLServerDatabase( ODBFilter& rImport, - sal_uInt16 nPrfx, const OUString& _sLocalName, - const Reference< XAttributeList > & _xAttrList) : - SvXMLImportContext( rImport, nPrfx, _sLocalName ) + const Reference< XFastAttributeList > & _xAttrList) : + SvXMLImportContext( rImport ) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap(); - Reference<XPropertySet> xDataSource = rImport.getDataSource(); PropertyValue aProperty; - const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; OUString sType,sHostName,sPortNumber,sDatabaseName; - for(sal_Int16 i = 0; i < nLength; ++i) + if (xDataSource.is()) { - OUString sLocalName; - const OUString sAttrName = _xAttrList->getNameByIndex( i ); - const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - const OUString sValue = _xAttrList->getValueByIndex( i ); - - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - case XML_TOK_DB_TYPE: - sType = sValue; - break; - case XML_TOK_HOSTNAME: - sHostName = sValue; - break; - case XML_TOK_PORT: - sPortNumber = sValue; - break; - case XML_TOK_LOCAL_SOCKET: - aProperty.Name = "LocalSocket"; - aProperty.Value <<= sValue; - rImport.addInfo(aProperty); - break; - case XML_TOK_DATABASE_NAME: - sDatabaseName = sValue; - break; + OUString sValue = aIter.toString(); + + switch( aIter.getToken() & TOKEN_MASK ) + { + case XML_TYPE: + sType = sValue; + break; + case XML_HOSTNAME: + sHostName = sValue; + break; + case XML_PORT: + sPortNumber = sValue; + break; + case XML_LOCAL_SOCKET: + aProperty.Name = "LocalSocket"; + aProperty.Value <<= sValue; + rImport.addInfo(aProperty); + break; + case XML_DATABASE_NAME: + sDatabaseName = sValue; + break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); + } } } if ( !sType.isEmpty() ) diff --git a/dbaccess/source/filter/xml/xmlServerDatabase.hxx b/dbaccess/source/filter/xml/xmlServerDatabase.hxx index f6576f62dab5..41c7186c13c1 100644 --- a/dbaccess/source/filter/xml/xmlServerDatabase.hxx +++ b/dbaccess/source/filter/xml/xmlServerDatabase.hxx @@ -30,9 +30,10 @@ namespace dbaxml { public: - OXMLServerDatabase( ODBFilter& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList); + OXMLServerDatabase( ODBFilter& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ); + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual ~OXMLServerDatabase() override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlTable.cxx b/dbaccess/source/filter/xml/xmlTable.cxx index b1fc0084d828..77861056ce94 100644 --- a/dbaccess/source/filter/xml/xmlTable.cxx +++ b/dbaccess/source/filter/xml/xmlTable.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <comphelper/propertysequence.hxx> +#include <sal/log.hxx> namespace dbaxml { @@ -43,50 +44,43 @@ namespace dbaxml using namespace ::com::sun::star::xml::sax; OXMLTable::OXMLTable( ODBFilter& _rImport - ,sal_uInt16 nPrfx - ,const OUString& _sLocalName - ,const uno::Reference< XAttributeList > & _xAttrList + ,const uno::Reference< XFastAttributeList > & _xAttrList ,const uno::Reference< css::container::XNameAccess >& _xParentContainer ,const OUString& _sServiceName ) - :SvXMLImportContext( _rImport, nPrfx, _sLocalName ) + :SvXMLImportContext( _rImport ) ,m_xParentContainer(_xParentContainer) ,m_bApplyFilter(false) ,m_bApplyOrder(false) { - - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = GetOwnImport().GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_QUERY_NAME: + case XML_NAME: m_sName = sValue; break; - case XML_TOK_CATALOG_NAME: + case XML_CATALOG_NAME: m_sCatalog = sValue; break; - case XML_TOK_SCHEMA_NAME: + case XML_SCHEMA_NAME: m_sSchema = sValue; break; - case XML_TOK_STYLE_NAME: + case XML_STYLE_NAME: m_sStyleName = sValue; break; - case XML_TOK_APPLY_FILTER: + case XML_APPLY_FILTER: m_bApplyFilter = sValue == "true"; break; - case XML_TOK_APPLY_ORDER: + case XML_APPLY_ORDER: m_bApplyOrder = sValue == "true"; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } uno::Sequence<uno::Any> aArguments(comphelper::InitAnyPropertySequence( @@ -104,24 +98,21 @@ OXMLTable::~OXMLTable() } -SvXMLImportContextRef OXMLTable::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLTable::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement & TOKEN_MASK ) { - case XML_TOK_FILTER_STATEMENT: + case XML_FILTER_STATEMENT: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); OUString s1,s2,s3; fillAttributes(xAttrList,m_sFilterStatement,s1,s2,s3); } break; - case XML_TOK_ORDER_STATEMENT: + case XML_ORDER_STATEMENT: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); OUString s1,s2,s3; @@ -129,7 +120,7 @@ SvXMLImportContextRef OXMLTable::CreateChildContext( } break; - case XML_TOK_COLUMNS: + case XML_COLUMNS: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); uno::Reference< XColumnsSupplier > xColumnsSup(m_xTable,UNO_QUERY); @@ -138,7 +129,7 @@ SvXMLImportContextRef OXMLTable::CreateChildContext( { xColumns = xColumnsSup->getColumns(); } - pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName ,xColumns,m_xTable); + pContext = new OXMLHierarchyCollection( GetOwnImport(), xColumns,m_xTable); } break; } @@ -171,7 +162,7 @@ void OXMLTable::setProperties(uno::Reference< XPropertySet > & _xProp ) } } -void OXMLTable::EndElement() +void OXMLTable::endFastElement(sal_Int32 ) { uno::Reference<XNameContainer> xNameContainer(m_xParentContainer,UNO_QUERY); if ( xNameContainer.is() ) @@ -206,39 +197,35 @@ void OXMLTable::EndElement() } -void OXMLTable::fillAttributes(const uno::Reference< XAttributeList > & _xAttrList +void OXMLTable::fillAttributes(const uno::Reference< XFastAttributeList > & _xAttrList ,OUString& _rsCommand ,OUString& _rsTableName ,OUString& _rsTableSchema ,OUString& _rsTableCatalog ) { - OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); - const SvXMLNamespaceMap& rMap = GetOwnImport().GetNamespaceMap(); - const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap(); - - sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0; - for(sal_Int16 i = 0; i < nLength; ++i) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( _xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sLocalName; - OUString sAttrName = _xAttrList->getNameByIndex( i ); - sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); - OUString sValue = _xAttrList->getValueByIndex( i ); + OUString sValue = aIter.toString(); - switch( rTokenMap.Get( nPrefix, sLocalName ) ) + switch( aIter.getToken() & TOKEN_MASK ) { - case XML_TOK_COMMAND: + case XML_COMMAND: _rsCommand = sValue; break; - case XML_TOK_CATALOG_NAME: + case XML_CATALOG_NAME: _rsTableCatalog = sValue; break; - case XML_TOK_SCHEMA_NAME: + case XML_SCHEMA_NAME: _rsTableSchema = sValue; break; - case XML_TOK_QUERY_NAME: + case XML_QUERY_NAME: _rsTableName = sValue; break; + default: + SAL_WARN("dbaccess", "unknown attribute " << SvXMLImport::getNameFromToken(aIter.getToken()) << " value=" << aIter.toString()); } } } diff --git a/dbaccess/source/filter/xml/xmlTable.hxx b/dbaccess/source/filter/xml/xmlTable.hxx index dc053cb03eec..2ba1f557ff50 100644 --- a/dbaccess/source/filter/xml/xmlTable.hxx +++ b/dbaccess/source/filter/xml/xmlTable.hxx @@ -42,7 +42,7 @@ namespace dbaxml ODBFilter& GetOwnImport(); - void fillAttributes( const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + static void fillAttributes( const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ,OUString& _rsCommand ,OUString& _rsTableName ,OUString& _rsTableSchema @@ -53,18 +53,17 @@ namespace dbaxml public: OXMLTable( ODBFilter& rImport - , sal_uInt16 nPrfx - ,const OUString& rLName - ,const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList + ,const css::uno::Reference< css::xml::sax::XFastAttributeList > & _xAttrList ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer ,const OUString& _sServiceName ); virtual ~OXMLTable() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; - virtual void EndElement() override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlTableFilterList.cxx b/dbaccess/source/filter/xml/xmlTableFilterList.cxx index dc98a855b6b5..00798eb19a89 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterList.cxx +++ b/dbaccess/source/filter/xml/xmlTableFilterList.cxx @@ -38,8 +38,8 @@ namespace dbaxml using namespace ::com::sun::star::beans; using namespace ::com::sun::star::xml::sax; -OXMLTableFilterList::OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& _sLocalName ) - :SvXMLImportContext( rImport, nPrfx, _sLocalName ) +OXMLTableFilterList::OXMLTableFilterList( SvXMLImport& rImport) + :SvXMLImportContext( rImport ) { } @@ -48,22 +48,28 @@ OXMLTableFilterList::~OXMLTableFilterList() { } -SvXMLImportContextRef OXMLTableFilterList::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & /*xAttrList*/ ) +css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLTableFilterList::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) { SvXMLImportContext *pContext = nullptr; - if ( XML_NAMESPACE_DB == nPrefix ) + if ( (nElement & NMSP_MASK) == NAMESPACE_TOKEN(XML_NAMESPACE_DB) || + (nElement & NMSP_MASK) == NAMESPACE_TOKEN(XML_NAMESPACE_DB_OASIS) ) { GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - if ( IsXMLToken( rLocalName, XML_TABLE_FILTER_PATTERN ) ) - pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,true,*this); - else if ( IsXMLToken( rLocalName, XML_TABLE_TYPE ) ) - pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,false,*this); - else if ( IsXMLToken( rLocalName, XML_TABLE_INCLUDE_FILTER ) ) - pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName ); + switch (nElement & TOKEN_MASK) + { + case XML_TABLE_FILTER_PATTERN: + pContext = new OXMLTableFilterPattern( GetImport(), true,*this); + break; + case XML_TABLE_TYPE: + pContext = new OXMLTableFilterPattern( GetImport(), false,*this); + break; + case XML_TABLE_INCLUDE_FILTER: + pContext = new OXMLTableFilterList( GetImport() ); + break; + default: break; + } } return pContext; @@ -74,7 +80,7 @@ ODBFilter& OXMLTableFilterList::GetOwnImport() return static_cast<ODBFilter&>(GetImport()); } -void OXMLTableFilterList::EndElement() +void OXMLTableFilterList::endFastElement(sal_Int32 ) { Reference<XPropertySet> xDataSource(GetOwnImport().getDataSource()); if ( xDataSource.is() ) diff --git a/dbaccess/source/filter/xml/xmlTableFilterList.hxx b/dbaccess/source/filter/xml/xmlTableFilterList.hxx index 7df344594135..755bb8e9f450 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterList.hxx +++ b/dbaccess/source/filter/xml/xmlTableFilterList.hxx @@ -33,16 +33,17 @@ namespace dbaxml ODBFilter& GetOwnImport(); public: - OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName); + OXMLTableFilterList( SvXMLImport& rImport ); virtual ~OXMLTableFilterList() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; - virtual void EndElement() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; /** pushes a new TableFilterPattern to the list of patterns @param _sTableFilterPattern diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx index 882d7576f22b..0e60eec92290 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx +++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.cxx @@ -25,12 +25,10 @@ namespace dbaxml using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; -OXMLTableFilterPattern::OXMLTableFilterPattern( SvXMLImport& rImport, - sal_uInt16 nPrfx - ,const OUString& _sLocalName +OXMLTableFilterPattern::OXMLTableFilterPattern( SvXMLImport& rImport ,bool _bNameFilter ,OXMLTableFilterList& _rParent) - :SvXMLImportContext( rImport, nPrfx, _sLocalName ) + :SvXMLImportContext( rImport ) ,m_rParent(_rParent) ,m_bNameFilter(_bNameFilter) { @@ -42,7 +40,7 @@ OXMLTableFilterPattern::~OXMLTableFilterPattern() } -void OXMLTableFilterPattern::Characters( const OUString& rChars ) +void OXMLTableFilterPattern::characters( const OUString& rChars ) { if ( m_bNameFilter ) m_rParent.pushTableFilterPattern(rChars); diff --git a/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx b/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx index e34e1a9674cb..81f479898a77 100644 --- a/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx +++ b/dbaccess/source/filter/xml/xmlTableFilterPattern.hxx @@ -30,14 +30,14 @@ namespace dbaxml bool m_bNameFilter; public: OXMLTableFilterPattern( SvXMLImport& rImport - ,sal_uInt16 nPrfx - ,const OUString& rLName ,bool _bNameFilter ,OXMLTableFilterList& _rParent); virtual ~OXMLTableFilterPattern() override; - virtual void Characters( const OUString& rChars ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual void SAL_CALL characters( const OUString& rChars ) override; }; } // namespace dbaxml diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 9aba80c73801..fa57e133bba3 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -404,6 +404,9 @@ public: { } + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList> & xAttrList) override @@ -414,8 +417,6 @@ public: } return nullptr; } - virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, - const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { @@ -455,8 +456,6 @@ public: return pContext; } - virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, - const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { @@ -467,23 +466,25 @@ public: class DBXMLDocumentBodyContext : public SvXMLImportContext { public: - DBXMLDocumentBodyContext(SvXMLImport & rImport, - sal_uInt16 const nPrefix, - const OUString& rLocalName) - : SvXMLImportContext(rImport, nPrefix, rLocalName) + DBXMLDocumentBodyContext(SvXMLImport & rImport) + : SvXMLImportContext(rImport) { } - virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 const nPrefix, - const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList> &) override + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + + virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { - if ((XML_NAMESPACE_OFFICE == nPrefix || XML_NAMESPACE_OOO == nPrefix) - && IsXMLToken(rLocalName, XML_DATABASE)) + ODBFilter & rImport(static_cast<ODBFilter&>(GetImport())); + switch (nElement) { - ODBFilter & rImport(static_cast<ODBFilter&>(GetImport())); - rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - return new OXMLDatabase(rImport, nPrefix, rLocalName ); + case XML_ELEMENT(OFFICE, XML_DATABASE): + case XML_ELEMENT(OOO, XML_DATABASE): + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + return new OXMLDatabase(rImport); + default: break; } return nullptr; } @@ -514,9 +515,6 @@ public: case XML_TOK_CONTENT_SCRIPTS: pContext = new XMLScriptContext(GetImport(), rLocalName, rImport.GetModel()); break; - case XML_TOK_CONTENT_BODY: - pContext = new DBXMLDocumentBodyContext(rImport, nPrefix, rLocalName); - break; default: break; } @@ -526,8 +524,17 @@ public: virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { + ODBFilter & rImport(static_cast<ODBFilter&>(GetImport())); + switch (nElement) + { + case XML_ELEMENT(OFFICE, XML_BODY): + case XML_ELEMENT(OOO, XML_BODY): + return new DBXMLDocumentBodyContext(rImport); + break; + default: break; + } return nullptr; } }; @@ -637,227 +644,6 @@ const SvXMLTokenMap& ODBFilter::GetDocContentElemTokenMap() const } -const SvXMLTokenMap& ODBFilter::GetDatabaseElemTokenMap() const -{ - if (!m_pDatabaseElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_DATASOURCE, XML_TOK_DATASOURCE }, - { XML_NAMESPACE_DB, XML_FORMS, XML_TOK_FORMS}, - { XML_NAMESPACE_DB, XML_REPORTS, XML_TOK_REPORTS}, - { XML_NAMESPACE_DB, XML_QUERIES, XML_TOK_QUERIES}, - { XML_NAMESPACE_DB, XML_TABLES, XML_TOK_TABLES}, - { XML_NAMESPACE_DB, XML_TABLE_REPRESENTATIONS, XML_TOK_TABLES}, - { XML_NAMESPACE_DB, XML_SCHEMA_DEFINITION, XML_TOK_SCHEMA_DEFINITION}, - XML_TOKEN_MAP_END - }; - m_pDatabaseElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pDatabaseElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetDataSourceElemTokenMap() const -{ - if (!m_pDataSourceElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, XML_TOK_CONNECTION_RESOURCE}, - { XML_NAMESPACE_DB, XML_SUPPRESS_VERSION_COLUMNS, XML_TOK_SUPPRESS_VERSION_COLUMNS}, - { XML_NAMESPACE_DB, XML_JAVA_DRIVER_CLASS, XML_TOK_JAVA_DRIVER_CLASS}, - { XML_NAMESPACE_DB, XML_EXTENSION, XML_TOK_EXTENSION}, - { XML_NAMESPACE_DB, XML_IS_FIRST_ROW_HEADER_LINE, XML_TOK_IS_FIRST_ROW_HEADER_LINE}, - { XML_NAMESPACE_DB, XML_SHOW_DELETED, XML_TOK_SHOW_DELETED}, - { XML_NAMESPACE_DB, XML_IS_TABLE_NAME_LENGTH_LIMITED, XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED}, - { XML_NAMESPACE_DB, XML_SYSTEM_DRIVER_SETTINGS, XML_TOK_SYSTEM_DRIVER_SETTINGS}, - { XML_NAMESPACE_DB, XML_ENABLE_SQL92_CHECK, XML_TOK_ENABLE_SQL92_CHECK}, - { XML_NAMESPACE_DB, XML_APPEND_TABLE_ALIAS_NAME, XML_TOK_APPEND_TABLE_ALIAS_NAME}, - { XML_NAMESPACE_DB, XML_PARAMETER_NAME_SUBSTITUTION, XML_TOK_PARAMETER_NAME_SUBSTITUTION}, - { XML_NAMESPACE_DB, XML_IGNORE_DRIVER_PRIVILEGES, XML_TOK_IGNORE_DRIVER_PRIVILEGES}, - { XML_NAMESPACE_DB, XML_BOOLEAN_COMPARISON_MODE, XML_TOK_BOOLEAN_COMPARISON_MODE}, - { XML_NAMESPACE_DB, XML_USE_CATALOG, XML_TOK_USE_CATALOG}, - { XML_NAMESPACE_DB, XML_BASE_DN, XML_TOK_BASE_DN}, - { XML_NAMESPACE_DB, XML_MAX_ROW_COUNT, XML_TOK_MAX_ROW_COUNT}, - { XML_NAMESPACE_DB, XML_LOGIN, XML_TOK_LOGIN}, - { XML_NAMESPACE_DB, XML_TABLE_FILTER, XML_TOK_TABLE_FILTER}, - { XML_NAMESPACE_DB, XML_TABLE_TYPE_FILTER, XML_TOK_TABLE_TYPE_FILTER}, - { XML_NAMESPACE_DB, XML_AUTO_INCREMENT, XML_TOK_AUTO_INCREMENT}, - { XML_NAMESPACE_DB, XML_DELIMITER, XML_TOK_DELIMITER}, - { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTINGS, XML_TOK_DATA_SOURCE_SETTINGS}, - { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET}, - // db odf 12 - { XML_NAMESPACE_DB, XML_CONNECTION_DATA, XML_TOK_CONNECTION_DATA}, - { XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, XML_TOK_DATABASE_DESCRIPTION}, - { XML_NAMESPACE_DB, XML_COMPOUND_DATABASE, XML_TOK_COMPOUND_DATABASE}, - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_DB_HREF}, - { XML_NAMESPACE_DB, XML_MEDIA_TYPE, XML_TOK_MEDIA_TYPE}, - { XML_NAMESPACE_DB, XML_TYPE, XML_TOK_DB_TYPE}, - { XML_NAMESPACE_DB, XML_HOSTNAME, XML_TOK_HOSTNAME}, - { XML_NAMESPACE_DB, XML_PORT, XML_TOK_PORT}, - { XML_NAMESPACE_DB, XML_LOCAL_SOCKET, XML_TOK_LOCAL_SOCKET}, - { XML_NAMESPACE_DB, XML_DATABASE_NAME, XML_TOK_DATABASE_NAME}, - { XML_NAMESPACE_DB, XML_DRIVER_SETTINGS, XML_TOK_DRIVER_SETTINGS}, - { XML_NAMESPACE_DB, XML_JAVA_CLASSPATH, XML_TOK_JAVA_CLASSPATH}, - { XML_NAMESPACE_DB, XML_CHARACTER_SET, XML_TOK_CHARACTER_SET}, - { XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS,XML_TOK_APPLICATION_CONNECTION_SETTINGS}, - XML_TOKEN_MAP_END - }; - m_pDataSourceElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pDataSourceElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetLoginElemTokenMap() const -{ - if (!m_pLoginElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_USER_NAME, XML_TOK_USER_NAME}, - { XML_NAMESPACE_DB, XML_IS_PASSWORD_REQUIRED, XML_TOK_IS_PASSWORD_REQUIRED}, - { XML_NAMESPACE_DB, XML_USE_SYSTEM_USER, XML_TOK_USE_SYSTEM_USER}, - { XML_NAMESPACE_DB, XML_LOGIN_TIMEOUT, XML_TOK_LOGIN_TIMEOUT}, - XML_TOKEN_MAP_END - }; - m_pLoginElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pLoginElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetDatabaseDescriptionElemTokenMap() const -{ - if (!m_pDatabaseDescriptionElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_FILE_BASED_DATABASE, XML_TOK_FILE_BASED_DATABASE}, - { XML_NAMESPACE_DB, XML_SERVER_DATABASE, XML_TOK_SERVER_DATABASE}, - XML_TOKEN_MAP_END - }; - m_pDatabaseDescriptionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pDatabaseDescriptionElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetDataSourceInfoElemTokenMap() const -{ - if (!m_pDataSourceInfoElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,XML_TOK_ADDITIONAL_COLUMN_STATEMENT}, - { XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT, XML_TOK_ROW_RETRIEVING_STATEMENT}, - { XML_NAMESPACE_DB, XML_STRING, XML_TOK_STRING}, - { XML_NAMESPACE_DB, XML_FIELD, XML_TOK_FIELD}, - { XML_NAMESPACE_DB, XML_DECIMAL, XML_TOK_DECIMAL}, - { XML_NAMESPACE_DB, XML_THOUSAND, XML_TOK_THOUSAND}, - { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING, XML_TOK_DATA_SOURCE_SETTING}, - { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, XML_TOK_DATA_SOURCE_SETTING_VALUE}, - { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_IS_LIST,XML_TOK_DATA_SOURCE_SETTING_IS_LIST}, - { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, XML_TOK_DATA_SOURCE_SETTING_TYPE}, - { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, XML_TOK_DATA_SOURCE_SETTING_NAME}, - { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET}, - { XML_NAMESPACE_DB, XML_ENCODING, XML_TOK_ENCODING}, - XML_TOKEN_MAP_END - }; - m_pDataSourceInfoElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pDataSourceInfoElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetDocumentsElemTokenMap() const -{ - if (!m_pDocumentsElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_COMPONENT, XML_TOK_COMPONENT}, - { XML_NAMESPACE_DB, XML_COMPONENT_COLLECTION, XML_TOK_COMPONENT_COLLECTION}, - { XML_NAMESPACE_DB, XML_QUERY_COLLECTION, XML_TOK_QUERY_COLLECTION}, - { XML_NAMESPACE_DB, XML_QUERY, XML_TOK_QUERY}, - { XML_NAMESPACE_DB, XML_TABLE, XML_TOK_TABLE}, - { XML_NAMESPACE_DB, XML_TABLE_REPRESENTATION, XML_TOK_TABLE}, - { XML_NAMESPACE_DB, XML_COLUMN, XML_TOK_COLUMN}, - XML_TOKEN_MAP_END - }; - m_pDocumentsElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pDocumentsElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetComponentElemTokenMap() const -{ - if (!m_pComponentElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_HREF }, - { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_TYPE }, - { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_SHOW }, - { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_ACTUATE}, - { XML_NAMESPACE_DB, XML_AS_TEMPLATE, XML_TOK_AS_TEMPLATE }, - { XML_NAMESPACE_DB, XML_NAME, XML_TOK_COMPONENT_NAME }, - XML_TOKEN_MAP_END - }; - m_pComponentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pComponentElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetQueryElemTokenMap() const -{ - if (!m_pQueryElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_COMMAND, XML_TOK_COMMAND }, - { XML_NAMESPACE_DB, XML_ESCAPE_PROCESSING, XML_TOK_ESCAPE_PROCESSING }, - { XML_NAMESPACE_DB, XML_NAME, XML_TOK_QUERY_NAME }, - { XML_NAMESPACE_DB, XML_FILTER_STATEMENT, XML_TOK_FILTER_STATEMENT }, - { XML_NAMESPACE_DB, XML_ORDER_STATEMENT, XML_TOK_ORDER_STATEMENT }, - { XML_NAMESPACE_DB, XML_CATALOG_NAME, XML_TOK_CATALOG_NAME }, - { XML_NAMESPACE_DB, XML_SCHEMA_NAME, XML_TOK_SCHEMA_NAME }, - { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_STYLE_NAME}, - { XML_NAMESPACE_DB, XML_APPLY_FILTER, XML_TOK_APPLY_FILTER}, - { XML_NAMESPACE_DB, XML_APPLY_ORDER, XML_TOK_APPLY_ORDER}, - { XML_NAMESPACE_DB, XML_COLUMNS, XML_TOK_COLUMNS}, - XML_TOKEN_MAP_END - }; - m_pQueryElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pQueryElemTokenMap; -} - - -const SvXMLTokenMap& ODBFilter::GetColumnElemTokenMap() const -{ - if (!m_pColumnElemTokenMap) - { - static const SvXMLTokenMapEntry aElemTokenMap[]= - { - { XML_NAMESPACE_DB, XML_NAME, XML_TOK_COLUMN_NAME }, - { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_COLUMN_STYLE_NAME }, - { XML_NAMESPACE_DB, XML_HELP_MESSAGE, XML_TOK_COLUMN_HELP_MESSAGE }, - { XML_NAMESPACE_DB, XML_VISIBILITY, XML_TOK_COLUMN_VISIBILITY }, - { XML_NAMESPACE_DB, XML_DEFAULT_VALUE, XML_TOK_COLUMN_DEFAULT_VALUE }, - { XML_NAMESPACE_DB, XML_TYPE_NAME, XML_TOK_COLUMN_TYPE_NAME }, - { XML_NAMESPACE_DB, XML_VISIBLE, XML_TOK_COLUMN_VISIBLE }, - { XML_NAMESPACE_DB, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_DEFAULT_CELL_STYLE_NAME }, - XML_TOKEN_MAP_END - }; - m_pColumnElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); - } - return *m_pColumnElemTokenMap; -} - SvXMLImportContext* ODBFilter::CreateStylesContext(sal_uInt16 _nPrefix,const OUString& rLocalName, const uno::Reference< XAttributeList>& xAttrList, bool bIsAutoStyle ) diff --git a/dbaccess/source/filter/xml/xmlfilter.hxx b/dbaccess/source/filter/xml/xmlfilter.hxx index 0e014f535d00..d722821baf29 100644 --- a/dbaccess/source/filter/xml/xmlfilter.hxx +++ b/dbaccess/source/filter/xml/xmlfilter.hxx @@ -64,15 +64,6 @@ private: std::vector< css::beans::PropertyValue> m_aInfoSequence; mutable std::unique_ptr<SvXMLTokenMap> m_pDocContentElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pDatabaseElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pDataSourceElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pLoginElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pDatabaseDescriptionElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pDataSourceInfoElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pDocumentsElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pComponentElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pQueryElemTokenMap; - mutable std::unique_ptr<SvXMLTokenMap> m_pColumnElemTokenMap; mutable rtl::Reference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper; mutable rtl::Reference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper; @@ -127,15 +118,6 @@ public: const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;} const SvXMLTokenMap& GetDocContentElemTokenMap() const; - const SvXMLTokenMap& GetDatabaseElemTokenMap() const; - const SvXMLTokenMap& GetDataSourceElemTokenMap() const; - const SvXMLTokenMap& GetLoginElemTokenMap() const; - const SvXMLTokenMap& GetDatabaseDescriptionElemTokenMap() const; - const SvXMLTokenMap& GetDataSourceInfoElemTokenMap() const; - const SvXMLTokenMap& GetDocumentsElemTokenMap() const; - const SvXMLTokenMap& GetComponentElemTokenMap() const; - const SvXMLTokenMap& GetQueryElemTokenMap() const; - const SvXMLTokenMap& GetColumnElemTokenMap() const; rtl::Reference < XMLPropertySetMapper > const & GetTableStylesPropertySetMapper() const; rtl::Reference < XMLPropertySetMapper > const & GetColumnStylesPropertySetMapper() const; |