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