xref: /trunk/main/dbaccess/source/core/inc/table.hxx (revision cdf0e10c)
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 _DBA_CORE_TABLE_HXX_
29 #define _DBA_CORE_TABLE_HXX_
30 
31 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
32 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
33 #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
34 #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
35 #include <com/sun/star/sdbcx/XRename.hpp>
36 #include <com/sun/star/sdbcx/XAlterTable.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/sdbc/XRow.hpp>
39 #include <com/sun/star/sdbc/XConnection.hpp>
40 
41 #include <cppuhelper/compbase7.hxx>
42 #include "apitools.hxx"
43 #include "datasettings.hxx"
44 #include <column.hxx>
45 #include <connectivity/CommonTools.hxx>
46 #include <connectivity/TTableHelper.hxx>
47 #include <comphelper/uno3.hxx>
48 #include <comphelper/IdPropArrayHelper.hxx>
49 
50 namespace dbaccess
51 {
52 
53 	//==========================================================================
54 	//= OTables
55 	//==========================================================================
56 	class ODBTable;
57 	class OContainerMediator;
58 	typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTable >	ODBTable_PROP;
59 	typedef ::connectivity::OTableHelper							OTable_Base;
60 
61 	class ODBTable	:public ODataSettings_Base
62 					,public ODBTable_PROP
63 					,public OTable_Base
64 					,public IColumnFactory
65 	{
66     private:
67         ::rtl::Reference< OContainerMediator >                                          m_pColumnMediator;
68 
69 	protected:
70 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >	m_xColumnDefinitions;
71 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >	m_xDriverColumns;
72 
73 	// <properties>
74 		sal_Int32																		m_nPrivileges;
75 	// </properties>
76 
77 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
78 		virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
79 
80 		// IColumnFactory
81 		virtual OColumn*	createColumn(const ::rtl::OUString& _rName) const;
82 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
83         virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
84 		virtual void columnDropped(const ::rtl::OUString& _sName);
85 
86 		/** creates the column collection for the table
87 			@param	_rNames
88 				The column names.
89 		*/
90 		virtual ::connectivity::sdbcx::OCollection* createColumns(const ::connectivity::TStringVector& _rNames);
91 
92 		/** creates the key collection for the table
93 			@param	_rNames
94 				The key names.
95 		*/
96 		virtual ::connectivity::sdbcx::OCollection* createKeys(const ::connectivity::TStringVector& _rNames);
97 
98 		/** creates the index collection for the table
99 			@param	_rNames
100 				The index names.
101 		*/
102 		virtual ::connectivity::sdbcx::OCollection* createIndexes(const ::connectivity::TStringVector& _rNames);
103 
104 		// OComponentHelper
105 		virtual void SAL_CALL disposing(void);
106 	public:
107 		/** constructs a wrapper supporting the com.sun.star.sdb.Table service.<BR>
108 			@param			_rxConn			the connection the table belongs to
109 			@param			_rxTable		the table from the driver can be null
110 			@param			_rCatalog		the name of the catalog the table belongs to. May be empty.
111 			@param			_rSchema		the name of the schema the table belongs to. May be empty.
112 			@param			_rName			the name of the table
113 			@param			_rType			the type of the table, as supplied by the driver
114 			@param			_rDesc			the description of the table, as supplied by the driver
115 		*/
116 		ODBTable(connectivity::sdbcx::OCollection* _pTables
117 				,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn
118 				,const ::rtl::OUString& _rCatalog
119 				, const ::rtl::OUString& _rSchema
120 				, const ::rtl::OUString& _rName
121 				,const ::rtl::OUString& _rType
122 				, const ::rtl::OUString& _rDesc
123 				,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions)
124 			throw(::com::sun::star::sdbc::SQLException);
125 
126 		ODBTable(connectivity::sdbcx::OCollection* _pTables
127 				,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn)
128 				throw(::com::sun::star::sdbc::SQLException);
129 		virtual ~ODBTable();
130 
131 		// ODescriptor
132 		virtual void construct();
133 
134 		//XInterface
135 		DECLARE_XINTERFACE()
136 		//XTypeProvider
137 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
138 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
139 		static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
140 
141 	// ::com::sun::star::lang::XServiceInfo
142 		DECLARE_SERVICE_INFO();
143 
144 	// com::sun::star::beans::XPropertySet
145 		//	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
146 		virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
147 
148 	// ::com::sun::star::sdbcx::XRename,
149 		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);
150 
151 	// ::com::sun::star::sdbcx::XAlterTable,
152 		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);
153 
154 		// com::sun::star::lang::XUnoTunnel
155         virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
156 
157     private:
158         using OTable_Base::createArrayHelper;
159         using OTable_Base::getFastPropertyValue;
160 	};
161 }
162 #endif // _DBA_CORE_TABLE_HXX_
163 
164 
165