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