1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #include <cppuhelper/typeprovider.hxx>
38 #include <cppuhelper/queryinterface.hxx>
39 #include <rtl/ref.hxx>
42 #include "pq_xindex.hxx"
43 #include "pq_xindexcolumns.hxx"
44 #include "pq_tools.hxx"
45 #include "pq_statics.hxx"
47 using com::sun::star::container::XNameAccess
;
49 using com::sun::star::uno::Reference
;
50 using com::sun::star::uno::Sequence
;
51 using com::sun::star::uno::Any
;
52 using com::sun::star::uno::Type
;
54 using com::sun::star::beans::XPropertySet
;
57 namespace pq_sdbc_driver
59 Index::Index( const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
60 const Reference
< css::sdbc::XConnection
> & connection
,
61 ConnectionSettings
*pSettings
,
65 getStatics().refl
.index
.implName
,
66 getStatics().refl
.index
.serviceNames
,
70 * getStatics().refl
.index
.pProps
),
71 m_schemaName(std::move( schemaName
)),
72 m_tableName(std::move( tableName
))
75 Reference
< XPropertySet
> Index::createDataDescriptor( )
77 rtl::Reference
<IndexDescriptor
> pIndex
= new IndexDescriptor(
78 m_xMutex
, m_conn
, m_pSettings
);
79 pIndex
->copyValuesFrom( this );
81 return Reference
< XPropertySet
> ( pIndex
);
84 Reference
< XNameAccess
> Index::getColumns( )
86 if( ! m_indexColumns
.is() )
88 Sequence
< OUString
> columnNames
;
89 getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES
) >>= columnNames
;
90 OUString indexName
= extractStringProperty( this, getStatics().NAME
);
91 m_indexColumns
= IndexColumns::create(
92 m_xMutex
, m_conn
, m_pSettings
, m_schemaName
,
93 m_tableName
, indexName
, columnNames
);
95 return m_indexColumns
;
98 Sequence
<Type
> Index::getTypes()
100 static cppu::OTypeCollection
collection(
101 cppu::UnoType
<css::sdbcx::XColumnsSupplier
>::get(),
102 ReflectionBase::getTypes());
104 return collection
.getTypes();
107 Sequence
< sal_Int8
> Index::getImplementationId()
109 return css::uno::Sequence
<sal_Int8
>();
112 Any
Index::queryInterface( const Type
& reqType
)
114 Any ret
= ReflectionBase::queryInterface( reqType
);
115 if( ! ret
.hasValue() )
116 ret
= ::cppu::queryInterface(
118 static_cast< css::sdbcx::XColumnsSupplier
* > ( this ) );
123 IndexDescriptor::IndexDescriptor(
124 const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
125 const Reference
< css::sdbc::XConnection
> & connection
,
126 ConnectionSettings
*pSettings
)
128 getStatics().refl
.indexDescriptor
.implName
,
129 getStatics().refl
.indexDescriptor
.serviceNames
,
133 * getStatics().refl
.indexDescriptor
.pProps
)
136 Reference
< XPropertySet
> IndexDescriptor::createDataDescriptor( )
138 rtl::Reference
<IndexDescriptor
> pIndex
= new IndexDescriptor(
139 m_xMutex
, m_conn
, m_pSettings
);
140 pIndex
->copyValuesFrom( this );
141 return Reference
< XPropertySet
> ( pIndex
);
144 Reference
< XNameAccess
> IndexDescriptor::getColumns( )
146 if( ! m_indexColumns
.is() )
148 m_indexColumns
= IndexColumnDescriptors::create(
149 m_xMutex
, m_conn
, m_pSettings
);
150 // Sequence< OUString > columnNames;
151 // getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
152 // OUString indexName = extractStringProperty( this, getStatics().NAME );
153 // m_indexColumns = IndexColumns::create(
154 // m_xMutex, m_conn, m_pSettings, m_schemaName,
155 // m_tableName, indexName, columnNames );
157 return m_indexColumns
;
160 Sequence
<Type
> IndexDescriptor::getTypes()
162 static cppu::OTypeCollection
collection(
163 cppu::UnoType
<css::sdbcx::XColumnsSupplier
>::get(),
164 ReflectionBase::getTypes());
166 return collection
.getTypes();
169 Sequence
< sal_Int8
> IndexDescriptor::getImplementationId()
171 return css::uno::Sequence
<sal_Int8
>();
174 Any
IndexDescriptor::queryInterface( const Type
& reqType
)
176 Any ret
= ReflectionBase::queryInterface( reqType
);
177 if( ! ret
.hasValue() )
178 ret
= ::cppu::queryInterface(
180 static_cast< css::sdbcx::XColumnsSupplier
* > ( this ) );
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */