LibreOffice Module dbaccess (master) 1
dataaccessdescriptor.cxx
Go to the documentation of this file.
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 <stringconstants.hxx>
21#include <strings.hxx>
22
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>
31
35#include <comphelper/uno3.hxx>
38
39namespace
40{
41
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;
52
53 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
54 namespace CommandType = ::com::sun::star::sdb::CommandType;
55
56 // DataAccessDescriptor
57 typedef ::comphelper::OMutexAndBroadcastHelper DataAccessDescriptor_MutexBase;
58
59 typedef ::cppu::WeakImplHelper< XServiceInfo
60 > DataAccessDescriptor_TypeBase;
61
62 typedef ::comphelper::OPropertyContainer DataAccessDescriptor_PropertyBase;
63
64 class DataAccessDescriptor :public DataAccessDescriptor_MutexBase
65 ,public DataAccessDescriptor_TypeBase
66 ,public DataAccessDescriptor_PropertyBase
67 ,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor >
68 {
69 public:
70 DataAccessDescriptor();
71
72 // UNO
74 DECLARE_XTYPEPROVIDER()
75
76 // XServiceInfo
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;
80
81 protected:
82 virtual ~DataAccessDescriptor() override;
83
84 protected:
85 // XPropertySet
86 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
87 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
88
89 // OPropertyArrayUsageHelper
90 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
91
92 private:
93 // </properties>
94 OUString m_sDataSourceName;
95 OUString m_sDatabaseLocation;
96 OUString m_sConnectionResource;
97 Sequence< PropertyValue > m_aConnectionInfo;
98 Reference< XConnection > m_xActiveConnection;
99 OUString m_sCommand;
100 sal_Int32 m_nCommandType;
101 OUString m_sFilter;
102 OUString m_sOrder;
103 OUString m_sHavingClause;
104 OUString m_sGroupBy;
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;
111 // </properties>
112 };
113
114 DataAccessDescriptor::DataAccessDescriptor()
115 :DataAccessDescriptor_PropertyBase( m_aBHelper )
116 ,m_nCommandType( CommandType::COMMAND )
117 ,m_bEscapeProcessing( true )
118 ,m_bBookmarkSelection( true )
119 {
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());
137 }
138
139 DataAccessDescriptor::~DataAccessDescriptor()
140 {
141 }
142
143 IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
144
145 IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
146
147 OUString SAL_CALL DataAccessDescriptor::getImplementationName()
148 {
149 return "com.sun.star.comp.dba.DataAccessDescriptor";
150 }
151
152 sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const OUString& rServiceName )
153 {
154 return cppu::supportsService(this, rServiceName);
155 }
156
157 Sequence< OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames( )
158 {
159 return { "com.sun.star.sdb.DataAccessDescriptor" };
160 }
161
162 Reference< XPropertySetInfo > SAL_CALL DataAccessDescriptor::getPropertySetInfo()
163 {
164 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
165 return xInfo;
166 }
167
168 ::cppu::IPropertyArrayHelper& DataAccessDescriptor::getInfoHelper()
169 {
170 return *getArrayHelper();
171 }
172
173 ::cppu::IPropertyArrayHelper* DataAccessDescriptor::createArrayHelper( ) const
174 {
175 Sequence< Property > aProps;
176 describeProperties( aProps );
177 return new ::cppu::OPropertyArrayHelper( aProps );
178 }
179
180 // DataAccessDescriptorFactory
181 class DataAccessDescriptorFactory: public ::cppu::WeakImplHelper<XServiceInfo, css::sdb::XDataAccessDescriptorFactory>
182 {
183 public:
184 // XServiceInfo
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;
188
189 // XDataAccessDescriptorFactory
190 virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor( ) override;
191
192 DataAccessDescriptorFactory();
193 };
194
195 DataAccessDescriptorFactory::DataAccessDescriptorFactory()
196 {
197 }
198
199 OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName()
200 {
201 return "com.sun.star.comp.dba.DataAccessDescriptorFactory";
202 }
203
204 sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const OUString& rServiceName )
205 {
206 return cppu::supportsService(this, rServiceName);
207 }
208
209 Sequence< OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames()
210 {
211 return { "com.sun.star.sdb.DataAccessDescriptorFactory" };
212 }
213
214 Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor( )
215 {
216 return new DataAccessDescriptor();
217 }
218
219}
220
221extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
223 css::uno::XComponentContext *,
224 css::uno::Sequence<css::uno::Any> const &)
225{
226 return cppu::acquire(new DataAccessDescriptorFactory());
227}
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::cppu::IPropertyArrayHelper * getArrayHelper()
sal_Int32 m_nCommandType
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dba_DataAccessDescriptorFactory(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Any m_aSelection
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OStatement, OStatementBase, OStatement_IFACE)
IMPLEMENT_FORWARD_XINTERFACE2(OStatement, OStatementBase, OStatement_IFACE)
#define PROPERTY_ID_ACTIVE_CONNECTION
#define PROPERTY_ID_DATABASE_LOCATION
#define PROPERTY_ID_HAVING_CLAUSE
#define PROPERTY_ID_RESULT_SET
#define PROPERTY_ID_ESCAPE_PROCESSING
#define PROPERTY_ID_DATASOURCENAME
#define PROPERTY_ID_COLUMN
#define PROPERTY_ID_SELECTION
#define PROPERTY_ID_FILTER
#define PROPERTY_ID_COMMAND
#define PROPERTY_ID_CONNECTION_INFO
#define PROPERTY_ID_ORDER
#define PROPERTY_ID_GROUP_BY
#define PROPERTY_ID_CONNECTION_RESOURCE
#define PROPERTY_ID_COLUMN_NAME
#define PROPERTY_ID_BOOKMARK_SELECTION
#define PROPERTY_ID_COMMAND_TYPE
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
constexpr OUStringLiteral PROPERTY_CONNECTION_RESOURCE(u"ConnectionResource")
constexpr OUStringLiteral PROPERTY_HAVING_CLAUSE(u"HavingClause")
constexpr OUStringLiteral PROPERTY_BOOKMARK_SELECTION(u"BookmarkSelection")
constexpr OUStringLiteral PROPERTY_COLUMN(u"Column")
constexpr OUStringLiteral PROPERTY_CONNECTION_INFO(u"ConnectionInfo")
constexpr OUStringLiteral PROPERTY_RESULT_SET(u"ResultSet")
constexpr OUStringLiteral PROPERTY_GROUP_BY(u"GroupBy")
constexpr OUStringLiteral PROPERTY_SELECTION(u"Selection")
constexpr OUStringLiteral PROPERTY_FILTER(u"Filter")
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION(u"ActiveConnection")
constexpr OUStringLiteral PROPERTY_ESCAPE_PROCESSING(u"EscapeProcessing")
constexpr OUStringLiteral PROPERTY_DATABASE_LOCATION(u"DatabaseLocation")
constexpr OUStringLiteral PROPERTY_COLUMN_NAME(u"ColumnName")
constexpr OUStringLiteral PROPERTY_DATASOURCENAME(u"DataSourceName")
constexpr OUStringLiteral PROPERTY_COMMAND_TYPE(u"CommandType")
constexpr OUStringLiteral PROPERTY_ORDER(u"Order")
unsigned char sal_Bool
#define DECLARE_XINTERFACE()