1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <connectivity/sdbcx/VColumn.hxx>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <comphelper/sequence.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <TConnection.hxx>
26 #include <com/sun/star/sdbc/ColumnValue.hpp>
28 using namespace connectivity
;
29 using namespace connectivity::sdbcx
;
31 using namespace ::com::sun::star::beans
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::lang
;
34 using namespace ::com::sun::star::sdbc
;
37 OUString SAL_CALL
OColumn::getImplementationName( )
40 return OUString("com.sun.star.sdbcx.VColumnDescriptor");
41 return OUString("com.sun.star.sdbcx.VColumn");
44 css::uno::Sequence
< OUString
> SAL_CALL
OColumn::getSupportedServiceNames( )
46 css::uno::Sequence
< OUString
> aSupported(1);
48 aSupported
[0] = "com.sun.star.sdbcx.ColumnDescriptor";
50 aSupported
[0] = "com.sun.star.sdbcx.Column";
55 sal_Bool SAL_CALL
OColumn::supportsService( const OUString
& _rServiceName
)
57 return cppu::supportsService(this, _rServiceName
);
60 OColumn::OColumn(bool _bCase
)
61 :OColumnDescriptor_BASE(m_aMutex
)
62 ,ODescriptor(OColumnDescriptor_BASE::rBHelper
,_bCase
,true)
63 ,m_IsNullable(ColumnValue::NULLABLE
)
67 ,m_IsAutoIncrement(false)
68 ,m_IsRowVersion(false)
74 OColumn::OColumn( const OUString
& Name
,
75 const OUString
& TypeName
,
76 const OUString
& DefaultValue
,
77 const OUString
& Description
,
86 const OUString
& CatalogName
,
87 const OUString
& SchemaName
,
88 const OUString
& TableName
)
89 :OColumnDescriptor_BASE(m_aMutex
)
90 ,ODescriptor(OColumnDescriptor_BASE::rBHelper
,_bCase
)
92 ,m_Description(Description
)
93 ,m_DefaultValue(DefaultValue
)
94 ,m_IsNullable(IsNullable
)
95 ,m_Precision(Precision
)
98 ,m_IsAutoIncrement(IsAutoIncrement
)
99 ,m_IsRowVersion(IsRowVersion
)
100 ,m_IsCurrency(IsCurrency
)
101 ,m_CatalogName(CatalogName
)
102 ,m_SchemaName(SchemaName
)
103 ,m_TableName(TableName
)
114 ::cppu::IPropertyArrayHelper
* OColumn::createArrayHelper( sal_Int32
/*_nId*/ ) const
116 return doCreateArrayHelper();
119 ::cppu::IPropertyArrayHelper
& SAL_CALL
OColumn::getInfoHelper()
121 return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
124 void SAL_CALL
OColumn::acquire() throw()
126 OColumnDescriptor_BASE::acquire();
129 void SAL_CALL
OColumn::release() throw()
131 OColumnDescriptor_BASE::release();
134 Any SAL_CALL
OColumn::queryInterface( const Type
& rType
)
136 Any aRet
= ODescriptor::queryInterface( rType
);
140 aRet
= OColumn_BASE::queryInterface(rType
);
142 aRet
= OColumnDescriptor_BASE::queryInterface( rType
);
147 Sequence
< Type
> SAL_CALL
OColumn::getTypes( )
150 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
152 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
155 void OColumn::construct()
157 ODescriptor::construct();
159 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
161 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME
), PROPERTY_ID_TYPENAME
, nAttrib
, &m_TypeName
, cppu::UnoType
<decltype(m_TypeName
)>::get());
162 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION
), PROPERTY_ID_DESCRIPTION
, nAttrib
, &m_Description
, cppu::UnoType
<decltype(m_Description
)>::get());
163 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE
), PROPERTY_ID_DEFAULTVALUE
, nAttrib
, &m_DefaultValue
, cppu::UnoType
<decltype(m_DefaultValue
)>::get());
164 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION
), PROPERTY_ID_PRECISION
, nAttrib
, &m_Precision
, cppu::UnoType
<decltype(m_Precision
)>::get());
165 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE
), PROPERTY_ID_TYPE
, nAttrib
, &m_Type
, cppu::UnoType
<decltype(m_Type
)>::get());
166 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE
), PROPERTY_ID_SCALE
, nAttrib
, &m_Scale
, cppu::UnoType
<decltype(m_Scale
)>::get());
167 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE
), PROPERTY_ID_ISNULLABLE
, nAttrib
, &m_IsNullable
, cppu::UnoType
<decltype(m_IsNullable
)>::get());
168 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT
), PROPERTY_ID_ISAUTOINCREMENT
, nAttrib
, &m_IsAutoIncrement
, cppu::UnoType
<bool>::get());
169 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION
), PROPERTY_ID_ISROWVERSION
, nAttrib
, &m_IsRowVersion
, cppu::UnoType
<bool>::get());
170 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY
), PROPERTY_ID_ISCURRENCY
, nAttrib
, &m_IsCurrency
, cppu::UnoType
<bool>::get());
171 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME
), PROPERTY_ID_CATALOGNAME
, nAttrib
, &m_CatalogName
, cppu::UnoType
<decltype(m_CatalogName
)>::get());
172 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME
), PROPERTY_ID_SCHEMANAME
, nAttrib
, &m_SchemaName
, cppu::UnoType
<decltype(m_SchemaName
)>::get());
173 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME
), PROPERTY_ID_TABLENAME
, nAttrib
, &m_TableName
, cppu::UnoType
<decltype(m_TableName
)>::get());
176 void OColumn::disposing()
178 OPropertySetHelper::disposing();
180 ::osl::MutexGuard
aGuard(m_aMutex
);
181 checkDisposed(OColumnDescriptor_BASE::rBHelper
.bDisposed
);
185 Reference
< XPropertySet
> SAL_CALL
OColumn::createDataDescriptor( )
187 ::osl::MutexGuard
aGuard(m_aMutex
);
188 checkDisposed(OColumnDescriptor_BASE::rBHelper
.bDisposed
);
191 OColumn
* pNewColumn
= new OColumn( m_Name
,
206 pNewColumn
->setNew(true);
210 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
OColumn::getPropertySetInfo( )
212 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
216 OUString SAL_CALL
OColumn::getName( )
221 void SAL_CALL
OColumn::setName( const OUString
& aName
)
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */