diff options
Diffstat (limited to 'dbaccess/source/filter/xml/xmlLogin.cxx')
-rw-r--r-- | dbaccess/source/filter/xml/xmlLogin.cxx | 113 |
1 files changed, 55 insertions, 58 deletions
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"); } } } |