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 : #ifndef INCLUDED_DBACCESS_SOURCE_INC_DSNTYPES_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_INC_DSNTYPES_HXX
22 :
23 : #include <sal/config.h>
24 :
25 : #include <vector>
26 :
27 : #include "dbadllapi.hxx"
28 : #include <connectivity/DriversConfig.hxx>
29 :
30 : namespace dbaccess
31 : {
32 :
33 : // DATASOURCE_TYPE
34 : /// known datasource types
35 : enum DATASOURCE_TYPE
36 : {
37 : DST_MSACCESS = 1,
38 : DST_MYSQL_ODBC = 2,
39 : DST_MYSQL_JDBC = 3,
40 : DST_ORACLE_JDBC = 4,
41 : //5 was DST_ADABAS
42 : DST_CALC = 6,
43 : DST_DBASE = 7,
44 : DST_FLAT = 8,
45 : DST_JDBC = 9,
46 : DST_ODBC = 10,
47 : DST_ADO = 11,
48 : DST_MOZILLA = 12,
49 : DST_THUNDERBIRD = 13,
50 : DST_LDAP = 14,
51 : DST_OUTLOOK = 15,
52 : DST_OUTLOOKEXP = 16,
53 : DST_EVOLUTION = 17,
54 : DST_EVOLUTION_GROUPWISE = 18,
55 : DST_EVOLUTION_LDAP = 19,
56 : DST_KAB = 20,
57 : DST_MACAB = 21,
58 : DST_MSACCESS_2007 = 22,
59 : DST_EMBEDDED_HSQLDB = 23,
60 : DST_MYSQL_NATIVE = 24,
61 : DST_MYSQL_NATIVE_DIRECT = 25,
62 : DST_FIREBIRD = 26,
63 : DST_EMBEDDED_FIREBIRD = 27,
64 :
65 : DST_USERDEFINE1, /// first user defined driver
66 : DST_USERDEFINE2,
67 : DST_USERDEFINE3,
68 : DST_USERDEFINE4,
69 : DST_USERDEFINE5,
70 : DST_USERDEFINE6,
71 : DST_USERDEFINE7,
72 : DST_USERDEFINE8,
73 : DST_USERDEFINE9,
74 : DST_USERDEFINE10,
75 :
76 : DST_UNKNOWN /// unrecognized type
77 : };
78 :
79 : #define PAGE_DBSETUPWIZARD_INTRO 0
80 : #define PAGE_DBSETUPWIZARD_DBASE 1
81 : #define PAGE_DBSETUPWIZARD_TEXT 2
82 : #define PAGE_DBSETUPWIZARD_MSACCESS 3
83 : #define PAGE_DBSETUPWIZARD_LDAP 4
84 : //5 was PAGE_DBSETUPWIZARD_ADABAS
85 : #define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6
86 : #define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7
87 : #define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8
88 : #define PAGE_DBSETUPWIZARD_ORACLE 9
89 : #define PAGE_DBSETUPWIZARD_JDBC 10
90 : #define PAGE_DBSETUPWIZARD_ADO 11
91 : #define PAGE_DBSETUPWIZARD_ODBC 12
92 : #define PAGE_DBSETUPWIZARD_SPREADSHEET 13
93 : #define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14
94 : #define PAGE_DBSETUPWIZARD_FINAL 16
95 : #define PAGE_DBSETUPWIZARD_USERDEFINED 17
96 : #define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18
97 :
98 : // ODsnTypeCollection
99 : class OOO_DLLPUBLIC_DBA ODsnTypeCollection
100 : {
101 : protected:
102 : typedef std::vector<OUString> StringVector;
103 :
104 : StringVector m_aDsnTypesDisplayNames; /// user readable names for the datasource types
105 : StringVector m_aDsnPrefixes; /// DSN prefixes which determine the type of a datasource
106 : ::connectivity::DriversConfig m_aDriverConfig;
107 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
108 :
109 : #if OSL_DEBUG_LEVEL > 0
110 : sal_Int32 m_nLivingIterators; /// just for debugging reasons, counts the living iterators
111 : #endif
112 :
113 : public:
114 : class TypeIterator;
115 : friend class ODsnTypeCollection::TypeIterator;
116 :
117 : ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xContext);
118 : ~ODsnTypeCollection();
119 :
120 : /// get the datasource type display name from a DSN string
121 : OUString getTypeDisplayName(const OUString& _sURL) const;
122 :
123 : /// on a given string, cut the type prefix and return the result
124 : OUString cutPrefix(const OUString& _sURL) const;
125 :
126 : /// on a given string, return the type prefix
127 : OUString getPrefix(const OUString& _sURL) const;
128 :
129 : /// determines whether there is a driver for the given URL prefix/pattern
130 : bool hasDriver( const sal_Char* _pAsciiPattern ) const;
131 :
132 : /// on a given string, return the Java Driver Class
133 : OUString getJavaDriverClass(const OUString& _sURL) const;
134 :
135 : /// returns the media type of a file based database
136 : OUString getMediaType(const OUString& _sURL) const;
137 :
138 : /// returns the dsn prefix for a given media type
139 : OUString getDatasourcePrefixFromMediaType(const OUString& _sMediaType,const OUString& _sExtension = OUString() );
140 :
141 : void extractHostNamePort(const OUString& _rDsn,OUString& _sDatabaseName,OUString& _rHostname,sal_Int32& _nPortNumber) const;
142 :
143 : /// check if the given data source allows creation of tables
144 : bool supportsTableCreation(const OUString& _sURL) const;
145 :
146 : /// check if the given data source allows to show column description.
147 : bool supportsColumnDescription(const OUString& _sURL) const;
148 :
149 : // check if a Browse button may be shown to insert connection url
150 : bool supportsBrowsing(const OUString& _sURL) const;
151 :
152 : // check if a Create New Database button may be shown to insert connection url
153 : bool supportsDBCreation(const OUString& _sURL) const;
154 :
155 : /// check if the given data source tyoe is based on the file system - i.e. the URL is a prefix plus a file URL
156 : bool isFileSystemBased(const OUString& _sURL) const;
157 :
158 : bool isConnectionUrlRequired(const OUString& _sURL) const;
159 :
160 : /// checks if the given data source type embeds its data into the database document
161 : static bool isEmbeddedDatabase( const OUString& _sURL );
162 :
163 : OUString getEmbeddedDatabase() const;
164 :
165 : // returns true when the properties dialog can be shown, otherwise false.
166 : static bool isShowPropertiesEnabled( const OUString& _sURL );
167 :
168 : /** returns default settings for newly created databases of the given type.
169 : */
170 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>
171 : getDefaultDBSettings( const OUString& _sURL ) const;
172 :
173 : /// get access to the first element of the types collection
174 : inline TypeIterator begin() const;
175 : /// get access to the (last + 1st) element of the types collection
176 : inline TypeIterator end() const;
177 :
178 : void fillPageIds(const OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const;
179 :
180 : DATASOURCE_TYPE determineType(const OUString& _rDsn) const;
181 :
182 : bool needsJVM(const OUString& _rDsn) const;
183 :
184 : sal_Int32 getIndexOf(const OUString& _sURL) const;
185 : sal_Int32 size() const;
186 : OUString getType(const OUString& _sURL) const;
187 : };
188 :
189 : //- ODsnTypeCollection::TypeIterator
190 : class OOO_DLLPUBLIC_DBA ODsnTypeCollection::TypeIterator
191 : {
192 : friend class ODsnTypeCollection;
193 :
194 : friend bool OOO_DLLPUBLIC_DBA operator==(const TypeIterator& lhs, const TypeIterator& rhs);
195 0 : friend bool OOO_DLLPUBLIC_DBA operator!=(const TypeIterator& lhs, const TypeIterator& rhs) { return !(lhs == rhs); }
196 :
197 : protected:
198 : const ODsnTypeCollection* m_pContainer;
199 : sal_Int32 m_nPosition;
200 :
201 : public:
202 : TypeIterator(const TypeIterator& _rSource);
203 : ~TypeIterator();
204 :
205 : OUString getURLPrefix() const;
206 : OUString getDisplayName() const;
207 :
208 : /// prefix increment
209 : const TypeIterator& operator++();
210 : /// postfix increment
211 : const TypeIterator operator++(int) { TypeIterator hold(*this); ++*this; return hold; }
212 :
213 : /// prefix decrement
214 : const TypeIterator& operator--();
215 : /// postfix decrement
216 : const TypeIterator operator--(int) { TypeIterator hold(*this); --*this; return hold; }
217 :
218 : protected:
219 : TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos = 0);
220 : };
221 :
222 :
223 0 : inline ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const { return ODsnTypeCollection::TypeIterator(this, 0);}
224 0 : inline ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const { return ODsnTypeCollection::TypeIterator(this, m_aDsnTypesDisplayNames.size());}
225 :
226 : } // namespace dbaccess
227 :
228 : #endif // INCLUDED_DBACCESS_SOURCE_INC_DSNTYPES_HXX
229 :
230 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|