bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / sdbcx / VDescriptor.cxx
blob0be99ce8b164d7f4dc344df10c58bd4d1b570e0c
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 <connectivity/sdbcx/VDescriptor.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <cppuhelper/queryinterface.hxx>
23 #include <cppuhelper/typeprovider.hxx>
25 #include <algorithm>
26 #include <string.h>
28 namespace connectivity
30 namespace sdbcx
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::beans;
37 // = ODescriptor
40 ODescriptor::ODescriptor(::cppu::OBroadcastHelper& _rBHelper, bool _bCase, bool _bNew)
41 :ODescriptor_PBASE(_rBHelper)
42 ,m_aCase(_bCase)
43 ,m_bNew(_bNew)
48 // css::lang::XUnoTunnel
49 sal_Int64 SAL_CALL ODescriptor::getSomething( const Sequence< sal_Int8 >& rId )
51 return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
52 ? reinterpret_cast< sal_Int64 >( this )
53 : 0;
57 ODescriptor* ODescriptor::getImplementation( const Reference< XInterface >& _rxSomeComp )
59 Reference< XUnoTunnel > xTunnel( _rxSomeComp, UNO_QUERY );
60 if ( xTunnel.is() )
61 return reinterpret_cast< ODescriptor* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
62 return nullptr;
66 namespace
68 struct ResetROAttribute
70 void operator ()( Property& _rProperty ) const
72 _rProperty.Attributes &= ~PropertyAttribute::READONLY;
75 struct SetROAttribute
77 void operator ()( Property& _rProperty ) const
79 _rProperty.Attributes |= PropertyAttribute::READONLY;
85 ::cppu::IPropertyArrayHelper* ODescriptor::doCreateArrayHelper() const
87 Sequence< Property > aProperties;
88 describeProperties( aProperties );
90 if ( isNew() )
91 std::for_each( aProperties.begin(), aProperties.end(), ResetROAttribute() );
92 else
93 std::for_each( aProperties.begin(), aProperties.end(), SetROAttribute() );
95 return new ::cppu::OPropertyArrayHelper( aProperties );
99 bool ODescriptor::isNew( const Reference< XInterface >& _rxDescriptor )
101 ODescriptor* pImplementation = getImplementation( _rxDescriptor );
102 return pImplementation && pImplementation->isNew();
106 Sequence< sal_Int8 > ODescriptor::getUnoTunnelImplementationId()
108 static ::cppu::OImplementationId implId;
110 return implId.getImplementationId();
114 Any SAL_CALL ODescriptor::queryInterface( const Type & rType )
116 Any aRet = ::cppu::queryInterface(rType,static_cast< XUnoTunnel*> (this));
117 return aRet.hasValue() ? aRet : ODescriptor_PBASE::queryInterface(rType);
121 void ODescriptor::setNew(bool _bNew)
123 m_bNew = _bNew;
127 Sequence< Type > SAL_CALL ODescriptor::getTypes( )
129 ::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(),
130 cppu::UnoType<XFastPropertySet>::get(),
131 cppu::UnoType<XPropertySet>::get(),
132 cppu::UnoType<XUnoTunnel>::get());
133 return aTypes.getTypes();
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */