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 _CONNECTIVITY_SDBCX_TABLE_HXX_ 25 #define _CONNECTIVITY_SDBCX_TABLE_HXX_ 26 27 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> 28 #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> 29 #include <com/sun/star/sdbcx/XRename.hpp> 30 #include <com/sun/star/sdbcx/XAlterTable.hpp> 31 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 32 #include <com/sun/star/sdbcx/XKeysSupplier.hpp> 33 #include <comphelper/IdPropArrayHelper.hxx> 34 #include <cppuhelper/compbase4.hxx> 35 #include <cppuhelper/implbase4.hxx> 36 #include <comphelper/broadcasthelper.hxx> 37 #include <com/sun/star/container/XNamed.hpp> 38 #include "connectivity/sdbcx/IRefreshable.hxx" 39 #include "connectivity/sdbcx/VDescriptor.hxx" 40 #include "connectivity/CommonTools.hxx" 41 #include "connectivity/dbtoolsdllapi.hxx" 42 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> 43 44 namespace connectivity 45 { 46 namespace sdbcx 47 { 48 49 class OTable; 50 class OCollection; 51 52 typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbcx::XColumnsSupplier, 53 ::com::sun::star::sdbcx::XKeysSupplier, 54 ::com::sun::star::container::XNamed, 55 ::com::sun::star::lang::XServiceInfo> OTableDescriptor_BASE; 56 57 typedef ::cppu::ImplHelper4< ::com::sun::star::sdbcx::XDataDescriptorFactory, 58 ::com::sun::star::sdbcx::XIndexesSupplier, 59 ::com::sun::star::sdbcx::XRename, 60 ::com::sun::star::sdbcx::XAlterTable > OTable_BASE; 61 62 typedef ::comphelper::OIdPropertyArrayUsageHelper<OTable> OTable_PROP; 63 64 65 class OOO_DLLPUBLIC_DBTOOLS OTable : 66 public comphelper::OBaseMutex, 67 public OTable_BASE, 68 public OTableDescriptor_BASE, 69 public IRefreshableColumns, 70 public OTable_PROP, 71 public ODescriptor 72 { 73 protected: 74 ::rtl::OUString m_CatalogName; 75 ::rtl::OUString m_SchemaName; 76 ::rtl::OUString m_Description; 77 ::rtl::OUString m_Type; 78 79 OCollection* m_pKeys; 80 OCollection* m_pColumns; 81 OCollection* m_pIndexes; 82 OCollection* m_pTables; // must hold his own container to notify him when renaming 83 84 using OTableDescriptor_BASE::rBHelper; 85 86 // OPropertyArrayUsageHelper 87 virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId ) const; 88 // OPropertySetHelper 89 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 90 public: 91 OTable( OCollection* _pTables, 92 sal_Bool _bCase); 93 OTable( OCollection* _pTables, 94 sal_Bool _bCase, 95 const ::rtl::OUString& _Name, 96 const ::rtl::OUString& _Type, 97 const ::rtl::OUString& _Description = ::rtl::OUString(), 98 const ::rtl::OUString& _SchemaName = ::rtl::OUString(), 99 const ::rtl::OUString& _CatalogName = ::rtl::OUString()); 100 101 virtual ~OTable(); 102 103 DECLARE_SERVICE_INFO(); 104 //XInterface 105 virtual void SAL_CALL acquire() throw(); 106 virtual void SAL_CALL release() throw(); 107 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 108 //XTypeProvider 109 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 110 111 // ODescriptor 112 virtual void construct(); 113 virtual void refreshColumns(); 114 virtual void refreshKeys(); 115 virtual void refreshIndexes(); 116 // ::cppu::OComponentHelper 117 virtual void SAL_CALL disposing(void); 118 // XPropertySet 119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 120 // XColumnsSupplier 121 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); 122 // XKeysSupplier 123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw(::com::sun::star::uno::RuntimeException); 124 // XNamed 125 virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); 126 virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); 127 // XDataDescriptorFactory 128 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( void ) throw(::com::sun::star::uno::RuntimeException); 129 // XIndexesSupplier 130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw(::com::sun::star::uno::RuntimeException); 131 // XRename 132 virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); 133 // XAlterTable 134 virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); 135 virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 136 137 // helper method 138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const; 139 }; 140 } 141 } 142 143 #endif // _CONNECTIVITY_SDBCX_TABLE_HXX_ 144 145