tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / sdbcx / VColumn.cxx
blobbae1f7140c8a4ddffa5de791ea37afc329593417
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/beans/PropertyAttribute.hpp>
22 #include <comphelper/sequence.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <TConnection.hxx>
25 #include <com/sun/star/sdbc/ColumnValue.hpp>
26 #include <utility>
28 using namespace connectivity;
29 using namespace connectivity::sdbcx;
30 using namespace cppu;
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( )
39 if(isNew())
40 return u"com.sun.star.sdbcx.VColumnDescriptor"_ustr;
41 return u"com.sun.star.sdbcx.VColumn"_ustr;
44 css::uno::Sequence< OUString > SAL_CALL OColumn::getSupportedServiceNames( )
46 return { isNew()?u"com.sun.star.sdbcx.ColumnDescriptor"_ustr:u"com.sun.star.sdbcx.Column"_ustr };
49 sal_Bool SAL_CALL OColumn::supportsService( const OUString& _rServiceName )
51 return cppu::supportsService(this, _rServiceName);
54 OColumn::OColumn(bool _bCase)
55 :OColumnDescriptor_BASE(m_aMutex)
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)
65 construct();
68 OColumn::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)
83 :OColumnDescriptor_BASE(m_aMutex)
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))
99 m_Name = Name;
101 construct();
104 OColumn::~OColumn()
108 ::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
110 return doCreateArrayHelper();
113 ::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
115 return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
118 void SAL_CALL OColumn::acquire() noexcept
120 OColumnDescriptor_BASE::acquire();
123 void SAL_CALL OColumn::release() noexcept
125 OColumnDescriptor_BASE::release();
128 Any SAL_CALL OColumn::queryInterface( const Type & rType )
130 Any aRet = ODescriptor::queryInterface( rType);
131 if(!aRet.hasValue())
133 if(!isNew())
134 aRet = OColumn_BASE::queryInterface(rType);
135 if(!aRet.hasValue())
136 aRet = OColumnDescriptor_BASE::queryInterface( rType);
138 return aRet;
141 Sequence< Type > SAL_CALL OColumn::getTypes( )
143 if(isNew())
144 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
146 return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
149 void OColumn::construct()
151 ODescriptor::construct();
153 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
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());
170 void OColumn::disposing()
172 OPropertySetHelper::disposing();
175 Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( )
177 ::osl::MutexGuard aGuard(m_aMutex);
178 checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
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;
199 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo( )
201 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
204 // XNamed
205 OUString SAL_CALL OColumn::getName( )
207 return m_Name;
210 void SAL_CALL OColumn::setName( const OUString& aName )
212 m_Name = aName;
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */