xref: /aoo42x/main/dbaccess/source/core/api/table.cxx (revision 96de5490)
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 #include "table.hxx"
28cdf0e10cSrcweir #include <definitioncolumn.hxx>
29cdf0e10cSrcweir #include "dbastrings.hrc"
30cdf0e10cSrcweir #include "core_resource.hxx"
31cdf0e10cSrcweir #include "core_resource.hrc"
32cdf0e10cSrcweir #include "CIndexes.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
36cdf0e10cSrcweir #include <comphelper/enumhelper.hxx>
37cdf0e10cSrcweir #include <comphelper/container.hxx>
38cdf0e10cSrcweir #include <comphelper/sequence.hxx>
39cdf0e10cSrcweir #include <comphelper/types.hxx>
40cdf0e10cSrcweir //#include <comphelper/extract.hxx>
41cdf0e10cSrcweir #include <com/sun/star/util/XRefreshListener.hpp>
42cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
43cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
44cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
45cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
46cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <connectivity/TKeys.hxx>
49cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
50cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include "sdbcoretools.hxx"
53cdf0e10cSrcweir #include "ContainerMediator.hxx"
54cdf0e10cSrcweir #include <rtl/logfile.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using namespace dbaccess;
57cdf0e10cSrcweir using namespace connectivity;
58cdf0e10cSrcweir using namespace ::com::sun::star::uno;
59cdf0e10cSrcweir using namespace ::com::sun::star::util;
60cdf0e10cSrcweir using namespace ::com::sun::star::lang;
61cdf0e10cSrcweir using namespace ::com::sun::star::beans;
62cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
63cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
64cdf0e10cSrcweir using namespace ::com::sun::star::container;
65cdf0e10cSrcweir using namespace ::osl;
66cdf0e10cSrcweir using namespace ::comphelper;
67cdf0e10cSrcweir using namespace ::cppu;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir typedef ::std::map <sal_Int32, OTableColumn*, std::less <sal_Int32> > OColMap;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //==========================================================================
72cdf0e10cSrcweir //= ODBTable
73cdf0e10cSrcweir //==========================================================================
DBG_NAME(ODBTable)74cdf0e10cSrcweir DBG_NAME(ODBTable)
75cdf0e10cSrcweir //--------------------------------------------------------------------------
76cdf0e10cSrcweir ODBTable::ODBTable(connectivity::sdbcx::OCollection* _pTables
77cdf0e10cSrcweir 		,const Reference< XConnection >& _rxConn
78cdf0e10cSrcweir 		,const ::rtl::OUString& _rCatalog
79cdf0e10cSrcweir 		,const ::rtl::OUString& _rSchema
80cdf0e10cSrcweir 		,const ::rtl::OUString& _rName
81cdf0e10cSrcweir 		,const ::rtl::OUString& _rType
82cdf0e10cSrcweir 		,const ::rtl::OUString& _rDesc
83cdf0e10cSrcweir 		,const Reference< XNameAccess >& _xColumnDefinitions) throw(SQLException)
84cdf0e10cSrcweir 	:OTable_Base(_pTables,_rxConn,_rxConn->getMetaData().is() && _rxConn->getMetaData()->supportsMixedCaseQuotedIdentifiers(), _rName, _rType, _rDesc, _rSchema, _rCatalog )
85cdf0e10cSrcweir 	,m_xColumnDefinitions(_xColumnDefinitions)
86cdf0e10cSrcweir 	,m_nPrivileges(0)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" );
89cdf0e10cSrcweir 	DBG_CTOR(ODBTable, NULL);
90cdf0e10cSrcweir 	DBG_ASSERT(getMetaData().is(), "ODBTable::ODBTable : invalid conn !");
91cdf0e10cSrcweir 	DBG_ASSERT(_rName.getLength(), "ODBTable::ODBTable : name !");
92cdf0e10cSrcweir 	// TODO : think about collecting the privileges here, as we can't ensure that in getFastPropertyValue, where
93cdf0e10cSrcweir 	// we do this at the moment, the statement needed can be supplied by the connection (for example the SQL-Server
94cdf0e10cSrcweir 	// ODBC driver does not allow more than one statement per connection, and in getFastPropertyValue it's more
95cdf0e10cSrcweir 	// likely that it's already used up than it's here.)
96cdf0e10cSrcweir }
97cdf0e10cSrcweir // -----------------------------------------------------------------------------
ODBTable(connectivity::sdbcx::OCollection * _pTables,const Reference<XConnection> & _rxConn)98cdf0e10cSrcweir ODBTable::ODBTable(connectivity::sdbcx::OCollection* _pTables
99cdf0e10cSrcweir 				   ,const Reference< XConnection >& _rxConn)
100cdf0e10cSrcweir 				throw(SQLException)
101cdf0e10cSrcweir 	:OTable_Base(_pTables,_rxConn, _rxConn->getMetaData().is() && _rxConn->getMetaData()->supportsMixedCaseQuotedIdentifiers())
102cdf0e10cSrcweir 	,m_nPrivileges(-1)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     DBG_CTOR(ODBTable, NULL);
105cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir // -------------------------------------------------------------------------
~ODBTable()108cdf0e10cSrcweir ODBTable::~ODBTable()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	DBG_DTOR(ODBTable, NULL);
111cdf0e10cSrcweir }
112cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPLEMENT_FORWARD_REFCOUNT(ODBTable,OTable_Base)113cdf0e10cSrcweir IMPLEMENT_FORWARD_REFCOUNT(ODBTable,OTable_Base)
114cdf0e10cSrcweir 
115cdf0e10cSrcweir //--------------------------------------------------------------------------
116cdf0e10cSrcweir OColumn* ODBTable::createColumn(const ::rtl::OUString& _rName) const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumn" );
119cdf0e10cSrcweir 	OColumn* pReturn = NULL;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	Reference<XPropertySet> xProp;
122cdf0e10cSrcweir 	if ( m_xDriverColumns.is() && m_xDriverColumns->hasByName(_rName) )
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir 		xProp.set(m_xDriverColumns->getByName(_rName),UNO_QUERY);
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 	else
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 		OColumns* pColumns = static_cast<OColumns*>(m_pColumns);
129cdf0e10cSrcweir 		xProp.set(pColumns->createBaseObject(_rName),UNO_QUERY);
130cdf0e10cSrcweir 	}
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	Reference<XPropertySet> xColumnDefintion;
133cdf0e10cSrcweir 	if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName) )
134cdf0e10cSrcweir 		xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY);
135cdf0e10cSrcweir 	pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	return pReturn;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
columnAppended(const Reference<XPropertySet> &)140cdf0e10cSrcweir void ODBTable::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::columnAppended" );
143cdf0e10cSrcweir     // not interested in
144cdf0e10cSrcweir }
145cdf0e10cSrcweir // -----------------------------------------------------------------------------
columnDropped(const::rtl::OUString & _sName)146cdf0e10cSrcweir void ODBTable::columnDropped(const ::rtl::OUString& _sName)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::columnDropped" );
149cdf0e10cSrcweir 	Reference<XDrop> xDrop(m_xColumnDefinitions,UNO_QUERY);
150cdf0e10cSrcweir 	if ( xDrop.is() && m_xColumnDefinitions->hasByName(_sName) )
151cdf0e10cSrcweir 	{
152cdf0e10cSrcweir 		xDrop->dropByName(_sName);
153cdf0e10cSrcweir 	}
154cdf0e10cSrcweir }
155cdf0e10cSrcweir //--------------------------------------------------------------------------
getImplementationId()156cdf0e10cSrcweir Sequence< sal_Int8 > ODBTable::getImplementationId() throw (RuntimeException)
157cdf0e10cSrcweir {
158cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getImplementationId" );
159cdf0e10cSrcweir 	static OImplementationId * pId = 0;
160cdf0e10cSrcweir 	if (! pId)
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		MutexGuard aGuard( Mutex::getGlobalMutex() );
163cdf0e10cSrcweir 		if (! pId)
164cdf0e10cSrcweir 		{
165cdf0e10cSrcweir 			static OImplementationId aId;
166cdf0e10cSrcweir 			pId = &aId;
167cdf0e10cSrcweir 		}
168cdf0e10cSrcweir 	}
169cdf0e10cSrcweir 	return pId->getImplementationId();
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir // OComponentHelper
173cdf0e10cSrcweir //------------------------------------------------------------------------------
disposing()174cdf0e10cSrcweir void SAL_CALL ODBTable::disposing()
175cdf0e10cSrcweir {
176cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::disposing" );
177cdf0e10cSrcweir 	OPropertySetHelper::disposing();
178cdf0e10cSrcweir 	OTable_Base::disposing();
179cdf0e10cSrcweir 	m_xColumnDefinitions = NULL;
180cdf0e10cSrcweir 	m_xDriverColumns = NULL;
181cdf0e10cSrcweir 	m_pColumnMediator = NULL;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir //------------------------------------------------------------------------------
getFastPropertyValue(Any & _rValue,sal_Int32 _nHandle) const185cdf0e10cSrcweir void ODBTable::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
186cdf0e10cSrcweir {
187cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getFastPropertyValue" );
188cdf0e10cSrcweir 	if ((PROPERTY_ID_PRIVILEGES == _nHandle) && (-1 == m_nPrivileges))
189cdf0e10cSrcweir 	{	// somebody is asking for the privileges an we do not know them, yet
190cdf0e10cSrcweir 		const_cast<ODBTable*>(this)->m_nPrivileges = ::dbtools::getTablePrivileges(getMetaData(),m_CatalogName,m_SchemaName, m_Name);
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	OTable_Base::getFastPropertyValue(_rValue, _nHandle);
194cdf0e10cSrcweir }
195cdf0e10cSrcweir // -------------------------------------------------------------------------
construct()196cdf0e10cSrcweir void ODBTable::construct()
197cdf0e10cSrcweir {
198cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::construct" );
199cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	// we don't collect the privileges here, this is potentially expensive. Instead we determine them on request.
202cdf0e10cSrcweir 	// (see getFastPropertyValue)
203cdf0e10cSrcweir 	m_nPrivileges = -1;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	OTable_Base::construct();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
208cdf0e10cSrcweir 					&m_sFilter, ::getCppuType(&m_sFilter));
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
211cdf0e10cSrcweir 					&m_sOrder, ::getCppuType(&m_sOrder));
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
214cdf0e10cSrcweir 					&m_bApplyFilter, ::getBooleanCppuType());
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
217cdf0e10cSrcweir 					&m_aFont, ::getCppuType(&m_aFont));
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
220cdf0e10cSrcweir 					&m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL)));
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
223cdf0e10cSrcweir 					&m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND | PropertyAttribute::READONLY,
226cdf0e10cSrcweir 					&m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
229cdf0e10cSrcweir 					&m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
232cdf0e10cSrcweir 					&m_nFontEmphasis, ::getCppuType(&m_nFontEmphasis));
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,
235cdf0e10cSrcweir 					&m_nFontRelief, ::getCppuType(&m_nFontRelief));
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTNAME,			PROPERTY_ID_FONTNAME,		 PropertyAttribute::BOUND,&m_aFont.Name,			::getCppuType(&m_aFont.Name));
238cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTHEIGHT,		PROPERTY_ID_FONTHEIGHT,		 PropertyAttribute::BOUND,&m_aFont.Height,			::getCppuType(&m_aFont.Height));
239cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTWIDTH,		PROPERTY_ID_FONTWIDTH,		 PropertyAttribute::BOUND,&m_aFont.Width,			::getCppuType(&m_aFont.Width));
240cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTSTYLENAME,	PROPERTY_ID_FONTSTYLENAME,	 PropertyAttribute::BOUND,&m_aFont.StyleName,		::getCppuType(&m_aFont.StyleName));
241cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTFAMILY,		PROPERTY_ID_FONTFAMILY,		 PropertyAttribute::BOUND,&m_aFont.Family,			::getCppuType(&m_aFont.Family));
242cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTCHARSET,		PROPERTY_ID_FONTCHARSET,	 PropertyAttribute::BOUND,&m_aFont.CharSet,			::getCppuType(&m_aFont.CharSet));
243cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTPITCH,		PROPERTY_ID_FONTPITCH,		 PropertyAttribute::BOUND,&m_aFont.Pitch,			::getCppuType(&m_aFont.Pitch));
244cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTCHARWIDTH,	PROPERTY_ID_FONTCHARWIDTH,	 PropertyAttribute::BOUND,&m_aFont.CharacterWidth,	::getCppuType(&m_aFont.CharacterWidth));
245cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTWEIGHT,		PROPERTY_ID_FONTWEIGHT,		 PropertyAttribute::BOUND,&m_aFont.Weight,			::getCppuType(&m_aFont.Weight));
246cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTSLANT,		PROPERTY_ID_FONTSLANT,		 PropertyAttribute::BOUND,&m_aFont.Slant,			::getCppuType(&m_aFont.Slant));
247cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTUNDERLINE,	PROPERTY_ID_FONTUNDERLINE,	 PropertyAttribute::BOUND,&m_aFont.Underline,		::getCppuType(&m_aFont.Underline));
248cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTSTRIKEOUT,	PROPERTY_ID_FONTSTRIKEOUT,	 PropertyAttribute::BOUND,&m_aFont.Strikeout,		::getCppuType(&m_aFont.Strikeout));
249cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTORIENTATION,	PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&m_aFont.Orientation,		::getCppuType(&m_aFont.Orientation));
250cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTKERNING,		PROPERTY_ID_FONTKERNING,	 PropertyAttribute::BOUND,&m_aFont.Kerning,			::getCppuType(&m_aFont.Kerning));
251cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&m_aFont.WordLineMode,	::getCppuType(&m_aFont.WordLineMode));
252cdf0e10cSrcweir 	registerProperty(PROPERTY_FONTTYPE,			PROPERTY_ID_FONTTYPE,		 PropertyAttribute::BOUND,&m_aFont.Type,			::getCppuType(&m_aFont.Type));
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	refreshColumns();
255cdf0e10cSrcweir }
256cdf0e10cSrcweir // -----------------------------------------------------------------------------
createArrayHelper(sal_Int32 _nId) const257cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ODBTable::createArrayHelper( sal_Int32 _nId) const
258cdf0e10cSrcweir {
259cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createArrayHelper" );
260cdf0e10cSrcweir 	Sequence< Property > aProps;
261cdf0e10cSrcweir 	describeProperties(aProps);
262cdf0e10cSrcweir 	if(!_nId)
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 		Property* pIter	= aProps.getArray();
265cdf0e10cSrcweir 		Property* pEnd	= pIter + aProps.getLength();
266cdf0e10cSrcweir 		for(;pIter != pEnd;++pIter)
267cdf0e10cSrcweir 		{
268cdf0e10cSrcweir 			if (0 == pIter->Name.compareToAscii(PROPERTY_CATALOGNAME))
269cdf0e10cSrcweir 				pIter->Attributes = PropertyAttribute::READONLY;
270cdf0e10cSrcweir 			else if (0 == pIter->Name.compareToAscii(PROPERTY_SCHEMANAME))
271cdf0e10cSrcweir 				pIter->Attributes = PropertyAttribute::READONLY;
272cdf0e10cSrcweir 			else if (0 == pIter->Name.compareToAscii(PROPERTY_DESCRIPTION))
273cdf0e10cSrcweir 				pIter->Attributes = PropertyAttribute::READONLY;
274cdf0e10cSrcweir 			else if (0 == pIter->Name.compareToAscii(PROPERTY_NAME))
275cdf0e10cSrcweir 				pIter->Attributes = PropertyAttribute::READONLY;
276cdf0e10cSrcweir 		}
277cdf0e10cSrcweir 	}
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 	return new ::cppu::OPropertyArrayHelper(aProps);
280cdf0e10cSrcweir }
281cdf0e10cSrcweir // -----------------------------------------------------------------------------
getInfoHelper()282cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & SAL_CALL ODBTable::getInfoHelper()
283cdf0e10cSrcweir {
284cdf0e10cSrcweir 	return *ODBTable_PROP::getArrayHelper(isNew() ? 1 : 0);
285cdf0e10cSrcweir }
286cdf0e10cSrcweir // -------------------------------------------------------------------------
287cdf0e10cSrcweir // XServiceInfo
288cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO1(ODBTable, "com.sun.star.sdb.dbaccess.ODBTable", SERVICE_SDBCX_TABLE)
289cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)290cdf0e10cSrcweir Any SAL_CALL ODBTable::queryInterface( const Type & rType ) throw(RuntimeException)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getInfoHelper" );
293cdf0e10cSrcweir 	if(rType == getCppuType( (Reference<XRename>*)0) && !getRenameService().is() )
294cdf0e10cSrcweir 		return Any();
295cdf0e10cSrcweir 	if(rType == getCppuType( (Reference<XAlterTable>*)0) && !getAlterService().is() )
296cdf0e10cSrcweir 		return Any();
297cdf0e10cSrcweir 	return OTable_Base::queryInterface( rType);
298cdf0e10cSrcweir }
299cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()300cdf0e10cSrcweir Sequence< Type > SAL_CALL ODBTable::getTypes(  ) throw(RuntimeException)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getTypes" );
303cdf0e10cSrcweir 	Type aRenameType = getCppuType( (Reference<XRename>*)0);
304cdf0e10cSrcweir 	Type aAlterType = getCppuType( (Reference<XAlterTable>*)0);
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	Sequence< Type > aTypes(OTable_Base::getTypes());
307cdf0e10cSrcweir 	::std::vector<Type> aOwnTypes;
308cdf0e10cSrcweir 	aOwnTypes.reserve(aTypes.getLength());
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	const Type* pIter = aTypes.getConstArray();
311cdf0e10cSrcweir 	const Type* pEnd = pIter + aTypes.getLength();
312cdf0e10cSrcweir 	for(;pIter != pEnd ;++pIter)
313cdf0e10cSrcweir 	{
314cdf0e10cSrcweir 		if( (*pIter != aRenameType || getRenameService().is()) && (*pIter != aAlterType || getAlterService().is()))
315cdf0e10cSrcweir 			aOwnTypes.push_back(*pIter);
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
319cdf0e10cSrcweir 	return Sequence< Type >(pTypes, aOwnTypes.size());
320cdf0e10cSrcweir }
321cdf0e10cSrcweir // XRename,
322cdf0e10cSrcweir //------------------------------------------------------------------------------
rename(const::rtl::OUString & _rNewName)323cdf0e10cSrcweir void SAL_CALL ODBTable::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException)
324cdf0e10cSrcweir {
325cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::rename" );
326cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
327cdf0e10cSrcweir 	checkDisposed(connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed);
328cdf0e10cSrcweir     if ( !getRenameService().is() )
329cdf0e10cSrcweir 	    throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     Reference<XPropertySet> xTable(this);
332cdf0e10cSrcweir     getRenameService()->rename(xTable,_rNewName);
333cdf0e10cSrcweir     ::connectivity::OTable_TYPEDEF::rename(_rNewName);
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir // XAlterTable,
337cdf0e10cSrcweir //------------------------------------------------------------------------------
alterColumnByName(const::rtl::OUString & _rName,const Reference<XPropertySet> & _rxDescriptor)338cdf0e10cSrcweir void SAL_CALL ODBTable::alterColumnByName( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
339cdf0e10cSrcweir {
340cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::alterColumnByName" );
341cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
342cdf0e10cSrcweir 	checkDisposed(connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed);
343cdf0e10cSrcweir     if ( !getAlterService().is() )
344cdf0e10cSrcweir 	    throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
345cdf0e10cSrcweir 
346cdf0e10cSrcweir     if ( !m_pColumns->hasByName(_rName) )
347cdf0e10cSrcweir         throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     Reference<XPropertySet> xTable(this);
350cdf0e10cSrcweir     getAlterService()->alterColumnByName(xTable,_rName,_rxDescriptor);
351cdf0e10cSrcweir 	m_pColumns->refresh();
352cdf0e10cSrcweir }
353cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & rId)354cdf0e10cSrcweir sal_Int64 SAL_CALL ODBTable::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getSomething" );
357cdf0e10cSrcweir 	sal_Int64 nRet(0);
358cdf0e10cSrcweir 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
359cdf0e10cSrcweir 		nRet = reinterpret_cast<sal_Int64>(this);
360cdf0e10cSrcweir 	else
361cdf0e10cSrcweir 		nRet = OTable_Base::getSomething(rId);
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	return nRet;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir // -----------------------------------------------------------------------------
getUnoTunnelImplementationId()366cdf0e10cSrcweir Sequence< sal_Int8 > ODBTable::getUnoTunnelImplementationId()
367cdf0e10cSrcweir {
368cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getUnoTunnelImplementationId" );
369cdf0e10cSrcweir 	static ::cppu::OImplementationId * pId = 0;
370cdf0e10cSrcweir 	if (! pId)
371cdf0e10cSrcweir 	{
372cdf0e10cSrcweir 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
373cdf0e10cSrcweir 		if (! pId)
374cdf0e10cSrcweir 		{
375cdf0e10cSrcweir 			static ::cppu::OImplementationId aId;
376cdf0e10cSrcweir 			pId = &aId;
377cdf0e10cSrcweir 		}
378cdf0e10cSrcweir 	}
379cdf0e10cSrcweir 	return pId->getImplementationId();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir // -----------------------------------------------------------------------------
createColumnDescriptor()382cdf0e10cSrcweir Reference< XPropertySet > ODBTable::createColumnDescriptor()
383cdf0e10cSrcweir {
384cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumnDescriptor" );
385cdf0e10cSrcweir 	return new OTableColumnDescriptor( true );
386cdf0e10cSrcweir }
387cdf0e10cSrcweir // -----------------------------------------------------------------------------
createColumns(const TStringVector & _rNames)388cdf0e10cSrcweir sdbcx::OCollection* ODBTable::createColumns(const TStringVector& _rNames)
389cdf0e10cSrcweir {
390cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumns" );
391cdf0e10cSrcweir 	Reference<XDatabaseMetaData> xMeta = getMetaData();
392cdf0e10cSrcweir 	OColumns* pCol = new OColumns(*this, m_aMutex, NULL, isCaseSensitive(), _rNames, this,this,
393cdf0e10cSrcweir 									getAlterService().is() || (xMeta.is() && xMeta->supportsAlterTableWithAddColumn()),
394cdf0e10cSrcweir 									getAlterService().is() || (xMeta.is() && xMeta->supportsAlterTableWithDropColumn()));
395cdf0e10cSrcweir 	static_cast<OColumnsHelper*>(pCol)->setParent(this);
396cdf0e10cSrcweir 	pCol->setParent(*this);
397cdf0e10cSrcweir 	m_pColumnMediator = new OContainerMediator( pCol, m_xColumnDefinitions, getConnection(), OContainerMediator::eColumns );
398cdf0e10cSrcweir 	pCol->setMediator( m_pColumnMediator.get() );
399cdf0e10cSrcweir 	return pCol;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir // -----------------------------------------------------------------------------
createKeys(const TStringVector & _rNames)402cdf0e10cSrcweir sdbcx::OCollection* ODBTable::createKeys(const TStringVector& _rNames)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createKeys" );
405cdf0e10cSrcweir 	return new connectivity::OKeysHelper(this,m_aMutex,_rNames);
406cdf0e10cSrcweir }
407cdf0e10cSrcweir // -----------------------------------------------------------------------------
createIndexes(const TStringVector & _rNames)408cdf0e10cSrcweir sdbcx::OCollection* ODBTable::createIndexes(const TStringVector& _rNames)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createIndexes" );
411cdf0e10cSrcweir 	return new OIndexes(this,m_aMutex,_rNames,NULL);
412cdf0e10cSrcweir }
413cdf0e10cSrcweir // -----------------------------------------------------------------------------
414