1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CONNECTIVITY_SDBCX_TABLE_HXX_
25cdf0e10cSrcweir #define _CONNECTIVITY_SDBCX_TABLE_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRename.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAlterTable.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
33cdf0e10cSrcweir #include <comphelper/IdPropArrayHelper.hxx>
34cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
35cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
36cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
37cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
38cdf0e10cSrcweir #include "connectivity/sdbcx/IRefreshable.hxx"
39cdf0e10cSrcweir #include "connectivity/sdbcx/VDescriptor.hxx"
40cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
41cdf0e10cSrcweir #include "connectivity/dbtoolsdllapi.hxx"
42cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace connectivity
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	namespace sdbcx
47cdf0e10cSrcweir 	{
48cdf0e10cSrcweir 
49cdf0e10cSrcweir         class OTable;
50cdf0e10cSrcweir 		class OCollection;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 		typedef ::cppu::WeakComponentImplHelper4<	::com::sun::star::sdbcx::XColumnsSupplier,
53cdf0e10cSrcweir 													::com::sun::star::sdbcx::XKeysSupplier,
54cdf0e10cSrcweir 													::com::sun::star::container::XNamed,
55cdf0e10cSrcweir 													::com::sun::star::lang::XServiceInfo> OTableDescriptor_BASE;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 		typedef ::cppu::ImplHelper4<				::com::sun::star::sdbcx::XDataDescriptorFactory,
58cdf0e10cSrcweir 													::com::sun::star::sdbcx::XIndexesSupplier,
59cdf0e10cSrcweir 													::com::sun::star::sdbcx::XRename,
60cdf0e10cSrcweir 													::com::sun::star::sdbcx::XAlterTable > OTable_BASE;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 		typedef ::comphelper::OIdPropertyArrayUsageHelper<OTable> OTable_PROP;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 		class OOO_DLLPUBLIC_DBTOOLS OTable :
66cdf0e10cSrcweir                                  public comphelper::OBaseMutex,
67cdf0e10cSrcweir 								 public OTable_BASE,
68cdf0e10cSrcweir 								 public OTableDescriptor_BASE,
69cdf0e10cSrcweir 								 public IRefreshableColumns,
70cdf0e10cSrcweir 								 public OTable_PROP,
71cdf0e10cSrcweir 								 public ODescriptor
72cdf0e10cSrcweir 		{
73cdf0e10cSrcweir 		protected:
74cdf0e10cSrcweir 			::rtl::OUString m_CatalogName;
75cdf0e10cSrcweir 			::rtl::OUString m_SchemaName;
76cdf0e10cSrcweir 			::rtl::OUString m_Description;
77cdf0e10cSrcweir 			::rtl::OUString m_Type;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 			OCollection*	m_pKeys;
80cdf0e10cSrcweir 			OCollection*	m_pColumns;
81cdf0e10cSrcweir 			OCollection*	m_pIndexes;
82cdf0e10cSrcweir 			OCollection*	m_pTables;	// must hold his own container to notify him when renaming
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 			using OTableDescriptor_BASE::rBHelper;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 			// OPropertyArrayUsageHelper
87cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId ) const;
88cdf0e10cSrcweir 			// OPropertySetHelper
89cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
90cdf0e10cSrcweir 		public:
91cdf0e10cSrcweir 			OTable(	OCollection*	_pTables,
92cdf0e10cSrcweir 					sal_Bool _bCase);
93cdf0e10cSrcweir 			OTable( OCollection*	_pTables,
94cdf0e10cSrcweir 					sal_Bool _bCase,
95cdf0e10cSrcweir 					const ::rtl::OUString& _Name,
96cdf0e10cSrcweir 					const ::rtl::OUString& _Type,
97cdf0e10cSrcweir 					const ::rtl::OUString& _Description = ::rtl::OUString(),
98cdf0e10cSrcweir 					const ::rtl::OUString& _SchemaName  = ::rtl::OUString(),
99cdf0e10cSrcweir 					const ::rtl::OUString& _CatalogName = ::rtl::OUString());
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 			virtual ~OTable();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
104cdf0e10cSrcweir 			//XInterface
105cdf0e10cSrcweir 			virtual void	SAL_CALL acquire() throw();
106cdf0e10cSrcweir 			virtual void	SAL_CALL release() throw();
107cdf0e10cSrcweir             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir 			//XTypeProvider
109cdf0e10cSrcweir             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 			// ODescriptor
112cdf0e10cSrcweir 			virtual void construct();
113cdf0e10cSrcweir 			virtual void refreshColumns();
114cdf0e10cSrcweir 			virtual void refreshKeys();
115cdf0e10cSrcweir 			virtual void refreshIndexes();
116cdf0e10cSrcweir 			// ::cppu::OComponentHelper
117cdf0e10cSrcweir 			virtual void SAL_CALL disposing(void);
118cdf0e10cSrcweir 			// XPropertySet
119cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 			// XColumnsSupplier
121cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns(  ) throw(::com::sun::star::uno::RuntimeException);
122cdf0e10cSrcweir 			// XKeysSupplier
123cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys(  ) throw(::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir 			// XNamed
125cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir             virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir 			// XDataDescriptorFactory
128cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( void ) throw(::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 			// XIndexesSupplier
130cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes(  ) throw(::com::sun::star::uno::RuntimeException);
131cdf0e10cSrcweir 			// XRename
132cdf0e10cSrcweir             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);
133cdf0e10cSrcweir 			// XAlterTable
134cdf0e10cSrcweir             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);
135cdf0e10cSrcweir             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);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 			// helper method
138cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
139cdf0e10cSrcweir 		};
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir #endif // _CONNECTIVITY_SDBCX_TABLE_HXX_
144cdf0e10cSrcweir 
145