LibreOffice Module connectivity (master) 1
VIndex.cxx
Go to the documentation of this file.
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 <sdbcx/VIndex.hxx>
21#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <TConnection.hxx>
27#include <utility>
29
30using namespace ::connectivity;
31using namespace ::dbtools;
32using namespace ::connectivity::sdbcx;
33using namespace ::cppu;
34using namespace ::com::sun::star::beans;
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::sdbc;
37using namespace ::com::sun::star::sdbcx;
38using namespace ::com::sun::star::container;
39using namespace ::com::sun::star::lang;
40
41
42OUString SAL_CALL OIndex::getImplementationName( )
43{
44 if(isNew())
45 return "com.sun.star.sdbcx.VIndexDescriptor";
46 return "com.sun.star.sdbcx.VIndex";
47}
48
49css::uno::Sequence< OUString > SAL_CALL OIndex::getSupportedServiceNames( )
50{
51 return { isNew()?OUString("com.sun.star.sdbcx.IndexDescriptor"):OUString("com.sun.star.sdbcx.Index") };
52}
53
54sal_Bool SAL_CALL OIndex::supportsService( const OUString& _rServiceName )
55{
56 return cppu::supportsService(this, _rServiceName);
57}
58
59OIndex::OIndex(bool _bCase) : ODescriptor_BASE(m_aMutex)
60 , ODescriptor(ODescriptor_BASE::rBHelper,_bCase,true)
61 ,m_IsUnique(false)
62 ,m_IsPrimaryKeyIndex(false)
63 ,m_IsClustered(false)
64{
65}
66
67OIndex::OIndex( const OUString& Name,
68 OUString Catalog,
69 bool _isUnique,
70 bool _isPrimaryKeyIndex,
71 bool _isClustered,
72 bool _bCase) : ODescriptor_BASE(m_aMutex)
73 ,ODescriptor(ODescriptor_BASE::rBHelper, _bCase)
74 ,m_Catalog(std::move(Catalog))
75 ,m_IsUnique(_isUnique)
76 ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex)
77 ,m_IsClustered(_isClustered)
78{
79 m_Name = Name;
80}
81
83{
84}
85
87{
88 return doCreateArrayHelper();
89}
90
92{
93 return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
94}
95
96Any SAL_CALL OIndex::queryInterface( const Type & rType )
97{
98 Any aRet = ODescriptor::queryInterface( rType);
99 if(!aRet.hasValue())
100 {
101 if(!isNew())
102 aRet = OIndex_BASE::queryInterface(rType);
103 if(!aRet.hasValue())
104 aRet = ODescriptor_BASE::queryInterface( rType);
105 }
106 return aRet;
107}
108
109Sequence< Type > SAL_CALL OIndex::getTypes( )
110{
111 if(isNew())
112 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
113 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
114}
115
117{
119
120 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
121
126}
127
129{
131
132 ::osl::MutexGuard aGuard(m_aMutex);
133
134 if(m_pColumns)
135 m_pColumns->disposing();
136}
137
138Reference< css::container::XNameAccess > SAL_CALL OIndex::getColumns( )
139{
140 ::osl::MutexGuard aGuard(m_aMutex);
141 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
142
143 try
144 {
145 if ( !m_pColumns )
147 }
148 catch( const RuntimeException& )
149 {
150 // allowed to leave this method
151 throw;
152 }
153 catch( const Exception& )
154 {
155 TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OIndex::getColumns" );
156 }
157
158 return m_pColumns.get();
159}
160
161Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor( )
162{
163 ::osl::MutexGuard aGuard(m_aMutex);
164 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
165
166
167 return this;
168}
169
170css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OIndex::getPropertySetInfo( )
171{
172 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
173}
174
175OUString SAL_CALL OIndex::getName( )
176{
177 return m_Name;
178}
179
180void SAL_CALL OIndex::setName( const OUString& /*aName*/ )
181{
182}
183
184// XInterface
185void SAL_CALL OIndex::acquire() noexcept
186{
187 ODescriptor_BASE::acquire();
188}
189
190void SAL_CALL OIndex::release() noexcept
191{
192 ODescriptor_BASE::release();
193}
194
196{
197}
198
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::cppu::IPropertyArrayHelper * getArrayHelper(sal_Int32 nId)
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
void disposing(std::unique_lock< std::mutex > &rGuard)
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
Definition: VDescriptor.cxx:94
::cppu::IPropertyArrayHelper * doCreateArrayHelper() const
helper for derived classes to implement OPropertyArrayUsageHelper::createArrayHelper
Definition: VDescriptor.cxx:66
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: VIndex.cxx:91
virtual void SAL_CALL acquire() noexcept override
Definition: VIndex.cxx:185
virtual void SAL_CALL release() noexcept override
Definition: VIndex.cxx:190
virtual ~OIndex() override
Definition: VIndex.cxx:82
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: VIndex.cxx:170
virtual void refreshColumns() override
Definition: VIndex.cxx:195
std::unique_ptr< OCollection > m_pColumns
Definition: VIndex.hxx:54
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: VIndex.cxx:109
virtual OUString SAL_CALL getName() override
Definition: VIndex.cxx:175
virtual void SAL_CALL disposing() override
Definition: VIndex.cxx:128
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
Definition: VIndex.cxx:161
virtual ::cppu::IPropertyArrayHelper * createArrayHelper(sal_Int32 _nId) const override
Definition: VIndex.cxx:86
virtual void construct() override
Definition: VIndex.cxx:116
virtual void SAL_CALL setName(const OUString &aName) override
Definition: VIndex.cxx:180
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
Definition: VIndex.cxx:138
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: VIndex.cxx:96
mutable::osl::Mutex m_aMutex
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
#define TOOLS_WARN_EXCEPTION(area, stream)
std::mutex m_aMutex
@ Exception
Type
cppu::WeakComponentImplHelper< css::sdbcx::XColumnsSupplier, css::container::XNamed, css::lang::XServiceInfo > ODescriptor_BASE
Definition: VTypeDef.hxx:31
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
#define PROPERTY_ID_CATALOG
Definition: propertyids.hxx:64
#define PROPERTY_ID_ISUNIQUE
Definition: propertyids.hxx:65
#define PROPERTY_ID_ISPRIMARYKEYINDEX
Definition: propertyids.hxx:66
#define PROPERTY_ID_ISCLUSTERED
Definition: propertyids.hxx:67
OUString Name
unsigned char sal_Bool