1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
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
;
41 OUString SAL_CALL
OIndex::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
44 return OUString("com.sun.star.sdbcx.VIndexDescriptor");
45 return OUString("com.sun.star.sdbcx.VIndex");
48 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
OIndex::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
50 ::com::sun::star::uno::Sequence
< OUString
> aSupported(1);
52 aSupported
[0] = "com.sun.star.sdbcx.IndexDescriptor";
54 aSupported
[0] = "com.sun.star.sdbcx.Index";
59 sal_Bool SAL_CALL
OIndex::supportsService( const OUString
& _rServiceName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
61 return cppu::supportsService(this, _rServiceName
);
64 OIndex::OIndex(bool _bCase
) : ODescriptor_BASE(m_aMutex
)
65 , ODescriptor(ODescriptor_BASE::rBHelper
,_bCase
,true)
67 ,m_IsPrimaryKeyIndex(false)
73 OIndex::OIndex( const OUString
& _Name
,
74 const OUString
& _Catalog
,
76 bool _isPrimaryKeyIndex
,
78 bool _bCase
) : ODescriptor_BASE(m_aMutex
)
79 ,ODescriptor(ODescriptor_BASE::rBHelper
,_bCase
)
81 ,m_IsUnique(_isUnique
)
82 ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex
)
83 ,m_IsClustered(_isClustered
)
94 ::cppu::IPropertyArrayHelper
* OIndex::createArrayHelper( sal_Int32
/*_nId*/ ) const
96 return doCreateArrayHelper();
99 ::cppu::IPropertyArrayHelper
& SAL_CALL
OIndex::getInfoHelper()
101 return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
104 Any SAL_CALL
OIndex::queryInterface( const Type
& rType
) throw(RuntimeException
, std::exception
)
106 Any aRet
= ODescriptor::queryInterface( rType
);
110 aRet
= OIndex_BASE::queryInterface(rType
);
112 aRet
= ODescriptor_BASE::queryInterface( rType
);
117 Sequence
< Type
> SAL_CALL
OIndex::getTypes( ) throw(RuntimeException
, std::exception
)
120 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
121 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
124 void OIndex::construct()
126 ODescriptor::construct();
128 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
130 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG
), PROPERTY_ID_CATALOG
, nAttrib
,&m_Catalog
, ::cppu::UnoType
<OUString
>::get());
131 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE
), PROPERTY_ID_ISUNIQUE
, nAttrib
,&m_IsUnique
, cppu::UnoType
<bool>::get());
132 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX
),PROPERTY_ID_ISPRIMARYKEYINDEX
, nAttrib
,&m_IsPrimaryKeyIndex
, cppu::UnoType
<bool>::get());
133 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED
), PROPERTY_ID_ISCLUSTERED
, nAttrib
,&m_IsClustered
, cppu::UnoType
<bool>::get());
136 void OIndex::disposing()
138 OPropertySetHelper::disposing();
140 ::osl::MutexGuard
aGuard(m_aMutex
);
143 m_pColumns
->disposing();
146 Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
OIndex::getColumns( ) throw(RuntimeException
, std::exception
)
148 ::osl::MutexGuard
aGuard(m_aMutex
);
149 checkDisposed(ODescriptor_BASE::rBHelper
.bDisposed
);
156 catch( const RuntimeException
& )
158 // allowed to leave this method
161 catch( const Exception
& )
163 OSL_FAIL( "OIndex::getColumns: caught an exception!" );
166 return const_cast<OIndex
*>(this)->m_pColumns
;
169 Reference
< XPropertySet
> SAL_CALL
OIndex::createDataDescriptor( ) throw(RuntimeException
, std::exception
)
171 ::osl::MutexGuard
aGuard(m_aMutex
);
172 checkDisposed(ODescriptor_BASE::rBHelper
.bDisposed
);
178 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OIndex::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
180 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
183 OUString SAL_CALL
OIndex::getName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
188 void SAL_CALL
OIndex::setName( const OUString
& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
193 void SAL_CALL
OIndex::acquire() throw()
195 ODescriptor_BASE::acquire();
198 void SAL_CALL
OIndex::release() throw()
200 ODescriptor_BASE::release();
203 void OIndex::refreshColumns()
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */