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/VDescriptor.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <cppuhelper/queryinterface.hxx>
23 #include <cppuhelper/typeprovider.hxx>
28 namespace connectivity
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::lang
;
34 using namespace ::com::sun::star::beans
;
40 ODescriptor::ODescriptor(::cppu::OBroadcastHelper
& _rBHelper
, bool _bCase
, bool _bNew
)
41 :ODescriptor_PBASE(_rBHelper
)
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 )
57 ODescriptor
* ODescriptor::getImplementation( const Reference
< XInterface
>& _rxSomeComp
)
59 Reference
< XUnoTunnel
> xTunnel( _rxSomeComp
, UNO_QUERY
);
61 return reinterpret_cast< ODescriptor
* >( xTunnel
->getSomething( getUnoTunnelImplementationId() ) );
68 struct ResetROAttribute
70 void operator ()( Property
& _rProperty
) const
72 _rProperty
.Attributes
&= ~PropertyAttribute::READONLY
;
77 void operator ()( Property
& _rProperty
) const
79 _rProperty
.Attributes
|= PropertyAttribute::READONLY
;
85 ::cppu::IPropertyArrayHelper
* ODescriptor::doCreateArrayHelper() const
87 Sequence
< Property
> aProperties
;
88 describeProperties( aProperties
);
91 std::for_each( aProperties
.begin(), aProperties
.end(), ResetROAttribute() );
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
)
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: */