1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VIndex.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "connectivity/sdbcx/VIndex.hxx"
34 #include <com/sun/star/lang/DisposedException.hpp>
35 #include "connectivity/sdbcx/VColumn.hxx"
36 #include <connectivity/dbexception.hxx>
37 #include <comphelper/sequence.hxx>
38 #include "connectivity/sdbcx/VCollection.hxx"
39 #include "TConnection.hxx"
40 // -------------------------------------------------------------------------
41 using namespace ::connectivity
;
42 using namespace ::connectivity
;
43 using namespace ::dbtools
;
44 using namespace ::connectivity::sdbcx
;
45 using namespace ::cppu
;
46 using namespace ::com::sun::star::beans
;
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::sdbc
;
49 using namespace ::com::sun::star::sdbcx
;
50 using namespace ::com::sun::star::container
;
51 using namespace ::com::sun::star::lang
;
53 // -----------------------------------------------------------------------------
54 ::rtl::OUString SAL_CALL
OIndex::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
)
57 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VIndexDescriptor");
58 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VIndex");
60 // -----------------------------------------------------------------------------
61 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
OIndex::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
)
63 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> aSupported(1);
65 aSupported
[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.IndexDescriptor");
67 aSupported
[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Index");
71 // -----------------------------------------------------------------------------
72 sal_Bool SAL_CALL
OIndex::supportsService( const ::rtl::OUString
& _rServiceName
) throw(::com::sun::star::uno::RuntimeException
)
74 Sequence
< ::rtl::OUString
> aSupported(getSupportedServiceNames());
75 const ::rtl::OUString
* pSupported
= aSupported
.getConstArray();
76 const ::rtl::OUString
* pEnd
= pSupported
+ aSupported
.getLength();
77 for (;pSupported
!= pEnd
&& !pSupported
->equals(_rServiceName
); ++pSupported
)
80 return pSupported
!= pEnd
;
82 // -------------------------------------------------------------------------
83 OIndex::OIndex(sal_Bool _bCase
) : ODescriptor_BASE(m_aMutex
)
84 , ODescriptor(ODescriptor_BASE::rBHelper
,_bCase
,sal_True
)
85 ,m_IsUnique(sal_False
)
86 ,m_IsPrimaryKeyIndex(sal_False
)
87 ,m_IsClustered(sal_False
)
91 // -------------------------------------------------------------------------
92 OIndex::OIndex( const ::rtl::OUString
& _Name
,
93 const ::rtl::OUString
& _Catalog
,
95 sal_Bool _isPrimaryKeyIndex
,
96 sal_Bool _isClustered
,
97 sal_Bool _bCase
) : ODescriptor_BASE(m_aMutex
)
98 ,ODescriptor(ODescriptor_BASE::rBHelper
,_bCase
)
100 ,m_IsUnique(_isUnique
)
101 ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex
)
102 ,m_IsClustered(_isClustered
)
107 // -------------------------------------------------------------------------
112 // -----------------------------------------------------------------------------
113 ::cppu::IPropertyArrayHelper
* OIndex::createArrayHelper( sal_Int32
/*_nId*/ ) const
115 return doCreateArrayHelper();
117 // -----------------------------------------------------------------------------
118 ::cppu::IPropertyArrayHelper
& SAL_CALL
OIndex::getInfoHelper()
120 return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
122 // -------------------------------------------------------------------------
123 Any SAL_CALL
OIndex::queryInterface( const Type
& rType
) throw(RuntimeException
)
125 Any aRet
= ODescriptor::queryInterface( rType
);
129 aRet
= OIndex_BASE::queryInterface(rType
);
131 aRet
= ODescriptor_BASE::queryInterface( rType
);
135 // -------------------------------------------------------------------------
136 Sequence
< Type
> SAL_CALL
OIndex::getTypes( ) throw(RuntimeException
)
139 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
140 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
142 // -------------------------------------------------------------------------
143 void OIndex::construct()
145 ODescriptor::construct();
147 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
149 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG
), PROPERTY_ID_CATALOG
, nAttrib
,&m_Catalog
, ::getCppuType(reinterpret_cast< ::rtl::OUString
*>(NULL
)));
150 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE
), PROPERTY_ID_ISUNIQUE
, nAttrib
,&m_IsUnique
, ::getBooleanCppuType());
151 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX
),PROPERTY_ID_ISPRIMARYKEYINDEX
, nAttrib
,&m_IsPrimaryKeyIndex
, ::getBooleanCppuType());
152 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED
), PROPERTY_ID_ISCLUSTERED
, nAttrib
,&m_IsClustered
, ::getBooleanCppuType());
154 // -------------------------------------------------------------------------
155 void OIndex::disposing(void)
157 OPropertySetHelper::disposing();
159 ::osl::MutexGuard
aGuard(m_aMutex
);
162 m_pColumns
->disposing();
164 // -------------------------------------------------------------------------
165 Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
OIndex::getColumns( ) throw(RuntimeException
)
167 ::osl::MutexGuard
aGuard(m_aMutex
);
168 checkDisposed(ODescriptor_BASE::rBHelper
.bDisposed
);
175 catch( const RuntimeException
& )
177 // allowed to leave this method
180 catch( const Exception
& )
182 OSL_ENSURE( false, "OIndex::getColumns: caught an exception!" );
185 return const_cast<OIndex
*>(this)->m_pColumns
;
187 // -------------------------------------------------------------------------
188 Reference
< XPropertySet
> SAL_CALL
OIndex::createDataDescriptor( ) throw(RuntimeException
)
190 ::osl::MutexGuard
aGuard(m_aMutex
);
191 checkDisposed(ODescriptor_BASE::rBHelper
.bDisposed
);
196 // -----------------------------------------------------------------------------
197 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OIndex::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
)
199 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
201 // -----------------------------------------------------------------------------
202 ::rtl::OUString SAL_CALL
OIndex::getName( ) throw(::com::sun::star::uno::RuntimeException
)
206 // -----------------------------------------------------------------------------
207 void SAL_CALL
OIndex::setName( const ::rtl::OUString
& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException
)
210 // -----------------------------------------------------------------------------
212 void SAL_CALL
OIndex::acquire() throw()
214 ODescriptor_BASE::acquire();
216 // -----------------------------------------------------------------------------
217 void SAL_CALL
OIndex::release() throw()
219 ODescriptor_BASE::release();
221 // -----------------------------------------------------------------------------
222 void OIndex::refreshColumns()
225 // -----------------------------------------------------------------------------