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