1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dsntypes.hxx,v $
11 * $Revision: 1.3.68.4 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef _DBACCESS_DSNTYPES_HXX_
33 #define _DBACCESS_DSNTYPES_HXX_
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <comphelper/stl_types.hxx>
38 #include "dbadllapi.hxx"
39 #include <tools/string.hxx>
41 //.........................................................................
44 //.........................................................................
46 //=========================================================================
48 //=========================================================================
49 /// known datasource types
69 DST_EVOLUTION_GROUPWISE
= 18,
70 DST_EVOLUTION_LDAP
= 19,
73 DST_MSACCESS_2007
= 22,
74 DST_EMBEDDED_HSQLDB
= 23,
75 DST_MYSQL_NATIVE
= 24,
76 DST_MYSQL_NATIVE_DIRECT
= 25,
78 DST_USERDEFINE1
, /// first user defined driver
90 DST_UNKNOWN
/// unrecognized type
93 #define PAGE_DBSETUPWIZARD_INTRO 0
94 #define PAGE_DBSETUPWIZARD_DBASE 1
95 #define PAGE_DBSETUPWIZARD_TEXT 2
96 #define PAGE_DBSETUPWIZARD_MSACCESS 3
97 #define PAGE_DBSETUPWIZARD_LDAP 4
98 #define PAGE_DBSETUPWIZARD_ADABAS 5
99 #define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6
100 #define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7
101 #define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8
102 #define PAGE_DBSETUPWIZARD_ORACLE 9
103 #define PAGE_DBSETUPWIZARD_JDBC 10
104 #define PAGE_DBSETUPWIZARD_ADO 11
105 #define PAGE_DBSETUPWIZARD_ODBC 12
106 #define PAGE_DBSETUPWIZARD_SPREADSHEET 13
107 #define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14
108 #define PAGE_DBSETUPWIZARD_MOZILLA 15
109 #define PAGE_DBSETUPWIZARD_FINAL 16
110 #define PAGE_DBSETUPWIZARD_USERDEFINED 17
111 #define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18
114 //=========================================================================
115 //= ODsnTypeCollection
116 //=========================================================================
117 class OOO_DLLPUBLIC_DBA ODsnTypeCollection
120 DECLARE_STL_VECTOR(String
, StringVector
);
122 StringVector m_aDsnTypesDisplayNames
; /// user readable names for the datasource types
123 StringVector m_aDsnPrefixes
; /// DSN prefixes which determine the type of a datasource
124 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xFactory
;
127 sal_Int32 m_nLivingIterators
; /// just for debugging reasons, counts the living iterators
132 friend class ODsnTypeCollection::TypeIterator
;
134 ODsnTypeCollection(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _xFactory
);
135 ~ODsnTypeCollection();
137 /// get the datasource type display name from a DSN string
138 String
getTypeDisplayName(const ::rtl::OUString
& _sURL
) const;
140 /// returns the extension of the user defined type
141 String
getTypeExtension(const ::rtl::OUString
& _sURL
) const;
143 /// on a given string, cut the type prefix and return the result
144 String
cutPrefix(const ::rtl::OUString
& _sURL
) const;
146 /// on a given string, return the type prefix
147 String
getPrefix(const ::rtl::OUString
& _sURL
) const;
149 /// determines whether there is a driver for the given URL prefix/pattern
150 bool hasDriver( const sal_Char
* _pAsciiPattern
) const;
152 /// on a given string, return the Java Driver Class
153 String
getJavaDriverClass(const ::rtl::OUString
& _sURL
) const;
155 /// returns the media type of a file based database
156 String
getMediaType(const ::rtl::OUString
& _sURL
) const;
158 /// returns the dsn prefix for a given media type
159 String
getDatasourcePrefixFromMediaType(const ::rtl::OUString
& _sMediaType
,const ::rtl::OUString
& _sExtension
= ::rtl::OUString() );
161 void extractHostNamePort(const ::rtl::OUString
& _rDsn
,String
& _sDatabaseName
,String
& _rHostname
,sal_Int32
& _nPortNumber
) const;
163 /// check if the given data source allows creation of tables
164 sal_Bool
supportsTableCreation(const ::rtl::OUString
& _sURL
) const;
166 // check if a Browse button may be shown to insert connection url
167 sal_Bool
supportsBrowsing(const ::rtl::OUString
& _sURL
) const;
169 /// check if the given data source tyoe is based on the file system - i.e. the URL is a prefix plus a file URL
170 sal_Bool
isFileSystemBased(const ::rtl::OUString
& _sURL
) const;
172 bool isConnectionUrlRequired(const ::rtl::OUString
& _sURL
) const;
174 /// checks if the given data source type embeds its data into the database document
175 bool isEmbeddedDatabase( const ::rtl::OUString
& _sURL
) const;
177 ::rtl::OUString
getEmbeddedDatabase() const;
179 // returns true when the properties dialog can be shown, otherwise false.
180 bool isShowPropertiesEnabled( const ::rtl::OUString
& _sURL
) const;
182 /** returns default settings for newly created databases of the given type.
184 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>
185 getDefaultDBSettings( const ::rtl::OUString
& _sURL
) const;
187 /// get access to the first element of the types collection
188 TypeIterator
begin() const;
189 /// get access to the (last + 1st) element of the types collection
190 TypeIterator
end() const;
192 void fillPageIds(const ::rtl::OUString
& _sURL
,::std::vector
<sal_Int16
>& _rOutPathIds
) const;
194 DATASOURCE_TYPE
determineType(const String
& _rDsn
) const;
196 bool needsJVM(const String
& _rDsn
) const;
198 sal_Int32
getIndexOf(const ::rtl::OUString
& _sURL
) const;
199 sal_Int32
size() const;
200 ::rtl::OUString
getType(const ::rtl::OUString
& _sURL
) const;
203 //-------------------------------------------------------------------------
204 //- ODsnTypeCollection::TypeIterator
205 //-------------------------------------------------------------------------
206 class OOO_DLLPUBLIC_DBA
ODsnTypeCollection::TypeIterator
208 friend class ODsnTypeCollection
;
210 friend bool OOO_DLLPUBLIC_DBA
operator==(const TypeIterator
& lhs
, const TypeIterator
& rhs
);
211 friend bool OOO_DLLPUBLIC_DBA
operator!=(const TypeIterator
& lhs
, const TypeIterator
& rhs
) { return !(lhs
== rhs
); }
214 const ODsnTypeCollection
* m_pContainer
;
215 sal_Int32 m_nPosition
;
218 TypeIterator(const TypeIterator
& _rSource
);
221 ::rtl::OUString
getURLPrefix() const;
222 String
getDisplayName() const;
225 const TypeIterator
& operator++();
226 /// postfix increment
227 const TypeIterator
operator++(int) { TypeIterator
hold(*this); ++*this; return hold
; }
230 const TypeIterator
& operator--();
231 /// postfix decrement
232 const TypeIterator
operator--(int) { TypeIterator
hold(*this); --*this; return hold
; }
235 TypeIterator(const ODsnTypeCollection
* _pContainer
, sal_Int32 _nInitialPos
= 0);
238 //.........................................................................
239 } // namespace dbaccess
240 //.........................................................................
242 #endif // _DBACCESS_DSNTYPES_HXX_