1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VDescriptor.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include <connectivity/sdbcx/VDescriptor.hxx>
34 #include <cppuhelper/queryinterface.hxx>
39 namespace connectivity
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::lang
;
45 using namespace ::com::sun::star::beans
;
47 // =========================================================================
49 // =========================================================================
50 // -------------------------------------------------------------------------
51 ODescriptor::ODescriptor(::cppu::OBroadcastHelper
& _rBHelper
,sal_Bool _bCase
, sal_Bool _bNew
)
52 :ODescriptor_PBASE(_rBHelper
)
58 // -------------------------------------------------------------------------
59 // com::sun::star::lang::XUnoTunnel
60 sal_Int64 SAL_CALL
ODescriptor::getSomething( const Sequence
< sal_Int8
>& rId
) throw(RuntimeException
)
62 return (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
63 ? reinterpret_cast< sal_Int64
>( this )
67 // -----------------------------------------------------------------------------
68 ODescriptor
* ODescriptor::getImplementation( const Reference
< XInterface
>& _rxSomeComp
)
70 Reference
< XUnoTunnel
> xTunnel( _rxSomeComp
, UNO_QUERY
);
72 return reinterpret_cast< ODescriptor
* >( xTunnel
->getSomething( getUnoTunnelImplementationId() ) );
76 // -----------------------------------------------------------------------------
79 struct ResetROAttribute
: public ::std::unary_function
< Property
, void >
81 void operator ()( Property
& _rProperty
) const
83 _rProperty
.Attributes
&= ~PropertyAttribute::READONLY
;
86 struct SetROAttribute
: public ::std::unary_function
< Property
, void >
88 void operator ()( Property
& _rProperty
) const
90 _rProperty
.Attributes
|= PropertyAttribute::READONLY
;
95 // -----------------------------------------------------------------------------
96 ::cppu::IPropertyArrayHelper
* ODescriptor::doCreateArrayHelper() const
98 Sequence
< Property
> aProperties
;
99 describeProperties( aProperties
);
102 ::std::for_each( aProperties
.getArray(), aProperties
.getArray() + aProperties
.getLength(), ResetROAttribute() );
104 ::std::for_each( aProperties
.getArray(), aProperties
.getArray() + aProperties
.getLength(), SetROAttribute() );
106 return new ::cppu::OPropertyArrayHelper( aProperties
);
109 // -----------------------------------------------------------------------------
110 sal_Bool
ODescriptor::isNew( const Reference
< XInterface
>& _rxDescriptor
)
112 ODescriptor
* pImplementation
= getImplementation( _rxDescriptor
);
113 return pImplementation
!= NULL
? pImplementation
->isNew() : sal_False
;
116 // -----------------------------------------------------------------------------
117 Sequence
< sal_Int8
> ODescriptor::getUnoTunnelImplementationId()
119 static ::cppu::OImplementationId
* pId
= 0;
122 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
125 static ::cppu::OImplementationId aId
;
129 return pId
->getImplementationId();
132 // -----------------------------------------------------------------------------
133 Any SAL_CALL
ODescriptor::queryInterface( const Type
& rType
) throw(RuntimeException
)
135 Any aRet
= ::cppu::queryInterface(rType
,static_cast< XUnoTunnel
*> (this));
136 return aRet
.hasValue() ? aRet
: ODescriptor_PBASE::queryInterface(rType
);
139 // -----------------------------------------------------------------------------
140 void ODescriptor::setNew(sal_Bool _bNew
)
145 // -----------------------------------------------------------------------------
146 Sequence
< Type
> SAL_CALL
ODescriptor::getTypes( ) throw(RuntimeException
)
148 ::cppu::OTypeCollection
aTypes( ::getCppuType( (const Reference
< XMultiPropertySet
> *)0 ),
149 ::getCppuType( (const Reference
< XFastPropertySet
> *)0 ),
150 ::getCppuType( (const Reference
< XPropertySet
> *)0 ),
151 ::getCppuType( (const Reference
< XUnoTunnel
> *)0 ));
152 return aTypes
.getTypes();