LCOV - code coverage report
Current view: top level - dbaccess/source/core/misc - dsntypes.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 275 0.0 %
Date: 2014-04-14 Functions: 0 38 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 "dsntypes.hxx"
      21             : #include "dbamiscres.hrc"
      22             : #include <unotools/confignode.hxx>
      23             : #include <tools/debug.hxx>
      24             : #include <osl/diagnose.h>
      25             : #include <tools/wldcrd.hxx>
      26             : #include <osl/file.hxx>
      27             : #include "dbastrings.hrc"
      28             : #include "core_resource.hxx"
      29             : #include "core_resource.hrc"
      30             : #include <comphelper/documentconstants.hxx>
      31             : #include <comphelper/string.hxx>
      32             : 
      33             : namespace dbaccess
      34             : {
      35             : 
      36             :     using namespace ::com::sun::star;
      37             :     using namespace ::com::sun::star::uno;
      38             :     using namespace ::com::sun::star::beans;
      39             :     using namespace ::com::sun::star::lang;
      40             : 
      41             :     namespace
      42             :     {
      43           0 :         void lcl_extractHostAndPort(const OUString& _sUrl,OUString& _sHostname,sal_Int32& _nPortNumber)
      44             :         {
      45           0 :             if ( comphelper::string::getTokenCount(_sUrl, ':') >= 2 )
      46             :             {
      47           0 :                 _sHostname      = _sUrl.getToken(0,':');
      48           0 :                 _nPortNumber    = _sUrl.getToken(1,':').toInt32();
      49             :             }
      50           0 :         }
      51             :     }
      52             : // ODsnTypeCollection
      53           0 : ODsnTypeCollection::ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xContext)
      54             : :m_aDriverConfig(_xContext)
      55           0 : ,m_xContext(_xContext)
      56             : #if OSL_DEBUG_LEVEL > 0
      57             : ,m_nLivingIterators(0)
      58             : #endif
      59             : {
      60           0 :     const uno::Sequence< OUString > aURLs = m_aDriverConfig.getURLs();
      61           0 :     const OUString* pIter = aURLs.getConstArray();
      62           0 :     const OUString* pEnd = pIter + aURLs.getLength();
      63           0 :     for(;pIter != pEnd;++pIter )
      64             :     {
      65           0 :         m_aDsnPrefixes.push_back(*pIter);
      66           0 :         m_aDsnTypesDisplayNames.push_back(m_aDriverConfig.getDriverTypeDisplayName(*pIter));
      67             :     }
      68             : 
      69             :     OSL_ENSURE(m_aDsnTypesDisplayNames.size() == m_aDsnPrefixes.size(),
      70           0 :         "ODsnTypeCollection::ODsnTypeCollection : invalid resources !");
      71           0 : }
      72             : 
      73           0 : ODsnTypeCollection::~ODsnTypeCollection()
      74             : {
      75             :     OSL_ENSURE(0 == m_nLivingIterators, "ODsnTypeCollection::~ODsnTypeCollection : there are still living iterator objects!");
      76           0 : }
      77             : 
      78           0 : OUString ODsnTypeCollection::getTypeDisplayName(const OUString& _sURL) const
      79             : {
      80           0 :     return m_aDriverConfig.getDriverTypeDisplayName(_sURL);
      81             : }
      82             : 
      83           0 : OUString ODsnTypeCollection::cutPrefix(const OUString& _sURL) const
      84             : {
      85           0 :     OUString sURL( _sURL);
      86           0 :     OUString sRet;
      87           0 :     OUString sOldPattern;
      88           0 :     StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
      89           0 :     StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
      90             : 
      91           0 :     for(;aIter != aEnd;++aIter)
      92             :     {
      93           0 :         WildCard aWildCard(*aIter);
      94           0 :         if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(_sURL) )
      95             :         {
      96             :             // This relies on the fact that all patterns are of the form
      97             :             //   foo*
      98             :             // that is, the very concept of "prefix" applies.
      99           0 :             OUString prefix(comphelper::string::stripEnd(*aIter, '*'));
     100             :             OSL_ENSURE(prefix.getLength() <= sURL.getLength(), "How can A match B when A shorter than B?");
     101           0 :             sRet = sURL.copy(prefix.getLength());
     102           0 :             sOldPattern = *aIter;
     103             :         }
     104           0 :     }
     105             : 
     106           0 :     return sRet;
     107             : }
     108             : 
     109           0 : OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const
     110             : {
     111           0 :     OUString sURL( _sURL);
     112           0 :     OUString sRet;
     113           0 :     OUString sOldPattern;
     114           0 :     StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
     115           0 :     StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
     116           0 :     for(;aIter != aEnd;++aIter)
     117             :     {
     118           0 :         WildCard aWildCard(*aIter);
     119           0 :         if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(sURL) )
     120             :         {
     121             :             // This relies on the fact that all patterns are of the form
     122             :             //   foo*
     123             :             // that is, the very concept of "prefix" applies.
     124           0 :             sRet = comphelper::string::stripEnd(*aIter, '*');
     125             :             OSL_ENSURE(sRet.getLength() <= sURL.getLength(), "How can A match B when A shorter than B?");
     126           0 :             sOldPattern = *aIter;
     127             :         }
     128           0 :     }
     129             : 
     130           0 :     return sRet;
     131             : }
     132             : 
     133           0 : bool ODsnTypeCollection::hasDriver( const sal_Char* _pAsciiPattern ) const
     134             : {
     135           0 :     OUString sPrefix( getPrefix( OUString::createFromAscii( _pAsciiPattern ) ) );
     136           0 :     return ( sPrefix.getLength() > 0 );
     137             : }
     138             : 
     139           0 : bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const
     140             : {
     141           0 :     OUString sURL( _sURL);
     142           0 :     OUString sRet;
     143           0 :     OUString sOldPattern;
     144           0 :     StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
     145           0 :     StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
     146           0 :     for(;aIter != aEnd;++aIter)
     147             :     {
     148           0 :         WildCard aWildCard(*aIter);
     149           0 :         if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(sURL) )
     150             :         {
     151           0 :             sRet = *aIter;
     152           0 :             sOldPattern = *aIter;
     153             :         }
     154           0 :     }
     155           0 :     return sRet.getLength() > 0 && sRet[sRet.getLength()-1] == '*';
     156             : }
     157             : 
     158           0 : OUString ODsnTypeCollection::getMediaType(const OUString& _sURL) const
     159             : {
     160           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     161           0 :     return aFeatures.getOrDefault("MediaType",OUString());
     162             : }
     163             : 
     164           0 : OUString ODsnTypeCollection::getDatasourcePrefixFromMediaType(const OUString& _sMediaType,const OUString& _sExtension)
     165             : {
     166           0 :     OUString sURL, sFallbackURL;
     167           0 :     const uno::Sequence< OUString > aURLs = m_aDriverConfig.getURLs();
     168           0 :     const OUString* pIter = aURLs.getConstArray();
     169           0 :     const OUString* pEnd = pIter + aURLs.getLength();
     170           0 :     for(;pIter != pEnd;++pIter )
     171             :     {
     172           0 :         const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(*pIter);
     173           0 :         if ( aFeatures.getOrDefault("MediaType",OUString()) == _sMediaType )
     174             :         {
     175           0 :             const OUString sFileExtension = aFeatures.getOrDefault("Extension",OUString());
     176           0 :             if ( _sExtension == sFileExtension )
     177             :             {
     178           0 :                 sURL = *pIter;
     179           0 :                 break;
     180             :             }
     181           0 :             if ( sFileExtension.isEmpty() && !_sExtension.isEmpty() )
     182           0 :                 sFallbackURL = *pIter;
     183             :         }
     184             :     }
     185             : 
     186           0 :     if ( !sURL.getLength() && sFallbackURL.getLength() )
     187           0 :         sURL = sFallbackURL;
     188             : 
     189           0 :     sURL = comphelper::string::stripEnd(sURL, '*');
     190           0 :     return sURL;
     191             : }
     192             : 
     193           0 : bool ODsnTypeCollection::isShowPropertiesEnabled( const OUString& _sURL ) const
     194             : {
     195           0 :     return !(    _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:embedded:hsqldb",sizeof("sdbc:embedded:hsqldb")-1)
     196           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:embedded:firebird",sizeof("sdbc:embedded:firebird")-1)
     197           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlook",sizeof("sdbc:address:outlook")-1)
     198           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlookexp",sizeof("sdbc:address:outlookexp")-1)
     199           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:mozilla:",sizeof("sdbc:address:mozilla:")-1)
     200           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:kab",sizeof("sdbc:address:kab")-1)
     201           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:local",sizeof("sdbc:address:evolution:local")-1)
     202           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:groupwise",sizeof("sdbc:address:evolution:groupwise")-1)
     203           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:ldap",sizeof("sdbc:address:evolution:ldap")-1)
     204           0 :             ||  _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:macab",sizeof("sdbc:address:macab")-1)  );
     205             : }
     206             : 
     207           0 : void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sDatabaseName,OUString& _rsHostname,sal_Int32& _nPortNumber) const
     208             : {
     209           0 :     OUString sUrl = cutPrefix(_rDsn);
     210           0 :     if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) )
     211             :     {
     212           0 :         lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
     213           0 :         if ( !_rsHostname.getLength() && comphelper::string::getTokenCount(sUrl, ':') == 2 )
     214             :         {
     215           0 :             _nPortNumber = -1;
     216           0 :             _rsHostname = sUrl.getToken(0,':');
     217             :         }
     218           0 :         if ( _rsHostname.getLength() )
     219           0 :             _rsHostname = _rsHostname.getToken(comphelper::string::getTokenCount(_rsHostname, '@') - 1, '@');
     220           0 :         _sDatabaseName = sUrl.getToken(comphelper::string::getTokenCount(sUrl, ':') - 1, ':');
     221             :     }
     222           0 :     else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:address:ldap:",sizeof("sdbc:address:ldap:")-1) )
     223             :     {
     224           0 :         lcl_extractHostAndPort(sUrl,_sDatabaseName,_nPortNumber);
     225             :     }
     226           0 :     else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:mysqlc:",sizeof("sdbc:mysql:mysqlc:")-1) || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:jdbc:",sizeof("sdbc:mysql:jdbc:")-1) )
     227             :     {
     228           0 :         lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
     229             : 
     230           0 :         if ( _nPortNumber == -1 && !_rsHostname.getLength() && comphelper::string::getTokenCount(sUrl, '/') == 2 )
     231           0 :             _rsHostname = sUrl.getToken(0,'/');
     232           0 :         _sDatabaseName = sUrl.getToken(comphelper::string::getTokenCount(sUrl, '/') - 1, '/');
     233             :     }
     234           0 :     else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=",sizeof("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=")-1)
     235           0 :          || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=",sizeof("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=")-1))
     236             :     {
     237           0 :         OUString sNewFileName;
     238           0 :         if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None )
     239             :         {
     240           0 :             _sDatabaseName = sNewFileName;
     241           0 :         }
     242           0 :     }
     243           0 : }
     244             : 
     245           0 : OUString ODsnTypeCollection::getJavaDriverClass(const OUString& _sURL) const
     246             : {
     247           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getProperties(_sURL);
     248           0 :     return aFeatures.getOrDefault("JavaDriverClass",OUString());
     249             : }
     250             : 
     251           0 : sal_Bool ODsnTypeCollection::isFileSystemBased(const OUString& _sURL) const
     252             : {
     253           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     254           0 :     return aFeatures.getOrDefault("FileSystemBased",sal_False);
     255             : }
     256             : 
     257           0 : sal_Bool ODsnTypeCollection::supportsTableCreation(const OUString& _sURL) const
     258             : {
     259           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     260           0 :     return aFeatures.getOrDefault("SupportsTableCreation",sal_False);
     261             : }
     262             : 
     263           0 : sal_Bool ODsnTypeCollection::supportsColumnDescription(const OUString& _sURL) const
     264             : {
     265           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     266           0 :     return aFeatures.getOrDefault("SupportsColumnDescription",sal_False);
     267             : }
     268             : 
     269           0 : sal_Bool ODsnTypeCollection::supportsBrowsing(const OUString& _sURL) const
     270             : {
     271           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     272           0 :     return aFeatures.getOrDefault("SupportsBrowsing",sal_False);
     273             : }
     274             : 
     275           0 : sal_Bool ODsnTypeCollection::supportsDBCreation(const OUString& _sURL) const
     276             : {
     277           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     278           0 :     return aFeatures.getOrDefault("SupportsDBCreation",sal_False);
     279             : }
     280             : 
     281           0 : bool ODsnTypeCollection::needsJVM(const OUString& _sURL) const
     282             : {
     283           0 :     const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
     284           0 :     return aFeatures.getOrDefault("UseJava",sal_False);
     285             : }
     286             : 
     287           0 : Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( const OUString& _sURL ) const
     288             : {
     289           0 :     const ::comphelper::NamedValueCollection& aProperties = m_aDriverConfig.getProperties(_sURL);
     290           0 :     return aProperties.getPropertyValues();
     291             : }
     292             : 
     293           0 : bool ODsnTypeCollection::isEmbeddedDatabase( const OUString& _sURL ) const
     294             : {
     295           0 :     return _sURL.startsWith( "sdbc:embedded:" );
     296             : }
     297             : 
     298           0 : OUString ODsnTypeCollection::getEmbeddedDatabase() const
     299             : {
     300           0 :     OUString sEmbeddedDatabaseURL;
     301           0 :     static const OUString s_sNodeName("org.openoffice.Office.DataAccess"); ///Installed
     302           0 :     const ::utl::OConfigurationTreeRoot aInstalled = ::utl::OConfigurationTreeRoot::createWithComponentContext(m_xContext, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
     303           0 :     if ( aInstalled.isValid() )
     304             :     {
     305           0 :         if ( aInstalled.hasByName("EmbeddedDatabases/DefaultEmbeddedDatabase/Value") )
     306             :         {
     307           0 :             static const OUString s_sValue("EmbeddedDatabases/DefaultEmbeddedDatabase/Value");
     308             : 
     309           0 :             aInstalled.getNodeValue(s_sValue) >>= sEmbeddedDatabaseURL;
     310           0 :             if ( !sEmbeddedDatabaseURL.isEmpty() )
     311           0 :                 aInstalled.getNodeValue(s_sValue + "/" + sEmbeddedDatabaseURL + "/URL") >>= sEmbeddedDatabaseURL;
     312             :         }
     313             :     }
     314           0 :     if ( sEmbeddedDatabaseURL.isEmpty() )
     315           0 :         sEmbeddedDatabaseURL = "sdbc:embedded:hsqldb";
     316             : 
     317           0 :     return sEmbeddedDatabaseURL;
     318             : }
     319             : 
     320           0 : ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const
     321             : {
     322           0 :     return TypeIterator(this, 0);
     323             : }
     324             : 
     325           0 : ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const
     326             : {
     327           0 :     return TypeIterator(this, m_aDsnTypesDisplayNames.size());
     328             : }
     329             : 
     330           0 : DATASOURCE_TYPE ODsnTypeCollection::determineType(const OUString& _rDsn) const
     331             : {
     332           0 :     OUString sDsn(comphelper::string::stripEnd(_rDsn, '*'));
     333           0 :     sal_Int32 nSeparator = sDsn.indexOf(static_cast<sal_Unicode>(':'));
     334           0 :     if (-1 == nSeparator)
     335             :     {
     336           0 :         if (!sDsn.isEmpty())
     337             :         {
     338             :             // there should be at least one such separator
     339             :             OSL_FAIL("ODsnTypeCollection::implDetermineType : missing the colon !");
     340             :         }
     341             : 
     342           0 :         return DST_UNKNOWN;
     343             :     }
     344             : 
     345             :     // find first :
     346           0 :     if (sDsn.startsWithIgnoreAsciiCase("jdbc:oracle:thin:"))
     347           0 :         return DST_ORACLE_JDBC;
     348             : 
     349           0 :     if (sDsn.startsWithIgnoreAsciiCase("jdbc:"))
     350           0 :         return DST_JDBC;
     351             : 
     352           0 :     if (sDsn.equalsIgnoreAsciiCase("sdbc:embedded:hsqldb"))
     353           0 :         return DST_EMBEDDED_HSQLDB;
     354             : 
     355           0 :     if (sDsn.equalsIgnoreAsciiCase("sdbc:embedded:firebird"))
     356           0 :         return DST_EMBEDDED_FIREBIRD;
     357             : 
     358             :     // find second :
     359           0 :     nSeparator = sDsn.indexOf(static_cast<sal_Unicode>(':'), nSeparator + 1);
     360           0 :     if (-1 == nSeparator)
     361             :     {
     362             :         // at the moment only jdbc is allowed to have just one separator
     363             :         OSL_FAIL("ODsnTypeCollection::implDetermineType : missing the second colon !");
     364           0 :         return DST_UNKNOWN;
     365             :     }
     366             : 
     367           0 :     if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:"))
     368             :     {
     369           0 :         if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:access"))
     370             :         {
     371           0 :             if (sDsn.equalsIgnoreAsciiCase("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;"))
     372           0 :                 return DST_MSACCESS_2007;
     373             :             else
     374           0 :                 return DST_MSACCESS;
     375             :         }
     376           0 :         return DST_ADO;
     377             :     }
     378             : 
     379             :     struct KnownPrefix
     380             :     {
     381             :         const sal_Char*         pAsciiPrefix;
     382             :         const DATASOURCE_TYPE   eType;
     383             :         const bool              bMatchComplete;
     384             : 
     385           0 :         KnownPrefix( const sal_Char* _p, const DATASOURCE_TYPE _t, const bool _m )
     386             :             :pAsciiPrefix( _p )
     387             :             ,eType ( _t )
     388           0 :             ,bMatchComplete( _m )
     389             :         {
     390           0 :         }
     391             :     };
     392             :     KnownPrefix aKnowPrefixes[] =
     393             :     {
     394             :         KnownPrefix( "sdbc:calc:",          DST_CALC,               false ),
     395             :         KnownPrefix( "sdbc:flat:",          DST_FLAT,               false ),
     396             :         KnownPrefix( "sdbc:odbc:",          DST_ODBC,               false ),
     397             :         KnownPrefix( "sdbc:dbase:",         DST_DBASE,              false ),
     398             :         KnownPrefix( "sdbc:firebird:",      DST_FIREBIRD,           false ),
     399             :         KnownPrefix( "sdbc:mysql:odbc:",    DST_MYSQL_ODBC,         false ),
     400             :         KnownPrefix( "sdbc:mysql:jdbc:",    DST_MYSQL_JDBC,         false ),
     401             :         KnownPrefix( "sdbc:mysql:mysqlc:",  DST_MYSQL_NATIVE,       false ),
     402             :         KnownPrefix( "sdbc:mysqlc:",        DST_MYSQL_NATIVE_DIRECT,false ),
     403             : 
     404             :         KnownPrefix( "sdbc:address:mozilla:",           DST_MOZILLA,            true ),
     405             :         KnownPrefix( "sdbc:address:thunderbird:",       DST_THUNDERBIRD,        true ),
     406             :         KnownPrefix( "sdbc:address:ldap:",              DST_LDAP,               true ),
     407             :         KnownPrefix( "sdbc:address:outlook",            DST_OUTLOOK,            true ),
     408             :         KnownPrefix( "sdbc:address:outlookexp",         DST_OUTLOOKEXP,         true ),
     409             :         KnownPrefix( "sdbc:address:evolution:ldap",     DST_EVOLUTION_LDAP,     true ),
     410             :         KnownPrefix( "sdbc:address:evolution:groupwise",DST_EVOLUTION_GROUPWISE,true ),
     411             :         KnownPrefix( "sdbc:address:evolution:local",    DST_EVOLUTION,          true ),
     412             :         KnownPrefix( "sdbc:address:kab",                DST_KAB,                true ),
     413             :         KnownPrefix( "sdbc:address:macab",              DST_MACAB,              true )
     414           0 :     };
     415             : 
     416           0 :     for ( size_t i=0; i < sizeof( aKnowPrefixes ) / sizeof( aKnowPrefixes[0] ); ++i )
     417             :     {
     418           0 :         sal_uInt16 nMatchLen = aKnowPrefixes[i].bMatchComplete ? sDsn.getLength() : (sal_uInt16)rtl_str_getLength( aKnowPrefixes[i].pAsciiPrefix );
     419           0 :         if ( sDsn.equalsIgnoreAsciiCaseAsciiL( aKnowPrefixes[i].pAsciiPrefix, nMatchLen ) )
     420           0 :             return aKnowPrefixes[i].eType;
     421             :     }
     422             : 
     423           0 :     return DST_UNKNOWN;
     424             : }
     425             : 
     426           0 : void ODsnTypeCollection::fillPageIds(const OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const
     427             : {
     428           0 :     DATASOURCE_TYPE eType = determineType(_sURL);
     429           0 :     switch(eType)
     430             :     {
     431             :         case DST_ADO:
     432           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADO);
     433           0 :             break;
     434             :         case DST_DBASE:
     435           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_DBASE);
     436           0 :             break;
     437             :         case DST_FLAT:
     438           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_TEXT);
     439           0 :             break;
     440             :         case DST_CALC:
     441           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_SPREADSHEET);
     442           0 :             break;
     443             :         case DST_ODBC:
     444           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ODBC);
     445           0 :             break;
     446             :         case DST_JDBC:
     447           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_JDBC);
     448           0 :             break;
     449             :         case DST_MYSQL_ODBC:
     450           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
     451           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_ODBC);
     452           0 :             break;
     453             :         case DST_MYSQL_JDBC:
     454           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
     455           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_JDBC);
     456           0 :             break;
     457             :         case DST_MYSQL_NATIVE:
     458           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
     459           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_NATIVE);
     460           0 :             break;
     461             :         case DST_ORACLE_JDBC:
     462           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ORACLE);
     463           0 :             break;
     464             :         case DST_LDAP:
     465           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP);
     466           0 :             break;
     467             :         case DST_MSACCESS:
     468             :         case DST_MSACCESS_2007:
     469           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS);
     470           0 :             break;
     471             :         case DST_OUTLOOKEXP:
     472             :         case DST_OUTLOOK:
     473             :         case DST_MOZILLA:
     474             :         case DST_THUNDERBIRD:
     475             :         case DST_EVOLUTION:
     476             :         case DST_EVOLUTION_GROUPWISE:
     477             :         case DST_EVOLUTION_LDAP:
     478             :         case DST_KAB:
     479             :         case DST_MACAB:
     480             :         case DST_EMBEDDED_HSQLDB:
     481             :         case DST_EMBEDDED_FIREBIRD:
     482           0 :             break;
     483             :         default:
     484           0 :             _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_USERDEFINED);
     485           0 :             break;
     486             :     }
     487           0 : }
     488             : 
     489           0 : OUString ODsnTypeCollection::getType(const OUString& _sURL) const
     490             : {
     491           0 :     OUString sOldPattern;
     492           0 :     StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
     493           0 :     StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
     494           0 :     for(;aIter != aEnd;++aIter)
     495             :     {
     496           0 :         WildCard aWildCard(*aIter);
     497           0 :         if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(_sURL) )
     498             :         {
     499           0 :             sOldPattern = *aIter;
     500             :         }
     501           0 :     }
     502           0 :     return sOldPattern;
     503             : }
     504             : 
     505           0 : sal_Int32 ODsnTypeCollection::getIndexOf(const OUString& _sURL) const
     506             : {
     507           0 :     sal_Int32 nRet = -1;
     508           0 :     OUString sURL( _sURL);
     509           0 :     OUString sOldPattern;
     510           0 :     StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
     511           0 :     StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
     512           0 :     for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i)
     513             :     {
     514           0 :         WildCard aWildCard(*aIter);
     515           0 :         if ( sOldPattern.getLength() < aIter->getLength() && aWildCard.Matches(sURL) )
     516             :         {
     517           0 :             nRet = i;
     518           0 :             sOldPattern = *aIter;
     519             :         }
     520           0 :     }
     521             : 
     522           0 :     return nRet;
     523             : }
     524             : 
     525           0 : sal_Int32 ODsnTypeCollection::size() const
     526             : {
     527           0 :     return m_aDsnPrefixes.size();
     528             : }
     529             : 
     530             : // ODsnTypeCollection::TypeIterator
     531           0 : ODsnTypeCollection::TypeIterator::TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos)
     532             :     :m_pContainer(_pContainer)
     533           0 :     ,m_nPosition(_nInitialPos)
     534             : {
     535             :     OSL_ENSURE(m_pContainer, "ODsnTypeCollection::TypeIterator::TypeIterator : invalid container!");
     536             : #if OSL_DEBUG_LEVEL > 0
     537             :     ++const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
     538             : #endif
     539           0 : }
     540             : 
     541           0 : ODsnTypeCollection::TypeIterator::TypeIterator(const TypeIterator& _rSource)
     542             :     :m_pContainer(_rSource.m_pContainer)
     543           0 :     ,m_nPosition(_rSource.m_nPosition)
     544             : {
     545             : #if OSL_DEBUG_LEVEL > 0
     546             :     ++const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
     547             : #endif
     548           0 : }
     549             : 
     550           0 : ODsnTypeCollection::TypeIterator::~TypeIterator()
     551             : {
     552             : #if OSL_DEBUG_LEVEL > 0
     553             :     --const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
     554             : #endif
     555           0 : }
     556             : 
     557           0 : OUString ODsnTypeCollection::TypeIterator::getDisplayName() const
     558             : {
     559             :     OSL_ENSURE(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!");
     560           0 :     return m_pContainer->m_aDsnTypesDisplayNames[m_nPosition];
     561             : }
     562             : 
     563           0 : OUString ODsnTypeCollection::TypeIterator::getURLPrefix() const
     564             : {
     565             :     OSL_ENSURE(m_nPosition < (sal_Int32)m_pContainer->m_aDsnPrefixes.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!");
     566           0 :     return m_pContainer->m_aDsnPrefixes[m_nPosition];
     567             : }
     568             : 
     569           0 : const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator++()
     570             : {
     571             :     OSL_ENSURE(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::operator++ : invalid position!");
     572           0 :     if (m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size())
     573           0 :         ++m_nPosition;
     574           0 :     return *this;
     575             : }
     576             : 
     577           0 : const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator--()
     578             : {
     579             :     OSL_ENSURE(m_nPosition >= 0, "ODsnTypeCollection::TypeIterator::operator-- : invalid position!");
     580           0 :     if (m_nPosition >= 0)
     581           0 :         --m_nPosition;
     582           0 :     return *this;
     583             : }
     584             : 
     585           0 : bool operator==(const ODsnTypeCollection::TypeIterator& lhs, const ODsnTypeCollection::TypeIterator& rhs)
     586             : {
     587           0 :     return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition);
     588             : }
     589             : 
     590             : }   // namespace dbaccess
     591             : 
     592             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10