build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / core / dataaccess / dataaccessdescriptor.cxx
blob01330f5f078d9557de7a1c38a01e7c5aad39ccb3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "dbastrings.hrc"
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <com/sun/star/sdb/CommandType.hpp>
26 #include <com/sun/star/sdbc/XConnection.hpp>
27 #include <com/sun/star/sdbc/XResultSet.hpp>
28 #include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <comphelper/proparrhlp.hxx>
33 #include <comphelper/propertycontainer.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <cppuhelper/implbase.hxx>
36 #include <cppuhelper/supportsservice.hxx>
37 #include <rtl/ref.hxx>
39 namespace
42 using ::com::sun::star::uno::Reference;
43 using ::com::sun::star::uno::RuntimeException;
44 using ::com::sun::star::uno::Any;
45 using ::com::sun::star::uno::Sequence;
46 using ::com::sun::star::lang::XServiceInfo;
47 using ::com::sun::star::beans::XPropertySetInfo;
48 using ::com::sun::star::beans::Property;
49 using ::com::sun::star::sdbc::XConnection;
50 using ::com::sun::star::sdbc::XResultSet;
51 using ::com::sun::star::beans::XPropertySet;
52 using ::com::sun::star::beans::PropertyValue;
54 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
55 namespace CommandType = ::com::sun::star::sdb::CommandType;
57 // DataAccessDescriptor
58 typedef ::comphelper::OMutexAndBroadcastHelper DataAccessDescriptor_MutexBase;
60 typedef ::cppu::WeakImplHelper< XServiceInfo
61 > DataAccessDescriptor_TypeBase;
63 typedef ::comphelper::OPropertyContainer DataAccessDescriptor_PropertyBase;
65 class DataAccessDescriptor :public DataAccessDescriptor_MutexBase
66 ,public DataAccessDescriptor_TypeBase
67 ,public DataAccessDescriptor_PropertyBase
68 ,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor >
70 public:
71 DataAccessDescriptor();
73 // UNO
74 DECLARE_XINTERFACE()
75 DECLARE_XTYPEPROVIDER()
77 // XServiceInfo
78 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException, std::exception) override;
79 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception) override;
80 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException, std::exception) override;
82 protected:
83 virtual ~DataAccessDescriptor() override;
85 protected:
86 // XPropertySet
87 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException, std::exception) override;
88 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
90 // OPropertyArrayUsageHelper
91 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
93 private:
94 // </properties>
95 OUString m_sDataSourceName;
96 OUString m_sDatabaseLocation;
97 OUString m_sConnectionResource;
98 Sequence< PropertyValue > m_aConnectionInfo;
99 Reference< XConnection > m_xActiveConnection;
100 OUString m_sCommand;
101 sal_Int32 m_nCommandType;
102 OUString m_sFilter;
103 OUString m_sOrder;
104 OUString m_sHavingClause;
105 OUString m_sGroupBy;
106 bool m_bEscapeProcessing;
107 Reference< XResultSet > m_xResultSet;
108 Sequence< Any > m_aSelection;
109 bool m_bBookmarkSelection;
110 OUString m_sColumnName;
111 Reference< XPropertySet > m_xColumn;
112 // </properties>
115 #define REGISTER_PROPERTY( propname, member ) \
116 registerProperty( PROPERTY_##propname, PROPERTY_ID_##propname, PropertyAttribute::BOUND, &member, cppu::UnoType<decltype(member)>::get() )
118 DataAccessDescriptor::DataAccessDescriptor()
119 :DataAccessDescriptor_MutexBase()
120 ,DataAccessDescriptor_TypeBase()
121 ,DataAccessDescriptor_PropertyBase( m_aBHelper )
122 ,m_sDataSourceName()
123 ,m_sDatabaseLocation()
124 ,m_sConnectionResource()
125 ,m_aConnectionInfo()
126 ,m_xActiveConnection()
127 ,m_sCommand()
128 ,m_nCommandType( CommandType::COMMAND )
129 ,m_sFilter()
130 ,m_sOrder()
131 ,m_sHavingClause()
132 ,m_sGroupBy()
133 ,m_bEscapeProcessing( true )
134 ,m_xResultSet()
135 ,m_aSelection()
136 ,m_bBookmarkSelection( true )
137 ,m_sColumnName()
138 ,m_xColumn()
140 REGISTER_PROPERTY( DATASOURCENAME, m_sDataSourceName );
141 REGISTER_PROPERTY( DATABASE_LOCATION, m_sDatabaseLocation );
142 REGISTER_PROPERTY( CONNECTION_RESOURCE, m_sConnectionResource );
143 REGISTER_PROPERTY( CONNECTION_INFO, m_aConnectionInfo );
144 REGISTER_PROPERTY( ACTIVE_CONNECTION, m_xActiveConnection );
145 REGISTER_PROPERTY( COMMAND, m_sCommand );
146 REGISTER_PROPERTY( COMMAND_TYPE, m_nCommandType );
147 REGISTER_PROPERTY( FILTER, m_sFilter );
148 REGISTER_PROPERTY( ORDER, m_sOrder );
149 REGISTER_PROPERTY( HAVING_CLAUSE, m_sHavingClause );
150 REGISTER_PROPERTY( GROUP_BY, m_sGroupBy );
151 REGISTER_PROPERTY( ESCAPE_PROCESSING, m_bEscapeProcessing );
152 REGISTER_PROPERTY( RESULT_SET, m_xResultSet );
153 REGISTER_PROPERTY( SELECTION, m_aSelection );
154 REGISTER_PROPERTY( BOOKMARK_SELECTION, m_bBookmarkSelection );
155 REGISTER_PROPERTY( COLUMN_NAME, m_sColumnName );
156 REGISTER_PROPERTY( COLUMN, m_xColumn );
159 DataAccessDescriptor::~DataAccessDescriptor()
163 IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
165 IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
167 OUString SAL_CALL DataAccessDescriptor::getImplementationName() throw (RuntimeException, std::exception)
169 return OUString( "com.sun.star.comp.dba.DataAccessDescriptor" );
172 sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
174 return cppu::supportsService(this, rServiceName);
177 Sequence< OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
179 Sequence< OUString > aServices { "com.sun.star.sdb.DataAccessDescriptor" };
180 return aServices;
183 Reference< XPropertySetInfo > SAL_CALL DataAccessDescriptor::getPropertySetInfo() throw(RuntimeException, std::exception)
185 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
186 return xInfo;
189 ::cppu::IPropertyArrayHelper& DataAccessDescriptor::getInfoHelper()
191 return *getArrayHelper();
194 ::cppu::IPropertyArrayHelper* DataAccessDescriptor::createArrayHelper( ) const
196 Sequence< Property > aProps;
197 describeProperties( aProps );
198 return new ::cppu::OPropertyArrayHelper( aProps );
201 // DataAccessDescriptorFactory
202 class DataAccessDescriptorFactory: public ::cppu::WeakImplHelper<XServiceInfo, css::sdb::XDataAccessDescriptorFactory>
204 public:
205 // XServiceInfo
206 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException, std::exception) override;
207 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception) override;
208 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException, std::exception) override;
210 // XDataAccessDescriptorFactory
211 virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor( ) throw (RuntimeException, std::exception) override;
213 DataAccessDescriptorFactory();
214 virtual ~DataAccessDescriptorFactory() override;
217 DataAccessDescriptorFactory::DataAccessDescriptorFactory()
221 DataAccessDescriptorFactory::~DataAccessDescriptorFactory()
225 OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName() throw (RuntimeException, std::exception)
227 return OUString( "com.sun.star.comp.dba.DataAccessDescriptorFactory" );
230 sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
232 return cppu::supportsService(this, rServiceName);
235 Sequence< OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames() throw (RuntimeException, std::exception)
237 Sequence< OUString > aServices { "com.sun.star.sdb.DataAccessDescriptorFactory" };
238 return aServices;
241 Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor( ) throw (RuntimeException, std::exception)
243 return new DataAccessDescriptor();
246 struct Instance {
247 explicit Instance():
248 instance(new DataAccessDescriptorFactory())
251 rtl::Reference<cppu::OWeakObject> instance;
254 struct Singleton:
255 public rtl::Static<Instance, Singleton>
260 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
261 com_sun_star_comp_dba_DataAccessDescriptorFactory(
262 css::uno::XComponentContext *,
263 css::uno::Sequence<css::uno::Any> const &)
265 return cppu::acquire(Singleton::get().instance.get());
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */