tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / sdbcx / VKey.cxx
blob0780d13fc9447c677f00cf3140d08de03cf88816
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <sdbcx/VKey.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <com/sun/star/sdbc/KeyRule.hpp>
23 #include <comphelper/sequence.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <connectivity/sdbcx/VCollection.hxx>
26 #include <TConnection.hxx>
27 #include <utility>
29 using namespace connectivity;
30 using namespace connectivity::sdbcx;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::sdbcx;
34 using namespace ::com::sun::star::container;
35 using namespace ::com::sun::star::lang;
38 OUString SAL_CALL OKey::getImplementationName( )
40 if(isNew())
41 return u"com.sun.star.sdbcx.VKeyDescriptor"_ustr;
42 return u"com.sun.star.sdbcx.VKey"_ustr;
45 css::uno::Sequence< OUString > SAL_CALL OKey::getSupportedServiceNames( )
47 return { isNew()?u"com.sun.star.sdbcx.KeyDescriptor"_ustr:u"com.sun.star.sdbcx.Key"_ustr };
50 sal_Bool SAL_CALL OKey::supportsService( const OUString& _rServiceName )
52 return cppu::supportsService(this, _rServiceName);
55 OKey::OKey(bool _bCase) : ODescriptor_BASE(m_aMutex)
56 , ODescriptor(ODescriptor_BASE::rBHelper, _bCase, true)
57 , m_aProps(std::make_shared<KeyProperties>())
61 OKey::OKey(const OUString& Name,std::shared_ptr<KeyProperties> _xProps, bool _bCase)
62 : ODescriptor_BASE(m_aMutex)
63 ,ODescriptor(ODescriptor_BASE::rBHelper, _bCase)
64 ,m_aProps(std::move(_xProps))
66 m_Name = Name;
68 //OKey::OKey( const OUString& _Name,
69 // const OUString& _ReferencedTable,
70 // sal_Int32 _Type,
71 // sal_Int32 _UpdateRule,
72 // sal_Int32 _DeleteRule,
73 // sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
74 // ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
75 // ,m_ReferencedTable(_ReferencedTable)
76 // ,m_Type(_Type)
77 // ,m_UpdateRule(_UpdateRule)
78 // ,m_DeleteRule(_DeleteRule)
79 // ,m_pColumns(NULL)
80 //{
81 // m_Name = _Name;
82 //}
84 OKey::~OKey( )
88 Any SAL_CALL OKey::queryInterface( const Type & rType )
90 Any aRet = ODescriptor::queryInterface( rType);
91 if(!aRet.hasValue())
93 if(!isNew())
94 aRet = OKey_BASE::queryInterface(rType);
95 if(!aRet.hasValue())
96 aRet = ODescriptor_BASE::queryInterface( rType);
99 return aRet;
102 Sequence< Type > SAL_CALL OKey::getTypes( )
104 if(isNew())
105 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
107 return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OKey_BASE::getTypes());
110 void OKey::construct()
112 ODescriptor::construct();
114 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
116 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE), PROPERTY_ID_REFERENCEDTABLE, nAttrib,&m_aProps->m_ReferencedTable, ::cppu::UnoType<OUString>::get());
117 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_aProps->m_Type, ::cppu::UnoType<sal_Int32>::get());
118 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_UPDATERULE), PROPERTY_ID_UPDATERULE, nAttrib,&m_aProps->m_UpdateRule, ::cppu::UnoType<sal_Int32>::get());
119 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE), PROPERTY_ID_DELETERULE, nAttrib,&m_aProps->m_DeleteRule, ::cppu::UnoType<sal_Int32>::get());
122 void SAL_CALL OKey::disposing()
124 OPropertySetHelper::disposing();
126 ::osl::MutexGuard aGuard(m_aMutex);
128 if(m_pColumns)
129 m_pColumns->disposing();
131 ODescriptor_BASE::disposing();
134 ::cppu::IPropertyArrayHelper* OKey::createArrayHelper( sal_Int32 /*_nId*/ ) const
136 return doCreateArrayHelper();
139 ::cppu::IPropertyArrayHelper & OKey::getInfoHelper()
141 return *getArrayHelper(isNew() ? 1 : 0);
144 Reference< css::container::XNameAccess > SAL_CALL OKey::getColumns( )
146 ::osl::MutexGuard aGuard(m_aMutex);
147 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
151 if ( !m_pColumns )
152 refreshColumns();
154 catch( const RuntimeException& )
156 // allowed to leave this method
157 throw;
159 catch( const Exception& )
161 // allowed
164 return m_pColumns.get();
167 Reference< XPropertySet > SAL_CALL OKey::createDataDescriptor( )
169 ::osl::MutexGuard aGuard(m_aMutex);
170 checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
173 return this;
176 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OKey::getPropertySetInfo( )
178 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
181 OUString SAL_CALL OKey::getName( )
183 return m_Name;
186 void SAL_CALL OKey::setName( const OUString& /*aName*/ )
190 // XInterface
191 void SAL_CALL OKey::acquire() noexcept
193 ODescriptor_BASE::acquire();
196 void SAL_CALL OKey::release() noexcept
198 ODescriptor_BASE::release();
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */