summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/ado/ADriver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/ado/ADriver.cxx')
-rw-r--r--connectivity/source/drivers/ado/ADriver.cxx90
1 files changed, 40 insertions, 50 deletions
diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx
index ee4ec27b6f05..6568f7a1ee84 100644
--- a/connectivity/source/drivers/ado/ADriver.cxx
+++ b/connectivity/source/drivers/ado/ADriver.cxx
@@ -24,16 +24,16 @@
#include <ado/Awrapado.hxx>
#include <ado/adoimp.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/servicehelper.hxx>
#include <connectivity/dbexception.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <o3tl/safeCoInitUninit.hxx>
+#include <rtl/ref.hxx>
#include <strings.hrc>
#include <objbase.h>
#include <resource/sharedresources.hxx>
-#include <memory>
-
using namespace connectivity;
using namespace connectivity::ado;
using namespace com::sun::star::uno;
@@ -94,13 +94,12 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const S
return nullptr;
// we need to wrap the connection as the construct call might throw
- std::unique_ptr<OConnection> pCon(new OConnection(this));
+ rtl::Reference<OConnection> pCon(new OConnection(this));
pCon->construct(url,info);
OConnection* pPtr = pCon.get();
- Reference< XConnection > xCon = pCon.release();
m_xConnections.push_back(WeakReferenceHelper(*pPtr));
- return xCon;
+ return pCon;
}
sal_Bool SAL_CALL ODriver::acceptsURL( const OUString& url )
@@ -123,34 +122,32 @@ Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const OUString
impl_checkURL_throw(url);
if ( acceptsURL(url) )
{
- std::vector< DriverPropertyInfo > aDriverInfo;
-
- Sequence< OUString > aBooleanValues(2);
- aBooleanValues[0] = "false";
- aBooleanValues[1] = "true";
+ Sequence< OUString > aBooleanValues{ "false", "true" };
- aDriverInfo.push_back(DriverPropertyInfo(
- "IgnoreDriverPrivileges"
- ,"Ignore the privileges from the database driver."
- ,false
- ,"false"
- ,aBooleanValues)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "EscapeDateTime"
- ,"Escape date time format."
- ,false
- ,"true"
- ,aBooleanValues)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "TypeInfoSettings"
- ,"Defines how the type info of the database metadata should be manipulated."
- ,false
- ,OUString( )
- ,Sequence< OUString > ())
- );
- return Sequence< DriverPropertyInfo >(aDriverInfo.data(),aDriverInfo.size());
+ return
+ {
+ {
+ "IgnoreDriverPrivileges",
+ "Ignore the privileges from the database driver.",
+ false,
+ "false",
+ aBooleanValues
+ },
+ {
+ "EscapeDateTime",
+ "Escape date time format.",
+ false,
+ "true",
+ aBooleanValues
+ },
+ {
+ "TypeInfoSettings",
+ "Defines how the type info of the database metadata should be manipulated.",
+ false,
+ {},
+ {}
+ }
+ };
}
return Sequence< DriverPropertyInfo >();
}
@@ -174,13 +171,11 @@ Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( co
OConnection* pConnection = nullptr;
Reference< css::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
- if(xTunnel.is())
+ if (auto pSearchConnection = comphelper::getFromUnoTunnel<OConnection>(xTunnel))
{
- OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelId()) );
-
auto foundConnection = std::any_of(m_xConnections.begin(), m_xConnections.end(),
[&pSearchConnection](const css::uno::WeakReferenceHelper& rxConnection) {
- return static_cast<OConnection*>(Reference< XConnection >::query(rxConnection.get().get()).get()) == pSearchConnection; });
+ return static_cast<OConnection*>(Reference< XConnection >::query(rxConnection.get()).get()) == pSearchConnection; });
if (foundConnection)
pConnection = pSearchConnection;
}
@@ -192,11 +187,11 @@ Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( co
aCatalog.Create();
if(aCatalog.IsValid())
{
- aCatalog.putref_ActiveConnection(*pConnection->getConnection());
- OCatalog* pCatalog = new OCatalog(aCatalog,pConnection);
+ aCatalog.putref_ActiveConnection(pConnection->getConnection());
+ rtl::Reference<OCatalog> pCatalog = new OCatalog(aCatalog,pConnection);
xTab = pCatalog;
pConnection->setCatalog(xTab);
- pConnection->setCatalog(pCatalog);
+ pConnection->setCatalog(pCatalog.get());
}
}
return xTab;
@@ -211,13 +206,11 @@ Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const OUS
void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >& _xInterface)
{
- ADOErrors *pErrors = nullptr;
+ sal::systools::COMReference<ADOErrors> pErrors;
_pAdoCon->get_Errors(&pErrors);
if(!pErrors)
return; // no error found
- pErrors->AddRef( );
-
// read all noted errors and issue them
sal_Int32 nLen;
pErrors->get_Count(&nLen);
@@ -227,28 +220,25 @@ void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >&
aException.ErrorCode = 1000;
for (sal_Int32 i = nLen-1; i>=0; --i)
{
- ADOError *pError = nullptr;
- pErrors->get_Item(OLEVariant(i),&pError);
- WpADOError aErr(pError);
- OSL_ENSURE(pError,"No error in collection found! BAD!");
- if(pError)
+ WpADOError aErr;
+ pErrors->get_Item(OLEVariant(i),&aErr);
+ OSL_ENSURE(aErr,"No error in collection found! BAD!");
+ if(aErr)
{
if(i==nLen-1)
aException = SQLException(aErr.GetDescription(),_xInterface,aErr.GetSQLState(),aErr.GetNumber(),Any());
else
{
SQLException aTemp(aErr.GetDescription(),
- _xInterface,aErr.GetSQLState(),aErr.GetNumber(),makeAny(aException));
+ _xInterface,aErr.GetSQLState(),aErr.GetNumber(),Any(aException));
aTemp.NextException <<= aException;
aException = aTemp;
}
}
}
pErrors->Clear();
- pErrors->Release();
throw aException;
}
- pErrors->Release();
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*