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/VIndex.hxx"
21 : #include <com/sun/star/lang/DisposedException.hpp>
22 : #include "connectivity/sdbcx/VColumn.hxx"
23 : #include <connectivity/dbexception.hxx>
24 : #include <comphelper/sequence.hxx>
25 : #include "connectivity/sdbcx/VCollection.hxx"
26 : #include <cppuhelper/supportsservice.hxx>
27 : #include "TConnection.hxx"
28 :
29 : using namespace ::connectivity;
30 : using namespace ::dbtools;
31 : using namespace ::connectivity::sdbcx;
32 : using namespace ::cppu;
33 : using namespace ::com::sun::star::beans;
34 : using namespace ::com::sun::star::uno;
35 : using namespace ::com::sun::star::sdbc;
36 : using namespace ::com::sun::star::sdbcx;
37 : using namespace ::com::sun::star::container;
38 : using namespace ::com::sun::star::lang;
39 :
40 :
41 0 : OUString SAL_CALL OIndex::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
42 : {
43 0 : if(isNew())
44 0 : return OUString("com.sun.star.sdbcx.VIndexDescriptor");
45 0 : return OUString("com.sun.star.sdbcx.VIndex");
46 : }
47 :
48 0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL OIndex::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
49 : {
50 0 : ::com::sun::star::uno::Sequence< OUString > aSupported(1);
51 0 : if(isNew())
52 0 : aSupported[0] = "com.sun.star.sdbcx.IndexDescriptor";
53 : else
54 0 : aSupported[0] = "com.sun.star.sdbcx.Index";
55 :
56 0 : return aSupported;
57 : }
58 :
59 0 : sal_Bool SAL_CALL OIndex::supportsService( const OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
60 : {
61 0 : return cppu::supportsService(this, _rServiceName);
62 : }
63 :
64 0 : OIndex::OIndex(bool _bCase) : ODescriptor_BASE(m_aMutex)
65 : , ODescriptor(ODescriptor_BASE::rBHelper,_bCase,true)
66 : ,m_IsUnique(false)
67 : ,m_IsPrimaryKeyIndex(false)
68 : ,m_IsClustered(false)
69 0 : ,m_pColumns(NULL)
70 : {
71 0 : }
72 :
73 0 : OIndex::OIndex( const OUString& _Name,
74 : const OUString& _Catalog,
75 : bool _isUnique,
76 : bool _isPrimaryKeyIndex,
77 : bool _isClustered,
78 : bool _bCase) : ODescriptor_BASE(m_aMutex)
79 : ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
80 : ,m_Catalog(_Catalog)
81 : ,m_IsUnique(_isUnique)
82 : ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex)
83 : ,m_IsClustered(_isClustered)
84 0 : ,m_pColumns(NULL)
85 : {
86 0 : m_Name = _Name;
87 0 : }
88 :
89 0 : OIndex::~OIndex( )
90 : {
91 0 : delete m_pColumns;
92 0 : }
93 :
94 0 : ::cppu::IPropertyArrayHelper* OIndex::createArrayHelper( sal_Int32 /*_nId*/ ) const
95 : {
96 0 : return doCreateArrayHelper();
97 : }
98 :
99 0 : ::cppu::IPropertyArrayHelper& SAL_CALL OIndex::getInfoHelper()
100 : {
101 0 : return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
102 : }
103 :
104 0 : Any SAL_CALL OIndex::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
105 : {
106 0 : Any aRet = ODescriptor::queryInterface( rType);
107 0 : if(!aRet.hasValue())
108 : {
109 0 : if(!isNew())
110 0 : aRet = OIndex_BASE::queryInterface(rType);
111 0 : if(!aRet.hasValue())
112 0 : aRet = ODescriptor_BASE::queryInterface( rType);
113 : }
114 0 : return aRet;
115 : }
116 :
117 0 : Sequence< Type > SAL_CALL OIndex::getTypes( ) throw(RuntimeException, std::exception)
118 : {
119 0 : if(isNew())
120 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
121 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
122 : }
123 :
124 0 : void OIndex::construct()
125 : {
126 0 : ODescriptor::construct();
127 :
128 0 : sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
129 :
130 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG), PROPERTY_ID_CATALOG, nAttrib,&m_Catalog, ::getCppuType(static_cast< OUString*>(0)));
131 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE), PROPERTY_ID_ISUNIQUE, nAttrib,&m_IsUnique, ::getBooleanCppuType());
132 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX),PROPERTY_ID_ISPRIMARYKEYINDEX, nAttrib,&m_IsPrimaryKeyIndex, ::getBooleanCppuType());
133 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED), PROPERTY_ID_ISCLUSTERED, nAttrib,&m_IsClustered, ::getBooleanCppuType());
134 0 : }
135 :
136 0 : void OIndex::disposing(void)
137 : {
138 0 : OPropertySetHelper::disposing();
139 :
140 0 : ::osl::MutexGuard aGuard(m_aMutex);
141 :
142 0 : if(m_pColumns)
143 0 : m_pColumns->disposing();
144 0 : }
145 :
146 0 : Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OIndex::getColumns( ) throw(RuntimeException, std::exception)
147 : {
148 0 : ::osl::MutexGuard aGuard(m_aMutex);
149 0 : checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
150 :
151 : try
152 : {
153 0 : if ( !m_pColumns )
154 0 : refreshColumns();
155 : }
156 0 : catch( const RuntimeException& )
157 : {
158 : // allowed to leave this method
159 0 : throw;
160 : }
161 0 : catch( const Exception& )
162 : {
163 : OSL_FAIL( "OIndex::getColumns: caught an exception!" );
164 : }
165 :
166 0 : return const_cast<OIndex*>(this)->m_pColumns;
167 : }
168 :
169 0 : Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor( ) throw(RuntimeException, std::exception)
170 : {
171 0 : ::osl::MutexGuard aGuard(m_aMutex);
172 0 : checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
173 :
174 :
175 0 : return this;
176 : }
177 :
178 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OIndex::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
179 : {
180 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
181 : }
182 :
183 0 : OUString SAL_CALL OIndex::getName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
184 : {
185 0 : return m_Name;
186 : }
187 :
188 0 : void SAL_CALL OIndex::setName( const OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
189 : {
190 0 : }
191 :
192 : // XInterface
193 0 : void SAL_CALL OIndex::acquire() throw()
194 : {
195 0 : ODescriptor_BASE::acquire();
196 0 : }
197 :
198 0 : void SAL_CALL OIndex::release() throw()
199 : {
200 0 : ODescriptor_BASE::release();
201 0 : }
202 :
203 0 : void OIndex::refreshColumns()
204 : {
205 0 : }
206 :
207 :
208 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|