xref: /aoo41x/main/dbaccess/source/core/inc/table.hxx (revision 2e2212a7)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBA_CORE_TABLE_HXX_
25cdf0e10cSrcweir #define _DBA_CORE_TABLE_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRename.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAlterTable.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
35cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx>
38cdf0e10cSrcweir #include "apitools.hxx"
39cdf0e10cSrcweir #include "datasettings.hxx"
40cdf0e10cSrcweir #include <column.hxx>
41cdf0e10cSrcweir #include <connectivity/CommonTools.hxx>
42cdf0e10cSrcweir #include <connectivity/TTableHelper.hxx>
43cdf0e10cSrcweir #include <comphelper/uno3.hxx>
44cdf0e10cSrcweir #include <comphelper/IdPropArrayHelper.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace dbaccess
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	//==========================================================================
50cdf0e10cSrcweir 	//= OTables
51cdf0e10cSrcweir 	//==========================================================================
52cdf0e10cSrcweir 	class ODBTable;
53cdf0e10cSrcweir 	class OContainerMediator;
54cdf0e10cSrcweir 	typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTable >	ODBTable_PROP;
55cdf0e10cSrcweir 	typedef ::connectivity::OTableHelper							OTable_Base;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	class ODBTable	:public ODataSettings_Base
58cdf0e10cSrcweir 					,public ODBTable_PROP
59cdf0e10cSrcweir 					,public OTable_Base
60cdf0e10cSrcweir 					,public IColumnFactory
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir     private:
63cdf0e10cSrcweir         ::rtl::Reference< OContainerMediator >                                          m_pColumnMediator;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	protected:
66cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >	m_xColumnDefinitions;
67cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >	m_xDriverColumns;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	// <properties>
70cdf0e10cSrcweir 		sal_Int32																		m_nPrivileges;
71cdf0e10cSrcweir 	// </properties>
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
74cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 		// IColumnFactory
77cdf0e10cSrcweir 		virtual OColumn*	createColumn(const ::rtl::OUString& _rName) const;
78cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
79cdf0e10cSrcweir         virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
80cdf0e10cSrcweir 		virtual void columnDropped(const ::rtl::OUString& _sName);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 		/** creates the column collection for the table
83cdf0e10cSrcweir 			@param	_rNames
84cdf0e10cSrcweir 				The column names.
85cdf0e10cSrcweir 		*/
86cdf0e10cSrcweir 		virtual ::connectivity::sdbcx::OCollection* createColumns(const ::connectivity::TStringVector& _rNames);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 		/** creates the key collection for the table
89cdf0e10cSrcweir 			@param	_rNames
90cdf0e10cSrcweir 				The key names.
91cdf0e10cSrcweir 		*/
92cdf0e10cSrcweir 		virtual ::connectivity::sdbcx::OCollection* createKeys(const ::connectivity::TStringVector& _rNames);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 		/** creates the index collection for the table
95cdf0e10cSrcweir 			@param	_rNames
96cdf0e10cSrcweir 				The index names.
97cdf0e10cSrcweir 		*/
98cdf0e10cSrcweir 		virtual ::connectivity::sdbcx::OCollection* createIndexes(const ::connectivity::TStringVector& _rNames);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		// OComponentHelper
101cdf0e10cSrcweir 		virtual void SAL_CALL disposing(void);
102cdf0e10cSrcweir 	public:
103cdf0e10cSrcweir 		/** constructs a wrapper supporting the com.sun.star.sdb.Table service.<BR>
104cdf0e10cSrcweir 			@param			_rxConn			the connection the table belongs to
105cdf0e10cSrcweir 			@param			_rxTable		the table from the driver can be null
106cdf0e10cSrcweir 			@param			_rCatalog		the name of the catalog the table belongs to. May be empty.
107cdf0e10cSrcweir 			@param			_rSchema		the name of the schema the table belongs to. May be empty.
108cdf0e10cSrcweir 			@param			_rName			the name of the table
109cdf0e10cSrcweir 			@param			_rType			the type of the table, as supplied by the driver
110cdf0e10cSrcweir 			@param			_rDesc			the description of the table, as supplied by the driver
111cdf0e10cSrcweir 		*/
112cdf0e10cSrcweir 		ODBTable(connectivity::sdbcx::OCollection* _pTables
113cdf0e10cSrcweir 				,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn
114cdf0e10cSrcweir 				,const ::rtl::OUString& _rCatalog
115cdf0e10cSrcweir 				, const ::rtl::OUString& _rSchema
116cdf0e10cSrcweir 				, const ::rtl::OUString& _rName
117cdf0e10cSrcweir 				,const ::rtl::OUString& _rType
118cdf0e10cSrcweir 				, const ::rtl::OUString& _rDesc
119cdf0e10cSrcweir 				,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions)
120cdf0e10cSrcweir 			throw(::com::sun::star::sdbc::SQLException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		ODBTable(connectivity::sdbcx::OCollection* _pTables
123cdf0e10cSrcweir 				,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn)
124cdf0e10cSrcweir 				throw(::com::sun::star::sdbc::SQLException);
125cdf0e10cSrcweir 		virtual ~ODBTable();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 		// ODescriptor
128cdf0e10cSrcweir 		virtual void construct();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 		//XInterface
131cdf0e10cSrcweir 		DECLARE_XINTERFACE()
132cdf0e10cSrcweir 		//XTypeProvider
133cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
134cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir 		static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	// ::com::sun::star::lang::XServiceInfo
138cdf0e10cSrcweir 		DECLARE_SERVICE_INFO();
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	// com::sun::star::beans::XPropertySet
141cdf0e10cSrcweir 		//	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
142cdf0e10cSrcweir 		virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	// ::com::sun::star::sdbcx::XRename,
145cdf0e10cSrcweir 		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);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	// ::com::sun::star::sdbcx::XAlterTable,
148cdf0e10cSrcweir 		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);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 		// com::sun::star::lang::XUnoTunnel
151cdf0e10cSrcweir         virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     private:
154cdf0e10cSrcweir         using OTable_Base::createArrayHelper;
155cdf0e10cSrcweir         using OTable_Base::getFastPropertyValue;
156cdf0e10cSrcweir 	};
157cdf0e10cSrcweir }
158cdf0e10cSrcweir #endif // _DBA_CORE_TABLE_HXX_
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 
161