19b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59b5730f6SAndrew Rist  * distributed with this work for additional information
69b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
99b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
109b5730f6SAndrew Rist  *
119b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129b5730f6SAndrew Rist  *
139b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149b5730f6SAndrew Rist  * software distributed under the License is distributed on an
159b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
179b5730f6SAndrew Rist  * specific language governing permissions and limitations
189b5730f6SAndrew Rist  * under the License.
199b5730f6SAndrew Rist  *
209b5730f6SAndrew Rist  *************************************************************/
219b5730f6SAndrew Rist 
229b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "connectivity/sdbcx/VColumn.hxx"
27cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
28cdf0e10cSrcweir #include <comphelper/sequence.hxx>
29cdf0e10cSrcweir #include "TConnection.hxx"
30cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp>
31cdf0e10cSrcweir // -------------------------------------------------------------------------
32cdf0e10cSrcweir using namespace connectivity;
33cdf0e10cSrcweir using namespace connectivity::sdbcx;
34cdf0e10cSrcweir using namespace cppu;
35cdf0e10cSrcweir using namespace connectivity;
36cdf0e10cSrcweir using namespace ::com::sun::star::beans;
37cdf0e10cSrcweir using namespace ::com::sun::star::uno;
38cdf0e10cSrcweir using namespace ::com::sun::star::lang;
39cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // -----------------------------------------------------------------------------
getImplementationName()42cdf0e10cSrcweir ::rtl::OUString SAL_CALL OColumn::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	if(isNew())
45ac472dbcSDamjan Jovanovic 		return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumnDescriptor");
46cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumn");
47cdf0e10cSrcweir }
48cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSupportedServiceNames()49cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OColumn::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
52cdf0e10cSrcweir 	if(isNew())
53ac472dbcSDamjan Jovanovic 		aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ColumnDescriptor");
54cdf0e10cSrcweir 	else
55cdf0e10cSrcweir 		aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	return aSupported;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir // -----------------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)60cdf0e10cSrcweir sal_Bool SAL_CALL OColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
63cdf0e10cSrcweir 	const ::rtl::OUString* pSupported = aSupported.getConstArray();
64cdf0e10cSrcweir 	const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
65cdf0e10cSrcweir 	for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
66cdf0e10cSrcweir 		;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	return pSupported != pEnd;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir // -------------------------------------------------------------------------
OColumn(sal_Bool _bCase)71cdf0e10cSrcweir OColumn::OColumn(sal_Bool _bCase)
72cdf0e10cSrcweir     :OColumnDescriptor_BASE(m_aMutex)
73cdf0e10cSrcweir     ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,sal_True)
74cdf0e10cSrcweir     ,m_IsNullable(ColumnValue::NULLABLE)
75cdf0e10cSrcweir     ,m_Precision(0)
76cdf0e10cSrcweir     ,m_Scale(0)
77cdf0e10cSrcweir     ,m_Type(0)
78cdf0e10cSrcweir     ,m_IsAutoIncrement(sal_False)
79cdf0e10cSrcweir     ,m_IsRowVersion(sal_False)
80cdf0e10cSrcweir     ,m_IsCurrency(sal_False)
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	construct();
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // -------------------------------------------------------------------------
OColumn(const::rtl::OUString & _Name,const::rtl::OUString & _TypeName,const::rtl::OUString & _DefaultValue,const::rtl::OUString & _Description,sal_Int32 _IsNullable,sal_Int32 _Precision,sal_Int32 _Scale,sal_Int32 _Type,sal_Bool _IsAutoIncrement,sal_Bool _IsRowVersion,sal_Bool _IsCurrency,sal_Bool _bCase)85cdf0e10cSrcweir OColumn::OColumn(	const ::rtl::OUString& _Name,
86cdf0e10cSrcweir 					const ::rtl::OUString& _TypeName,
87cdf0e10cSrcweir 					const ::rtl::OUString& _DefaultValue,
88cdf0e10cSrcweir                     const ::rtl::OUString& _Description,
89cdf0e10cSrcweir 					sal_Int32		_IsNullable,
90cdf0e10cSrcweir 					sal_Int32		_Precision,
91cdf0e10cSrcweir 					sal_Int32		_Scale,
92cdf0e10cSrcweir 					sal_Int32		_Type,
93cdf0e10cSrcweir 					sal_Bool		_IsAutoIncrement,
94cdf0e10cSrcweir 					sal_Bool		_IsRowVersion,
95cdf0e10cSrcweir 					sal_Bool		_IsCurrency,
96cdf0e10cSrcweir 					sal_Bool		_bCase)
97cdf0e10cSrcweir     :OColumnDescriptor_BASE(m_aMutex)
98cdf0e10cSrcweir     ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
99cdf0e10cSrcweir     ,m_TypeName(_TypeName)
100cdf0e10cSrcweir     ,m_Description(_Description)
101cdf0e10cSrcweir     ,m_DefaultValue(_DefaultValue)
102cdf0e10cSrcweir     ,m_IsNullable(_IsNullable)
103cdf0e10cSrcweir     ,m_Precision(_Precision)
104cdf0e10cSrcweir     ,m_Scale(_Scale)
105cdf0e10cSrcweir     ,m_Type(_Type)
106cdf0e10cSrcweir     ,m_IsAutoIncrement(_IsAutoIncrement)
107cdf0e10cSrcweir     ,m_IsRowVersion(_IsRowVersion)
108cdf0e10cSrcweir     ,m_IsCurrency(_IsCurrency)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	m_Name = _Name;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	construct();
113cdf0e10cSrcweir }
114cdf0e10cSrcweir // -------------------------------------------------------------------------
~OColumn()115cdf0e10cSrcweir OColumn::~OColumn()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir }
118cdf0e10cSrcweir // -----------------------------------------------------------------------------
createArrayHelper(sal_Int32) const119cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     return doCreateArrayHelper();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir // -----------------------------------------------------------------------------
getInfoHelper()124cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
127cdf0e10cSrcweir }
128cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()129cdf0e10cSrcweir void SAL_CALL OColumn::acquire() throw()
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	OColumnDescriptor_BASE::acquire();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()134cdf0e10cSrcweir void SAL_CALL OColumn::release() throw()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	OColumnDescriptor_BASE::release();
137cdf0e10cSrcweir }
138cdf0e10cSrcweir // -----------------------------------------------------------------------------
queryInterface(const Type & rType)139cdf0e10cSrcweir Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	Any aRet = ODescriptor::queryInterface( rType);
142cdf0e10cSrcweir 	if(!aRet.hasValue())
143cdf0e10cSrcweir 	{
144cdf0e10cSrcweir 		if(!isNew())
145cdf0e10cSrcweir 			aRet = OColumn_BASE::queryInterface(rType);
146cdf0e10cSrcweir 		if(!aRet.hasValue())
147cdf0e10cSrcweir 			aRet = OColumnDescriptor_BASE::queryInterface( rType);
148cdf0e10cSrcweir 	}
149cdf0e10cSrcweir 	return aRet;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()152cdf0e10cSrcweir Sequence< Type > SAL_CALL OColumn::getTypes(  ) throw(RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	if(isNew())
155cdf0e10cSrcweir 		return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
158cdf0e10cSrcweir }
159cdf0e10cSrcweir // -------------------------------------------------------------------------
construct()160cdf0e10cSrcweir void OColumn::construct()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	ODescriptor::construct();
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
165cdf0e10cSrcweir 
166*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),			PROPERTY_ID_TYPENAME,			nAttrib,&m_TypeName,		::getCppuType(static_cast< ::rtl::OUString*>(NULL)));
167*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION),		PROPERTY_ID_DESCRIPTION,		nAttrib,&m_Description,		::getCppuType(static_cast< ::rtl::OUString*>(NULL)));
168*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),		PROPERTY_ID_DEFAULTVALUE,		nAttrib,&m_DefaultValue,	::getCppuType(static_cast< ::rtl::OUString*>(NULL)));
169*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),		PROPERTY_ID_PRECISION,			nAttrib,&m_Precision,		::getCppuType(static_cast<sal_Int32*>(NULL)));
170*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),				PROPERTY_ID_TYPE,				nAttrib,&m_Type,			::getCppuType(static_cast<sal_Int32*>(NULL)));
171*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),			PROPERTY_ID_SCALE,				nAttrib,&m_Scale,			::getCppuType(static_cast<sal_Int32*>(NULL)));
172*bccc1572SDon Lewis 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),		PROPERTY_ID_ISNULLABLE,			nAttrib,&m_IsNullable,		::getCppuType(static_cast<sal_Int32*>(NULL)));
173cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT),	PROPERTY_ID_ISAUTOINCREMENT,	nAttrib,&m_IsAutoIncrement,	::getBooleanCppuType());
174cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION),		PROPERTY_ID_ISROWVERSION,		nAttrib,&m_IsRowVersion,	::getBooleanCppuType());
175cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY),		PROPERTY_ID_ISCURRENCY,			nAttrib,&m_IsCurrency,		::getBooleanCppuType());
176cdf0e10cSrcweir }
177cdf0e10cSrcweir // -------------------------------------------------------------------------
disposing(void)178cdf0e10cSrcweir void OColumn::disposing(void)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir 	OPropertySetHelper::disposing();
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
183cdf0e10cSrcweir 	checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir }
186cdf0e10cSrcweir // -------------------------------------------------------------------------
createDataDescriptor()187cdf0e10cSrcweir Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor(  ) throw(RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
190cdf0e10cSrcweir 	checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	OColumn* pNewColumn = new OColumn(	m_Name,
194cdf0e10cSrcweir 										m_TypeName,
195cdf0e10cSrcweir 										m_DefaultValue,
196cdf0e10cSrcweir                                         m_Description,
197cdf0e10cSrcweir 										m_IsNullable,
198cdf0e10cSrcweir 										m_Precision,
199cdf0e10cSrcweir 										m_Scale,
200cdf0e10cSrcweir 										m_Type,
201cdf0e10cSrcweir 										m_IsAutoIncrement,
202cdf0e10cSrcweir 										m_IsRowVersion,
203cdf0e10cSrcweir 										m_IsCurrency,
204cdf0e10cSrcweir 										isCaseSensitive());
205cdf0e10cSrcweir 	pNewColumn->setNew(sal_True);
206cdf0e10cSrcweir 	return pNewColumn;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()209cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
212cdf0e10cSrcweir }
213cdf0e10cSrcweir // -----------------------------------------------------------------------------
214cdf0e10cSrcweir // XNamed
getName()215cdf0e10cSrcweir ::rtl::OUString SAL_CALL OColumn::getName(  ) throw(::com::sun::star::uno::RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	return m_Name;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir // -----------------------------------------------------------------------------
setName(const::rtl::OUString & aName)220cdf0e10cSrcweir void SAL_CALL OColumn::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	m_Name = aName;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir // -----------------------------------------------------------------------------
225cdf0e10cSrcweir 
226