LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/filter/xml - xmlLogin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 37 0.0 %
Date: 2012-12-27 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "xmlLogin.hxx"
      21             : #include "xmlfilter.hxx"
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <xmloff/xmlnmspe.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "xmlEnums.hxx"
      26             : #include "xmlstrings.hrc"
      27             : #include <tools/debug.hxx>
      28             : #include <tools/diagnose_ex.h>
      29             : #include <com/sun/star/sdbc/XDataSource.hpp>
      30             : #include <vector>
      31             : 
      32             : namespace dbaxml
      33             : {
      34             :     using namespace ::com::sun::star::uno;
      35             :     using namespace ::com::sun::star::sdbc;
      36             :     using namespace ::com::sun::star::xml::sax;
      37             : DBG_NAME(OXMLLogin)
      38             : 
      39           0 : OXMLLogin::OXMLLogin( ODBFilter& rImport,
      40             :                 sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
      41             :                 const Reference< XAttributeList > & _xAttrList ) :
      42           0 :     SvXMLImportContext( rImport, nPrfx, _sLocalName )
      43             : {
      44             :     DBG_CTOR(OXMLLogin,NULL);
      45             : 
      46             :     OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
      47           0 :     const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
      48           0 :     const SvXMLTokenMap& rTokenMap = rImport.GetLoginElemTokenMap();
      49             : 
      50           0 :     Reference<XPropertySet> xDataSource(rImport.getDataSource());
      51             : 
      52           0 :     const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
      53           0 :     static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
      54           0 :     bool bUserFound = false;
      55           0 :     for(sal_Int16 i = 0; i < nLength; ++i)
      56             :     {
      57           0 :         ::rtl::OUString sLocalName;
      58           0 :         rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
      59           0 :         sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      60           0 :         rtl::OUString sValue = _xAttrList->getValueByIndex( i );
      61             : 
      62             :         try
      63             :         {
      64           0 :             switch( rTokenMap.Get( nPrefix, sLocalName ) )
      65             :             {
      66             :                 case XML_TOK_USER_NAME:
      67           0 :                     if ( !bUserFound )
      68             :                     {
      69           0 :                         bUserFound = true;
      70             :                         try
      71             :                         {
      72           0 :                             xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue));
      73             :                         }
      74           0 :                         catch(const Exception&)
      75             :                         {
      76             :                             DBG_UNHANDLED_EXCEPTION();
      77             :                         }
      78             :                     }
      79           0 :                     break;
      80             :                 case XML_TOK_IS_PASSWORD_REQUIRED:
      81             :                     try
      82             :                     {
      83           0 :                         xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny((sValue == s_sTRUE ? sal_True : sal_False)));
      84             :                     }
      85           0 :                     catch(const Exception&)
      86             :                     {
      87             :                         DBG_UNHANDLED_EXCEPTION();
      88             :                     }
      89           0 :                     break;
      90             :                 case XML_TOK_USE_SYSTEM_USER:
      91           0 :                     if ( !bUserFound )
      92             :                     {
      93           0 :                         bUserFound = true;
      94           0 :                         PropertyValue aProperty;
      95           0 :                         aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSystemUser"));
      96           0 :                         aProperty.Value <<= (sValue == s_sTRUE ? sal_True : sal_False);
      97           0 :                         rImport.addInfo(aProperty);
      98             :                     }
      99           0 :                     break;
     100             :                 case XML_TOK_LOGIN_TIMEOUT:
     101             :                     try
     102             :                     {
     103           0 :                         Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(sValue.toInt32());
     104             :                     }
     105           0 :                     catch(const Exception&)
     106             :                     {
     107             :                         DBG_UNHANDLED_EXCEPTION();
     108             :                     }
     109           0 :                     break;
     110             :             }
     111             :         }
     112           0 :         catch(const Exception&)
     113             :         {
     114             :             DBG_UNHANDLED_EXCEPTION();
     115             :         }
     116           0 :     }
     117           0 : }
     118             : // -----------------------------------------------------------------------------
     119             : 
     120           0 : OXMLLogin::~OXMLLogin()
     121             : {
     122             : 
     123             :     DBG_DTOR(OXMLLogin,NULL);
     124           0 : }
     125             : // -----------------------------------------------------------------------------
     126             : 
     127             : //----------------------------------------------------------------------------
     128             : } // namespace dbaxml
     129             : // -----------------------------------------------------------------------------
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10