LCOV - code coverage report
Current view: top level - dbaccess/source/filter/xml - xmlServerDatabase.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 57 0.0 %
Date: 2015-06-13 12:38:46 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 "xmlServerDatabase.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             : 
      30             : namespace dbaxml
      31             : {
      32             :     using namespace ::com::sun::star::uno;
      33             :     using namespace ::com::sun::star::xml::sax;
      34             : 
      35           0 : OXMLServerDatabase::OXMLServerDatabase( ODBFilter& rImport,
      36             :                 sal_uInt16 nPrfx, const OUString& _sLocalName,
      37             :                 const Reference< XAttributeList > & _xAttrList) :
      38           0 :     SvXMLImportContext( rImport, nPrfx, _sLocalName )
      39             : {
      40             : 
      41             :     OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
      42           0 :     const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
      43           0 :     const SvXMLTokenMap& rTokenMap = rImport.GetDataSourceElemTokenMap();
      44             : 
      45           0 :     Reference<XPropertySet> xDataSource = rImport.getDataSource();
      46             : 
      47           0 :     PropertyValue aProperty;
      48             : 
      49           0 :     const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
      50           0 :     OUString sType,sHostName,sPortNumber,sDatabaseName;
      51           0 :     for(sal_Int16 i = 0; i < nLength; ++i)
      52             :     {
      53           0 :         OUString sLocalName;
      54           0 :         const OUString sAttrName = _xAttrList->getNameByIndex( i );
      55           0 :         const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      56           0 :         const OUString sValue = _xAttrList->getValueByIndex( i );
      57             : 
      58           0 :         switch( rTokenMap.Get( nPrefix, sLocalName ) )
      59             :         {
      60             :             case XML_TOK_DB_TYPE:
      61           0 :                 sType = sValue;
      62           0 :                 break;
      63             :             case XML_TOK_HOSTNAME:
      64           0 :                 sHostName = sValue;
      65           0 :                 break;
      66             :             case XML_TOK_PORT:
      67           0 :                 sPortNumber = sValue;
      68           0 :                 break;
      69             :             case XML_TOK_LOCAL_SOCKET:
      70           0 :                 aProperty.Name = "LocalSocket";
      71           0 :                 aProperty.Value <<= sValue;
      72           0 :                 rImport.addInfo(aProperty);
      73           0 :                 break;
      74             :             case XML_TOK_DATABASE_NAME:
      75           0 :                 sDatabaseName = sValue;
      76           0 :                 break;
      77             :         }
      78           0 :     }
      79           0 :     if ( !sType.isEmpty() )
      80             :     {
      81           0 :         OUStringBuffer sURL;
      82           0 :         if  ( sType == "sdbc:mysql:jdbc" || sType == "sdbc:mysqlc" || sType == "sdbc:mysql:mysqlc" )
      83             :         {
      84           0 :             sURL.append( sType + ":" + sHostName);
      85           0 :             if ( !sPortNumber.isEmpty() )
      86             :             {
      87           0 :                 sURL.append(":" + sPortNumber);
      88             :             }
      89           0 :             if ( !sDatabaseName.isEmpty() )
      90             :             {
      91           0 :                 sURL.append("/" + sDatabaseName);
      92             :             }
      93             :         }
      94           0 :         else if ( sType == "jdbc:oracle:thin" )
      95             :         {
      96           0 :             sURL.append("jdbc:oracle:thin:@" + sHostName);
      97           0 :             if ( !sPortNumber.isEmpty() )
      98             :             {
      99           0 :                 sURL.append(":" + sPortNumber);
     100             :             }
     101           0 :             if ( !sDatabaseName.isEmpty() )
     102             :             {
     103           0 :                 sURL.append(":" + sDatabaseName);
     104             :             }
     105             :         }
     106           0 :         else if ( sType == "sdbc:address:ldap" )
     107             :         {
     108           0 :             sURL.append("sdbc:address:ldap:" + sHostName);
     109           0 :             if ( !sPortNumber.isEmpty() )
     110             :             {
     111           0 :                 sURL.append(":" + sPortNumber);
     112             :             }
     113             :         }
     114             :         else
     115             :         {
     116           0 :             sURL.append(sType + ":" + sHostName);
     117           0 :             if ( !sPortNumber.isEmpty() )
     118             :             {
     119           0 :                 sURL.append(":" + sPortNumber);
     120             :             }
     121           0 :             if ( !sDatabaseName.isEmpty() )
     122             :             {
     123           0 :                 sURL.append(":" + sDatabaseName);
     124             :             }
     125             :         }
     126             :         try
     127             :         {
     128           0 :             xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sURL.makeStringAndClear()));
     129             :         }
     130           0 :         catch(const Exception&)
     131             :         {
     132             :             DBG_UNHANDLED_EXCEPTION();
     133           0 :         }
     134           0 :     }
     135           0 : }
     136             : 
     137           0 : OXMLServerDatabase::~OXMLServerDatabase()
     138             : {
     139             : 
     140           0 : }
     141             : 
     142             : } // namespace dbaxml
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11