/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlLogin.cxx,v $ * * $Revision: 1.5 $ * * last change: $Author: hr $ $Date: 2005-09-23 12:11:49 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ************************************************************************/ #ifndef DBA_XMLLOGIN_HXX #include "xmlLogin.hxx" #endif #ifndef DBA_XMLFILTER_HXX #include "xmlfilter.hxx" #endif #ifndef _XMLOFF_XMLTOKEN_HXX #include #endif #ifndef _XMLOFF_XMLNMSPE_HXX #include #endif #ifndef _XMLOFF_NMSPMAP_HXX #include #endif #ifndef DBA_XMLENUMS_HXX #include "xmlEnums.hxx" #endif #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC #include "xmlstrings.hrc" #endif #ifndef _TOOLS_DEBUG_HXX #include #endif #include namespace dbaxml { using namespace ::rtl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; DBG_NAME(OXMLLogin) OXMLLogin::OXMLLogin( ODBFilter& rImport, sal_uInt16 nPrfx, const OUString& _sLocalName, const Reference< XAttributeList > & _xAttrList ) : SvXMLImportContext( rImport, nPrfx, _sLocalName ) { DBG_CTOR(OXMLLogin,NULL); OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!"); const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap(); const SvXMLTokenMap& rTokenMap = rImport.GetLoginElemTokenMap(); Reference xDataSource(rImport.getDataSource()); sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0; static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE); for(sal_Int16 i = 0; i < nLength; ++i) { OUString sLocalName; rtl::OUString sAttrName = _xAttrList->getNameByIndex( i ); sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName ); rtl::OUString sValue = _xAttrList->getValueByIndex( i ); try { switch( rTokenMap.Get( nPrefix, sLocalName ) ) { case XML_TOK_USER_NAME: xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue)); break; case XML_TOK_IS_PASSWORD_REQUIRED: xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny((sValue == s_sTRUE ? sal_True : sal_False))); break; } } catch(Exception) { OSL_ENSURE(0,"OXMLLogin::OXMLLogin: Could not set login!"); } } } // ----------------------------------------------------------------------------- OXMLLogin::~OXMLLogin() { DBG_DTOR(OXMLLogin,NULL); } // ----------------------------------------------------------------------------- //---------------------------------------------------------------------------- } // namespace dbaxml // -----------------------------------------------------------------------------