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 <stringconstants.hxx>
21 #include <strings.hxx>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/sdb/CommandType.hpp>
27 #include <com/sun/star/sdbc/XConnection.hpp>
28 #include <com/sun/star/sdbc/XResultSet.hpp>
29 #include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <comphelper/broadcasthelper.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <comphelper/propertycontainer.hxx>
35 #include <comphelper/uno3.hxx>
36 #include <cppuhelper/implbase.hxx>
37 #include <cppuhelper/supportsservice.hxx>
42 using ::com::sun::star::uno::Reference
;
43 using ::com::sun::star::uno::Any
;
44 using ::com::sun::star::uno::Sequence
;
45 using ::com::sun::star::lang::XServiceInfo
;
46 using ::com::sun::star::beans::XPropertySetInfo
;
47 using ::com::sun::star::beans::Property
;
48 using ::com::sun::star::sdbc::XConnection
;
49 using ::com::sun::star::sdbc::XResultSet
;
50 using ::com::sun::star::beans::XPropertySet
;
51 using ::com::sun::star::beans::PropertyValue
;
53 namespace PropertyAttribute
= ::com::sun::star::beans::PropertyAttribute
;
54 namespace CommandType
= ::com::sun::star::sdb::CommandType
;
56 // DataAccessDescriptor
57 typedef ::comphelper::OMutexAndBroadcastHelper DataAccessDescriptor_MutexBase
;
59 typedef ::cppu::WeakImplHelper
< XServiceInfo
60 > DataAccessDescriptor_TypeBase
;
62 typedef ::comphelper::OPropertyContainer DataAccessDescriptor_PropertyBase
;
64 class DataAccessDescriptor
:public DataAccessDescriptor_MutexBase
65 ,public DataAccessDescriptor_TypeBase
66 ,public DataAccessDescriptor_PropertyBase
67 ,public ::comphelper::OPropertyArrayUsageHelper
< DataAccessDescriptor
>
70 DataAccessDescriptor();
74 DECLARE_XTYPEPROVIDER()
77 virtual OUString SAL_CALL
getImplementationName( ) override
;
78 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
79 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
82 virtual ~DataAccessDescriptor() override
;
86 virtual Reference
< XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
87 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
89 // OPropertyArrayUsageHelper
90 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
94 OUString m_sDataSourceName
;
95 OUString m_sDatabaseLocation
;
96 OUString m_sConnectionResource
;
97 Sequence
< PropertyValue
> m_aConnectionInfo
;
98 Reference
< XConnection
> m_xActiveConnection
;
100 sal_Int32 m_nCommandType
;
103 OUString m_sHavingClause
;
105 bool m_bEscapeProcessing
;
106 Reference
< XResultSet
> m_xResultSet
;
107 Sequence
< Any
> m_aSelection
;
108 bool m_bBookmarkSelection
;
109 OUString m_sColumnName
;
110 Reference
< XPropertySet
> m_xColumn
;
114 DataAccessDescriptor::DataAccessDescriptor()
115 :DataAccessDescriptor_PropertyBase( m_aBHelper
)
116 ,m_nCommandType( CommandType::COMMAND
)
117 ,m_bEscapeProcessing( true )
118 ,m_bBookmarkSelection( true )
120 registerProperty(PROPERTY_DATASOURCENAME
, PROPERTY_ID_DATASOURCENAME
, PropertyAttribute::BOUND
, &m_sDataSourceName
, cppu::UnoType
<decltype(m_sDataSourceName
)>::get());
121 registerProperty(PROPERTY_DATABASE_LOCATION
, PROPERTY_ID_DATABASE_LOCATION
, PropertyAttribute::BOUND
, &m_sDatabaseLocation
, cppu::UnoType
<decltype(m_sDatabaseLocation
)>::get());
122 registerProperty(PROPERTY_CONNECTION_RESOURCE
, PROPERTY_ID_CONNECTION_RESOURCE
, PropertyAttribute::BOUND
, &m_sConnectionResource
, cppu::UnoType
<decltype(m_sConnectionResource
)>::get());
123 registerProperty(PROPERTY_CONNECTION_INFO
, PROPERTY_ID_CONNECTION_INFO
, PropertyAttribute::BOUND
, &m_aConnectionInfo
, cppu::UnoType
<decltype(m_aConnectionInfo
)>::get());
124 registerProperty(PROPERTY_ACTIVE_CONNECTION
, PROPERTY_ID_ACTIVE_CONNECTION
, PropertyAttribute::BOUND
, &m_xActiveConnection
, cppu::UnoType
<decltype(m_xActiveConnection
)>::get());
125 registerProperty(PROPERTY_COMMAND
, PROPERTY_ID_COMMAND
, PropertyAttribute::BOUND
, &m_sCommand
, cppu::UnoType
<decltype(m_sCommand
)>::get());
126 registerProperty(PROPERTY_COMMAND_TYPE
, PROPERTY_ID_COMMAND_TYPE
, PropertyAttribute::BOUND
, &m_nCommandType
, cppu::UnoType
<decltype(m_nCommandType
)>::get());
127 registerProperty(PROPERTY_FILTER
, PROPERTY_ID_FILTER
, PropertyAttribute::BOUND
, &m_sFilter
, cppu::UnoType
<decltype(m_sFilter
)>::get());
128 registerProperty(PROPERTY_ORDER
, PROPERTY_ID_ORDER
, PropertyAttribute::BOUND
, &m_sOrder
, cppu::UnoType
<decltype(m_sOrder
)>::get());
129 registerProperty(PROPERTY_HAVING_CLAUSE
, PROPERTY_ID_HAVING_CLAUSE
, PropertyAttribute::BOUND
, &m_sHavingClause
, cppu::UnoType
<decltype(m_sHavingClause
)>::get());
130 registerProperty(PROPERTY_GROUP_BY
, PROPERTY_ID_GROUP_BY
, PropertyAttribute::BOUND
, &m_sGroupBy
, cppu::UnoType
<decltype(m_sGroupBy
)>::get());
131 registerProperty(PROPERTY_ESCAPE_PROCESSING
, PROPERTY_ID_ESCAPE_PROCESSING
, PropertyAttribute::BOUND
, &m_bEscapeProcessing
, cppu::UnoType
<decltype(m_bEscapeProcessing
)>::get());
132 registerProperty(PROPERTY_RESULT_SET
, PROPERTY_ID_RESULT_SET
, PropertyAttribute::BOUND
, &m_xResultSet
, cppu::UnoType
<decltype(m_xResultSet
)>::get());
133 registerProperty(PROPERTY_SELECTION
, PROPERTY_ID_SELECTION
, PropertyAttribute::BOUND
, &m_aSelection
, cppu::UnoType
<decltype(m_aSelection
)>::get());
134 registerProperty(PROPERTY_BOOKMARK_SELECTION
, PROPERTY_ID_BOOKMARK_SELECTION
, PropertyAttribute::BOUND
, &m_bBookmarkSelection
, cppu::UnoType
<decltype(m_bBookmarkSelection
)>::get());
135 registerProperty(PROPERTY_COLUMN_NAME
, PROPERTY_ID_COLUMN_NAME
, PropertyAttribute::BOUND
, &m_sColumnName
, cppu::UnoType
<decltype(m_sColumnName
)>::get());
136 registerProperty(PROPERTY_COLUMN
, PROPERTY_ID_COLUMN
, PropertyAttribute::BOUND
, &m_xColumn
, cppu::UnoType
<decltype(m_xColumn
)>::get());
139 DataAccessDescriptor::~DataAccessDescriptor()
143 IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor
, DataAccessDescriptor_TypeBase
, DataAccessDescriptor_PropertyBase
);
145 IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor
, DataAccessDescriptor_TypeBase
, DataAccessDescriptor_PropertyBase
);
147 OUString SAL_CALL
DataAccessDescriptor::getImplementationName()
149 return u
"com.sun.star.comp.dba.DataAccessDescriptor"_ustr
;
152 sal_Bool SAL_CALL
DataAccessDescriptor::supportsService( const OUString
& rServiceName
)
154 return cppu::supportsService(this, rServiceName
);
157 Sequence
< OUString
> SAL_CALL
DataAccessDescriptor::getSupportedServiceNames( )
159 return { u
"com.sun.star.sdb.DataAccessDescriptor"_ustr
};
162 Reference
< XPropertySetInfo
> SAL_CALL
DataAccessDescriptor::getPropertySetInfo()
164 Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
168 ::cppu::IPropertyArrayHelper
& DataAccessDescriptor::getInfoHelper()
170 return *getArrayHelper();
173 ::cppu::IPropertyArrayHelper
* DataAccessDescriptor::createArrayHelper( ) const
175 Sequence
< Property
> aProps
;
176 describeProperties( aProps
);
177 return new ::cppu::OPropertyArrayHelper( aProps
);
180 // DataAccessDescriptorFactory
181 class DataAccessDescriptorFactory
: public ::cppu::WeakImplHelper
<XServiceInfo
, css::sdb::XDataAccessDescriptorFactory
>
185 virtual OUString SAL_CALL
getImplementationName( ) override
;
186 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
187 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
189 // XDataAccessDescriptorFactory
190 virtual Reference
< XPropertySet
> SAL_CALL
createDataAccessDescriptor( ) override
;
192 DataAccessDescriptorFactory();
195 DataAccessDescriptorFactory::DataAccessDescriptorFactory()
199 OUString SAL_CALL
DataAccessDescriptorFactory::getImplementationName()
201 return u
"com.sun.star.comp.dba.DataAccessDescriptorFactory"_ustr
;
204 sal_Bool SAL_CALL
DataAccessDescriptorFactory::supportsService( const OUString
& rServiceName
)
206 return cppu::supportsService(this, rServiceName
);
209 Sequence
< OUString
> SAL_CALL
DataAccessDescriptorFactory::getSupportedServiceNames()
211 return { u
"com.sun.star.sdb.DataAccessDescriptorFactory"_ustr
};
214 Reference
< XPropertySet
> SAL_CALL
DataAccessDescriptorFactory::createDataAccessDescriptor( )
216 return new DataAccessDescriptor();
221 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
222 com_sun_star_comp_dba_DataAccessDescriptorFactory(
223 css::uno::XComponentContext
*,
224 css::uno::Sequence
<css::uno::Any
> const &)
226 return cppu::acquire(new DataAccessDescriptorFactory());
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */