1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DBA_CORE_TABLEDECORATOR_HXX_ 25cdf0e10cSrcweir #define _DBA_CORE_TABLEDECORATOR_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ 28cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 31cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ 34cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ 37cdf0e10cSrcweir #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ 40cdf0e10cSrcweir #include <com/sun/star/sdbcx/XKeysSupplier.hpp> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_ 43cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRename.hpp> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ 46cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAlterTable.hpp> 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 49cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 52cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 55cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 56cdf0e10cSrcweir #endif 57cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPBASE9_HXX_ 58cdf0e10cSrcweir #include <cppuhelper/compbase9.hxx> 59cdf0e10cSrcweir #endif 60cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE5_HXX_ 61cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx> 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_ 64cdf0e10cSrcweir #include "apitools.hxx" 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #ifndef _DBA_CORE_DATASETTINGS_HXX_ 67cdf0e10cSrcweir #include "datasettings.hxx" 68cdf0e10cSrcweir #endif 69cdf0e10cSrcweir #ifndef _DBA_COREAPI_COLUMN_HXX_ 70cdf0e10cSrcweir #include "column.hxx" 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir 73cdf0e10cSrcweir #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ 74cdf0e10cSrcweir #include <connectivity/CommonTools.hxx> 75cdf0e10cSrcweir #endif 76cdf0e10cSrcweir #ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ 77cdf0e10cSrcweir #include <connectivity/sdbcx/IRefreshable.hxx> 78cdf0e10cSrcweir #endif 79cdf0e10cSrcweir #ifndef COMPHELPER_IDPROPERTYARRAYUSAGEHELPER_HXX 80cdf0e10cSrcweir #include <comphelper/IdPropArrayHelper.hxx> 81cdf0e10cSrcweir #endif 82cdf0e10cSrcweir 83cdf0e10cSrcweir namespace dbaccess 84cdf0e10cSrcweir { 85cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::sdbcx::XColumnsSupplier, 86cdf0e10cSrcweir ::com::sun::star::sdbcx::XKeysSupplier, 87cdf0e10cSrcweir ::com::sun::star::container::XNamed, 88cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo, 89cdf0e10cSrcweir ::com::sun::star::sdbcx::XDataDescriptorFactory, 90cdf0e10cSrcweir ::com::sun::star::sdbcx::XIndexesSupplier, 91cdf0e10cSrcweir ::com::sun::star::sdbcx::XRename, 92cdf0e10cSrcweir ::com::sun::star::lang::XUnoTunnel, 93cdf0e10cSrcweir ::com::sun::star::sdbcx::XAlterTable> OTableDescriptor_BASE; 94cdf0e10cSrcweir //========================================================================== 95cdf0e10cSrcweir //= OTables 96cdf0e10cSrcweir //========================================================================== 97cdf0e10cSrcweir class ODBTableDecorator; 98cdf0e10cSrcweir typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP; 99cdf0e10cSrcweir 100cdf0e10cSrcweir class ODBTableDecorator :public comphelper::OBaseMutex 101cdf0e10cSrcweir ,public OTableDescriptor_BASE 102cdf0e10cSrcweir ,public ODataSettings //ODataSettings_Base 103cdf0e10cSrcweir ,public IColumnFactory 104cdf0e10cSrcweir ,public ::connectivity::sdbcx::IRefreshableColumns 105cdf0e10cSrcweir ,public ODBTableDecorator_PROP 106cdf0e10cSrcweir { 107cdf0e10cSrcweir void fillPrivileges() const; 108cdf0e10cSrcweir protected: 109cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xColumnMediator; 110cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xTable; 111cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumnDefinitions; 112cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; 113cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; 114cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormats; 115cdf0e10cSrcweir 116cdf0e10cSrcweir // <properties> 117cdf0e10cSrcweir mutable sal_Int32 m_nPrivileges; 118cdf0e10cSrcweir // </properties> 119cdf0e10cSrcweir ::connectivity::sdbcx::OCollection* m_pColumns; 120cdf0e10cSrcweir ::connectivity::sdbcx::OCollection* m_pTables; 121cdf0e10cSrcweir 122cdf0e10cSrcweir // IColumnFactory 123cdf0e10cSrcweir virtual OColumn* createColumn(const ::rtl::OUString& _rName) const; 124cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor(); 125cdf0e10cSrcweir virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ); 126cdf0e10cSrcweir virtual void columnDropped(const ::rtl::OUString& _sName); 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual void refreshColumns(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId) const; 131cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 132cdf0e10cSrcweir 133cdf0e10cSrcweir // OPropertySetHelper 134cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 135cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 136cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 137cdf0e10cSrcweir sal_Int32 nHandle, 138cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue ) 139cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 140cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; 141cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 142cdf0e10cSrcweir sal_Int32 nHandle, 143cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue 144cdf0e10cSrcweir ) 145cdf0e10cSrcweir 146cdf0e10cSrcweir throw (::com::sun::star::uno::Exception); 147cdf0e10cSrcweir 148cdf0e10cSrcweir virtual ~ODBTableDecorator(); 149cdf0e10cSrcweir public: 150cdf0e10cSrcweir /** constructs a wrapper supporting the com.sun.star.sdb.Table service. 151cdf0e10cSrcweir 152cdf0e10cSrcweir @param _rxConn 153cdf0e10cSrcweir the connection the table belongs to. Must not be <NULL/> 154cdf0e10cSrcweir @param _rxTable 155cdf0e10cSrcweir the table from the driver can be <NULL/> 156cdf0e10cSrcweir */ 157cdf0e10cSrcweir ODBTableDecorator( 158cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, 159cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable, 160cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats, 161cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions 162cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException); 163cdf0e10cSrcweir 164cdf0e10cSrcweir 165cdf0e10cSrcweir 166cdf0e10cSrcweir // ODescriptor 167cdf0e10cSrcweir virtual void construct(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir //XInterface 170cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 171cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 172cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 173cdf0e10cSrcweir //XTypeProvider 174cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 175cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); 176cdf0e10cSrcweir 177cdf0e10cSrcweir // OComponentHelper 178cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 179cdf0e10cSrcweir 180cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 181cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 182cdf0e10cSrcweir // XPropertySet 183cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 184cdf0e10cSrcweir // ::com::sun::star::sdbcx::XRename, 185cdf0e10cSrcweir virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); 186cdf0e10cSrcweir 187cdf0e10cSrcweir // ::com::sun::star::sdbcx::XAlterTable, 188cdf0e10cSrcweir virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); 189cdf0e10cSrcweir virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 190cdf0e10cSrcweir 191cdf0e10cSrcweir // XNamed 192cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); 193cdf0e10cSrcweir virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 194cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel 195cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 196cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); 197cdf0e10cSrcweir getMetaData() const198cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const { return m_xMetaData; } getConnection() const199cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xMetaData.is() ? m_xMetaData->getConnection() : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>(); } 200cdf0e10cSrcweir 201cdf0e10cSrcweir // XColumnsSupplier 202cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException); 203cdf0e10cSrcweir // XKeysSupplier 204cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw (::com::sun::star::uno::RuntimeException); 205cdf0e10cSrcweir // XIndexesSupplier 206cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw (::com::sun::star::uno::RuntimeException); 207cdf0e10cSrcweir // XDataDescriptorFactory 208cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException); 209cdf0e10cSrcweir 210cdf0e10cSrcweir protected: 211cdf0e10cSrcweir using ODataSettings::getFastPropertyValue; 212cdf0e10cSrcweir }; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir #endif // _DBA_CORE_TABLEDECORATOR_HXX_ 215cdf0e10cSrcweir 216cdf0e10cSrcweir 217