LibreOffice Module connectivity (master) 1
pq_xbase.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * Effective License of whole file:
5 *
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.
9 *
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.
14 *
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,
18 * MA 02111-1307 USA
19 *
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 *
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
24 *
25 * Copyright: 2000 by Sun Microsystems, Inc.
26 *
27 * Contributor(s): Joerg Budischewski
28 *
29 * All parts contributed on or after August 2011:
30 *
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/.
34 *
35 ************************************************************************/
36
39#include <utility>
40
41#include "pq_statics.hxx"
42#include "pq_tools.hxx"
43#include "pq_xbase.hxx"
44
45using osl::MutexGuard;
46
47using com::sun::star::uno::Any;
50using com::sun::star::uno::RuntimeException;
51
52using com::sun::star::beans::Property;
53using com::sun::star::beans::XPropertySetInfo;
55
56namespace pq_sdbc_driver
57{
58
60 OUString implName,
61 const css::uno::Sequence< OUString > &supportedServices,
62 const ::rtl::Reference< comphelper::RefCountedMutex >& refMutex,
63 css::uno::Reference< css::sdbc::XConnection > conn,
64 ConnectionSettings *pSettings,
65 cppu::IPropertyArrayHelper & props /* must survive this object !*/ )
66 : ReflectionBase_BASE( refMutex->GetMutex() ),
67 OPropertySetHelper( ReflectionBase_BASE::rBHelper ),
68 m_implName(std::move( implName )),
69 m_supportedServices( supportedServices ),
70 m_xMutex( refMutex ),
71 m_conn(std::move( conn )),
72 m_pSettings( pSettings ),
73 m_propsDesc( props ),
74 m_values( props.getProperties().getLength() )
75{}
76
78{
79 return m_propsDesc;
80}
81
83 css::uno::Any & rConvertedValue,
84 css::uno::Any & rOldValue,
85 sal_Int32 nHandle,
86 const css::uno::Any& rValue )
87{
88
89 rOldValue = m_values[nHandle];
90 rConvertedValue = rValue; // TODO !!! implement correct conversion !
91 m_values[nHandle] = rValue;
92 return true;
93}
94
96 const OUString & name, const css::uno::Any & value )
97{
99 if( -1 == nHandle )
100 {
101 throw css::uno::RuntimeException(
102 "Unknown property '" + name + "' in " + m_implName,
103 *this );
104 }
106}
107
109 sal_Int32 nHandle,
110 const css::uno::Any& rValue )
111{
112// OUString s;
113// rValue >>= s;
114// printf( "setting value (handle %d):%s\n" ,
115// nHandle, OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
116 m_values[nHandle] = rValue;
117}
118
120 css::uno::Any& rValue,
121 sal_Int32 nHandle ) const
122{
123 rValue = m_values[nHandle];
124// OUString s;
125// rValue >>= s;
126// printf( "getting value (handle %d):%s\n" ,
127// nHandle, OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
128
129}
130
132{
133 return OPropertySetHelper::createPropertySetInfo( m_propsDesc );
134}
135
137{
138 return m_implName;
139}
140
141sal_Bool ReflectionBase::supportsService(const OUString& ServiceName)
142{
144}
145
147{
148 return m_supportedServices;
149}
150
151
153{
154 osl::MutexGuard guard( m_xMutex->GetMutex() );
155 static Sequence< css::uno::Type > collection(
156 ::comphelper::concatSequences(
158 ReflectionBase_BASE::getTypes() ) );
159 return collection;
160}
161
162
164 const css::uno::Type & reqType )
165{
166 Any ret = ReflectionBase_BASE::queryInterface( reqType );
167 return ret.hasValue() ? ret : OPropertySetHelper::queryInterface( reqType );
168
169}
170
172{
173 return css::uno::Sequence<sal_Int8>();
174}
175
177{
178 Reference< XPropertySetInfo > info = set->getPropertySetInfo();
179 if( info.is () )
180 {
182
183 const Sequence< Property > props = info->getProperties();
184 for( Property const & prop : props )
185 {
186 if( myPropInfo->hasPropertyByName( prop.Name ) )
188 prop.Name, set->getPropertyValue( prop.Name ) );
189 }
190 }
191}
192
194{
195 Statics & st = getStatics();
196 if( getInfoHelper().hasPropertyByName( st.SCHEMA_NAME ) )
197 return concatQualified(
198 extractStringProperty( this, getStatics().SCHEMA_NAME ),
200 else
201 return extractStringProperty( this, getStatics().NAME );
202}
203
204
205void ReflectionBase::setName( const OUString& /* aName */ )
206{
207 throw RuntimeException(
208 "pq_sdbc::ReflectionBase::setName not implemented",
209 *this );
210 //setPropertyValue( getStatics().NAME , makeAny( aName ) );
211}
212
213
214}
215
216/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NAME
virtual sal_Int32 SAL_CALL getHandleByName(const ::rtl::OUString &rPropertyName)=0
css::uno::Sequence< css::uno::Type > getTypes()
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &reqType) override
Definition: pq_xbase.cxx:163
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: pq_xbase.cxx:171
void copyValuesFrom(const css::uno::Reference< css::beans::XPropertySet > &set)
Definition: pq_xbase.cxx:176
void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: pq_xbase.cxx:119
virtual OUString SAL_CALL getImplementationName() override
Definition: pq_xbase.cxx:136
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: pq_xbase.cxx:131
virtual cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: pq_xbase.cxx:77
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
Definition: pq_xbase.hxx:61
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: pq_xbase.cxx:82
virtual void SAL_CALL setName(const OUString &aName) override
Definition: pq_xbase.cxx:205
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: pq_xbase.cxx:146
const css::uno::Sequence< OUString > m_supportedServices
Definition: pq_xbase.hxx:60
std::vector< css::uno::Any > m_values
Definition: pq_xbase.hxx:65
cppu::IPropertyArrayHelper & m_propsDesc
Definition: pq_xbase.hxx:64
virtual OUString SAL_CALL getName() override
Definition: pq_xbase.cxx:193
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: pq_xbase.cxx:108
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: pq_xbase.cxx:152
ReflectionBase(OUString implName, const css::uno::Sequence< OUString > &supportedServices, const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, css::uno::Reference< css::sdbc::XConnection > conn, ConnectionSettings *pSettings, cppu::IPropertyArrayHelper &props)
Definition: pq_xbase.cxx:59
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: pq_xbase.cxx:141
void setPropertyValue_NoBroadcast_public(const OUString &name, const css::uno::Any &value)
Definition: pq_xbase.cxx:95
Any value
double getLength(const B2DPolygon &rCandidate)
void set(css::uno::UnoInterfaceReference const &value)
class SAL_NO_VTABLE XPropertySet
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Statics & getStatics()
Definition: pq_statics.cxx:112
OUString concatQualified(std::u16string_view a, std::u16string_view b)
Definition: pq_tools.cxx:90
::cppu::WeakComponentImplHelper< css::lang::XServiceInfo, css::sdbcx::XDataDescriptorFactory, css::container::XNamed > ReflectionBase_BASE
Definition: pq_xbase.hxx:52
OUString extractStringProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
Definition: pq_tools.cxx:204
dictionary props
rtl::Reference< Connection > m_conn
OUString name
Definition: pq_statics.cxx:74
sal_Int32 nHandle
const char * implName
unsigned char sal_Bool