1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlLogin.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBA_XMLLOGIN_HXX
34 #include "xmlLogin.hxx"
36 #ifndef DBA_XMLFILTER_HXX
37 #include "xmlfilter.hxx"
39 #ifndef _XMLOFF_XMLTOKEN_HXX
40 #include <xmloff/xmltoken.hxx>
42 #ifndef _XMLOFF_XMLNMSPE_HXX
43 #include <xmloff/xmlnmspe.hxx>
45 #ifndef _XMLOFF_NMSPMAP_HXX
46 #include <xmloff/nmspmap.hxx>
48 #ifndef DBA_XMLENUMS_HXX
49 #include "xmlEnums.hxx"
51 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
52 #include "xmlstrings.hrc"
54 #ifndef _TOOLS_DEBUG_HXX
55 #include <tools/debug.hxx>
57 #ifndef TOOLS_DIAGNOSE_EX_H
58 #include <tools/diagnose_ex.h>
60 #include <com/sun/star/sdbc/XDataSource.hpp>
65 using namespace ::com::sun::star::uno
;
66 using namespace ::com::sun::star::sdbc
;
67 using namespace ::com::sun::star::xml::sax
;
70 OXMLLogin::OXMLLogin( ODBFilter
& rImport
,
71 sal_uInt16 nPrfx
, const ::rtl::OUString
& _sLocalName
,
72 const Reference
< XAttributeList
> & _xAttrList
) :
73 SvXMLImportContext( rImport
, nPrfx
, _sLocalName
)
75 DBG_CTOR(OXMLLogin
,NULL
);
77 OSL_ENSURE(_xAttrList
.is(),"Attribute list is NULL!");
78 const SvXMLNamespaceMap
& rMap
= rImport
.GetNamespaceMap();
79 const SvXMLTokenMap
& rTokenMap
= rImport
.GetLoginElemTokenMap();
81 Reference
<XPropertySet
> xDataSource(rImport
.getDataSource());
83 const sal_Int16 nLength
= (xDataSource
.is() && _xAttrList
.is()) ? _xAttrList
->getLength() : 0;
84 static const ::rtl::OUString s_sTRUE
= ::xmloff::token::GetXMLToken(XML_TRUE
);
85 bool bUserFound
= false;
86 for(sal_Int16 i
= 0; i
< nLength
; ++i
)
88 ::rtl::OUString sLocalName
;
89 rtl::OUString sAttrName
= _xAttrList
->getNameByIndex( i
);
90 sal_uInt16 nPrefix
= rMap
.GetKeyByAttrName( sAttrName
,&sLocalName
);
91 rtl::OUString sValue
= _xAttrList
->getValueByIndex( i
);
95 switch( rTokenMap
.Get( nPrefix
, sLocalName
) )
97 case XML_TOK_USER_NAME
:
103 xDataSource
->setPropertyValue(PROPERTY_USER
,makeAny(sValue
));
107 DBG_UNHANDLED_EXCEPTION();
111 case XML_TOK_IS_PASSWORD_REQUIRED
:
114 xDataSource
->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED
,makeAny((sValue
== s_sTRUE
? sal_True
: sal_False
)));
118 DBG_UNHANDLED_EXCEPTION();
121 case XML_TOK_USE_SYSTEM_USER
:
125 PropertyValue aProperty
;
126 aProperty
.Name
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSystemUser"));
127 aProperty
.Value
<<= (sValue
== s_sTRUE
? sal_True
: sal_False
);
128 rImport
.addInfo(aProperty
);
131 case XML_TOK_LOGIN_TIMEOUT
:
134 Reference
< XDataSource
>(xDataSource
,UNO_QUERY_THROW
)->setLoginTimeout(sValue
.toInt32());
138 DBG_UNHANDLED_EXCEPTION();
145 DBG_UNHANDLED_EXCEPTION();
149 // -----------------------------------------------------------------------------
151 OXMLLogin::~OXMLLogin()
154 DBG_DTOR(OXMLLogin
,NULL
);
156 // -----------------------------------------------------------------------------
158 //----------------------------------------------------------------------------
159 } // namespace dbaxml
160 // -----------------------------------------------------------------------------