Use correct object
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_xkey.cxx
blob81d1f7a86eb6280506160326784407c599d1c15b
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,
18 * MA 02111-1307 USA
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>
40 #include <utility>
42 #include "pq_xkey.hxx"
43 #include "pq_xkeycolumns.hxx"
44 #include "pq_statics.hxx"
46 using com::sun::star::container::XNameAccess;
48 using com::sun::star::uno::Reference;
49 using com::sun::star::uno::Sequence;
50 using com::sun::star::uno::Any;
51 using com::sun::star::uno::Type;
53 using com::sun::star::beans::XPropertySet;
56 namespace pq_sdbc_driver
58 Key::Key( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
59 const Reference< css::sdbc::XConnection > & connection,
60 ConnectionSettings *pSettings,
61 OUString schemaName,
62 OUString tableName )
63 : ReflectionBase(
64 getStatics().refl.key.implName,
65 getStatics().refl.key.serviceNames,
66 refMutex,
67 connection,
68 pSettings,
69 * getStatics().refl.key.pProps ),
70 m_schemaName(std::move( schemaName )),
71 m_tableName(std::move( tableName ))
74 Reference< XPropertySet > Key::createDataDescriptor( )
76 rtl::Reference<KeyDescriptor> pKeyDescriptor = new KeyDescriptor(
77 m_xMutex, m_conn, m_pSettings );
78 pKeyDescriptor->copyValuesFrom( this );
80 return Reference< XPropertySet > ( pKeyDescriptor );
83 Reference< XNameAccess > Key::getColumns( )
85 // TODO: cash columns object !
86 if( !m_keyColumns.is() )
88 Sequence< OUString > columnNames, foreignColumnNames;
89 getPropertyValue( getStatics().PRIVATE_COLUMNS ) >>= columnNames;
90 getPropertyValue( getStatics().PRIVATE_FOREIGN_COLUMNS ) >>= foreignColumnNames;
92 m_keyColumns = KeyColumns::create(
93 m_xMutex, m_conn, m_pSettings, m_schemaName,
94 m_tableName, columnNames, foreignColumnNames );
96 return m_keyColumns;
99 Sequence<Type > Key::getTypes()
101 static cppu::OTypeCollection collection(
102 cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
103 ReflectionBase::getTypes());
105 return collection.getTypes();
108 Sequence< sal_Int8> Key::getImplementationId()
110 return css::uno::Sequence<sal_Int8>();
113 Any Key::queryInterface( const Type & reqType )
115 Any ret = ReflectionBase::queryInterface( reqType );
116 if( ! ret.hasValue() )
117 ret = ::cppu::queryInterface(
118 reqType,
119 static_cast< css::sdbcx::XColumnsSupplier * > ( this ) );
120 return ret;
124 KeyDescriptor::KeyDescriptor( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
125 const Reference< css::sdbc::XConnection > & connection,
126 ConnectionSettings *pSettings )
127 : ReflectionBase(
128 getStatics().refl.keyDescriptor.implName,
129 getStatics().refl.keyDescriptor.serviceNames,
130 refMutex,
131 connection,
132 pSettings,
133 * getStatics().refl.keyDescriptor.pProps )
137 Reference< XPropertySet > KeyDescriptor::createDataDescriptor( )
139 rtl::Reference<KeyDescriptor> pKeyDescriptor = new KeyDescriptor(
140 m_xMutex, m_conn, m_pSettings );
141 pKeyDescriptor->copyValuesFrom( this );
143 return Reference< XPropertySet > ( pKeyDescriptor );
146 Reference< XNameAccess > KeyDescriptor::getColumns( )
148 // TODO: cash columns object !
149 if( !m_keyColumns.is() )
151 m_keyColumns = new KeyColumnDescriptors( m_xMutex, m_conn, m_pSettings );
153 return m_keyColumns;
156 Sequence<Type > KeyDescriptor::getTypes()
158 static cppu::OTypeCollection collection(
159 cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
160 ReflectionBase::getTypes());
162 return collection.getTypes();
165 Sequence< sal_Int8> KeyDescriptor::getImplementationId()
167 return css::uno::Sequence<sal_Int8>();
170 Any KeyDescriptor::queryInterface( const Type & reqType )
172 Any ret = ReflectionBase::queryInterface( reqType );
173 if( ! ret.hasValue() )
174 ret = ::cppu::queryInterface(
175 reqType,
176 static_cast< css::sdbcx::XColumnsSupplier * > ( this ) );
177 return ret;
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */