2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 22:04:38 +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 .
|
|
|
|
*/
|
2001-01-26 18:05:48 +00:00
|
|
|
|
|
|
|
#include "calc/CDriver.hxx"
|
|
|
|
#include "calc/CConnection.hxx"
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
2014-06-04 15:29:58 +02:00
|
|
|
#include <connectivity/dbexception.hxx>
|
2008-10-01 12:28:29 +00:00
|
|
|
#include "resource/sharedresources.hxx"
|
|
|
|
#include "resource/calc_res.hrc"
|
2014-06-04 15:29:58 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-01-26 18:05:48 +00:00
|
|
|
|
|
|
|
using namespace connectivity::calc;
|
|
|
|
using namespace connectivity::file;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
|
|
|
|
|
|
|
|
// static ServiceInfo
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
|
2001-01-26 18:05:48 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString("com.sun.star.comp.sdbc.calc.ODriver");
|
2001-01-26 18:05:48 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException, std::exception)
|
2001-01-26 18:05:48 +00:00
|
|
|
{
|
|
|
|
return getImplementationName_Static();
|
|
|
|
}
|
|
|
|
|
|
|
|
// service names from file::OFileDriver
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2001-01-26 18:05:48 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
|
|
|
|
connectivity::calc::ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
|
|
|
|
{
|
2013-05-21 16:22:38 +02:00
|
|
|
return *(new ODriver( comphelper::getComponentContext(_rxFactory) ));
|
2001-01-26 18:05:48 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url,
|
2014-02-25 21:31:58 +01:00
|
|
|
const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException, std::exception)
|
2001-01-26 18:05:48 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if (ODriver_BASE::rBHelper.bDisposed)
|
|
|
|
throw DisposedException();
|
|
|
|
|
2002-08-01 07:44:59 +00:00
|
|
|
if ( ! acceptsURL(url) )
|
2015-11-10 10:12:07 +01:00
|
|
|
return nullptr;
|
2002-08-01 07:44:59 +00:00
|
|
|
|
2001-01-26 18:05:48 +00:00
|
|
|
OCalcConnection* pCon = new OCalcConnection(this);
|
|
|
|
pCon->construct(url,info);
|
|
|
|
Reference< XConnection > xCon = pCon;
|
|
|
|
m_xConnections.push_back(WeakReferenceHelper(*pCon));
|
|
|
|
|
|
|
|
return xCon;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw(SQLException, RuntimeException, std::exception)
|
2001-01-26 18:05:48 +00:00
|
|
|
{
|
2013-03-08 14:11:35 +01:00
|
|
|
return url.startsWith("sdbc:calc:");
|
2001-01-26 18:05:48 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException, std::exception)
|
2004-08-02 15:59:02 +00:00
|
|
|
{
|
|
|
|
if ( !acceptsURL(url) )
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
SharedResources aResources;
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbtools::throwGenericSQLException(sMessage ,*this);
|
|
|
|
}
|
2004-08-02 15:59:02 +00:00
|
|
|
return Sequence< DriverPropertyInfo >();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2001-01-26 18:05:48 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|