1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #include <cppuhelper/supportsservice.hxx>
38 #include <comphelper/sequence.hxx>
40 #include "pq_tools.hxx"
41 #include "pq_xbase.hxx"
43 using osl::MutexGuard
;
45 using com::sun::star::uno::Any
;
46 using com::sun::star::uno::Sequence
;
47 using com::sun::star::uno::Reference
;
48 using com::sun::star::uno::RuntimeException
;
50 using com::sun::star::beans::Property
;
51 using com::sun::star::beans::XPropertySetInfo
;
52 using com::sun::star::beans::XPropertySet
;
54 namespace pq_sdbc_driver
57 ReflectionBase::ReflectionBase(
58 const OUString
&implName
,
59 const css::uno::Sequence
< OUString
> &supportedServices
,
60 const ::rtl::Reference
< comphelper::RefCountedMutex
>& refMutex
,
61 const css::uno::Reference
< css::sdbc::XConnection
> &conn
,
62 ConnectionSettings
*pSettings
,
63 cppu::IPropertyArrayHelper
& props
/* must survive this object !*/ )
64 : ReflectionBase_BASE( refMutex
->GetMutex() ),
65 OPropertySetHelper( ReflectionBase_BASE::rBHelper
),
66 m_implName( implName
),
67 m_supportedServices( supportedServices
),
70 m_pSettings( pSettings
),
72 m_values( props
.getProperties().getLength() )
75 cppu::IPropertyArrayHelper
& ReflectionBase::getInfoHelper()
80 sal_Bool
ReflectionBase::convertFastPropertyValue(
81 css::uno::Any
& rConvertedValue
,
82 css::uno::Any
& rOldValue
,
84 const css::uno::Any
& rValue
)
87 rOldValue
= m_values
[nHandle
];
88 rConvertedValue
= rValue
; // TODO !!! implement correct conversion !
89 m_values
[nHandle
] = rValue
;
93 void ReflectionBase::setPropertyValue_NoBroadcast_public(
94 const OUString
& name
, const css::uno::Any
& value
)
96 sal_Int32 nHandle
= m_propsDesc
.getHandleByName( name
);
99 throw css::uno::RuntimeException(
100 "Unknown property '" + name
+ "' in " + m_implName
,
103 setFastPropertyValue_NoBroadcast( nHandle
, value
);
106 void ReflectionBase::setFastPropertyValue_NoBroadcast(
108 const css::uno::Any
& rValue
)
112 // printf( "setting value (handle %d):%s\n" ,
113 // nHandle, OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
114 m_values
[nHandle
] = rValue
;
117 void ReflectionBase::getFastPropertyValue(
118 css::uno::Any
& rValue
,
119 sal_Int32 nHandle
) const
121 rValue
= m_values
[nHandle
];
124 // printf( "getting value (handle %d):%s\n" ,
125 // nHandle, OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
129 Reference
< css::beans::XPropertySetInfo
> ReflectionBase::getPropertySetInfo()
131 return OPropertySetHelper::createPropertySetInfo( m_propsDesc
);
134 OUString
ReflectionBase::getImplementationName()
139 sal_Bool
ReflectionBase::supportsService(const OUString
& ServiceName
)
141 return cppu::supportsService(this, ServiceName
);
144 Sequence
< OUString
> ReflectionBase::getSupportedServiceNames()
146 return m_supportedServices
;
150 Sequence
< css::uno::Type
> ReflectionBase::getTypes()
152 osl::MutexGuard
guard( m_xMutex
->GetMutex() );
153 static Sequence
< css::uno::Type
> collection(
154 ::comphelper::concatSequences(
155 ::cppu::OPropertySetHelper::getTypes(),
156 ReflectionBase_BASE::getTypes() ) );
161 css::uno::Any
ReflectionBase::queryInterface(
162 const css::uno::Type
& reqType
)
164 Any ret
= ReflectionBase_BASE::queryInterface( reqType
);
165 return ret
.hasValue() ? ret
: OPropertySetHelper::queryInterface( reqType
);
169 Sequence
< sal_Int8
> ReflectionBase::getImplementationId()
171 return css::uno::Sequence
<sal_Int8
>();
174 void ReflectionBase::copyValuesFrom( const Reference
< XPropertySet
> & set
)
176 Reference
< XPropertySetInfo
> info
= set
->getPropertySetInfo();
179 Reference
< XPropertySetInfo
> myPropInfo
= getPropertySetInfo();
181 const Sequence
< Property
> props
= info
->getProperties();
182 for( Property
const & prop
: props
)
184 if( myPropInfo
->hasPropertyByName( prop
.Name
) )
185 setPropertyValue_NoBroadcast_public(
186 prop
.Name
, set
->getPropertyValue( prop
.Name
) );
191 OUString
ReflectionBase::getName( )
193 Statics
& st
= getStatics();
194 if( getInfoHelper().hasPropertyByName( st
.SCHEMA_NAME
) )
195 return concatQualified(
196 extractStringProperty( this, getStatics().SCHEMA_NAME
),
197 extractStringProperty( this, getStatics().NAME
) );
199 return extractStringProperty( this, getStatics().NAME
);
203 void ReflectionBase::setName( const OUString
& /* aName */ )
205 throw RuntimeException(
206 "pq_sdbc::ReflectionBase::setName not implemented",
208 //setPropertyValue( getStatics().NAME , makeAny( aName ) );
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */