Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include <connectivity/sdbcx/VDescriptor.hxx>
21 : : #include <cppuhelper/queryinterface.hxx>
22 : :
23 : : #include <functional>
24 : : #include <algorithm>
25 : : #include <string.h>
26 : :
27 : : namespace connectivity
28 : : {
29 : : namespace sdbcx
30 : : {
31 : : using namespace ::com::sun::star::uno;
32 : : using namespace ::com::sun::star::lang;
33 : : using namespace ::com::sun::star::beans;
34 : :
35 : : // =========================================================================
36 : : // = ODescriptor
37 : : // =========================================================================
38 : : // -------------------------------------------------------------------------
39 : 4148 : ODescriptor::ODescriptor(::cppu::OBroadcastHelper& _rBHelper,sal_Bool _bCase, sal_Bool _bNew)
40 : : :ODescriptor_PBASE(_rBHelper)
41 : : ,m_aCase(_bCase)
42 : 4148 : ,m_bNew(_bNew)
43 : : {
44 : 4148 : }
45 : :
46 : : // -------------------------------------------------------------------------
47 : : // com::sun::star::lang::XUnoTunnel
48 : 0 : sal_Int64 SAL_CALL ODescriptor::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
49 : : {
50 [ # # ][ # # ]: 0 : return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
[ # # ]
51 : : ? reinterpret_cast< sal_Int64 >( this )
52 [ # # # # ]: 0 : : 0;
53 : : }
54 : :
55 : : // -----------------------------------------------------------------------------
56 : 360 : ODescriptor* ODescriptor::getImplementation( const Reference< XInterface >& _rxSomeComp )
57 : : {
58 [ + - ]: 360 : Reference< XUnoTunnel > xTunnel( _rxSomeComp, UNO_QUERY );
59 [ - + ]: 360 : if ( xTunnel.is() )
60 [ # # ][ # # ]: 0 : return reinterpret_cast< ODescriptor* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
[ # # ][ # # ]
61 : 360 : return NULL;
62 : : }
63 : :
64 : : // -----------------------------------------------------------------------------
65 : : namespace
66 : : {
67 : : struct ResetROAttribute : public ::std::unary_function< Property, void >
68 : : {
69 : 0 : void operator ()( Property& _rProperty ) const
70 : : {
71 : 0 : _rProperty.Attributes &= ~PropertyAttribute::READONLY;
72 : 0 : }
73 : : };
74 : : struct SetROAttribute : public ::std::unary_function< Property, void >
75 : : {
76 : 800 : void operator ()( Property& _rProperty ) const
77 : : {
78 : 800 : _rProperty.Attributes |= PropertyAttribute::READONLY;
79 : 800 : }
80 : : };
81 : : }
82 : :
83 : : // -----------------------------------------------------------------------------
84 : 72 : ::cppu::IPropertyArrayHelper* ODescriptor::doCreateArrayHelper() const
85 : : {
86 [ + - ]: 72 : Sequence< Property > aProperties;
87 [ + - ]: 72 : describeProperties( aProperties );
88 : :
89 [ - + ]: 72 : if ( isNew() )
90 [ # # ][ # # ]: 0 : ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), ResetROAttribute() );
91 : : else
92 [ + - ][ + - ]: 72 : ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), SetROAttribute() );
93 : :
94 [ + - ][ + - ]: 72 : return new ::cppu::OPropertyArrayHelper( aProperties );
95 : : }
96 : :
97 : : // -----------------------------------------------------------------------------
98 : 0 : sal_Bool ODescriptor::isNew( const Reference< XInterface >& _rxDescriptor )
99 : : {
100 : 0 : ODescriptor* pImplementation = getImplementation( _rxDescriptor );
101 [ # # ]: 0 : return pImplementation != NULL ? pImplementation->isNew() : sal_False;
102 : : }
103 : :
104 : : // -----------------------------------------------------------------------------
105 : 0 : Sequence< sal_Int8 > ODescriptor::getUnoTunnelImplementationId()
106 : : {
107 : : static ::cppu::OImplementationId * pId = 0;
108 [ # # ]: 0 : if (! pId)
109 : : {
110 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
111 [ # # ]: 0 : if (! pId)
112 : : {
113 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
114 : 0 : pId = &aId;
115 [ # # ]: 0 : }
116 : : }
117 : 0 : return pId->getImplementationId();
118 : : }
119 : :
120 : : // -----------------------------------------------------------------------------
121 : 20840 : Any SAL_CALL ODescriptor::queryInterface( const Type & rType ) throw(RuntimeException)
122 : : {
123 [ + - ]: 20840 : Any aRet = ::cppu::queryInterface(rType,static_cast< XUnoTunnel*> (this));
124 [ + + ][ + - ]: 20840 : return aRet.hasValue() ? aRet : ODescriptor_PBASE::queryInterface(rType);
125 : : }
126 : :
127 : : // -----------------------------------------------------------------------------
128 : 0 : void ODescriptor::setNew(sal_Bool _bNew)
129 : : {
130 : 0 : m_bNew = _bNew;
131 : 0 : }
132 : :
133 : : // -----------------------------------------------------------------------------
134 : 0 : Sequence< Type > SAL_CALL ODescriptor::getTypes( ) throw(RuntimeException)
135 : : {
136 [ # # ]: 0 : ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
137 [ # # ]: 0 : ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
138 [ # # ]: 0 : ::getCppuType( (const Reference< XPropertySet > *)0 ),
139 [ # # ][ # # ]: 0 : ::getCppuType( (const Reference< XUnoTunnel > *)0 ));
[ # # ][ # # ]
140 [ # # ][ # # ]: 0 : return aTypes.getTypes();
141 : : }
142 : :
143 : : }
144 : : }
145 : :
146 : :
147 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|