Line data Source code
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 :
20 : #include "connectivity/sdbcx/VColumn.hxx"
21 : #include <com/sun/star/lang/DisposedException.hpp>
22 : #include <comphelper/sequence.hxx>
23 : #include "TConnection.hxx"
24 : #include <com/sun/star/sdbc/ColumnValue.hpp>
25 : // -------------------------------------------------------------------------
26 : using namespace connectivity;
27 : using namespace connectivity::sdbcx;
28 : using namespace cppu;
29 : using namespace connectivity;
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;
34 :
35 : // -----------------------------------------------------------------------------
36 0 : ::rtl::OUString SAL_CALL OColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
37 : {
38 0 : if(isNew())
39 0 : return ::rtl::OUString("com.sun.star.sdbcx.VColumnDescription");
40 0 : return ::rtl::OUString("com.sun.star.sdbcx.VColumn");
41 : }
42 : // -----------------------------------------------------------------------------
43 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
44 : {
45 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
46 0 : if(isNew())
47 0 : aSupported[0] = ::rtl::OUString("com.sun.star.sdbcx.ColumnDescription");
48 : else
49 0 : aSupported[0] = ::rtl::OUString("com.sun.star.sdbcx.Column");
50 :
51 0 : return aSupported;
52 : }
53 : // -----------------------------------------------------------------------------
54 0 : sal_Bool SAL_CALL OColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
55 : {
56 0 : Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
57 0 : const ::rtl::OUString* pSupported = aSupported.getConstArray();
58 0 : const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
59 0 : for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
60 : ;
61 :
62 0 : return pSupported != pEnd;
63 : }
64 : // -------------------------------------------------------------------------
65 0 : OColumn::OColumn(sal_Bool _bCase)
66 : :OColumnDescriptor_BASE(m_aMutex)
67 : ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,sal_True)
68 : ,m_IsNullable(ColumnValue::NULLABLE)
69 : ,m_Precision(0)
70 : ,m_Scale(0)
71 : ,m_Type(0)
72 : ,m_IsAutoIncrement(sal_False)
73 : ,m_IsRowVersion(sal_False)
74 0 : ,m_IsCurrency(sal_False)
75 : {
76 0 : construct();
77 0 : }
78 : // -------------------------------------------------------------------------
79 77 : OColumn::OColumn( const ::rtl::OUString& _Name,
80 : const ::rtl::OUString& _TypeName,
81 : const ::rtl::OUString& _DefaultValue,
82 : const ::rtl::OUString& _Description,
83 : sal_Int32 _IsNullable,
84 : sal_Int32 _Precision,
85 : sal_Int32 _Scale,
86 : sal_Int32 _Type,
87 : sal_Bool _IsAutoIncrement,
88 : sal_Bool _IsRowVersion,
89 : sal_Bool _IsCurrency,
90 : sal_Bool _bCase,
91 : const ::rtl::OUString& _CatalogName,
92 : const ::rtl::OUString& _SchemaName,
93 : const ::rtl::OUString& _TableName)
94 : :OColumnDescriptor_BASE(m_aMutex)
95 : ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
96 : ,m_TypeName(_TypeName)
97 : ,m_Description(_Description)
98 : ,m_DefaultValue(_DefaultValue)
99 : ,m_IsNullable(_IsNullable)
100 : ,m_Precision(_Precision)
101 : ,m_Scale(_Scale)
102 : ,m_Type(_Type)
103 : ,m_IsAutoIncrement(_IsAutoIncrement)
104 : ,m_IsRowVersion(_IsRowVersion)
105 : ,m_IsCurrency(_IsCurrency)
106 : ,m_CatalogName(_CatalogName)
107 : ,m_SchemaName(_SchemaName)
108 77 : ,m_TableName(_TableName)
109 : {
110 77 : m_Name = _Name;
111 :
112 77 : construct();
113 77 : }
114 : // -------------------------------------------------------------------------
115 0 : OColumn::~OColumn()
116 : {
117 0 : }
118 : // -----------------------------------------------------------------------------
119 1 : ::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
120 : {
121 1 : return doCreateArrayHelper();
122 : }
123 : // -----------------------------------------------------------------------------
124 374 : ::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
125 : {
126 374 : return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
127 : }
128 : // -----------------------------------------------------------------------------
129 607 : void SAL_CALL OColumn::acquire() throw()
130 : {
131 607 : OColumnDescriptor_BASE::acquire();
132 607 : }
133 : // -----------------------------------------------------------------------------
134 530 : void SAL_CALL OColumn::release() throw()
135 : {
136 530 : OColumnDescriptor_BASE::release();
137 530 : }
138 : // -----------------------------------------------------------------------------
139 0 : Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException)
140 : {
141 0 : Any aRet = ODescriptor::queryInterface( rType);
142 0 : if(!aRet.hasValue())
143 : {
144 0 : if(!isNew())
145 0 : aRet = OColumn_BASE::queryInterface(rType);
146 0 : if(!aRet.hasValue())
147 0 : aRet = OColumnDescriptor_BASE::queryInterface( rType);
148 : }
149 0 : return aRet;
150 : }
151 : // -------------------------------------------------------------------------
152 0 : Sequence< Type > SAL_CALL OColumn::getTypes( ) throw(RuntimeException)
153 : {
154 0 : if(isNew())
155 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
156 :
157 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
158 : }
159 : // -------------------------------------------------------------------------
160 77 : void OColumn::construct()
161 : {
162 77 : ODescriptor::construct();
163 :
164 77 : sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
165 :
166 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME), PROPERTY_ID_TYPENAME, nAttrib, &m_TypeName, ::getCppuType(&m_TypeName));
167 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION, nAttrib, &m_Description, ::getCppuType(&m_Description));
168 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), PROPERTY_ID_DEFAULTVALUE, nAttrib, &m_DefaultValue, ::getCppuType(&m_DefaultValue));
169 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION), PROPERTY_ID_PRECISION, nAttrib, &m_Precision, ::getCppuType(&m_Precision));
170 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib, &m_Type, ::getCppuType(&m_Type));
171 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), PROPERTY_ID_SCALE, nAttrib, &m_Scale, ::getCppuType(&m_Scale));
172 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE), PROPERTY_ID_ISNULLABLE, nAttrib, &m_IsNullable, ::getCppuType(&m_IsNullable));
173 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT, nAttrib, &m_IsAutoIncrement, ::getBooleanCppuType());
174 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION), PROPERTY_ID_ISROWVERSION, nAttrib, &m_IsRowVersion, ::getBooleanCppuType());
175 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY), PROPERTY_ID_ISCURRENCY, nAttrib, &m_IsCurrency, ::getBooleanCppuType());
176 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME, nAttrib, &m_CatalogName, ::getCppuType(&m_CatalogName));
177 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib, &m_SchemaName, ::getCppuType(&m_SchemaName));
178 77 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, nAttrib, &m_TableName, ::getCppuType(&m_TableName));
179 77 : }
180 : // -------------------------------------------------------------------------
181 0 : void OColumn::disposing(void)
182 : {
183 0 : OPropertySetHelper::disposing();
184 :
185 0 : ::osl::MutexGuard aGuard(m_aMutex);
186 0 : checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
187 :
188 0 : }
189 : // -------------------------------------------------------------------------
190 0 : Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( ) throw(RuntimeException)
191 : {
192 0 : ::osl::MutexGuard aGuard(m_aMutex);
193 0 : checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
194 :
195 :
196 : OColumn* pNewColumn = new OColumn( m_Name,
197 : m_TypeName,
198 : m_DefaultValue,
199 : m_Description,
200 : m_IsNullable,
201 : m_Precision,
202 : m_Scale,
203 : m_Type,
204 : m_IsAutoIncrement,
205 : m_IsRowVersion,
206 : m_IsCurrency,
207 0 : isCaseSensitive(),
208 : m_CatalogName,
209 : m_SchemaName,
210 0 : m_TableName);
211 0 : pNewColumn->setNew(sal_True);
212 0 : return pNewColumn;
213 : }
214 : // -----------------------------------------------------------------------------
215 2 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
216 : {
217 2 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
218 : }
219 : // -----------------------------------------------------------------------------
220 : // XNamed
221 0 : ::rtl::OUString SAL_CALL OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException)
222 : {
223 0 : return m_Name;
224 : }
225 : // -----------------------------------------------------------------------------
226 2 : void SAL_CALL OColumn::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException)
227 : {
228 2 : m_Name = aName;
229 2 : }
230 : // -----------------------------------------------------------------------------
231 :
232 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|