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 <comphelper/sequence.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include "TConnection.hxx"
25 #include <com/sun/star/sdbc/ColumnValue.hpp>
27 using namespace connectivity
;
28 using namespace connectivity::sdbcx
;
30 using namespace ::com::sun::star::beans
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::lang
;
33 using namespace ::com::sun::star::sdbc
;
36 OUString SAL_CALL
OColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
39 return OUString("com.sun.star.sdbcx.VColumnDescription");
40 return OUString("com.sun.star.sdbcx.VColumn");
43 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
OColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
45 ::com::sun::star::uno::Sequence
< OUString
> aSupported(1);
47 aSupported
[0] = "com.sun.star.sdbcx.ColumnDescription";
49 aSupported
[0] = "com.sun.star.sdbcx.Column";
54 sal_Bool SAL_CALL
OColumn::supportsService( const OUString
& _rServiceName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
56 return cppu::supportsService(this, _rServiceName
);
59 OColumn::OColumn(bool _bCase
)
60 :OColumnDescriptor_BASE(m_aMutex
)
61 ,ODescriptor(OColumnDescriptor_BASE::rBHelper
,_bCase
,true)
62 ,m_IsNullable(ColumnValue::NULLABLE
)
66 ,m_IsAutoIncrement(false)
67 ,m_IsRowVersion(false)
73 OColumn::OColumn( const OUString
& _Name
,
74 const OUString
& _TypeName
,
75 const OUString
& _DefaultValue
,
76 const OUString
& _Description
,
77 sal_Int32 _IsNullable
,
81 bool _IsAutoIncrement
,
85 const OUString
& _CatalogName
,
86 const OUString
& _SchemaName
,
87 const OUString
& _TableName
)
88 :OColumnDescriptor_BASE(m_aMutex
)
89 ,ODescriptor(OColumnDescriptor_BASE::rBHelper
,_bCase
)
90 ,m_TypeName(_TypeName
)
91 ,m_Description(_Description
)
92 ,m_DefaultValue(_DefaultValue
)
93 ,m_IsNullable(_IsNullable
)
94 ,m_Precision(_Precision
)
97 ,m_IsAutoIncrement(_IsAutoIncrement
)
98 ,m_IsRowVersion(_IsRowVersion
)
99 ,m_IsCurrency(_IsCurrency
)
100 ,m_CatalogName(_CatalogName
)
101 ,m_SchemaName(_SchemaName
)
102 ,m_TableName(_TableName
)
113 ::cppu::IPropertyArrayHelper
* OColumn::createArrayHelper( sal_Int32
/*_nId*/ ) const
115 return doCreateArrayHelper();
118 ::cppu::IPropertyArrayHelper
& SAL_CALL
OColumn::getInfoHelper()
120 return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
123 void SAL_CALL
OColumn::acquire() throw()
125 OColumnDescriptor_BASE::acquire();
128 void SAL_CALL
OColumn::release() throw()
130 OColumnDescriptor_BASE::release();
133 Any SAL_CALL
OColumn::queryInterface( const Type
& rType
) throw(RuntimeException
, std::exception
)
135 Any aRet
= ODescriptor::queryInterface( rType
);
139 aRet
= OColumn_BASE::queryInterface(rType
);
141 aRet
= OColumnDescriptor_BASE::queryInterface( rType
);
146 Sequence
< Type
> SAL_CALL
OColumn::getTypes( ) throw(RuntimeException
, std::exception
)
149 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
151 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
154 void OColumn::construct()
156 ODescriptor::construct();
158 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
160 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME
), PROPERTY_ID_TYPENAME
, nAttrib
, &m_TypeName
, cppu::UnoType
<decltype(m_TypeName
)>::get());
161 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION
), PROPERTY_ID_DESCRIPTION
, nAttrib
, &m_Description
, cppu::UnoType
<decltype(m_Description
)>::get());
162 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE
), PROPERTY_ID_DEFAULTVALUE
, nAttrib
, &m_DefaultValue
, cppu::UnoType
<decltype(m_DefaultValue
)>::get());
163 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION
), PROPERTY_ID_PRECISION
, nAttrib
, &m_Precision
, cppu::UnoType
<decltype(m_Precision
)>::get());
164 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE
), PROPERTY_ID_TYPE
, nAttrib
, &m_Type
, cppu::UnoType
<decltype(m_Type
)>::get());
165 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE
), PROPERTY_ID_SCALE
, nAttrib
, &m_Scale
, cppu::UnoType
<decltype(m_Scale
)>::get());
166 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE
), PROPERTY_ID_ISNULLABLE
, nAttrib
, &m_IsNullable
, cppu::UnoType
<decltype(m_IsNullable
)>::get());
167 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT
), PROPERTY_ID_ISAUTOINCREMENT
, nAttrib
, &m_IsAutoIncrement
, cppu::UnoType
<bool>::get());
168 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION
), PROPERTY_ID_ISROWVERSION
, nAttrib
, &m_IsRowVersion
, cppu::UnoType
<bool>::get());
169 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY
), PROPERTY_ID_ISCURRENCY
, nAttrib
, &m_IsCurrency
, cppu::UnoType
<bool>::get());
170 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME
), PROPERTY_ID_CATALOGNAME
, nAttrib
, &m_CatalogName
, cppu::UnoType
<decltype(m_CatalogName
)>::get());
171 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME
), PROPERTY_ID_SCHEMANAME
, nAttrib
, &m_SchemaName
, cppu::UnoType
<decltype(m_SchemaName
)>::get());
172 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME
), PROPERTY_ID_TABLENAME
, nAttrib
, &m_TableName
, cppu::UnoType
<decltype(m_TableName
)>::get());
175 void OColumn::disposing()
177 OPropertySetHelper::disposing();
179 ::osl::MutexGuard
aGuard(m_aMutex
);
180 checkDisposed(OColumnDescriptor_BASE::rBHelper
.bDisposed
);
184 Reference
< XPropertySet
> SAL_CALL
OColumn::createDataDescriptor( ) throw(RuntimeException
, std::exception
)
186 ::osl::MutexGuard
aGuard(m_aMutex
);
187 checkDisposed(OColumnDescriptor_BASE::rBHelper
.bDisposed
);
190 OColumn
* pNewColumn
= new OColumn( m_Name
,
205 pNewColumn
->setNew(true);
209 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OColumn::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
211 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
215 OUString SAL_CALL
OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
220 void SAL_CALL
OColumn::setName( const OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */