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 <rtl/ustrbuf.hxx>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <cppuhelper/queryinterface.hxx>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
44 #include "pq_xkey.hxx"
45 #include "pq_xkeycolumns.hxx"
46 #include "pq_tools.hxx"
47 #include "pq_statics.hxx"
49 using com::sun::star::container::XNameAccess
;
51 using com::sun::star::uno::Reference
;
52 using com::sun::star::uno::Sequence
;
53 using com::sun::star::uno::Any
;
54 using com::sun::star::uno::Type
;
56 using com::sun::star::beans::XPropertySet
;
59 namespace pq_sdbc_driver
61 Key::Key( const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
62 const Reference
< css::sdbc::XConnection
> & connection
,
63 ConnectionSettings
*pSettings
,
64 const OUString
& schemaName
,
65 const OUString
& tableName
)
67 getStatics().refl
.key
.implName
,
68 getStatics().refl
.key
.serviceNames
,
72 * getStatics().refl
.key
.pProps
),
73 m_schemaName( schemaName
),
74 m_tableName( tableName
)
77 Reference
< XPropertySet
> Key::createDataDescriptor( )
79 KeyDescriptor
* pKeyDescriptor
= new KeyDescriptor(
80 m_xMutex
, m_conn
, m_pSettings
);
81 pKeyDescriptor
->copyValuesFrom( this );
83 return Reference
< XPropertySet
> ( pKeyDescriptor
);
86 Reference
< XNameAccess
> Key::getColumns( )
88 // TODO: cash columns object !
89 if( !m_keyColumns
.is() )
91 Sequence
< OUString
> columnNames
, foreignColumnNames
;
92 getPropertyValue( getStatics().PRIVATE_COLUMNS
) >>= columnNames
;
93 getPropertyValue( getStatics().PRIVATE_FOREIGN_COLUMNS
) >>= foreignColumnNames
;
95 m_keyColumns
= KeyColumns::create(
96 m_xMutex
, m_conn
, m_pSettings
, m_schemaName
,
97 m_tableName
, columnNames
, foreignColumnNames
);
102 Sequence
<Type
> Key::getTypes()
104 static cppu::OTypeCollection
collection(
105 cppu::UnoType
<css::sdbcx::XColumnsSupplier
>::get(),
106 ReflectionBase::getTypes());
108 return collection
.getTypes();
111 Sequence
< sal_Int8
> Key::getImplementationId()
113 return css::uno::Sequence
<sal_Int8
>();
116 Any
Key::queryInterface( const Type
& reqType
)
118 Any ret
= ReflectionBase::queryInterface( reqType
);
119 if( ! ret
.hasValue() )
120 ret
= ::cppu::queryInterface(
122 static_cast< css::sdbcx::XColumnsSupplier
* > ( this ) );
127 KeyDescriptor::KeyDescriptor( const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
128 const Reference
< css::sdbc::XConnection
> & connection
,
129 ConnectionSettings
*pSettings
)
131 getStatics().refl
.keyDescriptor
.implName
,
132 getStatics().refl
.keyDescriptor
.serviceNames
,
136 * getStatics().refl
.keyDescriptor
.pProps
)
140 Reference
< XPropertySet
> KeyDescriptor::createDataDescriptor( )
142 KeyDescriptor
* pKeyDescriptor
= new KeyDescriptor(
143 m_xMutex
, m_conn
, m_pSettings
);
144 pKeyDescriptor
->copyValuesFrom( this );
146 return Reference
< XPropertySet
> ( pKeyDescriptor
);
149 Reference
< XNameAccess
> KeyDescriptor::getColumns( )
151 // TODO: cash columns object !
152 if( !m_keyColumns
.is() )
154 m_keyColumns
= new KeyColumnDescriptors( m_xMutex
, m_conn
, m_pSettings
);
159 Sequence
<Type
> KeyDescriptor::getTypes()
161 static cppu::OTypeCollection
collection(
162 cppu::UnoType
<css::sdbcx::XColumnsSupplier
>::get(),
163 ReflectionBase::getTypes());
165 return collection
.getTypes();
168 Sequence
< sal_Int8
> KeyDescriptor::getImplementationId()
170 return css::uno::Sequence
<sal_Int8
>();
173 Any
KeyDescriptor::queryInterface( const Type
& reqType
)
175 Any ret
= ReflectionBase::queryInterface( reqType
);
176 if( ! ret
.hasValue() )
177 ret
= ::cppu::queryInterface(
179 static_cast< css::sdbcx::XColumnsSupplier
* > ( this ) );
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */