1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_INC_DSNTYPES_HXX
21 #define INCLUDED_DBACCESS_SOURCE_INC_DSNTYPES_HXX
23 #include <sal/config.h>
27 #include "dbadllapi.hxx"
28 #include <connectivity/DriversConfig.hxx>
34 /// known datasource types
54 DST_EVOLUTION_GROUPWISE
= 18,
55 DST_EVOLUTION_LDAP
= 19,
58 DST_MSACCESS_2007
= 22,
59 DST_EMBEDDED_HSQLDB
= 23,
60 DST_MYSQL_NATIVE
= 24,
61 DST_MYSQL_NATIVE_DIRECT
= 25,
63 DST_EMBEDDED_FIREBIRD
= 27,
66 DST_USERDEFINE1
, /// first user defined driver
77 DST_UNKNOWN
/// unrecognized type
80 #define PAGE_DBSETUPWIZARD_INTRO 0
81 #define PAGE_DBSETUPWIZARD_DBASE 1
82 #define PAGE_DBSETUPWIZARD_TEXT 2
83 #define PAGE_DBSETUPWIZARD_MSACCESS 3
84 #define PAGE_DBSETUPWIZARD_LDAP 4
85 //5 was PAGE_DBSETUPWIZARD_ADABAS
86 #define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6
87 #define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7
88 #define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8
89 #define PAGE_DBSETUPWIZARD_ORACLE 9
90 #define PAGE_DBSETUPWIZARD_JDBC 10
91 #define PAGE_DBSETUPWIZARD_ADO 11
92 #define PAGE_DBSETUPWIZARD_ODBC 12
93 #define PAGE_DBSETUPWIZARD_SPREADSHEET 13
94 #define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14
95 #define PAGE_DBSETUPWIZARD_FINAL 16
96 #define PAGE_DBSETUPWIZARD_USERDEFINED 17
97 #define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18
100 class OOO_DLLPUBLIC_DBA ODsnTypeCollection
103 typedef std::vector
<OUString
> StringVector
;
105 StringVector m_aDsnTypesDisplayNames
; /// user readable names for the datasource types
106 StringVector m_aDsnPrefixes
; /// DSN prefixes which determine the type of a datasource
107 ::connectivity::DriversConfig m_aDriverConfig
;
108 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
110 #if OSL_DEBUG_LEVEL > 0
111 sal_Int32 m_nLivingIterators
; /// just for debugging reasons, counts the living iterators
116 friend class ODsnTypeCollection::TypeIterator
;
118 ODsnTypeCollection(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _xContext
);
119 ~ODsnTypeCollection();
121 /// get the datasource type display name from a DSN string
122 OUString
getTypeDisplayName(const OUString
& _sURL
) const;
124 /// on a given string, cut the type prefix and return the result
125 OUString
cutPrefix(const OUString
& _sURL
) const;
127 /// on a given string, return the type prefix
128 OUString
getPrefix(const OUString
& _sURL
) const;
130 /// determines whether there is a driver for the given URL prefix/pattern
131 bool hasDriver( const sal_Char
* _pAsciiPattern
) const;
133 /// on a given string, return the Java Driver Class
134 OUString
getJavaDriverClass(const OUString
& _sURL
) const;
136 /// returns the media type of a file based database
137 OUString
getMediaType(const OUString
& _sURL
) const;
139 /// returns the dsn prefix for a given media type
140 OUString
getDatasourcePrefixFromMediaType(const OUString
& _sMediaType
,const OUString
& _sExtension
= OUString() );
142 void extractHostNamePort(const OUString
& _rDsn
,OUString
& _sDatabaseName
,OUString
& _rHostname
,sal_Int32
& _nPortNumber
) const;
144 /// check if the given data source allows creation of tables
145 bool supportsTableCreation(const OUString
& _sURL
) const;
147 /// check if the given data source allows to show column description.
148 bool supportsColumnDescription(const OUString
& _sURL
) const;
150 // check if a Browse button may be shown to insert connection url
151 bool supportsBrowsing(const OUString
& _sURL
) const;
153 // check if a Create New Database button may be shown to insert connection url
154 bool supportsDBCreation(const OUString
& _sURL
) const;
156 /// check if the given data source tyoe is based on the file system - i.e. the URL is a prefix plus a file URL
157 bool isFileSystemBased(const OUString
& _sURL
) const;
159 bool isConnectionUrlRequired(const OUString
& _sURL
) const;
161 /// checks if the given data source type embeds its data into the database document
162 static bool isEmbeddedDatabase( const OUString
& _sURL
);
164 OUString
getEmbeddedDatabase() const;
166 // returns true when the properties dialog can be shown, otherwise false.
167 static bool isShowPropertiesEnabled( const OUString
& _sURL
);
169 /** returns default settings for newly created databases of the given type.
171 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>
172 getDefaultDBSettings( const OUString
& _sURL
) const;
174 /// get access to the first element of the types collection
175 inline TypeIterator
begin() const;
176 /// get access to the (last + 1st) element of the types collection
177 inline TypeIterator
end() const;
179 void fillPageIds(const OUString
& _sURL
,::std::vector
<sal_Int16
>& _rOutPathIds
) const;
181 DATASOURCE_TYPE
determineType(const OUString
& _rDsn
) const;
183 bool needsJVM(const OUString
& _rDsn
) const;
185 sal_Int32
getIndexOf(const OUString
& _sURL
) const;
186 sal_Int32
size() const;
187 OUString
getType(const OUString
& _sURL
) const;
190 //- ODsnTypeCollection::TypeIterator
191 class OOO_DLLPUBLIC_DBA
ODsnTypeCollection::TypeIterator
193 friend class ODsnTypeCollection
;
195 friend bool OOO_DLLPUBLIC_DBA
operator==(const TypeIterator
& lhs
, const TypeIterator
& rhs
);
196 friend bool OOO_DLLPUBLIC_DBA
operator!=(const TypeIterator
& lhs
, const TypeIterator
& rhs
) { return !(lhs
== rhs
); }
199 const ODsnTypeCollection
* m_pContainer
;
200 sal_Int32 m_nPosition
;
203 TypeIterator(const TypeIterator
& _rSource
);
206 OUString
getURLPrefix() const;
207 OUString
getDisplayName() const;
210 const TypeIterator
& operator++();
211 /// postfix increment
212 const TypeIterator
operator++(int) { TypeIterator
hold(*this); ++*this; return hold
; }
215 const TypeIterator
& operator--();
216 /// postfix decrement
217 const TypeIterator
operator--(int) { TypeIterator
hold(*this); --*this; return hold
; }
220 TypeIterator(const ODsnTypeCollection
* _pContainer
, sal_Int32 _nInitialPos
= 0);
224 inline ODsnTypeCollection::TypeIterator
ODsnTypeCollection::begin() const { return ODsnTypeCollection::TypeIterator(this, 0);}
225 inline ODsnTypeCollection::TypeIterator
ODsnTypeCollection::end() const { return ODsnTypeCollection::TypeIterator(this, m_aDsnTypesDisplayNames
.size());}
227 } // namespace dbaccess
229 #endif // INCLUDED_DBACCESS_SOURCE_INC_DSNTYPES_HXX
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */