LibreOffice Module connectivity (master) 1
VColumn.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <com/sun/star/beans/PropertyAttribute.hpp>
24#include <TConnection.hxx>
25#include <com/sun/star/sdbc/ColumnValue.hpp>
26#include <utility>
27
28using namespace connectivity;
29using namespace connectivity::sdbcx;
30using namespace cppu;
31using namespace ::com::sun::star::beans;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::lang;
34using namespace ::com::sun::star::sdbc;
35
36
37OUString SAL_CALL OColumn::getImplementationName( )
38{
39 if(isNew())
40 return "com.sun.star.sdbcx.VColumnDescriptor";
41 return "com.sun.star.sdbcx.VColumn";
42}
43
44css::uno::Sequence< OUString > SAL_CALL OColumn::getSupportedServiceNames( )
45{
46 return { isNew()?OUString("com.sun.star.sdbcx.ColumnDescriptor"):OUString("com.sun.star.sdbcx.Column") };
47}
48
49sal_Bool SAL_CALL OColumn::supportsService( const OUString& _rServiceName )
50{
51 return cppu::supportsService(this, _rServiceName);
52}
53
54OColumn::OColumn(bool _bCase)
56 ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,true)
57 ,m_IsNullable(ColumnValue::NULLABLE)
58 ,m_Precision(0)
59 ,m_Scale(0)
60 ,m_Type(0)
61 ,m_IsAutoIncrement(false)
62 ,m_IsRowVersion(false)
63 ,m_IsCurrency(false)
64{
65 construct();
66}
67
68OColumn::OColumn( const OUString& Name,
69 OUString TypeName,
70 OUString DefaultValue,
71 OUString Description,
72 sal_Int32 IsNullable,
73 sal_Int32 Precision,
74 sal_Int32 Scale,
75 sal_Int32 Type,
76 bool IsAutoIncrement,
77 bool IsRowVersion,
78 bool IsCurrency,
79 bool _bCase,
80 OUString CatalogName,
81 OUString SchemaName,
82 OUString TableName)
84 ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
85 ,m_TypeName(std::move(TypeName))
86 ,m_Description(std::move(Description))
87 ,m_DefaultValue(std::move(DefaultValue))
88 ,m_IsNullable(IsNullable)
89 ,m_Precision(Precision)
90 ,m_Scale(Scale)
91 ,m_Type(Type)
92 ,m_IsAutoIncrement(IsAutoIncrement)
93 ,m_IsRowVersion(IsRowVersion)
94 ,m_IsCurrency(IsCurrency)
95 ,m_CatalogName(std::move(CatalogName))
96 ,m_SchemaName(std::move(SchemaName))
97 ,m_TableName(std::move(TableName))
98{
99 m_Name = Name;
100
101 construct();
102}
103
104OColumn::~OColumn()
105{
106}
107
108::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
109{
110 return doCreateArrayHelper();
111}
112
113::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
114{
115 return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
116}
117
118void SAL_CALL OColumn::acquire() noexcept
119{
120 OColumnDescriptor_BASE::acquire();
121}
122
123void SAL_CALL OColumn::release() noexcept
124{
125 OColumnDescriptor_BASE::release();
126}
127
128Any SAL_CALL OColumn::queryInterface( const Type & rType )
129{
130 Any aRet = ODescriptor::queryInterface( rType);
131 if(!aRet.hasValue())
132 {
133 if(!isNew())
134 aRet = OColumn_BASE::queryInterface(rType);
135 if(!aRet.hasValue())
136 aRet = OColumnDescriptor_BASE::queryInterface( rType);
137 }
138 return aRet;
139}
140
141Sequence< Type > SAL_CALL OColumn::getTypes( )
142{
143 if(isNew())
144 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
145
146 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
147}
148
149void OColumn::construct()
150{
152
153 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
154
155 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME), PROPERTY_ID_TYPENAME, nAttrib, &m_TypeName, cppu::UnoType<decltype(m_TypeName)>::get());
156 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION, nAttrib, &m_Description, cppu::UnoType<decltype(m_Description)>::get());
157 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), PROPERTY_ID_DEFAULTVALUE, nAttrib, &m_DefaultValue, cppu::UnoType<decltype(m_DefaultValue)>::get());
158 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION), PROPERTY_ID_PRECISION, nAttrib, &m_Precision, cppu::UnoType<decltype(m_Precision)>::get());
159 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib, &m_Type, cppu::UnoType<decltype(m_Type)>::get());
160 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), PROPERTY_ID_SCALE, nAttrib, &m_Scale, cppu::UnoType<decltype(m_Scale)>::get());
161 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE), PROPERTY_ID_ISNULLABLE, nAttrib, &m_IsNullable, cppu::UnoType<decltype(m_IsNullable)>::get());
162 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT, nAttrib, &m_IsAutoIncrement, cppu::UnoType<bool>::get());
163 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION), PROPERTY_ID_ISROWVERSION, nAttrib, &m_IsRowVersion, cppu::UnoType<bool>::get());
164 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY), PROPERTY_ID_ISCURRENCY, nAttrib, &m_IsCurrency, cppu::UnoType<bool>::get());
165 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME, nAttrib, &m_CatalogName, cppu::UnoType<decltype(m_CatalogName)>::get());
166 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib, &m_SchemaName, cppu::UnoType<decltype(m_SchemaName)>::get());
167 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, nAttrib, &m_TableName, cppu::UnoType<decltype(m_TableName)>::get());
168}
169
170void OColumn::disposing()
171{
173}
174
175Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( )
176{
177 ::osl::MutexGuard aGuard(m_aMutex);
178 checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
179
180 rtl::Reference<OColumn> pNewColumn = new OColumn( m_Name,
181 m_TypeName,
182 m_DefaultValue,
183 m_Description,
184 m_IsNullable,
185 m_Precision,
186 m_Scale,
187 m_Type,
188 m_IsAutoIncrement,
189 m_IsRowVersion,
190 m_IsCurrency,
191 isCaseSensitive(),
192 m_CatalogName,
193 m_SchemaName,
194 m_TableName);
195 pNewColumn->setNew(true);
196 return pNewColumn;
197}
198
199css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo( )
200{
201 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
202}
203
204// XNamed
205OUString SAL_CALL OColumn::getName( )
206{
207 return m_Name;
208}
209
210void SAL_CALL OColumn::setName( const OUString& aName )
211{
212 m_Name = aName;
213}
214
215
216/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString m_Name
::cppu::IPropertyArrayHelper * getArrayHelper(sal_Int32 nId)
void disposing(std::unique_lock< std::mutex > &rGuard)
sal_Int32 m_Precision
Definition: OColumn.hxx:37
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
virtual void construct() override
Definition: PColumn.cxx:172
virtual void construct() override
Definition: VColumn.cxx:149
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
Definition: VDescriptor.cxx:94
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
std::mutex m_aMutex
OUString aName
Type
::cppu::WeakComponentImplHelper< css::container::XNamed, css::lang::XServiceInfo > OColumnDescriptor_BASE
Definition: VColumn.hxx:39
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
#define PROPERTY_ID_TYPE
Definition: propertyids.hxx:51
#define PROPERTY_ID_TABLENAME
Definition: propertyids.hxx:78
#define PROPERTY_ID_DESCRIPTION
Definition: propertyids.hxx:58
#define PROPERTY_ID_CATALOGNAME
Definition: propertyids.hxx:70
#define PROPERTY_ID_ISROWVERSION
Definition: propertyids.hxx:57
#define PROPERTY_ID_ISNULLABLE
Definition: propertyids.hxx:55
#define PROPERTY_ID_PRECISION
Definition: propertyids.hxx:53
#define PROPERTY_ID_SCHEMANAME
Definition: propertyids.hxx:69
#define PROPERTY_ID_ISAUTOINCREMENT
Definition: propertyids.hxx:56
#define PROPERTY_ID_ISCURRENCY
Definition: propertyids.hxx:81
#define PROPERTY_ID_TYPENAME
Definition: propertyids.hxx:52
#define PROPERTY_ID_DEFAULTVALUE
Definition: propertyids.hxx:59
#define PROPERTY_ID_SCALE
Definition: propertyids.hxx:54
OUString Name
unsigned char sal_Bool