LibreOffice Module connectivity (master) 1
VKey.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/VKey.hxx>
21#include <com/sun/star/beans/PropertyAttribute.hpp>
22#include <com/sun/star/sdbc/KeyRule.hpp>
26#include <TConnection.hxx>
27#include <utility>
28
29using namespace connectivity;
30using namespace connectivity::sdbcx;
31using namespace ::com::sun::star::beans;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::sdbc;
34using namespace ::com::sun::star::sdbcx;
35using namespace ::com::sun::star::container;
36using namespace ::com::sun::star::lang;
37
38
39OUString SAL_CALL OKey::getImplementationName( )
40{
41 if(isNew())
42 return "com.sun.star.sdbcx.VKeyDescriptor";
43 return "com.sun.star.sdbcx.VKey";
44}
45
46css::uno::Sequence< OUString > SAL_CALL OKey::getSupportedServiceNames( )
47{
48 return { isNew()?OUString("com.sun.star.sdbcx.KeyDescriptor"):OUString("com.sun.star.sdbcx.Key") };
49}
50
51sal_Bool SAL_CALL OKey::supportsService( const OUString& _rServiceName )
52{
53 return cppu::supportsService(this, _rServiceName);
54}
55
57 , ODescriptor(ODescriptor_BASE::rBHelper, _bCase, true)
59{
60}
61
62OKey::OKey(const OUString& Name,std::shared_ptr<KeyProperties> _xProps, bool _bCase)
64 ,ODescriptor(ODescriptor_BASE::rBHelper, _bCase)
65 ,m_aProps(std::move(_xProps))
66{
67 m_Name = Name;
68}
69//OKey::OKey( const OUString& _Name,
70// const OUString& _ReferencedTable,
71// sal_Int32 _Type,
72// sal_Int32 _UpdateRule,
73// sal_Int32 _DeleteRule,
74// sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
75// ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
76// ,m_ReferencedTable(_ReferencedTable)
77// ,m_Type(_Type)
78// ,m_UpdateRule(_UpdateRule)
79// ,m_DeleteRule(_DeleteRule)
80// ,m_pColumns(NULL)
81//{
82// m_Name = _Name;
83//}
84
86{
87}
88
89Any SAL_CALL OKey::queryInterface( const Type & rType )
90{
91 Any aRet = ODescriptor::queryInterface( rType);
92 if(!aRet.hasValue())
93 {
94 if(!isNew())
95 aRet = OKey_BASE::queryInterface(rType);
96 if(!aRet.hasValue())
97 aRet = ODescriptor_BASE::queryInterface( rType);
98 }
99
100 return aRet;
101}
102
103Sequence< Type > SAL_CALL OKey::getTypes( )
104{
105 if(isNew())
106 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
107
108 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OKey_BASE::getTypes());
109}
110
112{
114
115 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
116
121}
122
123void SAL_CALL OKey::disposing()
124{
126
127 ::osl::MutexGuard aGuard(m_aMutex);
128
129 if(m_pColumns)
130 m_pColumns->disposing();
131
132 ODescriptor_BASE::disposing();
133}
134
136{
137 return doCreateArrayHelper();
138}
139
141{
142 return *getArrayHelper(isNew() ? 1 : 0);
143}
144
145Reference< css::container::XNameAccess > SAL_CALL OKey::getColumns( )
146{
147 ::osl::MutexGuard aGuard(m_aMutex);
148 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
149
150 try
151 {
152 if ( !m_pColumns )
154 }
155 catch( const RuntimeException& )
156 {
157 // allowed to leave this method
158 throw;
159 }
160 catch( const Exception& )
161 {
162 // allowed
163 }
164
165 return m_pColumns.get();
166}
167
168Reference< XPropertySet > SAL_CALL OKey::createDataDescriptor( )
169{
170 ::osl::MutexGuard aGuard(m_aMutex);
171 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
172
173
174 return this;
175}
176
177css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OKey::getPropertySetInfo( )
178{
179 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
180}
181
182OUString SAL_CALL OKey::getName( )
183{
184 return m_Name;
185}
186
187void SAL_CALL OKey::setName( const OUString& /*aName*/ )
188{
189}
190
191// XInterface
192void SAL_CALL OKey::acquire() noexcept
193{
194 ODescriptor_BASE::acquire();
195}
196
197void SAL_CALL OKey::release() noexcept
198{
199 ODescriptor_BASE::release();
200}
201
202
203/* 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
std::shared_ptr< KeyProperties > m_aProps
Definition: VKey.hxx:68
virtual void SAL_CALL setName(const OUString &aName) override
Definition: VKey.cxx:187
virtual void construct() override
Definition: VKey.cxx:111
virtual void SAL_CALL disposing() override
Definition: VKey.cxx:123
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: VKey.cxx:103
virtual void SAL_CALL release() noexcept override
Definition: VKey.cxx:197
virtual void SAL_CALL acquire() noexcept override
Definition: VKey.cxx:192
virtual ~OKey() override
Definition: VKey.cxx:85
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: VKey.cxx:177
virtual OUString SAL_CALL getName() override
Definition: VKey.cxx:182
std::unique_ptr< OCollection > m_pColumns
Definition: VKey.hxx:70
virtual ::cppu::IPropertyArrayHelper * createArrayHelper(sal_Int32 _nId) const override
Definition: VKey.cxx:135
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: VKey.cxx:140
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
Definition: VKey.cxx:145
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: VKey.cxx:89
OKey(bool _bCase)
Definition: VKey.cxx:56
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
Definition: VKey.cxx:168
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
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)
std::shared_ptr< T > make_shared(Args &&... args)
#define PROPERTY_ID_REFERENCEDTABLE
Definition: propertyids.hxx:61
#define PROPERTY_ID_TYPE
Definition: propertyids.hxx:51
#define PROPERTY_ID_DELETERULE
Definition: propertyids.hxx:63
#define PROPERTY_ID_UPDATERULE
Definition: propertyids.hxx:62
uno::Sequence< beans::Property > m_aProps
OUString Name
unsigned char sal_Bool