fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / core / dataaccess / dataaccessdescriptor.cxx
blobc3072d65351b284554fda7b15d823878ea4e099e
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"
21 #include "module_dba.hxx"
22 #include "services.hxx"
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/sdb/CommandType.hpp>
28 #include <com/sun/star/sdbc/XConnection.hpp>
29 #include <com/sun/star/sdbc/XResultSet.hpp>
30 #include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp>
32 #include <comphelper/broadcasthelper.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <comphelper/propertycontainer.hxx>
35 #include <comphelper/uno3.hxx>
36 #include <cppuhelper/implbase1.hxx>
37 #include <cppuhelper/implbase2.hxx>
38 #include <cppuhelper/supportsservice.hxx>
40 namespace dbaccess
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::XInterface;
45 using ::com::sun::star::uno::UNO_QUERY;
46 using ::com::sun::star::uno::UNO_QUERY_THROW;
47 using ::com::sun::star::uno::UNO_SET_THROW;
48 using ::com::sun::star::uno::Exception;
49 using ::com::sun::star::uno::RuntimeException;
50 using ::com::sun::star::uno::Any;
51 using ::com::sun::star::uno::makeAny;
52 using ::com::sun::star::uno::Sequence;
53 using ::com::sun::star::lang::XServiceInfo;
54 using ::com::sun::star::lang::XMultiServiceFactory;
55 using ::com::sun::star::beans::XPropertySetInfo;
56 using ::com::sun::star::beans::Property;
57 using ::com::sun::star::sdbc::XConnection;
58 using ::com::sun::star::sdbc::XResultSet;
59 using ::com::sun::star::sdb::XDataAccessDescriptorFactory;
60 using ::com::sun::star::beans::XPropertySet;
61 using ::com::sun::star::uno::XComponentContext;
62 using ::com::sun::star::beans::PropertyValue;
64 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
65 namespace CommandType = ::com::sun::star::sdb::CommandType;
67 // DataAccessDescriptor
68 typedef ::comphelper::OMutexAndBroadcastHelper DataAccessDescriptor_MutexBase;
70 typedef ::cppu::WeakImplHelper1 < XServiceInfo
71 > DataAccessDescriptor_TypeBase;
73 typedef ::comphelper::OPropertyContainer DataAccessDescriptor_PropertyBase;
75 class DataAccessDescriptor :public DataAccessDescriptor_MutexBase
76 ,public DataAccessDescriptor_TypeBase
77 ,public DataAccessDescriptor_PropertyBase
78 ,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor >
80 public:
81 DataAccessDescriptor( const Reference<XComponentContext> & _rContext );
83 // UNO
84 DECLARE_XINTERFACE()
85 DECLARE_XTYPEPROVIDER()
87 // XServiceInfo
88 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
90 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
92 protected:
93 virtual ~DataAccessDescriptor();
95 protected:
96 // XPropertySet
97 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
100 // OPropertyArrayUsageHelper
101 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
103 private:
104 Reference<XComponentContext> m_xContext;
106 // </properties>
107 OUString m_sDataSourceName;
108 OUString m_sDatabaseLocation;
109 OUString m_sConnectionResource;
110 Sequence< PropertyValue > m_aConnectionInfo;
111 Reference< XConnection > m_xActiveConnection;
112 OUString m_sCommand;
113 sal_Int32 m_nCommandType;
114 OUString m_sFilter;
115 OUString m_sOrder;
116 OUString m_sHavingClause;
117 OUString m_sGroupBy;
118 bool m_bEscapeProcessing;
119 Reference< XResultSet > m_xResultSet;
120 Sequence< Any > m_aSelection;
121 bool m_bBookmarkSelection;
122 OUString m_sColumnName;
123 Reference< XPropertySet > m_xColumn;
124 // </properties>
127 #define REGISTER_PROPERTY( propname, member ) \
128 registerProperty( PROPERTY_##propname, PROPERTY_ID_##propname, PropertyAttribute::BOUND, &member, cppu::UnoType<decltype(member)>::get() )
130 DataAccessDescriptor::DataAccessDescriptor( const Reference<XComponentContext> & _rContext )
131 :DataAccessDescriptor_MutexBase()
132 ,DataAccessDescriptor_TypeBase()
133 ,DataAccessDescriptor_PropertyBase( m_aBHelper )
134 ,m_xContext( _rContext )
135 ,m_sDataSourceName()
136 ,m_sDatabaseLocation()
137 ,m_sConnectionResource()
138 ,m_aConnectionInfo()
139 ,m_xActiveConnection()
140 ,m_sCommand()
141 ,m_nCommandType( CommandType::COMMAND )
142 ,m_sFilter()
143 ,m_sOrder()
144 ,m_sHavingClause()
145 ,m_sGroupBy()
146 ,m_bEscapeProcessing( true )
147 ,m_xResultSet()
148 ,m_aSelection()
149 ,m_bBookmarkSelection( true )
150 ,m_sColumnName()
151 ,m_xColumn()
153 REGISTER_PROPERTY( DATASOURCENAME, m_sDataSourceName );
154 REGISTER_PROPERTY( DATABASE_LOCATION, m_sDatabaseLocation );
155 REGISTER_PROPERTY( CONNECTION_RESOURCE, m_sConnectionResource );
156 REGISTER_PROPERTY( CONNECTION_INFO, m_aConnectionInfo );
157 REGISTER_PROPERTY( ACTIVE_CONNECTION, m_xActiveConnection );
158 REGISTER_PROPERTY( COMMAND, m_sCommand );
159 REGISTER_PROPERTY( COMMAND_TYPE, m_nCommandType );
160 REGISTER_PROPERTY( FILTER, m_sFilter );
161 REGISTER_PROPERTY( ORDER, m_sOrder );
162 REGISTER_PROPERTY( HAVING_CLAUSE, m_sHavingClause );
163 REGISTER_PROPERTY( GROUP_BY, m_sGroupBy );
164 REGISTER_PROPERTY( ESCAPE_PROCESSING, m_bEscapeProcessing );
165 REGISTER_PROPERTY( RESULT_SET, m_xResultSet );
166 REGISTER_PROPERTY( SELECTION, m_aSelection );
167 REGISTER_PROPERTY( BOOKMARK_SELECTION, m_bBookmarkSelection );
168 REGISTER_PROPERTY( COLUMN_NAME, m_sColumnName );
169 REGISTER_PROPERTY( COLUMN, m_xColumn );
172 DataAccessDescriptor::~DataAccessDescriptor()
176 IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
178 IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
180 OUString SAL_CALL DataAccessDescriptor::getImplementationName() throw (RuntimeException, std::exception)
182 return OUString( "com.sun.star.comp.dba.DataAccessDescriptor" );
185 sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
187 return cppu::supportsService(this, rServiceName);
190 Sequence< OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
192 Sequence< OUString > aServices(1);
193 aServices[0] = "com.sun.star.sdb.DataAccessDescriptor";
194 return aServices;
197 Reference< XPropertySetInfo > SAL_CALL DataAccessDescriptor::getPropertySetInfo() throw(RuntimeException, std::exception)
199 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
200 return xInfo;
203 ::cppu::IPropertyArrayHelper& DataAccessDescriptor::getInfoHelper()
205 return *getArrayHelper();
208 ::cppu::IPropertyArrayHelper* DataAccessDescriptor::createArrayHelper( ) const
210 Sequence< Property > aProps;
211 describeProperties( aProps );
212 return new ::cppu::OPropertyArrayHelper( aProps );
215 // DataAccessDescriptorFactory
216 typedef ::cppu::WeakImplHelper2 < XServiceInfo
217 , XDataAccessDescriptorFactory
218 > DataAccessDescriptorFactory_Base;
219 class DataAccessDescriptorFactory : public DataAccessDescriptorFactory_Base
221 public:
222 // XServiceInfo
223 virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
224 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
225 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
227 // XServiceInfo - static versions
228 static Sequence< OUString > getSupportedServiceNames_static() throw( RuntimeException );
229 static OUString getImplementationName_static() throw( RuntimeException );
230 static Reference< XInterface > Create(const Reference< XComponentContext >& _rxContext);
231 static OUString getSingletonName_static();
233 // XDataAccessDescriptorFactory
234 virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
236 protected:
237 DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext );
238 virtual ~DataAccessDescriptorFactory();
240 private:
241 Reference<XComponentContext> m_xContext;
244 DataAccessDescriptorFactory::DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext )
245 :m_xContext( _rxContext )
249 DataAccessDescriptorFactory::~DataAccessDescriptorFactory()
253 OUString DataAccessDescriptorFactory::getSingletonName_static()
255 return OUString( "com.sun.star.sdb.DataAccessDescriptorFactory" );
258 Sequence< OUString > DataAccessDescriptorFactory::getSupportedServiceNames_static() throw( RuntimeException )
260 Sequence< OUString > aServices(1);
261 aServices[0] = getSingletonName_static();
262 return aServices;
265 OUString DataAccessDescriptorFactory::getImplementationName_static() throw( RuntimeException )
267 return OUString( "com.sun.star.comp.dba.DataAccessDescriptorFactory" );
270 Reference< XInterface > DataAccessDescriptorFactory::Create( const Reference< XComponentContext >& _rxContext )
272 return *( new DataAccessDescriptorFactory( _rxContext ) );
275 OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName() throw (RuntimeException, std::exception)
277 return getImplementationName_static();
280 sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
282 return cppu::supportsService(this, rServiceName);
285 Sequence< OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
287 return getSupportedServiceNames_static();
290 Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor( ) throw (RuntimeException, std::exception)
292 return new DataAccessDescriptor( m_xContext );
295 } // namespace dbaccess
297 extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory()
299 static ::dba::OSingletonRegistration< ::dbaccess::DataAccessDescriptorFactory > aAutoRegistration;
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */