1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _CONNECTIVITY_ODATABASEMETADATABASE_HXX_ 29 #define _CONNECTIVITY_ODATABASEMETADATABASE_HXX_ 30 31 #include <com/sun/star/sdbc/XDatabaseMetaData2.hpp> 32 #include <cppuhelper/implbase2.hxx> 33 #include <comphelper/broadcasthelper.hxx> 34 #include <com/sun/star/lang/XEventListener.hpp> 35 #include "FDatabaseMetaDataResultSet.hxx" 36 #include <functional> 37 #include "connectivity/dbtoolsdllapi.hxx" 38 39 namespace connectivity 40 { 41 typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > TConditions; 42 class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataBase : 43 public comphelper::OBaseMutex, 44 public ::cppu::WeakImplHelper2< ::com::sun::star::sdbc::XDatabaseMetaData2, 45 ::com::sun::star::lang::XEventListener> 46 { 47 private: 48 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aConnectionInfo; 49 ::connectivity::ODatabaseMetaDataResultSet::ORows m_aTypeInfoRows; 50 51 // cached database information 52 ::std::pair<bool,sal_Bool> m_isCatalogAtStart; 53 ::std::pair<bool,::rtl::OUString> m_sCatalogSeparator; 54 ::std::pair<bool,::rtl::OUString> m_sIdentifierQuoteString; 55 ::std::pair<bool,sal_Bool> m_supportsCatalogsInTableDefinitions; 56 ::std::pair<bool,sal_Bool> m_supportsSchemasInTableDefinitions; 57 ::std::pair<bool,sal_Bool> m_supportsCatalogsInDataManipulation; 58 ::std::pair<bool,sal_Bool> m_supportsSchemasInDataManipulation; 59 ::std::pair<bool,sal_Bool> m_supportsMixedCaseQuotedIdentifiers; 60 ::std::pair<bool,sal_Bool> m_supportsAlterTableWithAddColumn; 61 ::std::pair<bool,sal_Bool> m_supportsAlterTableWithDropColumn; 62 ::std::pair<bool,sal_Int32> m_MaxStatements; 63 ::std::pair<bool,sal_Int32> m_MaxTablesInSelect; 64 ::std::pair<bool,sal_Bool> m_storesMixedCaseQuotedIdentifiers; 65 66 template <typename T> T callImplMethod(::std::pair<bool,T>& _rCache,const ::std::mem_fun_t<T,ODatabaseMetaDataBase>& _pImplMethod) 67 { 68 ::osl::MutexGuard aGuard( m_aMutex ); 69 if ( !_rCache.first ) 70 { 71 _rCache.second = _pImplMethod(this); 72 _rCache.first = true; 73 } 74 return _rCache.second; 75 } 76 protected: 77 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; 78 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> m_xListenerHelper; // forward the calls from the connection to me 79 80 virtual ~ODatabaseMetaDataBase(); 81 82 protected: 83 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw() = 0; 84 // cached database information 85 virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( ) = 0; 86 virtual sal_Bool impl_isCatalogAtStart_throw( ) = 0; 87 virtual ::rtl::OUString impl_getCatalogSeparator_throw( ) = 0; 88 virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( ) = 0; 89 virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) = 0; 90 virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( ) = 0; 91 virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) = 0; 92 virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) = 0; 93 virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( ) = 0; 94 virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( ) = 0; 95 virtual sal_Int32 impl_getMaxStatements_throw( ) = 0; 96 virtual sal_Int32 impl_getMaxTablesInSelect_throw( ) = 0; 97 virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( ) = 0; 98 99 100 public: 101 102 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); 103 104 // XDatabaseMetaData2 105 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getConnectionInfo( ) throw (::com::sun::star::uno::RuntimeException); 106 107 // XEventListener 108 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 109 110 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); 111 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 112 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 113 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); 114 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); 115 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 117 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 118 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 120 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 121 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 122 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 124 125 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); 126 // cached database information 127 virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 128 virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 129 virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 130 virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 131 virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 132 virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 133 virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 134 virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 135 virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 136 virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 137 virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 138 virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 139 virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 140 }; 141 } 142 #endif // _CONNECTIVITY_ODATABASEMETADATABASE_HXX_ 143