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