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