2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
#include "dbastrings.hrc"
|
|
|
|
#include "module_dba.hxx"
|
|
|
|
|
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
2013-12-06 17:55:56 +01:00
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2008-01-30 07:32:55 +00:00
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XResultSet.hpp>
|
|
|
|
#include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp>
|
|
|
|
|
|
|
|
#include <comphelper/broadcasthelper.hxx>
|
|
|
|
#include <comphelper/proparrhlp.hxx>
|
|
|
|
#include <comphelper/propertycontainer.hxx>
|
|
|
|
#include <comphelper/uno3.hxx>
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
|
|
|
#include <cppuhelper/implbase2.hxx>
|
2013-12-05 12:47:58 -02:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::XInterface;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY_THROW;
|
|
|
|
using ::com::sun::star::uno::UNO_SET_THROW;
|
|
|
|
using ::com::sun::star::uno::Exception;
|
|
|
|
using ::com::sun::star::uno::RuntimeException;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::uno::makeAny;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::lang::XServiceInfo;
|
|
|
|
using ::com::sun::star::lang::XMultiServiceFactory;
|
|
|
|
using ::com::sun::star::beans::XPropertySetInfo;
|
|
|
|
using ::com::sun::star::beans::Property;
|
|
|
|
using ::com::sun::star::sdbc::XConnection;
|
|
|
|
using ::com::sun::star::sdbc::XResultSet;
|
|
|
|
using ::com::sun::star::sdb::XDataAccessDescriptorFactory;
|
|
|
|
using ::com::sun::star::beans::XPropertySet;
|
|
|
|
using ::com::sun::star::uno::XComponentContext;
|
|
|
|
using ::com::sun::star::beans::PropertyValue;
|
|
|
|
|
|
|
|
namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
|
|
|
|
namespace CommandType = ::com::sun::star::sdb::CommandType;
|
|
|
|
|
2013-08-17 23:43:14 +02:00
|
|
|
// DataAccessDescriptor
|
2008-01-30 07:32:55 +00:00
|
|
|
typedef ::comphelper::OMutexAndBroadcastHelper DataAccessDescriptor_MutexBase;
|
|
|
|
|
|
|
|
typedef ::cppu::WeakImplHelper1 < XServiceInfo
|
|
|
|
> DataAccessDescriptor_TypeBase;
|
|
|
|
|
|
|
|
typedef ::comphelper::OPropertyContainer DataAccessDescriptor_PropertyBase;
|
|
|
|
|
|
|
|
class DataAccessDescriptor :public DataAccessDescriptor_MutexBase
|
|
|
|
,public DataAccessDescriptor_TypeBase
|
|
|
|
,public DataAccessDescriptor_PropertyBase
|
|
|
|
,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor >
|
|
|
|
{
|
|
|
|
public:
|
2013-03-19 13:08:47 +02:00
|
|
|
DataAccessDescriptor( const Reference<XComponentContext> & _rContext );
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
// UNO
|
|
|
|
DECLARE_XINTERFACE()
|
|
|
|
DECLARE_XTYPEPROVIDER()
|
|
|
|
|
|
|
|
// XServiceInfo
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
|
|
|
|
virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
|
|
|
|
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
~DataAccessDescriptor();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// XPropertySet
|
|
|
|
virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException);
|
|
|
|
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
|
|
|
|
|
|
|
|
// OPropertyArrayUsageHelper
|
|
|
|
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
|
|
|
|
|
|
|
|
private:
|
2013-03-19 13:08:47 +02:00
|
|
|
Reference<XComponentContext> m_xContext;
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
// </properties>
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_sDataSourceName;
|
|
|
|
OUString m_sDatabaseLocation;
|
|
|
|
OUString m_sConnectionResource;
|
2008-01-30 07:32:55 +00:00
|
|
|
Sequence< PropertyValue > m_aConnectionInfo;
|
|
|
|
Reference< XConnection > m_xActiveConnection;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_sCommand;
|
2008-01-30 07:32:55 +00:00
|
|
|
sal_Int32 m_nCommandType;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_sFilter;
|
|
|
|
OUString m_sOrder;
|
|
|
|
OUString m_sHavingClause;
|
|
|
|
OUString m_sGroupBy;
|
2008-01-30 07:32:55 +00:00
|
|
|
sal_Bool m_bEscapeProcessing;
|
|
|
|
Reference< XResultSet > m_xResultSet;
|
|
|
|
Sequence< Any > m_aSelection;
|
|
|
|
sal_Bool m_bBookmarkSelection;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_sColumnName;
|
2008-01-30 07:32:55 +00:00
|
|
|
Reference< XPropertySet > m_xColumn;
|
|
|
|
// </properties>
|
|
|
|
};
|
|
|
|
|
|
|
|
#define REGISTER_PROPERTY( propname, member ) \
|
|
|
|
registerProperty( PROPERTY_##propname, PROPERTY_ID_##propname, PropertyAttribute::BOUND, &member, ::getCppuType( &member ) )
|
|
|
|
|
2013-03-19 13:08:47 +02:00
|
|
|
DataAccessDescriptor::DataAccessDescriptor( const Reference<XComponentContext> & _rContext )
|
2008-01-30 07:32:55 +00:00
|
|
|
:DataAccessDescriptor_MutexBase()
|
|
|
|
,DataAccessDescriptor_TypeBase()
|
|
|
|
,DataAccessDescriptor_PropertyBase( m_aBHelper )
|
2013-03-19 13:08:47 +02:00
|
|
|
,m_xContext( _rContext )
|
2008-01-30 07:32:55 +00:00
|
|
|
,m_sDataSourceName()
|
|
|
|
,m_sDatabaseLocation()
|
|
|
|
,m_sConnectionResource()
|
|
|
|
,m_aConnectionInfo()
|
|
|
|
,m_xActiveConnection()
|
|
|
|
,m_sCommand()
|
|
|
|
,m_nCommandType( CommandType::COMMAND )
|
|
|
|
,m_sFilter()
|
|
|
|
,m_sOrder()
|
|
|
|
,m_sHavingClause()
|
|
|
|
,m_sGroupBy()
|
|
|
|
,m_bEscapeProcessing( sal_True )
|
|
|
|
,m_xResultSet()
|
|
|
|
,m_aSelection()
|
|
|
|
,m_bBookmarkSelection( sal_True )
|
|
|
|
,m_sColumnName()
|
|
|
|
,m_xColumn()
|
|
|
|
{
|
|
|
|
REGISTER_PROPERTY( DATASOURCENAME, m_sDataSourceName );
|
|
|
|
REGISTER_PROPERTY( DATABASE_LOCATION, m_sDatabaseLocation );
|
|
|
|
REGISTER_PROPERTY( CONNECTION_RESOURCE, m_sConnectionResource );
|
|
|
|
REGISTER_PROPERTY( CONNECTION_INFO, m_aConnectionInfo );
|
|
|
|
REGISTER_PROPERTY( ACTIVE_CONNECTION, m_xActiveConnection );
|
|
|
|
REGISTER_PROPERTY( COMMAND, m_sCommand );
|
|
|
|
REGISTER_PROPERTY( COMMAND_TYPE, m_nCommandType );
|
|
|
|
REGISTER_PROPERTY( FILTER, m_sFilter );
|
|
|
|
REGISTER_PROPERTY( ORDER, m_sOrder );
|
|
|
|
REGISTER_PROPERTY( HAVING_CLAUSE, m_sHavingClause );
|
|
|
|
REGISTER_PROPERTY( GROUP_BY, m_sGroupBy );
|
|
|
|
REGISTER_PROPERTY( ESCAPE_PROCESSING, m_bEscapeProcessing );
|
|
|
|
REGISTER_PROPERTY( RESULT_SET, m_xResultSet );
|
|
|
|
REGISTER_PROPERTY( SELECTION, m_aSelection );
|
|
|
|
REGISTER_PROPERTY( BOOKMARK_SELECTION, m_bBookmarkSelection );
|
|
|
|
REGISTER_PROPERTY( COLUMN_NAME, m_sColumnName );
|
|
|
|
REGISTER_PROPERTY( COLUMN, m_xColumn );
|
|
|
|
}
|
|
|
|
|
|
|
|
DataAccessDescriptor::~DataAccessDescriptor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
|
|
|
|
|
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
|
|
|
|
|
2013-01-19 13:36:05 -02:00
|
|
|
OUString SAL_CALL DataAccessDescriptor::getImplementationName() throw (RuntimeException)
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-01-19 13:36:05 -02:00
|
|
|
return OUString( "com.sun.star.comp.dba.DataAccessDescriptor" );
|
2008-01-30 07:32:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
::sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const OUString& rServiceName ) throw (RuntimeException)
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-12-05 12:47:58 -02:00
|
|
|
return cppu::supportsService(this, rServiceName);
|
2008-01-30 07:32:55 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 13:36:05 -02:00
|
|
|
Sequence< OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames( ) throw (RuntimeException)
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-01-19 13:36:05 -02:00
|
|
|
Sequence< OUString > aServices(1);
|
|
|
|
aServices[0] = "com.sun.star.sdb.DataAccessDescriptor";
|
2008-01-30 07:32:55 +00:00
|
|
|
return aServices;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference< XPropertySetInfo > SAL_CALL DataAccessDescriptor::getPropertySetInfo() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
|
|
|
|
return xInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
::cppu::IPropertyArrayHelper& DataAccessDescriptor::getInfoHelper()
|
|
|
|
{
|
|
|
|
return *getArrayHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
::cppu::IPropertyArrayHelper* DataAccessDescriptor::createArrayHelper( ) const
|
|
|
|
{
|
|
|
|
Sequence< Property > aProps;
|
|
|
|
describeProperties( aProps );
|
|
|
|
return new ::cppu::OPropertyArrayHelper( aProps );
|
|
|
|
}
|
|
|
|
|
2013-08-17 23:43:14 +02:00
|
|
|
// DataAccessDescriptorFactory
|
2008-01-30 07:32:55 +00:00
|
|
|
typedef ::cppu::WeakImplHelper2 < XServiceInfo
|
|
|
|
, XDataAccessDescriptorFactory
|
|
|
|
> DataAccessDescriptorFactory_Base;
|
|
|
|
class DataAccessDescriptorFactory : public DataAccessDescriptorFactory_Base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// XServiceInfo
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
|
|
|
|
virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
|
|
|
|
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
// XServiceInfo - static versions
|
2013-04-07 12:06:47 +02:00
|
|
|
static Sequence< OUString > getSupportedServiceNames_static(void) throw( RuntimeException );
|
|
|
|
static OUString getImplementationName_static(void) throw( RuntimeException );
|
2008-01-30 07:32:55 +00:00
|
|
|
static Reference< XInterface > Create(const Reference< XComponentContext >& _rxContext);
|
2013-04-07 12:06:47 +02:00
|
|
|
static OUString getSingletonName_static();
|
2008-01-30 07:32:55 +00:00
|
|
|
|
|
|
|
// XDataAccessDescriptorFactory
|
|
|
|
virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor( ) throw (RuntimeException);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext );
|
|
|
|
~DataAccessDescriptorFactory();
|
|
|
|
|
|
|
|
private:
|
2013-03-19 13:08:47 +02:00
|
|
|
Reference<XComponentContext> m_xContext;
|
2008-01-30 07:32:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DataAccessDescriptorFactory::DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext )
|
2013-03-19 13:08:47 +02:00
|
|
|
:m_xContext( _rxContext )
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DataAccessDescriptorFactory::~DataAccessDescriptorFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-19 13:36:05 -02:00
|
|
|
OUString DataAccessDescriptorFactory::getSingletonName_static()
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-01-19 13:36:05 -02:00
|
|
|
return OUString( "com.sun.star.sdb.DataAccessDescriptorFactory" );
|
2008-01-30 07:32:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > DataAccessDescriptorFactory::getSupportedServiceNames_static() throw( RuntimeException )
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aServices(1);
|
2008-01-30 07:32:55 +00:00
|
|
|
aServices[0] = getSingletonName_static();
|
|
|
|
return aServices;
|
|
|
|
}
|
|
|
|
|
2013-01-19 13:36:05 -02:00
|
|
|
OUString DataAccessDescriptorFactory::getImplementationName_static() throw( RuntimeException )
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-01-19 13:36:05 -02:00
|
|
|
return OUString( "com.sun.star.comp.dba.DataAccessDescriptorFactory" );
|
2008-01-30 07:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Reference< XInterface > DataAccessDescriptorFactory::Create( const Reference< XComponentContext >& _rxContext )
|
|
|
|
{
|
|
|
|
return *( new DataAccessDescriptorFactory( _rxContext ) );
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName() throw (RuntimeException)
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
|
|
|
return getImplementationName_static();
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
::sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const OUString& rServiceName ) throw (RuntimeException)
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
2013-12-05 12:47:58 -02:00
|
|
|
return cppu::supportsService(this, rServiceName);
|
2008-01-30 07:32:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames( ) throw (RuntimeException)
|
2008-01-30 07:32:55 +00:00
|
|
|
{
|
|
|
|
return getSupportedServiceNames_static();
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor( ) throw (RuntimeException)
|
|
|
|
{
|
2013-03-19 13:08:47 +02:00
|
|
|
return new DataAccessDescriptor( m_xContext );
|
2008-01-30 07:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dbaccess
|
|
|
|
|
|
|
|
extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory()
|
|
|
|
{
|
|
|
|
static ::dba::OSingletonRegistration< ::dbaccess::DataAccessDescriptorFactory > aAutoRegistration;
|
|
|
|
}
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|