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