summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/calc/CConnection.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/calc/CConnection.cxx')
-rw-r--r--connectivity/source/drivers/calc/CConnection.cxx61
1 files changed, 26 insertions, 35 deletions
diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx
index 9b03d473bda1..d1ae21a38e07 100644
--- a/connectivity/source/drivers/calc/CConnection.cxx
+++ b/connectivity/source/drivers/calc/CConnection.cxx
@@ -62,9 +62,9 @@ void OCalcConnection::construct(const OUString& url,const Sequence< PropertyValu
sal_Int32 nLen = url.indexOf(':');
nLen = url.indexOf(':',nLen+1);
- OUString aDSN(url.copy(nLen+1));
- m_aFileName = aDSN;
+ m_aFileName = url.copy(nLen+1); // DSN
+
INetURLObject aURL;
aURL.SetSmartProtocol(INetProtocol::File);
{
@@ -80,18 +80,15 @@ void OCalcConnection::construct(const OUString& url,const Sequence< PropertyValu
m_aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
m_sPassword.clear();
- const char pPwd[] = "password";
- const PropertyValue *pIter = info.getConstArray();
- const PropertyValue *pEnd = pIter + info.getLength();
- for(;pIter != pEnd;++pIter)
+ for (auto& propval : info)
{
- if(pIter->Name == pPwd)
+ if (propval.Name == "password")
{
- pIter->Value >>= m_sPassword;
+ propval.Value >>= m_sPassword;
break;
}
- } // for(;pIter != pEnd;++pIter)
+ }
ODocHolder aDocHolder(this); // just to test that the doc can be loaded
acquireDoc();
}
@@ -104,18 +101,17 @@ Reference< XSpreadsheetDocument> const & OCalcConnection::acquireDoc()
return m_xDoc;
}
// open read-only as long as updating isn't implemented
- Sequence<PropertyValue> aArgs(2);
- aArgs[0].Name = "Hidden";
- aArgs[0].Value <<= true;
- aArgs[1].Name = "ReadOnly";
- aArgs[1].Value <<= true;
+ Sequence<PropertyValue> aArgs(m_sPassword.isEmpty() ? 2 : 3);
+ auto pArgs = aArgs.getArray();
+ pArgs[0].Name = "Hidden";
+ pArgs[0].Value <<= true;
+ pArgs[1].Name = "ReadOnly";
+ pArgs[1].Value <<= true;
if ( !m_sPassword.isEmpty() )
{
- const sal_Int32 nPos = aArgs.getLength();
- aArgs.realloc(nPos+1);
- aArgs[nPos].Name = "Password";
- aArgs[nPos].Value <<= m_sPassword;
+ pArgs[2].Name = "Password";
+ pArgs[2].Value <<= m_sPassword;
}
Reference< XDesktop2 > xDesktop = Desktop::create( getDriver()->getComponentContext() );
@@ -124,7 +120,7 @@ Reference< XSpreadsheetDocument> const & OCalcConnection::acquireDoc()
try
{
xComponent = xDesktop->loadComponentFromURL(
- m_aFileName, "_blank", 0, aArgs );
+ m_aFileName, u"_blank"_ustr, 0, aArgs );
}
catch( const Exception& )
{
@@ -143,12 +139,11 @@ Reference< XSpreadsheetDocument> const & OCalcConnection::acquireDoc()
Exception aLoaderError;
OSL_VERIFY( aLoaderException >>= aLoaderError );
- SQLException aDetailException;
- aDetailException.Message = m_aResources.getResourceStringWithSubstitution(
- STR_LOAD_FILE_ERROR_MESSAGE,
- "$exception_type$", aLoaderException.getValueTypeName(),
- "$error_message$", aLoaderError.Message
- );
+ SQLException aDetailException(m_aResources.getResourceStringWithSubstitution(
+ STR_LOAD_FILE_ERROR_MESSAGE, "$exception_type$",
+ aLoaderException.getValueTypeName(),
+ "$error_message$", aLoaderError.Message),
+ {}, {}, 0, {});
aErrorDetails <<= aDetailException;
}
@@ -195,7 +190,7 @@ void OCalcConnection::disposing()
// XServiceInfo
-IMPLEMENT_SERVICE_INFO(OCalcConnection, "com.sun.star.sdbc.drivers.calc.Connection", "com.sun.star.sdbc.Connection")
+IMPLEMENT_SERVICE_INFO(OCalcConnection, u"com.sun.star.sdbc.drivers.calc.Connection"_ustr, u"com.sun.star.sdbc.Connection"_ustr)
Reference< XDatabaseMetaData > SAL_CALL OCalcConnection::getMetaData( )
@@ -218,12 +213,11 @@ Reference< XDatabaseMetaData > SAL_CALL OCalcConnection::getMetaData( )
css::uno::Reference< XTablesSupplier > OCalcConnection::createCatalog()
{
::osl::MutexGuard aGuard( m_aMutex );
- Reference< XTablesSupplier > xTab = m_xCatalog;
+ rtl::Reference< connectivity::sdbcx::OCatalog > xTab = m_xCatalog;
if(!xTab.is())
{
- OCalcCatalog *pCat = new OCalcCatalog(this);
- xTab = pCat;
- m_xCatalog = xTab;
+ xTab = new OCalcCatalog(this);
+ m_xCatalog = xTab.get();
}
return xTab;
}
@@ -247,8 +241,7 @@ Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareStatement( cons
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- auto pStmt = new connectivity::component::OComponentPreparedStatement(this);
- Reference< XPreparedStatement > xHoldAlive = pStmt;
+ rtl::Reference<connectivity::component::OComponentPreparedStatement> pStmt = new connectivity::component::OComponentPreparedStatement(this);
pStmt->construct(sql);
m_aStatements.push_back(WeakReferenceHelper(*pStmt));
return pStmt;
@@ -260,9 +253,7 @@ Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareCall( const OUS
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::prepareCall", *this );
- return nullptr;
+ ::dbtools::throwFeatureNotImplementedSQLException( u"XConnection::prepareCall"_ustr, *this );
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */