summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/file/FDriver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/file/FDriver.cxx')
-rw-r--r--connectivity/source/drivers/file/FDriver.cxx119
1 files changed, 54 insertions, 65 deletions
diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx
index 16cf60e02cb4..e5788a257ddb 100644
--- a/connectivity/source/drivers/file/FDriver.cxx
+++ b/connectivity/source/drivers/file/FDriver.cxx
@@ -20,11 +20,13 @@
#include <file/FDriver.hxx>
#include <file/FConnection.hxx>
#include <file/fcode.hxx>
+#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <connectivity/dbexception.hxx>
#include <strings.hrc>
#include <resource/sharedresources.hxx>
+#include <utility>
using namespace connectivity::file;
@@ -35,9 +37,9 @@ using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdbcx;
using namespace com::sun::star::container;
-OFileDriver::OFileDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
+OFileDriver::OFileDriver(css::uno::Reference< css::uno::XComponentContext > _xContext)
: ODriver_BASE(m_aMutex)
- ,m_xContext(_rxContext)
+ ,m_xContext(std::move(_xContext))
{
}
@@ -48,7 +50,7 @@ void OFileDriver::disposing()
for (auto const& connection : m_xConnections)
{
- Reference< XComponent > xComp(connection.get(), UNO_QUERY);
+ rtl::Reference< OConnection > xComp(connection);
if (xComp.is())
xComp->dispose();
}
@@ -61,7 +63,7 @@ void OFileDriver::disposing()
OUString SAL_CALL OFileDriver::getImplementationName( )
{
- return "com.sun.star.sdbc.driver.file.Driver";
+ return u"com.sun.star.sdbc.driver.file.Driver"_ustr;
}
sal_Bool SAL_CALL OFileDriver::supportsService( const OUString& _rServiceName )
@@ -72,7 +74,7 @@ sal_Bool SAL_CALL OFileDriver::supportsService( const OUString& _rServiceName )
Sequence< OUString > SAL_CALL OFileDriver::getSupportedServiceNames( )
{
- return { "com.sun.star.sdbc.Driver", "com.sun.star.sdbcx.Driver" };
+ return { u"com.sun.star.sdbc.Driver"_ustr, u"com.sun.star.sdbcx.Driver"_ustr };
}
@@ -81,12 +83,11 @@ Reference< XConnection > SAL_CALL OFileDriver::connect( const OUString& url, con
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(ODriver_BASE::rBHelper.bDisposed);
- OConnection* pCon = new OConnection(this);
- Reference< XConnection > xCon = pCon;
+ rtl::Reference<OConnection> pCon = new OConnection(this);
pCon->construct(url,info);
- m_xConnections.push_back(WeakReferenceHelper(*pCon));
+ m_xConnections.push_back(pCon);
- return xCon;
+ return pCon;
}
sal_Bool SAL_CALL OFileDriver::acceptsURL( const OUString& url )
@@ -98,62 +99,60 @@ Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const OUSt
{
if ( acceptsURL(url) )
{
- std::vector< DriverPropertyInfo > aDriverInfo;
- Sequence< OUString > aBoolean(2);
- aBoolean[0] = "0";
- aBoolean[1] = "1";
+ Sequence< OUString > aBoolean { u"0"_ustr, u"1"_ustr };
- aDriverInfo.push_back(DriverPropertyInfo(
- "CharSet"
- ,"CharSet of the database."
+ return
+ {
+ {
+ u"CharSet"_ustr
+ ,u"CharSet of the database."_ustr
,false
- ,OUString()
- ,Sequence< OUString >())
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "Extension"
- ,"Extension of the file format."
+ ,{}
+ ,{}
+ },
+ {
+ u"Extension"_ustr
+ ,u"Extension of the file format."_ustr
,false
- ,".*"
- ,Sequence< OUString >())
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "ShowDeleted"
- ,"Display inactive records."
+ ,u".*"_ustr
+ ,{}
+ },
+ {
+ u"ShowDeleted"_ustr
+ ,u"Display inactive records."_ustr
,false
- ,"0"
- ,aBoolean)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "EnableSQL92Check"
- ,"Use SQL92 naming constraints."
+ ,u"0"_ustr
+ ,aBoolean
+ },
+ {
+ u"EnableSQL92Check"_ustr
+ ,u"Use SQL92 naming constraints."_ustr
,false
- ,"0"
- ,aBoolean)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "UseRelativePath"
- ,"Handle the connection url as relative path."
+ ,u"0"_ustr
+ ,aBoolean
+ },
+ {
+ u"UseRelativePath"_ustr
+ ,u"Handle the connection url as relative path."_ustr
,false
- ,"0"
- ,aBoolean)
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- "URL"
- ,"The URL of the database document which is used to create an absolute path."
+ ,u"0"_ustr
+ ,aBoolean
+ },
+ {
+ u"URL"_ustr
+ ,u"The URL of the database document which is used to create an absolute path."_ustr
,false
- ,OUString()
- ,Sequence< OUString >())
- );
- return Sequence< DriverPropertyInfo >(aDriverInfo.data(),aDriverInfo.size());
+ ,{}
+ ,{}
+ }
+ };
} // if ( acceptsURL(url) )
{
::connectivity::SharedResources aResources;
const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
::dbtools::throwGenericSQLException(sMessage ,*this);
} // if ( ! acceptsURL(url) )
- return Sequence< DriverPropertyInfo >();
}
sal_Int32 SAL_CALL OFileDriver::getMajorVersion( )
@@ -173,25 +172,15 @@ Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(ODriver_BASE::rBHelper.bDisposed);
- Reference< XTablesSupplier > xTab;
- Reference< css::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
- if(xTunnel.is())
+ if (OConnection* pSearchConnection = comphelper::getFromUnoTunnel<OConnection>(connection))
{
- OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelId()) );
- OConnection* pConnection = nullptr;
for (auto const& elem : m_xConnections)
{
- if (static_cast<OConnection*>( Reference< XConnection >::query(elem.get().get()).get() ) == pSearchConnection)
- {
- pConnection = pSearchConnection;
- break;
- }
+ if (elem.get().get() == pSearchConnection)
+ return pSearchConnection->createCatalog();
}
-
- if(pConnection)
- xTab = pConnection->createCatalog();
}
- return xTab;
+ return {};
}