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 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; 140 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 141 sal_Int32 nHandle, 142 const ::com::sun::star::uno::Any& rValue 143 ); 144 145 virtual ~ODBTableDecorator(); 146 public: 147 /** constructs a wrapper supporting the com.sun.star.sdb.Table service. 148 149 @param _rxConn 150 the connection the table belongs to. Must not be <NULL/> 151 @param _rxTable 152 the table from the driver can be <NULL/> 153 */ 154 ODBTableDecorator( 155 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, 156 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable, 157 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats, 158 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions 159 ); 160 161 162 163 // ODescriptor 164 virtual void construct(); 165 166 //XInterface 167 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ); 168 virtual void SAL_CALL acquire() throw(); 169 virtual void SAL_CALL release() throw(); 170 //XTypeProvider 171 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ); 172 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 173 174 // OComponentHelper 175 virtual void SAL_CALL disposing(void); 176 177 // ::com::sun::star::lang::XServiceInfo 178 DECLARE_SERVICE_INFO(); 179 // XPropertySet 180 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 181 // ::com::sun::star::sdbcx::XRename, 182 virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ); 183 184 // ::com::sun::star::sdbcx::XAlterTable, 185 virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ); 186 virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ); 187 188 // XNamed 189 virtual ::rtl::OUString SAL_CALL getName(); 190 virtual void SAL_CALL setName( const ::rtl::OUString& aName ); 191 // com::sun::star::lang::XUnoTunnel 192 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ); 193 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); 194 195 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const { return m_xMetaData; } 196 ::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>(); } 197 198 // XColumnsSupplier 199 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ); 200 // XKeysSupplier 201 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ); 202 // XIndexesSupplier 203 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ); 204 // XDataDescriptorFactory 205 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ); 206 207 protected: 208 using ODataSettings::getFastPropertyValue; 209 }; 210 } 211 #endif // _DBA_CORE_TABLEDECORATOR_HXX_ 212