1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _DBA_CORE_TABLEDECORATOR_HXX_
28cdf0e10cSrcweir #include "TableDeco.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
31cdf0e10cSrcweir #include <definitioncolumn.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
34cdf0e10cSrcweir #include "dbastrings.hrc"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _DBA_CORE_RESOURCE_HXX_
37cdf0e10cSrcweir #include "core_resource.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _DBA_CORE_RESOURCE_HRC_
40cdf0e10cSrcweir #include "core_resource.hrc"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
43cdf0e10cSrcweir #include <tools/debug.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
47cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _COMPHELPER_ENUMHELPER_HXX_
50cdf0e10cSrcweir #include <comphelper/enumhelper.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #ifndef _COMPHELPER_CONTAINER_HXX_
53cdf0e10cSrcweir #include <comphelper/container.hxx>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
56cdf0e10cSrcweir #include <comphelper/sequence.hxx>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_HXX_
59cdf0e10cSrcweir #include <comphelper/property.hxx>
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
62cdf0e10cSrcweir #include <comphelper/types.hxx>
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_
65cdf0e10cSrcweir #include <com/sun/star/util/XRefreshListener.hpp>
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
68cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
69cdf0e10cSrcweir #endif
70cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
71cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
72cdf0e10cSrcweir #endif
73cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
74cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
75cdf0e10cSrcweir #endif
76cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
77cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_
80cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
81cdf0e10cSrcweir #endif
82cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_
83cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
84cdf0e10cSrcweir #endif
85cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_
86cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_
89cdf0e10cSrcweir #include <comphelper/extract.hxx>
90cdf0e10cSrcweir #endif
91cdf0e10cSrcweir #ifndef DBA_CONTAINERMEDIATOR_HXX
92cdf0e10cSrcweir #include "ContainerMediator.hxx"
93cdf0e10cSrcweir #endif
94cdf0e10cSrcweir #include <rtl/logfile.hxx>
95cdf0e10cSrcweir 
96cdf0e10cSrcweir using namespace dbaccess;
97cdf0e10cSrcweir using namespace ::com::sun::star::uno;
98cdf0e10cSrcweir using namespace ::com::sun::star::util;
99cdf0e10cSrcweir using namespace ::com::sun::star::lang;
100cdf0e10cSrcweir using namespace ::com::sun::star::beans;
101cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
102cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
103cdf0e10cSrcweir using namespace ::com::sun::star::container;
104cdf0e10cSrcweir using namespace ::osl;
105cdf0e10cSrcweir using namespace ::comphelper;
106cdf0e10cSrcweir using namespace ::dbtools;
107cdf0e10cSrcweir using namespace ::cppu;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //==========================================================================
110cdf0e10cSrcweir //= ODBTableDecorator
111cdf0e10cSrcweir //==========================================================================
DBG_NAME(ODBTableDecorator)112cdf0e10cSrcweir DBG_NAME(ODBTableDecorator)
113cdf0e10cSrcweir // -----------------------------------------------------------------------------
114cdf0e10cSrcweir ODBTableDecorator::ODBTableDecorator( const Reference< XConnection >& _rxConnection, const Reference< XColumnsSupplier >& _rxNewTable,
115cdf0e10cSrcweir 		const Reference< XNumberFormatsSupplier >& _rxNumberFormats, const Reference< XNameAccess >& _xColumnDefinitions ) throw(SQLException)
116cdf0e10cSrcweir 	:OTableDescriptor_BASE(m_aMutex)
117cdf0e10cSrcweir 	,ODataSettings(OTableDescriptor_BASE::rBHelper)
118cdf0e10cSrcweir 	,m_xTable(_rxNewTable)
119cdf0e10cSrcweir 	,m_xColumnDefinitions(_xColumnDefinitions)
120cdf0e10cSrcweir     ,m_xConnection( _rxConnection )
121cdf0e10cSrcweir     ,m_xMetaData( _rxConnection.is() ? _rxConnection->getMetaData() : Reference< XDatabaseMetaData >() )
122cdf0e10cSrcweir 	,m_xNumberFormats( _rxNumberFormats )
123cdf0e10cSrcweir 	,m_nPrivileges(-1)
124cdf0e10cSrcweir 	,m_pColumns(NULL)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::ODBTableDecorator" );
127cdf0e10cSrcweir 	DBG_CTOR(ODBTableDecorator, NULL);
128cdf0e10cSrcweir 	ODataSettings::registerPropertiesFor(this);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir // -------------------------------------------------------------------------
~ODBTableDecorator()131cdf0e10cSrcweir ODBTableDecorator::~ODBTableDecorator()
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	DBG_DTOR(ODBTableDecorator, NULL);
134cdf0e10cSrcweir 	if ( m_pColumns )
135cdf0e10cSrcweir 		delete m_pColumns;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir //--------------------------------------------------------------------------
getImplementationId()139cdf0e10cSrcweir Sequence< sal_Int8 > ODBTableDecorator::getImplementationId() throw (RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getImplementationId" );
142cdf0e10cSrcweir 	static OImplementationId * pId = 0;
143cdf0e10cSrcweir 	if (! pId)
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		MutexGuard aGuard( Mutex::getGlobalMutex() );
146cdf0e10cSrcweir 		if (! pId)
147cdf0e10cSrcweir 		{
148cdf0e10cSrcweir 			static OImplementationId aId;
149cdf0e10cSrcweir 			pId = &aId;
150cdf0e10cSrcweir 		}
151cdf0e10cSrcweir 	}
152cdf0e10cSrcweir 	return pId->getImplementationId();
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // OComponentHelper
156cdf0e10cSrcweir //------------------------------------------------------------------------------
disposing()157cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::disposing()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::disposing" );
160cdf0e10cSrcweir 	OPropertySetHelper::disposing();
161cdf0e10cSrcweir 	OTableDescriptor_BASE::disposing();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
164cdf0e10cSrcweir 	m_xTable		= NULL;
165cdf0e10cSrcweir 	m_xMetaData		= NULL;
166cdf0e10cSrcweir 	m_pTables		= NULL;
167cdf0e10cSrcweir 	m_xColumnDefinitions = NULL;
168cdf0e10cSrcweir 	m_xNumberFormats = NULL;
169cdf0e10cSrcweir 	if ( m_pColumns )
170cdf0e10cSrcweir 		m_pColumns->disposing();
171cdf0e10cSrcweir     m_xColumnMediator = NULL;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir // -----------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)174cdf0e10cSrcweir sal_Bool SAL_CALL ODBTableDecorator::convertFastPropertyValue(
175cdf0e10cSrcweir 							Any & rConvertedValue,
176cdf0e10cSrcweir 							Any & rOldValue,
177cdf0e10cSrcweir 							sal_Int32 nHandle,
178cdf0e10cSrcweir 							const Any& rValue )
179cdf0e10cSrcweir 								throw (::com::sun::star::lang::IllegalArgumentException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::convertFastPropertyValue" );
182cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
183cdf0e10cSrcweir 	switch(nHandle)
184cdf0e10cSrcweir 	{
185cdf0e10cSrcweir 		case PROPERTY_ID_PRIVILEGES:
186cdf0e10cSrcweir 		case PROPERTY_ID_FILTER:
187cdf0e10cSrcweir 		case PROPERTY_ID_ORDER:
188cdf0e10cSrcweir 		case PROPERTY_ID_APPLYFILTER:
189cdf0e10cSrcweir 		case PROPERTY_ID_FONT:
190cdf0e10cSrcweir 		case PROPERTY_ID_ROW_HEIGHT:
191cdf0e10cSrcweir 		case PROPERTY_ID_TEXTCOLOR:
192cdf0e10cSrcweir 		case PROPERTY_ID_TEXTLINECOLOR:
193cdf0e10cSrcweir 		case PROPERTY_ID_TEXTEMPHASIS:
194cdf0e10cSrcweir 		case PROPERTY_ID_TEXTRELIEF:
195cdf0e10cSrcweir 		case PROPERTY_ID_FONTCHARWIDTH:
196cdf0e10cSrcweir 		case PROPERTY_ID_FONTCHARSET:
197cdf0e10cSrcweir 		case PROPERTY_ID_FONTFAMILY:
198cdf0e10cSrcweir 		case PROPERTY_ID_FONTHEIGHT:
199cdf0e10cSrcweir 		case PROPERTY_ID_FONTKERNING:
200cdf0e10cSrcweir 		case PROPERTY_ID_FONTNAME:
201cdf0e10cSrcweir 		case PROPERTY_ID_FONTORIENTATION:
202cdf0e10cSrcweir 		case PROPERTY_ID_FONTPITCH:
203cdf0e10cSrcweir 		case PROPERTY_ID_FONTSLANT:
204cdf0e10cSrcweir 		case PROPERTY_ID_FONTSTRIKEOUT:
205cdf0e10cSrcweir 		case PROPERTY_ID_FONTSTYLENAME:
206cdf0e10cSrcweir 		case PROPERTY_ID_FONTUNDERLINE:
207cdf0e10cSrcweir 		case PROPERTY_ID_FONTWEIGHT:
208cdf0e10cSrcweir 		case PROPERTY_ID_FONTWIDTH:
209cdf0e10cSrcweir 		case PROPERTY_ID_FONTWORDLINEMODE:
210cdf0e10cSrcweir 		case PROPERTY_ID_FONTTYPE:
211cdf0e10cSrcweir 			bRet = ODataSettings::convertFastPropertyValue(rConvertedValue, rOldValue,nHandle,rValue);
212cdf0e10cSrcweir 			break;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		default:
215cdf0e10cSrcweir 			{
216cdf0e10cSrcweir 				Any aValue;
217cdf0e10cSrcweir 				getFastPropertyValue(aValue,nHandle);
218cdf0e10cSrcweir 				bRet = ::comphelper::tryPropertyValue(rConvertedValue,rOldValue,rValue,aValue,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
219cdf0e10cSrcweir 			}
220cdf0e10cSrcweir 			break; // we assume that it works
221cdf0e10cSrcweir 	}
222cdf0e10cSrcweir 	return bRet;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir // -----------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _rValue)225cdf0e10cSrcweir void ODBTableDecorator::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::setFastPropertyValue_NoBroadcast" );
228cdf0e10cSrcweir 	switch(_nHandle)
229cdf0e10cSrcweir 	{
230cdf0e10cSrcweir 		case PROPERTY_ID_PRIVILEGES:
231cdf0e10cSrcweir 			OSL_ENSURE(0,"Property is readonly!");
232cdf0e10cSrcweir 		case PROPERTY_ID_FILTER:
233cdf0e10cSrcweir 		case PROPERTY_ID_ORDER:
234cdf0e10cSrcweir 		case PROPERTY_ID_APPLYFILTER:
235cdf0e10cSrcweir 		case PROPERTY_ID_FONT:
236cdf0e10cSrcweir 		case PROPERTY_ID_ROW_HEIGHT:
237cdf0e10cSrcweir 		case PROPERTY_ID_TEXTCOLOR:
238cdf0e10cSrcweir 		case PROPERTY_ID_TEXTLINECOLOR:
239cdf0e10cSrcweir 		case PROPERTY_ID_TEXTEMPHASIS:
240cdf0e10cSrcweir 		case PROPERTY_ID_TEXTRELIEF:
241cdf0e10cSrcweir 		case PROPERTY_ID_FONTCHARWIDTH:
242cdf0e10cSrcweir 		case PROPERTY_ID_FONTCHARSET:
243cdf0e10cSrcweir 		case PROPERTY_ID_FONTFAMILY:
244cdf0e10cSrcweir 		case PROPERTY_ID_FONTHEIGHT:
245cdf0e10cSrcweir 		case PROPERTY_ID_FONTKERNING:
246cdf0e10cSrcweir 		case PROPERTY_ID_FONTNAME:
247cdf0e10cSrcweir 		case PROPERTY_ID_FONTORIENTATION:
248cdf0e10cSrcweir 		case PROPERTY_ID_FONTPITCH:
249cdf0e10cSrcweir 		case PROPERTY_ID_FONTSLANT:
250cdf0e10cSrcweir 		case PROPERTY_ID_FONTSTRIKEOUT:
251cdf0e10cSrcweir 		case PROPERTY_ID_FONTSTYLENAME:
252cdf0e10cSrcweir 		case PROPERTY_ID_FONTUNDERLINE:
253cdf0e10cSrcweir 		case PROPERTY_ID_FONTWEIGHT:
254cdf0e10cSrcweir 		case PROPERTY_ID_FONTWIDTH:
255cdf0e10cSrcweir 		case PROPERTY_ID_FONTWORDLINEMODE:
256cdf0e10cSrcweir 		case PROPERTY_ID_FONTTYPE:
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 			ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
259cdf0e10cSrcweir 			break;
260cdf0e10cSrcweir 		case PROPERTY_ID_CATALOGNAME:
261cdf0e10cSrcweir 			{
262cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
263cdf0e10cSrcweir 				xProp->setPropertyValue(PROPERTY_CATALOGNAME,_rValue);
264cdf0e10cSrcweir 			}
265cdf0e10cSrcweir 			break;
266cdf0e10cSrcweir 		case PROPERTY_ID_SCHEMANAME:
267cdf0e10cSrcweir 			{
268cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
269cdf0e10cSrcweir 				xProp->setPropertyValue(PROPERTY_SCHEMANAME,_rValue);
270cdf0e10cSrcweir 			}
271cdf0e10cSrcweir 			break;
272cdf0e10cSrcweir 		case PROPERTY_ID_NAME:
273cdf0e10cSrcweir 			{
274cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
275cdf0e10cSrcweir 				xProp->setPropertyValue(PROPERTY_NAME,_rValue);
276cdf0e10cSrcweir 			}
277cdf0e10cSrcweir 			break;
278cdf0e10cSrcweir 		case PROPERTY_ID_DESCRIPTION:
279cdf0e10cSrcweir 			{
280cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
281cdf0e10cSrcweir 				xProp->setPropertyValue(PROPERTY_DESCRIPTION,_rValue);
282cdf0e10cSrcweir 			}
283cdf0e10cSrcweir 			break;
284cdf0e10cSrcweir 		case PROPERTY_ID_TYPE:
285cdf0e10cSrcweir 			{
286cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
287cdf0e10cSrcweir 				xProp->setPropertyValue(PROPERTY_TYPE,_rValue);
288cdf0e10cSrcweir 			}
289cdf0e10cSrcweir 			break;
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir }
292cdf0e10cSrcweir //------------------------------------------------------------------------------
getFastPropertyValue(Any & _rValue,sal_Int32 _nHandle) const293cdf0e10cSrcweir void ODBTableDecorator::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
294cdf0e10cSrcweir {
295cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getFastPropertyValue" );
296cdf0e10cSrcweir 	switch(_nHandle)
297cdf0e10cSrcweir 	{
298cdf0e10cSrcweir 		case PROPERTY_ID_PRIVILEGES:
299cdf0e10cSrcweir 			{
300cdf0e10cSrcweir 				if ( -1 == m_nPrivileges )
301cdf0e10cSrcweir 					fillPrivileges();
302cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
303cdf0e10cSrcweir 				Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
304cdf0e10cSrcweir 				if ( xInfo->hasPropertyByName(PROPERTY_PRIVILEGES) )
305cdf0e10cSrcweir 				{
306cdf0e10cSrcweir 					_rValue <<= m_nPrivileges;
307cdf0e10cSrcweir 					break;
308cdf0e10cSrcweir 				}
309cdf0e10cSrcweir 			}
310cdf0e10cSrcweir 			// run through
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		case PROPERTY_ID_FILTER:
313cdf0e10cSrcweir 		case PROPERTY_ID_ORDER:
314cdf0e10cSrcweir 		case PROPERTY_ID_APPLYFILTER:
315cdf0e10cSrcweir 		case PROPERTY_ID_FONT:
316cdf0e10cSrcweir 		case PROPERTY_ID_ROW_HEIGHT:
317cdf0e10cSrcweir 		case PROPERTY_ID_TEXTCOLOR:
318cdf0e10cSrcweir 		case PROPERTY_ID_TEXTLINECOLOR:
319cdf0e10cSrcweir 		case PROPERTY_ID_TEXTEMPHASIS:
320cdf0e10cSrcweir 		case PROPERTY_ID_TEXTRELIEF:
321cdf0e10cSrcweir 		case PROPERTY_ID_FONTCHARWIDTH:
322cdf0e10cSrcweir 		case PROPERTY_ID_FONTCHARSET:
323cdf0e10cSrcweir 		case PROPERTY_ID_FONTFAMILY:
324cdf0e10cSrcweir 		case PROPERTY_ID_FONTHEIGHT:
325cdf0e10cSrcweir 		case PROPERTY_ID_FONTKERNING:
326cdf0e10cSrcweir 		case PROPERTY_ID_FONTNAME:
327cdf0e10cSrcweir 		case PROPERTY_ID_FONTORIENTATION:
328cdf0e10cSrcweir 		case PROPERTY_ID_FONTPITCH:
329cdf0e10cSrcweir 		case PROPERTY_ID_FONTSLANT:
330cdf0e10cSrcweir 		case PROPERTY_ID_FONTSTRIKEOUT:
331cdf0e10cSrcweir 		case PROPERTY_ID_FONTSTYLENAME:
332cdf0e10cSrcweir 		case PROPERTY_ID_FONTUNDERLINE:
333cdf0e10cSrcweir 		case PROPERTY_ID_FONTWEIGHT:
334cdf0e10cSrcweir 		case PROPERTY_ID_FONTWIDTH:
335cdf0e10cSrcweir 		case PROPERTY_ID_FONTWORDLINEMODE:
336cdf0e10cSrcweir 		case PROPERTY_ID_FONTTYPE:
337cdf0e10cSrcweir 			ODataSettings::getFastPropertyValue(_rValue, _nHandle);
338cdf0e10cSrcweir 			break;
339cdf0e10cSrcweir 		case PROPERTY_ID_CATALOGNAME:
340cdf0e10cSrcweir 			{
341cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
342cdf0e10cSrcweir 				_rValue = xProp->getPropertyValue(PROPERTY_CATALOGNAME);
343cdf0e10cSrcweir 			}
344cdf0e10cSrcweir 			break;
345cdf0e10cSrcweir 		case PROPERTY_ID_SCHEMANAME:
346cdf0e10cSrcweir 			{
347cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
348cdf0e10cSrcweir 				_rValue = xProp->getPropertyValue(PROPERTY_SCHEMANAME);
349cdf0e10cSrcweir 			}
350cdf0e10cSrcweir 			break;
351cdf0e10cSrcweir 		case PROPERTY_ID_NAME:
352cdf0e10cSrcweir 			{
353cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
354cdf0e10cSrcweir 				_rValue = xProp->getPropertyValue(PROPERTY_NAME);
355cdf0e10cSrcweir 			}
356cdf0e10cSrcweir 			break;
357cdf0e10cSrcweir 		case PROPERTY_ID_DESCRIPTION:
358cdf0e10cSrcweir 			{
359cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
360cdf0e10cSrcweir 				_rValue = xProp->getPropertyValue(PROPERTY_DESCRIPTION);
361cdf0e10cSrcweir 			}
362cdf0e10cSrcweir 			break;
363cdf0e10cSrcweir 		case PROPERTY_ID_TYPE:
364cdf0e10cSrcweir 			{
365cdf0e10cSrcweir 				Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
366cdf0e10cSrcweir 				_rValue = xProp->getPropertyValue(PROPERTY_TYPE);
367cdf0e10cSrcweir 			}
368cdf0e10cSrcweir 			break;
369cdf0e10cSrcweir 		default:
370cdf0e10cSrcweir 			OSL_ENSURE(0,"Invalid Handle for table");
371cdf0e10cSrcweir 	}
372cdf0e10cSrcweir }
373cdf0e10cSrcweir // -------------------------------------------------------------------------
construct()374cdf0e10cSrcweir void ODBTableDecorator::construct()
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::construct" );
377cdf0e10cSrcweir 	sal_Bool bNotFound = sal_True;
378cdf0e10cSrcweir 	Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
379cdf0e10cSrcweir 	if ( xProp.is() )
380cdf0e10cSrcweir 	{
381cdf0e10cSrcweir 		Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
382cdf0e10cSrcweir 		bNotFound = !xInfo->hasPropertyByName(PROPERTY_PRIVILEGES);
383cdf0e10cSrcweir 	}
384cdf0e10cSrcweir 	if ( bNotFound )
385cdf0e10cSrcweir 		registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND  | PropertyAttribute::READONLY,
386cdf0e10cSrcweir 						&m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
387cdf0e10cSrcweir }
388cdf0e10cSrcweir // -----------------------------------------------------------------------------
createArrayHelper(sal_Int32) const389cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ODBTableDecorator::createArrayHelper(sal_Int32 /*_nId*/) const
390cdf0e10cSrcweir {
391cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createArrayHelper" );
392cdf0e10cSrcweir 	Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
393cdf0e10cSrcweir 	Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	Sequence< Property > aTableProps = xInfo->getProperties();
396cdf0e10cSrcweir 	Property* pIter = aTableProps.getArray();
397cdf0e10cSrcweir 	Property* pEnd = pIter + aTableProps.getLength();
398cdf0e10cSrcweir 	for (;pIter != pEnd ; ++pIter)
399cdf0e10cSrcweir 	{
400cdf0e10cSrcweir 		if (0 == pIter->Name.compareToAscii(PROPERTY_CATALOGNAME))
401cdf0e10cSrcweir 			pIter->Handle = PROPERTY_ID_CATALOGNAME;
402cdf0e10cSrcweir 		else if (0 ==pIter->Name.compareToAscii(PROPERTY_SCHEMANAME))
403cdf0e10cSrcweir 			pIter->Handle = PROPERTY_ID_SCHEMANAME;
404cdf0e10cSrcweir 		else if (0 ==pIter->Name.compareToAscii(PROPERTY_NAME))
405cdf0e10cSrcweir 			pIter->Handle = PROPERTY_ID_NAME;
406cdf0e10cSrcweir 		else if (0 ==pIter->Name.compareToAscii(PROPERTY_DESCRIPTION))
407cdf0e10cSrcweir 			pIter->Handle = PROPERTY_ID_DESCRIPTION;
408cdf0e10cSrcweir 		else if (0 ==pIter->Name.compareToAscii(PROPERTY_TYPE))
409cdf0e10cSrcweir 			pIter->Handle = PROPERTY_ID_TYPE;
410cdf0e10cSrcweir 		else if (0 ==pIter->Name.compareToAscii(PROPERTY_PRIVILEGES))
411cdf0e10cSrcweir 			pIter->Handle = PROPERTY_ID_PRIVILEGES;
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	describeProperties(aTableProps);
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 	return new ::cppu::OPropertyArrayHelper(aTableProps);
417cdf0e10cSrcweir }
418cdf0e10cSrcweir // -----------------------------------------------------------------------------
getInfoHelper()419cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & SAL_CALL ODBTableDecorator::getInfoHelper()
420cdf0e10cSrcweir {
421cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getInfoHelper" );
422cdf0e10cSrcweir 	Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
425cdf0e10cSrcweir     bool bIsDescriptor = (xInfo->getPropertyByName(PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) == 0;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir     return *ODBTableDecorator_PROP::getArrayHelper( bIsDescriptor ? 0 : 1 );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     // TODO: this is a HACK, and prone to errors
430cdf0e10cSrcweir     // The OIdPropertyArrayUsageHelper is intended for classes where there exists a known, limited
431cdf0e10cSrcweir     // number of different property set infos (distinguished by the ID), all implemented by this very
432cdf0e10cSrcweir     // same class.
433cdf0e10cSrcweir     // However, in this case here we have an unknown, potentially unlimited number of different
434cdf0e10cSrcweir     // property set infos: Depending on the table for which we act as decorator, different property
435cdf0e10cSrcweir     // sets might exist.
436cdf0e10cSrcweir }
437cdf0e10cSrcweir // -------------------------------------------------------------------------
438cdf0e10cSrcweir // XServiceInfo
439cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO1(ODBTableDecorator, "com.sun.star.sdb.dbaccess.ODBTableDecorator", SERVICE_SDBCX_TABLE)
440cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)441cdf0e10cSrcweir Any SAL_CALL ODBTableDecorator::queryInterface( const Type & rType ) throw(RuntimeException)
442cdf0e10cSrcweir {
443cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::queryInterface" );
444cdf0e10cSrcweir 	Any aRet;
445cdf0e10cSrcweir 	if(m_xTable.is())
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		aRet = m_xTable->queryInterface(rType);
448cdf0e10cSrcweir 		if(aRet.hasValue())
449cdf0e10cSrcweir 		{	// now we know that our table supports this type so we return ourself
450cdf0e10cSrcweir 			aRet = OTableDescriptor_BASE::queryInterface(rType);
451cdf0e10cSrcweir 			if(!aRet.hasValue())
452cdf0e10cSrcweir 				aRet = ODataSettings::queryInterface(rType);
453cdf0e10cSrcweir 		}
454cdf0e10cSrcweir 	}
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	return aRet;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()459cdf0e10cSrcweir Sequence< Type > SAL_CALL ODBTableDecorator::getTypes(  ) throw(RuntimeException)
460cdf0e10cSrcweir {
461cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getTypes" );
462cdf0e10cSrcweir 	Reference<XTypeProvider> xTypes(m_xTable,UNO_QUERY);
463cdf0e10cSrcweir 	OSL_ENSURE(xTypes.is(),"Table must be a TypePropvider!");
464cdf0e10cSrcweir 	return xTypes->getTypes();
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir // -----------------------------------------------------------------------------
468cdf0e10cSrcweir // XRename,
469cdf0e10cSrcweir //------------------------------------------------------------------------------
rename(const::rtl::OUString & _rNewName)470cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException)
471cdf0e10cSrcweir {
472cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::rename" );
473cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
474cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
475cdf0e10cSrcweir 	Reference<XRename> xRename(m_xTable,UNO_QUERY);
476cdf0e10cSrcweir 	if(xRename.is())
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir //		::rtl::OUString sOldName;
479cdf0e10cSrcweir //		Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
480cdf0e10cSrcweir //		xProp->getPropertyValue(PROPERTY_NAME) >>= sOldName;
481cdf0e10cSrcweir 		xRename->rename(_rNewName);
482cdf0e10cSrcweir 	}
483cdf0e10cSrcweir 	else // not supported
484cdf0e10cSrcweir 		throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir // XAlterTable,
488cdf0e10cSrcweir //------------------------------------------------------------------------------
alterColumnByName(const::rtl::OUString & _rName,const Reference<XPropertySet> & _rxDescriptor)489cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::alterColumnByName( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::alterColumnByName" );
492cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
493cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
494cdf0e10cSrcweir 	Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
495cdf0e10cSrcweir 	if(xAlter.is())
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir 		xAlter->alterColumnByName(_rName,_rxDescriptor);
498cdf0e10cSrcweir 	}
499cdf0e10cSrcweir 	else
500cdf0e10cSrcweir 		throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_NAME),*this,SQLSTATE_GENERAL,1000,Any() );
501cdf0e10cSrcweir 	if(m_pColumns)
502cdf0e10cSrcweir 		m_pColumns->refresh();
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir //------------------------------------------------------------------------------
alterColumnByIndex(sal_Int32 _nIndex,const Reference<XPropertySet> & _rxDescriptor)506cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::alterColumnByIndex( sal_Int32 _nIndex, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::alterColumnByIndex" );
509cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
510cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
511cdf0e10cSrcweir 	Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
512cdf0e10cSrcweir 	if(xAlter.is())
513cdf0e10cSrcweir 	{
514cdf0e10cSrcweir 		xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
515cdf0e10cSrcweir 		if(m_pColumns)
516cdf0e10cSrcweir 			m_pColumns->refresh();
517cdf0e10cSrcweir 	}
518cdf0e10cSrcweir 	else // not supported
519cdf0e10cSrcweir 		throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_INDEX),*this,SQLSTATE_GENERAL,1000,Any() );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir // -----------------------------------------------------------------------------
getIndexes()522cdf0e10cSrcweir Reference< XNameAccess> ODBTableDecorator::getIndexes() throw (RuntimeException)
523cdf0e10cSrcweir {
524cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getIndexes" );
525cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
526cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
527cdf0e10cSrcweir 	return Reference< XIndexesSupplier>(m_xTable,UNO_QUERY)->getIndexes();
528cdf0e10cSrcweir }
529cdf0e10cSrcweir // -------------------------------------------------------------------------
getKeys()530cdf0e10cSrcweir Reference< XIndexAccess> ODBTableDecorator::getKeys() throw (RuntimeException)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getKeys" );
533cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
534cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
535cdf0e10cSrcweir 	return Reference< XKeysSupplier>(m_xTable,UNO_QUERY)->getKeys();
536cdf0e10cSrcweir }
537cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumns()538cdf0e10cSrcweir Reference< XNameAccess> ODBTableDecorator::getColumns() throw (RuntimeException)
539cdf0e10cSrcweir {
540cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getColumns" );
541cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
542cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 	if(!m_pColumns)
545cdf0e10cSrcweir 		refreshColumns();
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 	return m_pColumns;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir // -----------------------------------------------------------------------------
getName()550cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODBTableDecorator::getName() throw(RuntimeException)
551cdf0e10cSrcweir {
552cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getName" );
553cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
554cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
555cdf0e10cSrcweir 	Reference<XNamed> xName(m_xTable,UNO_QUERY);
556cdf0e10cSrcweir 	OSL_ENSURE(xName.is(),"Table should support the XNamed interface");
557cdf0e10cSrcweir 	return xName->getName();
558cdf0e10cSrcweir }
559cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & rId)560cdf0e10cSrcweir sal_Int64 SAL_CALL ODBTableDecorator::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
561cdf0e10cSrcweir {
562cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getSomething" );
563cdf0e10cSrcweir 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
564cdf0e10cSrcweir 		return reinterpret_cast<sal_Int64>(this);
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 	sal_Int64 nRet = 0;
567cdf0e10cSrcweir 	Reference<XUnoTunnel> xTunnel(m_xTable,UNO_QUERY);
568cdf0e10cSrcweir 	if(xTunnel.is())
569cdf0e10cSrcweir 		nRet = xTunnel->getSomething(rId);
570cdf0e10cSrcweir 	return nRet;
571cdf0e10cSrcweir }
572cdf0e10cSrcweir // -----------------------------------------------------------------------------
getUnoTunnelImplementationId()573cdf0e10cSrcweir Sequence< sal_Int8 > ODBTableDecorator::getUnoTunnelImplementationId()
574cdf0e10cSrcweir {
575cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getUnoTunnelImplementationId" );
576cdf0e10cSrcweir 	static ::cppu::OImplementationId * pId = 0;
577cdf0e10cSrcweir 	if (! pId)
578cdf0e10cSrcweir 	{
579cdf0e10cSrcweir 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
580cdf0e10cSrcweir 		if (! pId)
581cdf0e10cSrcweir 		{
582cdf0e10cSrcweir 			static ::cppu::OImplementationId aId;
583cdf0e10cSrcweir 			pId = &aId;
584cdf0e10cSrcweir 		}
585cdf0e10cSrcweir 	}
586cdf0e10cSrcweir 	return pId->getImplementationId();
587cdf0e10cSrcweir }
588cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillPrivileges() const589cdf0e10cSrcweir void ODBTableDecorator::fillPrivileges() const
590cdf0e10cSrcweir {
591cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::fillPrivileges" );
592cdf0e10cSrcweir 	// somebody is asking for the privileges an we do not know them, yet
593cdf0e10cSrcweir 	m_nPrivileges = 0;
594cdf0e10cSrcweir 	try
595cdf0e10cSrcweir 	{
596cdf0e10cSrcweir 		Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
597cdf0e10cSrcweir 		if ( xProp.is() )
598cdf0e10cSrcweir 		{
599cdf0e10cSrcweir 			if ( xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES) )
600cdf0e10cSrcweir 			{
601cdf0e10cSrcweir 				xProp->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
602cdf0e10cSrcweir 			}
603cdf0e10cSrcweir 			if ( m_nPrivileges == 0 ) // second chance
604cdf0e10cSrcweir 			{
605cdf0e10cSrcweir 				::rtl::OUString sCatalog,sSchema,sName;
606cdf0e10cSrcweir 				xProp->getPropertyValue(PROPERTY_CATALOGNAME)	>>= sCatalog;
607cdf0e10cSrcweir 				xProp->getPropertyValue(PROPERTY_SCHEMANAME)	>>= sSchema;
608cdf0e10cSrcweir 				xProp->getPropertyValue(PROPERTY_NAME)			>>= sName;
609cdf0e10cSrcweir 				m_nPrivileges = ::dbtools::getTablePrivileges(getMetaData(),sCatalog,sSchema, sName);
610cdf0e10cSrcweir 			}
611cdf0e10cSrcweir 		}
612cdf0e10cSrcweir 	}
613cdf0e10cSrcweir 	catch(const SQLException& e)
614cdf0e10cSrcweir 	{
615cdf0e10cSrcweir         (void)e;
616cdf0e10cSrcweir 		DBG_ERROR("ODBTableDecorator::ODBTableDecorator : could not collect the privileges !");
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir }
619cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDataDescriptor()620cdf0e10cSrcweir Reference< XPropertySet > SAL_CALL ODBTableDecorator::createDataDescriptor(  ) throw (RuntimeException)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createDataDescriptor" );
623cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
624cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 	Reference< XDataDescriptorFactory > xFactory( m_xTable, UNO_QUERY );
627cdf0e10cSrcweir 	DBG_ASSERT( xFactory.is(), "ODBTableDecorator::createDataDescriptor: invalid table!" );
628cdf0e10cSrcweir 	Reference< XColumnsSupplier > xColsSupp;
629cdf0e10cSrcweir 	if ( xFactory.is() )
630cdf0e10cSrcweir 		xColsSupp = xColsSupp.query( xFactory->createDataDescriptor() );
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	return new ODBTableDecorator(
633cdf0e10cSrcweir 		m_xConnection,
634cdf0e10cSrcweir 		xColsSupp,
635cdf0e10cSrcweir 		m_xNumberFormats,
636cdf0e10cSrcweir 		NULL
637cdf0e10cSrcweir 	);
638cdf0e10cSrcweir }
639cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()640cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODBTableDecorator::getPropertySetInfo(  ) throw(RuntimeException)
641cdf0e10cSrcweir {
642cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::getPropertySetInfo" );
643cdf0e10cSrcweir 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
644cdf0e10cSrcweir }
645cdf0e10cSrcweir // -----------------------------------------------------------------------------
refreshColumns()646cdf0e10cSrcweir void ODBTableDecorator::refreshColumns()
647cdf0e10cSrcweir {
648cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::refreshColumns" );
649cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
650cdf0e10cSrcweir 	::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
651cdf0e10cSrcweir 
652cdf0e10cSrcweir 	::std::vector< ::rtl::OUString> aVector;
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	Reference<XNameAccess> xNames;
655cdf0e10cSrcweir 	if(m_xTable.is())
656cdf0e10cSrcweir 	{
657cdf0e10cSrcweir 		xNames = m_xTable->getColumns();
658cdf0e10cSrcweir 		if(xNames.is())
659cdf0e10cSrcweir 		{
660cdf0e10cSrcweir 			Sequence< ::rtl::OUString> aNames = xNames->getElementNames();
661cdf0e10cSrcweir 			const ::rtl::OUString* pIter	= aNames.getConstArray();
662cdf0e10cSrcweir 			const ::rtl::OUString* pEnd		= pIter + aNames.getLength();
663cdf0e10cSrcweir 			for(;pIter != pEnd;++pIter)
664cdf0e10cSrcweir 				aVector.push_back(*pIter);
665cdf0e10cSrcweir 		}
666cdf0e10cSrcweir 	}
667cdf0e10cSrcweir 	if(!m_pColumns)
668cdf0e10cSrcweir 	{
669cdf0e10cSrcweir 		OColumns* pCol = new OColumns(*this,m_aMutex,xNames,m_xMetaData.is() && m_xMetaData->supportsMixedCaseQuotedIdentifiers(),aVector,
670cdf0e10cSrcweir 									this,this,
671cdf0e10cSrcweir 									m_xMetaData.is() && m_xMetaData->supportsAlterTableWithAddColumn(),
672cdf0e10cSrcweir 									m_xMetaData.is() && m_xMetaData->supportsAlterTableWithDropColumn());
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 		pCol->setParent(*this);
675cdf0e10cSrcweir         OContainerMediator* pMediator = new OContainerMediator( pCol, m_xColumnDefinitions, m_xConnection, OContainerMediator::eColumns );
676cdf0e10cSrcweir 		m_xColumnMediator = pMediator;
677cdf0e10cSrcweir 		pCol->setMediator( pMediator );
678cdf0e10cSrcweir 		m_pColumns	= pCol;
679cdf0e10cSrcweir 	}
680cdf0e10cSrcweir 	else
681cdf0e10cSrcweir 		m_pColumns->reFill(aVector);
682cdf0e10cSrcweir }
683cdf0e10cSrcweir // -----------------------------------------------------------------------------
createColumn(const::rtl::OUString & _rName) const684cdf0e10cSrcweir OColumn* ODBTableDecorator::createColumn(const ::rtl::OUString& _rName) const
685cdf0e10cSrcweir {
686cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createColumn" );
687cdf0e10cSrcweir 	OColumn* pReturn = NULL;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 	Reference<XNameAccess> xNames;
690cdf0e10cSrcweir 	if ( m_xTable.is() )
691cdf0e10cSrcweir 	{
692cdf0e10cSrcweir 		xNames = m_xTable->getColumns();
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 		if ( xNames.is() && xNames->hasByName(_rName) )
695cdf0e10cSrcweir 		{
696cdf0e10cSrcweir 			Reference<XPropertySet> xProp(xNames->getByName(_rName),UNO_QUERY);
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 			Reference<XPropertySet> xColumnDefintion;
699cdf0e10cSrcweir 			if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName))
700cdf0e10cSrcweir 				xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY);
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 			pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false );
703cdf0e10cSrcweir 		}
704cdf0e10cSrcweir 	}
705cdf0e10cSrcweir 	return pReturn;
706cdf0e10cSrcweir }
707cdf0e10cSrcweir // -----------------------------------------------------------------------------
columnAppended(const Reference<XPropertySet> &)708cdf0e10cSrcweir void ODBTableDecorator::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::columnAppended" );
711cdf0e10cSrcweir     // not interested in
712cdf0e10cSrcweir }
713cdf0e10cSrcweir // -----------------------------------------------------------------------------
columnDropped(const::rtl::OUString & _sName)714cdf0e10cSrcweir void ODBTableDecorator::columnDropped(const ::rtl::OUString& _sName)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::columnDropped" );
717cdf0e10cSrcweir 	Reference<XDrop> xDrop(m_xColumnDefinitions,UNO_QUERY);
718cdf0e10cSrcweir 	if ( xDrop.is() && m_xColumnDefinitions->hasByName(_sName) )
719cdf0e10cSrcweir 		xDrop->dropByName(_sName);
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
722cdf0e10cSrcweir // -----------------------------------------------------------------------------
createColumnDescriptor()723cdf0e10cSrcweir Reference< XPropertySet > ODBTableDecorator::createColumnDescriptor()
724cdf0e10cSrcweir {
725cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::createColumnDescriptor" );
726cdf0e10cSrcweir 	Reference<XDataDescriptorFactory> xNames;
727cdf0e10cSrcweir 	if(m_xTable.is())
728cdf0e10cSrcweir 		xNames.set(m_xTable->getColumns(),UNO_QUERY);
729cdf0e10cSrcweir 	Reference< XPropertySet > xRet;
730cdf0e10cSrcweir 	if ( xNames.is() )
731cdf0e10cSrcweir 		xRet = new OTableColumnDescriptorWrapper( xNames->createDataDescriptor(), false, true );
732cdf0e10cSrcweir 	return xRet;
733cdf0e10cSrcweir }
734cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()735cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::acquire() throw()
736cdf0e10cSrcweir {
737cdf0e10cSrcweir 	OTableDescriptor_BASE::acquire();
738cdf0e10cSrcweir }
739cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()740cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::release() throw()
741cdf0e10cSrcweir {
742cdf0e10cSrcweir 	OTableDescriptor_BASE::release();
743cdf0e10cSrcweir }
744cdf0e10cSrcweir 
745cdf0e10cSrcweir // -----------------------------------------------------------------------------
setName(const::rtl::OUString &)746cdf0e10cSrcweir void SAL_CALL ODBTableDecorator::setName( const ::rtl::OUString& /*aName*/ ) throw (::com::sun::star::uno::RuntimeException)
747cdf0e10cSrcweir {
748cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTableDecorator::setName" );
749cdf0e10cSrcweir     throwFunctionNotSupportedException( "XNamed::setName", *this );
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir // -----------------------------------------------------------------------------
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 
755