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_CONNECTIVITY_SOURCE_INC_TDATABASEMETADATABASE_HXX
21 : #define INCLUDED_CONNECTIVITY_SOURCE_INC_TDATABASEMETADATABASE_HXX
22 :
23 : #include <com/sun/star/sdbc/XDatabaseMetaData2.hpp>
24 : #include <cppuhelper/implbase2.hxx>
25 : #include <comphelper/broadcasthelper.hxx>
26 : #include <com/sun/star/lang/XEventListener.hpp>
27 : #include "FDatabaseMetaDataResultSet.hxx"
28 : #include <functional>
29 : #include <connectivity/dbtoolsdllapi.hxx>
30 :
31 : namespace connectivity
32 : {
33 : typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > TConditions;
34 : class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataBase :
35 : public comphelper::OBaseMutex,
36 : public ::cppu::WeakImplHelper2< ::com::sun::star::sdbc::XDatabaseMetaData2,
37 : ::com::sun::star::lang::XEventListener>
38 : {
39 : private:
40 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aConnectionInfo;
41 : ::connectivity::ODatabaseMetaDataResultSet::ORows m_aTypeInfoRows;
42 :
43 : // cached database information
44 : ::std::pair<bool,bool> m_isCatalogAtStart;
45 : ::std::pair<bool,OUString> m_sCatalogSeparator;
46 : ::std::pair<bool,OUString> m_sIdentifierQuoteString;
47 : ::std::pair<bool,bool> m_supportsCatalogsInTableDefinitions;
48 : ::std::pair<bool,bool> m_supportsSchemasInTableDefinitions;
49 : ::std::pair<bool,bool> m_supportsCatalogsInDataManipulation;
50 : ::std::pair<bool,bool> m_supportsSchemasInDataManipulation;
51 : ::std::pair<bool,bool> m_supportsMixedCaseQuotedIdentifiers;
52 : ::std::pair<bool,bool> m_supportsAlterTableWithAddColumn;
53 : ::std::pair<bool,bool> m_supportsAlterTableWithDropColumn;
54 : ::std::pair<bool,sal_Int32> m_MaxStatements;
55 : ::std::pair<bool,sal_Int32> m_MaxTablesInSelect;
56 : ::std::pair<bool,bool> m_storesMixedCaseQuotedIdentifiers;
57 :
58 10905 : template <typename T> T callImplMethod(::std::pair<bool,T>& _rCache,const ::std::mem_fun_t<T,ODatabaseMetaDataBase>& _pImplMethod)
59 : {
60 10905 : ::osl::MutexGuard aGuard( m_aMutex );
61 10905 : if ( !_rCache.first )
62 : {
63 306 : _rCache.second = _pImplMethod(this);
64 306 : _rCache.first = true;
65 : }
66 10905 : return _rCache.second;
67 : }
68 : protected:
69 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
70 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> m_xListenerHelper; // forward the calls from the connection to me
71 :
72 : virtual ~ODatabaseMetaDataBase();
73 :
74 : protected:
75 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw() = 0;
76 : // cached database information
77 : virtual OUString impl_getIdentifierQuoteString_throw( ) = 0;
78 : virtual bool impl_isCatalogAtStart_throw( ) = 0;
79 : virtual OUString impl_getCatalogSeparator_throw( ) = 0;
80 : virtual bool impl_supportsCatalogsInTableDefinitions_throw( ) = 0;
81 : virtual bool impl_supportsSchemasInTableDefinitions_throw( ) = 0;
82 : virtual bool impl_supportsCatalogsInDataManipulation_throw( ) = 0;
83 : virtual bool impl_supportsSchemasInDataManipulation_throw( ) = 0;
84 : virtual bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) = 0;
85 : virtual bool impl_supportsAlterTableWithAddColumn_throw( ) = 0;
86 : virtual bool impl_supportsAlterTableWithDropColumn_throw( ) = 0;
87 : virtual sal_Int32 impl_getMaxStatements_throw( ) = 0;
88 : virtual sal_Int32 impl_getMaxTablesInSelect_throw( ) = 0;
89 : virtual bool impl_storesMixedCaseQuotedIdentifiers_throw( ) = 0;
90 :
91 :
92 : public:
93 :
94 : ODatabaseMetaDataBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
95 :
96 : // XDatabaseMetaData2
97 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getConnectionInfo( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 :
99 : // XEventListener
100 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 :
102 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern, const OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table, const OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const OUString& primarySchema, const OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const OUString& foreignSchema, const OUString& foreignTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 :
117 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 : // cached database information
119 : virtual OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 : virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : virtual OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 : virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 : virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 : virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 : virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 : virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 : virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 : virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 : };
133 : }
134 : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_TDATABASEMETADATABASE_HXX
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|