calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / dbaccess / source / inc / dsntypes.hxx
blob7bc664f10d85cde1380c0be43c4fedc124d51fbb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
25 #include <vector>
27 #include <dbadllapi.hxx>
28 #include <connectivity/DriversConfig.hxx>
30 namespace dbaccess
33 // DATASOURCE_TYPE
34 /// known datasource types
35 enum DATASOURCE_TYPE
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 DST_POSTGRES = 28,
65 DST_WRITER = 29,
67 DST_USERDEFINE1, /// first user defined driver
68 DST_USERDEFINE2,
69 DST_USERDEFINE3,
70 DST_USERDEFINE4,
71 DST_USERDEFINE5,
72 DST_USERDEFINE6,
73 DST_USERDEFINE7,
74 DST_USERDEFINE8,
75 DST_USERDEFINE9,
76 DST_USERDEFINE10,
78 DST_UNKNOWN /// unrecognized type
81 #define PAGE_DBSETUPWIZARD_INTRO 0
82 #define PAGE_DBSETUPWIZARD_DBASE 1
83 #define PAGE_DBSETUPWIZARD_TEXT 2
84 #define PAGE_DBSETUPWIZARD_MSACCESS 3
85 #define PAGE_DBSETUPWIZARD_LDAP 4
86 //5 was PAGE_DBSETUPWIZARD_ADABAS
87 #define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6
88 #define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7
89 #define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8
90 #define PAGE_DBSETUPWIZARD_ORACLE 9
91 #define PAGE_DBSETUPWIZARD_JDBC 10
92 #define PAGE_DBSETUPWIZARD_ADO 11
93 #define PAGE_DBSETUPWIZARD_ODBC 12
94 #define PAGE_DBSETUPWIZARD_DOCUMENT_OR_SPREADSHEET 13
95 #define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14
96 #define PAGE_DBSETUPWIZARD_FINAL 16
97 #define PAGE_DBSETUPWIZARD_USERDEFINED 17
98 #define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18
100 // ODsnTypeCollection
101 class OOO_DLLPUBLIC_DBA ODsnTypeCollection final
104 std::vector<OUString> m_aDsnTypesDisplayNames; /// user readable names for the datasource types
105 std::vector<OUString> m_aDsnPrefixes; /// DSN prefixes which determine the type of a datasource
106 ::connectivity::DriversConfig m_aDriverConfig;
108 #if OSL_DEBUG_LEVEL > 0
109 sal_Int32 m_nLivingIterators; /// just for debugging reasons, counts the living iterators
110 #endif
112 public:
113 class TypeIterator;
114 friend class ODsnTypeCollection::TypeIterator;
116 ODsnTypeCollection(const css::uno::Reference< css::uno::XComponentContext >& _xContext);
117 ~ODsnTypeCollection();
119 /// get the datasource type display name from a DSN string
120 OUString getTypeDisplayName(std::u16string_view _sURL) const;
122 /// on a given string, cut the type prefix and return the result
123 OUString cutPrefix(std::u16string_view _sURL) const;
125 /// on a given string, return the type prefix
126 OUString getPrefix(std::u16string_view _sURL) const;
128 /// determines whether there is a driver for the given URL prefix/pattern
129 bool hasDriver( const char* _pAsciiPattern ) const;
131 /// on a given string, return the Java Driver Class
132 OUString getJavaDriverClass(std::u16string_view _sURL) const;
134 /// returns the media type of a file based database
135 OUString getMediaType(std::u16string_view _sURL) const;
137 /// returns the dsn prefix for a given media type
138 OUString getDatasourcePrefixFromMediaType(std::u16string_view _sMediaType, std::u16string_view _sExtension );
140 void extractHostNamePort(const OUString& _rDsn,OUString& _sDatabaseName,OUString& _rHostname,sal_Int32& _nPortNumber) const;
142 /// check if the given data source allows creation of tables
143 bool supportsTableCreation(std::u16string_view _sURL) const;
145 /// check if the given data source allows to show column description.
146 bool supportsColumnDescription(std::u16string_view _sURL) const;
148 // check if a Browse button may be shown to insert connection url
149 bool supportsBrowsing(std::u16string_view _sURL) const;
151 // check if a Create New Database button may be shown to insert connection url
152 bool supportsDBCreation(std::u16string_view _sURL) const;
154 /// check if the given data source type is based on the file system - i.e. the URL is a prefix plus a file URL
155 bool isFileSystemBased(std::u16string_view _sURL) const;
157 bool isConnectionUrlRequired(std::u16string_view _sURL) const;
159 /// checks if the given data source type embeds its data into the database document
160 static bool isEmbeddedDatabase( std::u16string_view _sURL );
162 static OUString getEmbeddedDatabase();
164 // returns true when the properties dialog can be shown, otherwise false.
165 static bool isShowPropertiesEnabled( const OUString& _sURL );
167 /** returns default settings for newly created databases of the given type.
169 css::uno::Sequence< css::beans::PropertyValue>
170 getDefaultDBSettings( std::u16string_view _sURL ) const;
172 /// get access to the first element of the types collection
173 inline TypeIterator begin() const;
174 /// get access to the (last + 1st) element of the types collection
175 inline TypeIterator end() const;
177 void fillPageIds(std::u16string_view _sURL,std::vector<sal_Int16>& _rOutPathIds) const;
179 DATASOURCE_TYPE determineType(std::u16string_view _rDsn) const;
181 sal_Int32 getIndexOf(std::u16string_view _sURL) const;
182 sal_Int32 size() const;
183 OUString getType(std::u16string_view _sURL) const;
186 //- ODsnTypeCollection::TypeIterator
187 class OOO_DLLPUBLIC_DBA ODsnTypeCollection::TypeIterator
189 friend class ODsnTypeCollection;
191 friend bool OOO_DLLPUBLIC_DBA operator==(const TypeIterator& lhs, const TypeIterator& rhs);
192 friend bool OOO_DLLPUBLIC_DBA operator!=(const TypeIterator& lhs, const TypeIterator& rhs) { return !(lhs == rhs); }
194 protected:
195 const ODsnTypeCollection* m_pContainer;
196 sal_Int32 m_nPosition;
198 public:
199 TypeIterator(const TypeIterator& _rSource);
200 ~TypeIterator();
202 OUString const & getURLPrefix() const;
203 OUString const & getDisplayName() const;
205 /// prefix increment
206 const TypeIterator& operator++();
208 protected:
209 TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos);
213 inline ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const { return ODsnTypeCollection::TypeIterator(this, 0);}
214 inline ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const { return ODsnTypeCollection::TypeIterator(this, m_aDsnTypesDisplayNames.size());}
216 } // namespace dbaccess
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */