1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <connectivity/sdbcx/VKey.hxx>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <com/sun/star/sdbc/KeyRule.hpp>
24 #include <comphelper/sequence.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <connectivity/sdbcx/VColumn.hxx>
27 #include <connectivity/sdbcx/VCollection.hxx>
28 #include <TConnection.hxx>
30 using namespace connectivity
;
31 using namespace connectivity::sdbcx
;
32 using namespace ::com::sun::star::beans
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::sdbc
;
35 using namespace ::com::sun::star::sdbcx
;
36 using namespace ::com::sun::star::container
;
37 using namespace ::com::sun::star::lang
;
40 OUString SAL_CALL
OKey::getImplementationName( )
43 return OUString("com.sun.star.sdbcx.VKeyDescriptor");
44 return OUString("com.sun.star.sdbcx.VKey");
47 css::uno::Sequence
< OUString
> SAL_CALL
OKey::getSupportedServiceNames( )
49 css::uno::Sequence
< OUString
> aSupported(1);
51 aSupported
[0] = "com.sun.star.sdbcx.KeyDescriptor";
53 aSupported
[0] = "com.sun.star.sdbcx.Key";
58 sal_Bool SAL_CALL
OKey::supportsService( const OUString
& _rServiceName
)
60 return cppu::supportsService(this, _rServiceName
);
63 OKey::OKey(bool _bCase
) : ODescriptor_BASE(m_aMutex
)
64 , ODescriptor(ODescriptor_BASE::rBHelper
, _bCase
, true)
65 , m_aProps(new KeyProperties())
69 OKey::OKey(const OUString
& Name
,const std::shared_ptr
<KeyProperties
>& _rProps
, bool _bCase
)
70 : ODescriptor_BASE(m_aMutex
)
71 ,ODescriptor(ODescriptor_BASE::rBHelper
, _bCase
)
76 //OKey::OKey( const OUString& _Name,
77 // const OUString& _ReferencedTable,
79 // sal_Int32 _UpdateRule,
80 // sal_Int32 _DeleteRule,
81 // sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
82 // ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
83 // ,m_ReferencedTable(_ReferencedTable)
85 // ,m_UpdateRule(_UpdateRule)
86 // ,m_DeleteRule(_DeleteRule)
96 Any SAL_CALL
OKey::queryInterface( const Type
& rType
)
98 Any aRet
= ODescriptor::queryInterface( rType
);
102 aRet
= OKey_BASE::queryInterface(rType
);
104 aRet
= ODescriptor_BASE::queryInterface( rType
);
110 Sequence
< Type
> SAL_CALL
OKey::getTypes( )
113 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
115 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OKey_BASE::getTypes());
118 void OKey::construct()
120 ODescriptor::construct();
122 sal_Int32 nAttrib
= isNew() ? 0 : PropertyAttribute::READONLY
;
124 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE
), PROPERTY_ID_REFERENCEDTABLE
, nAttrib
,&m_aProps
->m_ReferencedTable
, ::cppu::UnoType
<OUString
>::get());
125 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE
), PROPERTY_ID_TYPE
, nAttrib
,&m_aProps
->m_Type
, ::cppu::UnoType
<sal_Int32
>::get());
126 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_UPDATERULE
), PROPERTY_ID_UPDATERULE
, nAttrib
,&m_aProps
->m_UpdateRule
, ::cppu::UnoType
<sal_Int32
>::get());
127 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE
), PROPERTY_ID_DELETERULE
, nAttrib
,&m_aProps
->m_DeleteRule
, ::cppu::UnoType
<sal_Int32
>::get());
130 void SAL_CALL
OKey::disposing()
132 OPropertySetHelper::disposing();
134 ::osl::MutexGuard
aGuard(m_aMutex
);
137 m_pColumns
->disposing();
139 ODescriptor_BASE::disposing();
142 ::cppu::IPropertyArrayHelper
* OKey::createArrayHelper( sal_Int32
/*_nId*/ ) const
144 return doCreateArrayHelper();
147 ::cppu::IPropertyArrayHelper
& OKey::getInfoHelper()
149 return *getArrayHelper(isNew() ? 1 : 0);
152 Reference
< css::container::XNameAccess
> SAL_CALL
OKey::getColumns( )
154 ::osl::MutexGuard
aGuard(m_aMutex
);
155 checkDisposed(ODescriptor_BASE::rBHelper
.bDisposed
);
162 catch( const RuntimeException
& )
164 // allowed to leave this method
167 catch( const Exception
& )
172 return m_pColumns
.get();
175 Reference
< XPropertySet
> SAL_CALL
OKey::createDataDescriptor( )
177 ::osl::MutexGuard
aGuard(m_aMutex
);
178 checkDisposed(ODescriptor_BASE::rBHelper
.bDisposed
);
184 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
OKey::getPropertySetInfo( )
186 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
189 OUString SAL_CALL
OKey::getName( )
194 void SAL_CALL
OKey::setName( const OUString
& /*aName*/ )
199 void SAL_CALL
OKey::acquire() throw()
201 ODescriptor_BASE::acquire();
204 void SAL_CALL
OKey::release() throw()
206 ODescriptor_BASE::release();
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */