bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / sdbcx / VIndex.cxx
blob67fb446b485f33ec47adb7963812c747ada56423
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <connectivity/sdbcx/VColumn.hxx>
24 #include <connectivity/dbexception.hxx>
25 #include <comphelper/sequence.hxx>
26 #include <connectivity/sdbcx/VCollection.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <TConnection.hxx>
30 using namespace ::connectivity;
31 using namespace ::dbtools;
32 using namespace ::connectivity::sdbcx;
33 using namespace ::cppu;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::sdbc;
37 using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::container;
39 using namespace ::com::sun::star::lang;
42 OUString SAL_CALL OIndex::getImplementationName( )
44 if(isNew())
45 return OUString("com.sun.star.sdbcx.VIndexDescriptor");
46 return OUString("com.sun.star.sdbcx.VIndex");
49 css::uno::Sequence< OUString > SAL_CALL OIndex::getSupportedServiceNames( )
51 css::uno::Sequence< OUString > aSupported(1);
52 if(isNew())
53 aSupported[0] = "com.sun.star.sdbcx.IndexDescriptor";
54 else
55 aSupported[0] = "com.sun.star.sdbcx.Index";
57 return aSupported;
60 sal_Bool SAL_CALL OIndex::supportsService( const OUString& _rServiceName )
62 return cppu::supportsService(this, _rServiceName);
65 OIndex::OIndex(bool _bCase) : ODescriptor_BASE(m_aMutex)
66 , ODescriptor(ODescriptor_BASE::rBHelper,_bCase,true)
67 ,m_IsUnique(false)
68 ,m_IsPrimaryKeyIndex(false)
69 ,m_IsClustered(false)
73 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)
85 m_Name = Name;
88 OIndex::~OIndex( )
92 ::cppu::IPropertyArrayHelper* OIndex::createArrayHelper( sal_Int32 /*_nId*/ ) const
94 return doCreateArrayHelper();
97 ::cppu::IPropertyArrayHelper& SAL_CALL OIndex::getInfoHelper()
99 return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
102 Any SAL_CALL OIndex::queryInterface( const Type & rType )
104 Any aRet = ODescriptor::queryInterface( rType);
105 if(!aRet.hasValue())
107 if(!isNew())
108 aRet = OIndex_BASE::queryInterface(rType);
109 if(!aRet.hasValue())
110 aRet = ODescriptor_BASE::queryInterface( rType);
112 return aRet;
115 Sequence< Type > SAL_CALL OIndex::getTypes( )
117 if(isNew())
118 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
119 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
122 void OIndex::construct()
124 ODescriptor::construct();
126 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
128 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG), PROPERTY_ID_CATALOG, nAttrib,&m_Catalog, ::cppu::UnoType<OUString>::get());
129 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE), PROPERTY_ID_ISUNIQUE, nAttrib,&m_IsUnique, cppu::UnoType<bool>::get());
130 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX),PROPERTY_ID_ISPRIMARYKEYINDEX, nAttrib,&m_IsPrimaryKeyIndex, cppu::UnoType<bool>::get());
131 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED), PROPERTY_ID_ISCLUSTERED, nAttrib,&m_IsClustered, cppu::UnoType<bool>::get());
134 void OIndex::disposing()
136 OPropertySetHelper::disposing();
138 ::osl::MutexGuard aGuard(m_aMutex);
140 if(m_pColumns)
141 m_pColumns->disposing();
144 Reference< css::container::XNameAccess > SAL_CALL OIndex::getColumns( )
146 ::osl::MutexGuard aGuard(m_aMutex);
147 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
151 if ( !m_pColumns )
152 refreshColumns();
154 catch( const RuntimeException& )
156 // allowed to leave this method
157 throw;
159 catch( const Exception& )
161 OSL_FAIL( "OIndex::getColumns: caught an exception!" );
164 return m_pColumns.get();
167 Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor( )
169 ::osl::MutexGuard aGuard(m_aMutex);
170 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
173 return this;
176 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OIndex::getPropertySetInfo( )
178 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
181 OUString SAL_CALL OIndex::getName( )
183 return m_Name;
186 void SAL_CALL OIndex::setName( const OUString& /*aName*/ )
190 // XInterface
191 void SAL_CALL OIndex::acquire() throw()
193 ODescriptor_BASE::acquire();
196 void SAL_CALL OIndex::release() throw()
198 ODescriptor_BASE::release();
201 void OIndex::refreshColumns()
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */