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