1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VColumn.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "connectivity/sdbcx/VColumn.hxx"
34 #include <com/sun/star/lang/DisposedException.hpp>
35 #include <comphelper/sequence.hxx>
36 #include "TConnection.hxx"
37 #include <com/sun/star/sdbc/ColumnValue.hpp>
38 // -------------------------------------------------------------------------
39 using namespace connectivity
;
40 using namespace connectivity::sdbcx
;
42 using namespace connectivity
;
43 using namespace ::com::sun::star::beans
;
44 using namespace ::com::sun::star::uno
;
45 using namespace ::com::sun::star::lang
;
46 using namespace ::com::sun::star::sdbc
;
48 // -----------------------------------------------------------------------------
49 ::rtl::OUString SAL_CALL
OColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
)
52 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumnDescription");
53 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumn");
55 // -----------------------------------------------------------------------------
56 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
OColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
)
58 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> aSupported(1);
60 aSupported
[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ColumnDescription");
62 aSupported
[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");
66 // -----------------------------------------------------------------------------
67 sal_Bool SAL_CALL
OColumn::supportsService( const ::rtl::OUString
& _rServiceName
) throw(::com::sun::star::uno::RuntimeException
)
69 Sequence
< ::rtl::OUString
> aSupported(getSupportedServiceNames());
70 const ::rtl::OUString
* pSupported
= aSupported
.getConstArray();
71 const ::rtl::OUString
* pEnd
= pSupported
+ aSupported
.getLength();
72 for (;pSupported
!= pEnd
&& !pSupported
->equals(_rServiceName
); ++pSupported
)
75 return pSupported
!= pEnd
;
77 // -------------------------------------------------------------------------
78 OColumn::OColumn(sal_Bool _bCase
)
79 :OColumnDescriptor_BASE(m_aMutex
)
80 ,ODescriptor(OColumnDescriptor_BASE::rBHelper
,_bCase
,sal_True
)
81 ,m_IsNullable(ColumnValue::NULLABLE
)
85 ,m_IsAutoIncrement(sal_False
)
86 ,m_IsRowVersion(sal_False
)
87 ,m_IsCurrency(sal_False
)
91 // -------------------------------------------------------------------------
92 OColumn::OColumn( const ::rtl::OUString
& _Name
,
93 const ::rtl::OUString
& _TypeName
,
94 const ::rtl::OUString
& _DefaultValue
,
95 sal_Int32 _IsNullable
,
99 sal_Bool _IsAutoIncrement
,
100 sal_Bool _IsRowVersion
,
101 sal_Bool _IsCurrency
,
103 :OColumnDescriptor_BASE(m_aMutex
)
104 ,ODescriptor(OColumnDescriptor_BASE::rBHelper
,_bCase
)
105 ,m_TypeName(_TypeName
)
106 ,m_DefaultValue(_DefaultValue
)
107 ,m_IsNullable(_IsNullable
)
108 ,m_Precision(_Precision
)
111 ,m_IsAutoIncrement(_IsAutoIncrement
)
112 ,m_IsRowVersion(_IsRowVersion
)
113 ,m_IsCurrency(_IsCurrency
)
119 // -------------------------------------------------------------------------
123 // -----------------------------------------------------------------------------
124 ::cppu::IPropertyArrayHelper
* OColumn::createArrayHelper( sal_Int32
/*_nId*/ ) const
126 return doCreateArrayHelper();
128 // -----------------------------------------------------------------------------
129 ::cppu::IPropertyArrayHelper
& SAL_CALL
OColumn::getInfoHelper()
131 return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
133 // -----------------------------------------------------------------------------
134 void SAL_CALL
OColumn::acquire() throw()
136 OColumnDescriptor_BASE::acquire();
138 // -----------------------------------------------------------------------------
139 void SAL_CALL
OColumn::release() throw()
141 OColumnDescriptor_BASE::release();
143 // -----------------------------------------------------------------------------
144 Any SAL_CALL
OColumn::queryInterface( const Type
& rType
) throw(RuntimeException
)
146 Any aRet
= ODescriptor::queryInterface( rType
);
150 aRet
= OColumn_BASE::queryInterface(rType
);
152 aRet
= OColumnDescriptor_BASE::queryInterface( rType
);
156 // -------------------------------------------------------------------------
157 Sequence
< Type
> SAL_CALL
OColumn::getTypes( ) throw(RuntimeException
)
160 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
162 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
164 // -------------------------------------------------------------------------
165 void OColumn::construct()
167 ODescriptor::construct();
169 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
171 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME
), PROPERTY_ID_TYPENAME
, nAttrib
,&m_TypeName
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
172 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION
), PROPERTY_ID_DESCRIPTION
, nAttrib
,&m_Description
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
173 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE
), PROPERTY_ID_DEFAULTVALUE
, nAttrib
,&m_DefaultValue
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
174 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION
), PROPERTY_ID_PRECISION
, nAttrib
,&m_Precision
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
175 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE
), PROPERTY_ID_TYPE
, nAttrib
,&m_Type
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
176 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE
), PROPERTY_ID_SCALE
, nAttrib
,&m_Scale
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
177 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE
), PROPERTY_ID_ISNULLABLE
, nAttrib
,&m_IsNullable
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
178 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT
), PROPERTY_ID_ISAUTOINCREMENT
, nAttrib
,&m_IsAutoIncrement
, ::getBooleanCppuType());
179 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION
), PROPERTY_ID_ISROWVERSION
, nAttrib
,&m_IsRowVersion
, ::getBooleanCppuType());
180 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY
), PROPERTY_ID_ISCURRENCY
, nAttrib
,&m_IsCurrency
, ::getBooleanCppuType());
182 // -------------------------------------------------------------------------
183 void OColumn::disposing(void)
185 OPropertySetHelper::disposing();
187 ::osl::MutexGuard
aGuard(m_aMutex
);
188 checkDisposed(OColumnDescriptor_BASE::rBHelper
.bDisposed
);
191 // -------------------------------------------------------------------------
192 Reference
< XPropertySet
> SAL_CALL
OColumn::createDataDescriptor( ) throw(RuntimeException
)
194 ::osl::MutexGuard
aGuard(m_aMutex
);
195 checkDisposed(OColumnDescriptor_BASE::rBHelper
.bDisposed
);
198 OColumn
* pNewColumn
= new OColumn( m_Name
,
209 pNewColumn
->m_Description
= m_Description
;
210 pNewColumn
->setNew(sal_True
);
213 // -----------------------------------------------------------------------------
214 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OColumn::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
)
216 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
218 // -----------------------------------------------------------------------------
220 ::rtl::OUString SAL_CALL
OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException
)
224 // -----------------------------------------------------------------------------
225 void SAL_CALL
OColumn::setName( const ::rtl::OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
)
229 // -----------------------------------------------------------------------------