Kaydet (Commit) 9eb929aa authored tarafından Miklos Vajna's avatar Miklos Vajna

connectivity: turn on clang-format for the Writer driver

I (tried to) keep this consistent locally with astyle in the past,
switching to clang-format means consistency is enforced by CI.

Change-Id: I1016e253c6536b207a05328e5f6f13de37889588
Reviewed-on: https://gerrit.libreoffice.org/57046Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
üst 59fe3d7d
...@@ -34,21 +34,21 @@ namespace connectivity ...@@ -34,21 +34,21 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
OWriterCatalog::OWriterCatalog(OWriterConnection* pConnection)
OWriterCatalog::OWriterCatalog(OWriterConnection* pConnection) : file::OFileCatalog(pConnection) : file::OFileCatalog(pConnection)
{ {
} }
void OWriterCatalog::refreshTables() void OWriterCatalog::refreshTables()
{ {
::std::vector< OUString> aVector; ::std::vector<OUString> aVector;
uno::Sequence<OUString> aTypes; uno::Sequence<OUString> aTypes;
OWriterConnection::ODocHolder aDocHolder(static_cast<OWriterConnection*>(m_pConnection)); OWriterConnection::ODocHolder aDocHolder(static_cast<OWriterConnection*>(m_pConnection));
uno::Reference< sdbc::XResultSet > xResult = m_xMetaData->getTables(uno::Any(), "%", "%", aTypes); uno::Reference<sdbc::XResultSet> xResult = m_xMetaData->getTables(uno::Any(), "%", "%", aTypes);
if (xResult.is()) if (xResult.is())
{ {
uno::Reference< sdbc::XRow > xRow(xResult, uno::UNO_QUERY); uno::Reference<sdbc::XRow> xRow(xResult, uno::UNO_QUERY);
while (xResult->next()) while (xResult->next())
aVector.push_back(xRow->getString(3)); aVector.push_back(xRow->getString(3));
} }
......
...@@ -40,20 +40,22 @@ namespace connectivity ...@@ -40,20 +40,22 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
OWriterConnection::OWriterConnection(ODriver* _pDriver)
OWriterConnection::OWriterConnection(ODriver* _pDriver) : OConnection(_pDriver),m_nDocCount(0) : OConnection(_pDriver)
, m_nDocCount(0)
{ {
} }
OWriterConnection::~OWriterConnection() = default; OWriterConnection::~OWriterConnection() = default;
void OWriterConnection::construct(const OUString& rURL, const uno::Sequence< beans::PropertyValue >& rInfo) void OWriterConnection::construct(const OUString& rURL,
const uno::Sequence<beans::PropertyValue>& rInfo)
{ {
// open file // open file
sal_Int32 nLen = rURL.indexOf(':'); sal_Int32 nLen = rURL.indexOf(':');
nLen = rURL.indexOf(':',nLen+1); nLen = rURL.indexOf(':', nLen + 1);
OUString aDSN(rURL.copy(nLen+1)); OUString aDSN(rURL.copy(nLen + 1));
m_aFileName = aDSN; m_aFileName = aDSN;
INetURLObject aURL; INetURLObject aURL;
...@@ -104,18 +106,18 @@ uno::Reference<text::XTextDocument> const& OWriterConnection::acquireDoc() ...@@ -104,18 +106,18 @@ uno::Reference<text::XTextDocument> const& OWriterConnection::acquireDoc()
if (!m_sPassword.isEmpty()) if (!m_sPassword.isEmpty())
{ {
const sal_Int32 nPos = aArgs.getLength(); const sal_Int32 nPos = aArgs.getLength();
aArgs.realloc(nPos+1); aArgs.realloc(nPos + 1);
aArgs[nPos].Name = "Password"; aArgs[nPos].Name = "Password";
aArgs[nPos].Value <<= m_sPassword; aArgs[nPos].Value <<= m_sPassword;
} }
uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(getDriver()->getComponentContext()); uno::Reference<frame::XDesktop2> xDesktop
uno::Reference< lang::XComponent > xComponent; = frame::Desktop::create(getDriver()->getComponentContext());
uno::Reference<lang::XComponent> xComponent;
uno::Any aLoaderException; uno::Any aLoaderException;
try try
{ {
xComponent = xDesktop->loadComponentFromURL( xComponent = xDesktop->loadComponentFromURL(m_aFileName, "_blank", 0, aArgs);
m_aFileName, "_blank", 0, aArgs);
} }
catch (const uno::Exception&) catch (const uno::Exception&)
{ {
...@@ -133,13 +135,13 @@ uno::Reference<text::XTextDocument> const& OWriterConnection::acquireDoc() ...@@ -133,13 +135,13 @@ uno::Reference<text::XTextDocument> const& OWriterConnection::acquireDoc()
uno::Exception aLoaderError; uno::Exception aLoaderError;
OSL_VERIFY(aLoaderException >>= aLoaderError); OSL_VERIFY(aLoaderException >>= aLoaderError);
SAL_WARN("connectivity.writer", "empty m_xDoc, exception type: " << aLoaderException.getValueTypeName() << ", error message: " << aLoaderError); SAL_WARN("connectivity.writer",
"empty m_xDoc, exception type: " << aLoaderException.getValueTypeName()
<< ", error message: " << aLoaderError);
} }
const OUString sError(m_aResources.getResourceStringWithSubstitution( const OUString sError(m_aResources.getResourceStringWithSubstitution(
STR_COULD_NOT_LOAD_FILE, STR_COULD_NOT_LOAD_FILE, "$filename$", m_aFileName));
"$filename$", m_aFileName
));
::dbtools::throwGenericSQLException(sError, *this); ::dbtools::throwGenericSQLException(sError, *this);
} }
osl_atomic_increment(&m_nDocCount); osl_atomic_increment(&m_nDocCount);
...@@ -178,17 +180,15 @@ void OWriterConnection::disposing() ...@@ -178,17 +180,15 @@ void OWriterConnection::disposing()
// XServiceInfo // XServiceInfo
IMPLEMENT_SERVICE_INFO(OWriterConnection, "com.sun.star.sdbc.drivers.writer.Connection",
"com.sun.star.sdbc.Connection")
IMPLEMENT_SERVICE_INFO(OWriterConnection, "com.sun.star.sdbc.drivers.writer.Connection", "com.sun.star.sdbc.Connection") uno::Reference<sdbc::XDatabaseMetaData> SAL_CALL OWriterConnection::getMetaData()
uno::Reference< sdbc::XDatabaseMetaData > SAL_CALL OWriterConnection::getMetaData()
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed); checkDisposed(OConnection_BASE::rBHelper.bDisposed);
uno::Reference<sdbc::XDatabaseMetaData> xMetaData = m_xMetaData;
uno::Reference< sdbc::XDatabaseMetaData > xMetaData = m_xMetaData;
if (!xMetaData.is()) if (!xMetaData.is())
{ {
xMetaData = new OWriterDatabaseMetaData(this); xMetaData = new OWriterDatabaseMetaData(this);
...@@ -198,11 +198,10 @@ uno::Reference< sdbc::XDatabaseMetaData > SAL_CALL OWriterConnection::getMetaDat ...@@ -198,11 +198,10 @@ uno::Reference< sdbc::XDatabaseMetaData > SAL_CALL OWriterConnection::getMetaDat
return xMetaData; return xMetaData;
} }
css::uno::Reference<css::sdbcx::XTablesSupplier> OWriterConnection::createCatalog()
css::uno::Reference< css::sdbcx::XTablesSupplier > OWriterConnection::createCatalog()
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
uno::Reference< css::sdbcx::XTablesSupplier > xTab = m_xCatalog; uno::Reference<css::sdbcx::XTablesSupplier> xTab = m_xCatalog;
if (!xTab.is()) if (!xTab.is())
{ {
auto pCat = new OWriterCatalog(this); auto pCat = new OWriterCatalog(this);
...@@ -212,8 +211,7 @@ css::uno::Reference< css::sdbcx::XTablesSupplier > OWriterConnection::createCata ...@@ -212,8 +211,7 @@ css::uno::Reference< css::sdbcx::XTablesSupplier > OWriterConnection::createCata
return xTab; return xTab;
} }
uno::Reference<sdbc::XStatement> SAL_CALL OWriterConnection::createStatement()
uno::Reference< sdbc::XStatement > SAL_CALL OWriterConnection::createStatement()
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed); checkDisposed(OConnection_BASE::rBHelper.bDisposed);
...@@ -223,8 +221,8 @@ uno::Reference< sdbc::XStatement > SAL_CALL OWriterConnection::createStatement() ...@@ -223,8 +221,8 @@ uno::Reference< sdbc::XStatement > SAL_CALL OWriterConnection::createStatement()
return xReturn; return xReturn;
} }
uno::Reference<sdbc::XPreparedStatement>
uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareStatement(const OUString& sql) SAL_CALL OWriterConnection::prepareStatement(const OUString& sql)
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed); checkDisposed(OConnection_BASE::rBHelper.bDisposed);
...@@ -236,8 +234,8 @@ uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareSt ...@@ -236,8 +234,8 @@ uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareSt
return pStmt; return pStmt;
} }
uno::Reference<sdbc::XPreparedStatement>
uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareCall(const OUString& /*sql*/) SAL_CALL OWriterConnection::prepareCall(const OUString& /*sql*/)
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed); checkDisposed(OConnection_BASE::rBHelper.bDisposed);
......
...@@ -27,8 +27,8 @@ namespace connectivity ...@@ -27,8 +27,8 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
OWriterDatabaseMetaData::OWriterDatabaseMetaData(file::OConnection* pConnection)
OWriterDatabaseMetaData::OWriterDatabaseMetaData(file::OConnection* pConnection) :OComponentDatabaseMetaData(pConnection) : OComponentDatabaseMetaData(pConnection)
{ {
} }
...@@ -41,10 +41,9 @@ OUString SAL_CALL OWriterDatabaseMetaData::getURL() ...@@ -41,10 +41,9 @@ OUString SAL_CALL OWriterDatabaseMetaData::getURL()
return "sdbc:writer:" + m_pConnection->getURL(); return "sdbc:writer:" + m_pConnection->getURL();
} }
uno::Reference<sdbc::XResultSet> SAL_CALL OWriterDatabaseMetaData::getTables( uno::Reference<sdbc::XResultSet> SAL_CALL OWriterDatabaseMetaData::getTables(
const uno::Any& /*catalog*/, const OUString& /*schemaPattern*/, const uno::Any& /*catalog*/, const OUString& /*schemaPattern*/,
const OUString& tableNamePattern, const uno::Sequence< OUString >& types) const OUString& tableNamePattern, const uno::Sequence<OUString>& types)
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
...@@ -89,12 +88,12 @@ uno::Reference<sdbc::XResultSet> SAL_CALL OWriterDatabaseMetaData::getTables( ...@@ -89,12 +88,12 @@ uno::Reference<sdbc::XResultSet> SAL_CALL OWriterDatabaseMetaData::getTables(
ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORows aRows;
sal_Int32 nTableCount = aTableNames.getLength(); sal_Int32 nTableCount = aTableNames.getLength();
for (sal_Int32 nTable=0; nTable<nTableCount; nTable++) for (sal_Int32 nTable = 0; nTable < nTableCount; nTable++)
{ {
OUString aName = aTableNames[nTable]; OUString aName = aTableNames[nTable];
if (match(tableNamePattern,aName,'\0')) if (match(tableNamePattern, aName, '\0'))
{ {
ODatabaseMetaDataResultSet::ORow aRow { nullptr, nullptr, nullptr }; ODatabaseMetaDataResultSet::ORow aRow{ nullptr, nullptr, nullptr };
aRow.reserve(6); aRow.reserve(6);
aRow.push_back(new ORowSetValueDecorator(aName)); aRow.push_back(new ORowSetValueDecorator(aName));
aRow.push_back(new ORowSetValueDecorator(aTable)); aRow.push_back(new ORowSetValueDecorator(aTable));
......
...@@ -32,37 +32,32 @@ namespace connectivity ...@@ -32,37 +32,32 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
OUString ODriver::getImplementationName_Static() OUString ODriver::getImplementationName_Static()
{ {
return OUString("com.sun.star.comp.sdbc.writer.ODriver"); return OUString("com.sun.star.comp.sdbc.writer.ODriver");
} }
OUString SAL_CALL ODriver::getImplementationName() OUString SAL_CALL ODriver::getImplementationName() { return getImplementationName_Static(); }
{
return getImplementationName_Static();
}
uno::Reference< css::uno::XInterface > uno::Reference<css::uno::XInterface>
ODriver_CreateInstance(const uno::Reference< ODriver_CreateInstance(const uno::Reference<lang::XMultiServiceFactory>& _rxFactory)
lang::XMultiServiceFactory >& _rxFactory)
{ {
return *(new ODriver(comphelper::getComponentContext(_rxFactory))); return *(new ODriver(comphelper::getComponentContext(_rxFactory)));
} }
uno::Reference< sdbc::XConnection > SAL_CALL ODriver::connect(const OUString& url, uno::Reference<sdbc::XConnection>
const uno::Sequence< beans::PropertyValue >& info) SAL_CALL ODriver::connect(const OUString& url, const uno::Sequence<beans::PropertyValue>& info)
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
if (ODriver_BASE::rBHelper.bDisposed) if (ODriver_BASE::rBHelper.bDisposed)
throw lang::DisposedException(); throw lang::DisposedException();
if (! acceptsURL(url)) if (!acceptsURL(url))
return nullptr; return nullptr;
auto pCon = new OWriterConnection(this); auto pCon = new OWriterConnection(this);
pCon->construct(url, info); pCon->construct(url, info);
uno::Reference< sdbc::XConnection > xCon = pCon; uno::Reference<sdbc::XConnection> xCon = pCon;
m_xConnections.push_back(uno::WeakReferenceHelper(*pCon)); m_xConnections.push_back(uno::WeakReferenceHelper(*pCon));
return xCon; return xCon;
...@@ -73,15 +68,16 @@ sal_Bool SAL_CALL ODriver::acceptsURL(const OUString& url) ...@@ -73,15 +68,16 @@ sal_Bool SAL_CALL ODriver::acceptsURL(const OUString& url)
return url.startsWith("sdbc:writer:"); return url.startsWith("sdbc:writer:");
} }
uno::Sequence< sdbc::DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo(const OUString& url, const uno::Sequence< beans::PropertyValue >& /*info*/) uno::Sequence<sdbc::DriverPropertyInfo> SAL_CALL
ODriver::getPropertyInfo(const OUString& url, const uno::Sequence<beans::PropertyValue>& /*info*/)
{ {
if (!acceptsURL(url)) if (!acceptsURL(url))
{ {
SharedResources aResources; SharedResources aResources;
const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
::dbtools::throwGenericSQLException(sMessage,*this); ::dbtools::throwGenericSQLException(sMessage, *this);
} }
return uno::Sequence< sdbc::DriverPropertyInfo >(); return uno::Sequence<sdbc::DriverPropertyInfo>();
} }
} // namespace writer } // namespace writer
......
...@@ -45,7 +45,8 @@ class XTextDocument; ...@@ -45,7 +45,8 @@ class XTextDocument;
using namespace ::com::sun::star; using namespace ::com::sun::star;
static void lcl_GetDataArea(const uno::Reference<text::XTextTable>& xTable, sal_Int32& rColumnCount, sal_Int32& rRowCount) static void lcl_GetDataArea(const uno::Reference<text::XTextTable>& xTable, sal_Int32& rColumnCount,
sal_Int32& rRowCount)
{ {
uno::Reference<container::XIndexAccess> xColumns(xTable->getColumns(), uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xColumns(xTable->getColumns(), uno::UNO_QUERY);
if (xColumns.is()) if (xColumns.is())
...@@ -54,18 +55,18 @@ static void lcl_GetDataArea(const uno::Reference<text::XTextTable>& xTable, sal_ ...@@ -54,18 +55,18 @@ static void lcl_GetDataArea(const uno::Reference<text::XTextTable>& xTable, sal_
uno::Reference<container::XIndexAccess> xRows(xTable->getRows(), uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xRows(xTable->getRows(), uno::UNO_QUERY);
if (xRows.is()) if (xRows.is())
rRowCount = xRows->getCount() - 1; // first row (headers) is not counted rRowCount = xRows->getCount() - 1; // first row (headers) is not counted
} }
static void lcl_GetColumnInfo(const uno::Reference<text::XTextTable>& xTable, static void lcl_GetColumnInfo(const uno::Reference<text::XTextTable>& xTable, sal_Int32 nDocColumn,
sal_Int32 nDocColumn, bool bHasHeaders, bool bHasHeaders, OUString& rName, sal_Int32& rDataType,
OUString& rName, sal_Int32& rDataType, bool& rCurrency) bool& rCurrency)
{ {
uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY); uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
// get column name from first row, if range contains headers // get column name from first row, if range contains headers
if (bHasHeaders) if (bHasHeaders)
{ {
uno::Reference<text::XText> xHeaderText(xCellRange->getCellByPosition(nDocColumn, /*nStartRow*/0), uno::UNO_QUERY); uno::Reference<text::XText> xHeaderText(
xCellRange->getCellByPosition(nDocColumn, /*nStartRow*/ 0), uno::UNO_QUERY);
if (xHeaderText.is()) if (xHeaderText.is())
rName = xHeaderText->getString(); rName = xHeaderText->getString();
} }
...@@ -74,10 +75,9 @@ static void lcl_GetColumnInfo(const uno::Reference<text::XTextTable>& xTable, ...@@ -74,10 +75,9 @@ static void lcl_GetColumnInfo(const uno::Reference<text::XTextTable>& xTable,
rDataType = sdbc::DataType::VARCHAR; rDataType = sdbc::DataType::VARCHAR;
} }
static void lcl_SetValue(connectivity::ORowSetValue& rValue,
static void lcl_SetValue(connectivity::ORowSetValue& rValue, const uno::Reference<text::XTextTable>& xTable, const uno::Reference<text::XTextTable>& xTable, sal_Int32 nStartCol,
sal_Int32 nStartCol, bool bHasHeaders, bool bHasHeaders, sal_Int32 nDBRow, sal_Int32 nDBColumn)
sal_Int32 nDBRow, sal_Int32 nDBColumn)
{ {
sal_Int32 nDocColumn = nStartCol + nDBColumn - 1; // database counts from 1 sal_Int32 nDocColumn = nStartCol + nDBColumn - 1; // database counts from 1
sal_Int32 nDocRow = nDBRow - 1; sal_Int32 nDocRow = nDBRow - 1;
...@@ -92,7 +92,8 @@ static void lcl_SetValue(connectivity::ORowSetValue& rValue, const uno::Referenc ...@@ -92,7 +92,8 @@ static void lcl_SetValue(connectivity::ORowSetValue& rValue, const uno::Referenc
} }
catch (const lang::IndexOutOfBoundsException& /*rException*/) catch (const lang::IndexOutOfBoundsException& /*rException*/)
{ {
SAL_WARN("connectivity.writer", "getCellByPosition(" << nDocColumn << ", " << nDocRow << ") failed"); SAL_WARN("connectivity.writer",
"getCellByPosition(" << nDocColumn << ", " << nDocRow << ") failed");
rValue = OUString(); rValue = OUString();
} }
...@@ -108,15 +109,16 @@ namespace connectivity ...@@ -108,15 +109,16 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
void OWriterTable::fillColumns() void OWriterTable::fillColumns()
{ {
if (!m_xTable.is()) if (!m_xTable.is())
throw sdbc::SQLException(); throw sdbc::SQLException();
OUString aTypeName; OUString aTypeName;
::comphelper::UStringMixEqual aCase(m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); ::comphelper::UStringMixEqual aCase(
const bool bStoresMixedCaseQuotedIdentifiers = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(); m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
const bool bStoresMixedCaseQuotedIdentifiers
= getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers();
for (sal_Int32 i = 0; i < m_nDataCols; i++) for (sal_Int32 i = 0; i < m_nDataCols; i++)
{ {
...@@ -124,8 +126,7 @@ void OWriterTable::fillColumns() ...@@ -124,8 +126,7 @@ void OWriterTable::fillColumns()
sal_Int32 eType = sdbc::DataType::OTHER; sal_Int32 eType = sdbc::DataType::OTHER;
bool bCurrency = false; bool bCurrency = false;
lcl_GetColumnInfo(m_xTable, m_nStartCol + i, m_bHasHeaders, lcl_GetColumnInfo(m_xTable, m_nStartCol + i, m_bHasHeaders, aColumnName, eType, bCurrency);
aColumnName, eType, bCurrency);
sal_Int32 nPrecision = 0; //! ... sal_Int32 nPrecision = 0; //! ...
sal_Int32 nDecimals = 0; //! ... sal_Int32 nDecimals = 0; //! ...
...@@ -157,20 +158,21 @@ void OWriterTable::fillColumns() ...@@ -157,20 +158,21 @@ void OWriterTable::fillColumns()
// check if the column name already exists // check if the column name already exists
OUString aAlias = aColumnName; OUString aAlias = aColumnName;
auto aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); auto aFind
= connectivity::find(m_aColumns->get().begin(), m_aColumns->get().end(), aAlias, aCase);
sal_Int32 nExprCnt = 0; sal_Int32 nExprCnt = 0;
while (aFind != m_aColumns->get().end()) while (aFind != m_aColumns->get().end())
{ {
(aAlias = aColumnName) += OUString::number(++nExprCnt); (aAlias = aColumnName) += OUString::number(++nExprCnt);
aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); aFind = connectivity::find(m_aColumns->get().begin(), m_aColumns->get().end(), aAlias,
aCase);
} }
sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias, aTypeName, OUString(),OUString(), sdbcx::OColumn* pColumn = new sdbcx::OColumn(
sdbc::ColumnValue::NULLABLE, nPrecision, nDecimals, aAlias, aTypeName, OUString(), OUString(), sdbc::ColumnValue::NULLABLE, nPrecision,
eType, false, false, bCurrency, nDecimals, eType, false, false, bCurrency, bStoresMixedCaseQuotedIdentifiers,
bStoresMixedCaseQuotedIdentifiers,
m_CatalogName, getSchema(), getName()); m_CatalogName, getSchema(), getName());
uno::Reference< XPropertySet> xCol = pColumn; uno::Reference<XPropertySet> xCol = pColumn;
m_aColumns->get().push_back(xCol); m_aColumns->get().push_back(xCol);
m_aTypes.push_back(eType); m_aTypes.push_back(eType);
m_aPrecisions.push_back(nPrecision); m_aPrecisions.push_back(nPrecision);
...@@ -178,19 +180,14 @@ void OWriterTable::fillColumns() ...@@ -178,19 +180,14 @@ void OWriterTable::fillColumns()
} }
} }
OWriterTable::OWriterTable(sdbcx::OCollection* _pTables, OWriterConnection* _pConnection, OWriterTable::OWriterTable(sdbcx::OCollection* _pTables, OWriterConnection* _pConnection,
const OUString& Name, const OUString& Name, const OUString& Type)
const OUString& Type : OWriterTable_BASE(_pTables, _pConnection, Name, Type, OUString() /*Description*/,
) : OWriterTable_BASE(_pTables,_pConnection,Name, OUString() /*SchemaName*/, OUString() /*CatalogName*/)
Type, , m_pWriterConnection(_pConnection)
OUString()/*Description*/, , m_nStartCol(0)
OUString()/*SchemaName*/, , m_nDataCols(0)
OUString()/*CatalogName*/) , m_bHasHeaders(false)
,m_pWriterConnection(_pConnection)
,m_nStartCol(0)
,m_nDataCols(0)
,m_bHasHeaders(false)
{ {
} }
...@@ -229,25 +226,24 @@ void SAL_CALL OWriterTable::disposing() ...@@ -229,25 +226,24 @@ void SAL_CALL OWriterTable::disposing()
if (m_pWriterConnection) if (m_pWriterConnection)
m_pWriterConnection->releaseDoc(); m_pWriterConnection->releaseDoc();
m_pWriterConnection = nullptr; m_pWriterConnection = nullptr;
} }
uno::Sequence< sal_Int8 > OWriterTable::getUnoTunnelImplementationId() uno::Sequence<sal_Int8> OWriterTable::getUnoTunnelImplementationId()
{ {
static ::cppu::OImplementationId implId; static ::cppu::OImplementationId implId;
return implId.getImplementationId(); return implId.getImplementationId();
} }
sal_Int64 OWriterTable::getSomething(const uno::Sequence< sal_Int8 >& rId) sal_Int64 OWriterTable::getSomething(const uno::Sequence<sal_Int8>& rId)
{ {
return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16)) return (rId.getLength() == 16
? reinterpret_cast< sal_Int64 >(this) && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16))
? reinterpret_cast<sal_Int64>(this)
: OWriterTable_BASE::getSomething(rId); : OWriterTable_BASE::getSomething(rId);
} }
bool OWriterTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, bool OWriterTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, bool bRetrieveData)
bool bRetrieveData)
{ {
// read the bookmark // read the bookmark
...@@ -262,13 +258,12 @@ bool OWriterTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, ...@@ -262,13 +258,12 @@ bool OWriterTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols,
auto aIter = _rCols.get().begin(); auto aIter = _rCols.get().begin();
auto aEnd = _rCols.get().end(); auto aEnd = _rCols.get().end();
const OValueRefVector::Vector::size_type nCount = _rRow->get().size(); const OValueRefVector::Vector::size_type nCount = _rRow->get().size();
for (OValueRefVector::Vector::size_type i = 1; aIter != aEnd && i < nCount; for (OValueRefVector::Vector::size_type i = 1; aIter != aEnd && i < nCount; ++aIter, i++)
++aIter, i++)
{ {
if ((_rRow->get())[i]->isBound()) if ((_rRow->get())[i]->isBound())
{ {
lcl_SetValue((_rRow->get())[i]->get(), m_xTable, m_nStartCol, m_bHasHeaders, lcl_SetValue((_rRow->get())[i]->get(), m_xTable, m_nStartCol, m_bHasHeaders, m_nFilePos,
m_nFilePos, i); i);
} }
} }
return true; return true;
......
...@@ -31,10 +31,13 @@ namespace connectivity ...@@ -31,10 +31,13 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
sdbcx::ObjectType OWriterTables::createObject(const OUString& rName) sdbcx::ObjectType OWriterTables::createObject(const OUString& rName)
{ {
OWriterTable* pTable = new OWriterTable(this, static_cast<OWriterConnection*>(static_cast<file::OFileCatalog&>(m_rParent).getConnection()), rName, "TABLE"); OWriterTable* pTable
= new OWriterTable(this,
static_cast<OWriterConnection*>(
static_cast<file::OFileCatalog&>(m_rParent).getConnection()),
rName, "TABLE");
sdbcx::ObjectType xRet = pTable; sdbcx::ObjectType xRet = pTable;
pTable->construct(); pTable->construct();
return xRet; return xRet;
......
...@@ -22,43 +22,31 @@ ...@@ -22,43 +22,31 @@
using namespace com::sun::star; using namespace com::sun::star;
using createFactoryFunc = uno::Reference<lang::XSingleServiceFactory> (*) using createFactoryFunc = uno::Reference<lang::XSingleServiceFactory> (*)(
( const uno::Reference<lang::XMultiServiceFactory>& rServiceManager,
const uno::Reference< lang::XMultiServiceFactory >& rServiceManager, const OUString& rComponentName, ::cppu::ComponentInstantiation pCreateFunction,
const OUString& rComponentName, const uno::Sequence<OUString>& rServiceNames, rtl_ModuleCount*);
::cppu::ComponentInstantiation pCreateFunction,
const uno::Sequence< OUString >& rServiceNames,
rtl_ModuleCount*
);
struct ProviderRequest struct ProviderRequest
{ {
uno::Reference< lang::XSingleServiceFactory > xRet; uno::Reference<lang::XSingleServiceFactory> xRet;
uno::Reference< lang::XMultiServiceFactory > const xServiceManager; uno::Reference<lang::XMultiServiceFactory> const xServiceManager;
OUString const sImplementationName; OUString const sImplementationName;
ProviderRequest( ProviderRequest(void* pServiceManager, sal_Char const* pImplementationName)
void* pServiceManager,
sal_Char const* pImplementationName
)
: xServiceManager(static_cast<lang::XMultiServiceFactory*>(pServiceManager)) : xServiceManager(static_cast<lang::XMultiServiceFactory*>(pServiceManager))
, sImplementationName(OUString::createFromAscii(pImplementationName)) , sImplementationName(OUString::createFromAscii(pImplementationName))
{ {
} }
bool CREATE_PROVIDER( bool CREATE_PROVIDER(const OUString& Implname, const uno::Sequence<OUString>& Services,
const OUString& Implname, ::cppu::ComponentInstantiation Factory, createFactoryFunc creator)
const uno::Sequence< OUString >& Services,
::cppu::ComponentInstantiation Factory,
createFactoryFunc creator
)
{ {
if (!xRet.is() && (Implname == sImplementationName)) if (!xRet.is() && (Implname == sImplementationName))
{ {
try try
{ {
xRet = creator(xServiceManager, sImplementationName,Factory, Services,nullptr); xRet = creator(xServiceManager, sImplementationName, Factory, Services, nullptr);
} }
catch (...) catch (...)
{ {
...@@ -67,28 +55,22 @@ struct ProviderRequest ...@@ -67,28 +55,22 @@ struct ProviderRequest
return xRet.is(); return xRet.is();
} }
void* getProvider() const void* getProvider() const { return xRet.get(); }
{
return xRet.get();
}
}; };
extern "C" SAL_DLLPUBLIC_EXPORT void*
extern "C" SAL_DLLPUBLIC_EXPORT void* connectivity_writer_component_getFactory( connectivity_writer_component_getFactory(const sal_Char* pImplementationName, void* pServiceManager,
const sal_Char* pImplementationName,
void* pServiceManager,
void* /*pRegistryKey*/) void* /*pRegistryKey*/)
{ {
void* pRet = nullptr; void* pRet = nullptr;
if (pServiceManager) if (pServiceManager)
{ {
ProviderRequest aReq(pServiceManager,pImplementationName); ProviderRequest aReq(pServiceManager, pImplementationName);
aReq.CREATE_PROVIDER( aReq.CREATE_PROVIDER(connectivity::writer::ODriver::getImplementationName_Static(),
connectivity::writer::ODriver::getImplementationName_Static(),
connectivity::writer::ODriver::getSupportedServiceNames_Static(), connectivity::writer::ODriver::getSupportedServiceNames_Static(),
connectivity::writer::ODriver_CreateInstance, ::cppu::createSingleFactory) connectivity::writer::ODriver_CreateInstance,
; ::cppu::createSingleFactory);
if (aReq.xRet.is()) if (aReq.xRet.is())
aReq.xRet->acquire(); aReq.xRet->acquire();
......
...@@ -26,7 +26,6 @@ namespace connectivity ...@@ -26,7 +26,6 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
class OWriterConnection; class OWriterConnection;
class OWriterCatalog : public file::OFileCatalog class OWriterCatalog : public file::OFileCatalog
{ {
......
...@@ -46,7 +46,6 @@ namespace utl ...@@ -46,7 +46,6 @@ namespace utl
class CloseVeto; class CloseVeto;
} }
namespace connectivity namespace connectivity
{ {
namespace writer namespace writer
...@@ -55,12 +54,13 @@ class ODriver; ...@@ -55,12 +54,13 @@ class ODriver;
class OWriterConnection : public file::OConnection class OWriterConnection : public file::OConnection
{ {
// the spreadsheet document: // the spreadsheet document:
css::uno::Reference< css::text::XTextDocument > m_xDoc; css::uno::Reference<css::text::XTextDocument> m_xDoc;
OUString m_sPassword; OUString m_sPassword;
OUString m_aFileName; OUString m_aFileName;
oslInterlockedCount m_nDocCount; oslInterlockedCount m_nDocCount;
class CloseVetoButTerminateListener : public cppu::WeakComponentImplHelper<css::frame::XTerminateListener> class CloseVetoButTerminateListener
: public cppu::WeakComponentImplHelper<css::frame::XTerminateListener>
{ {
private: private:
/// close listener that vetoes so nobody else disposes m_xDoc /// close listener that vetoes so nobody else disposes m_xDoc
...@@ -69,6 +69,7 @@ class OWriterConnection : public file::OConnection ...@@ -69,6 +69,7 @@ class OWriterConnection : public file::OConnection
/// its still possible to do so properly /// its still possible to do so properly
css::uno::Reference<css::frame::XDesktop2> m_xDesktop; css::uno::Reference<css::frame::XDesktop2> m_xDesktop;
osl::Mutex m_aMutex; osl::Mutex m_aMutex;
public: public:
CloseVetoButTerminateListener() CloseVetoButTerminateListener()
: cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aMutex) : cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aMutex)
...@@ -93,9 +94,7 @@ class OWriterConnection : public file::OConnection ...@@ -93,9 +94,7 @@ class OWriterConnection : public file::OConnection
} }
// XTerminateListener // XTerminateListener
void SAL_CALL queryTermination(const css::lang::EventObject& /*rEvent*/) override void SAL_CALL queryTermination(const css::lang::EventObject& /*rEvent*/) override {}
{
}
void SAL_CALL notifyTermination(const css::lang::EventObject& /*rEvent*/) override void SAL_CALL notifyTermination(const css::lang::EventObject& /*rEvent*/) override
{ {
...@@ -123,7 +122,7 @@ public: ...@@ -123,7 +122,7 @@ public:
~OWriterConnection() override; ~OWriterConnection() override;
void construct(const OUString& rURL, void construct(const OUString& rURL,
const css::uno::Sequence< css::beans::PropertyValue >& rInfo) override; const css::uno::Sequence<css::beans::PropertyValue>& rInfo) override;
// XServiceInfo // XServiceInfo
DECLARE_SERVICE_INFO(); DECLARE_SERVICE_INFO();
...@@ -132,22 +131,26 @@ public: ...@@ -132,22 +131,26 @@ public:
void SAL_CALL disposing() override; void SAL_CALL disposing() override;
// XConnection // XConnection
css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override; css::uno::Reference<css::sdbc::XDatabaseMetaData> SAL_CALL getMetaData() override;
css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog() override; css::uno::Reference<css::sdbcx::XTablesSupplier> createCatalog() override;
css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override; css::uno::Reference<css::sdbc::XStatement> SAL_CALL createStatement() override;
css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString& sql) override; css::uno::Reference<css::sdbc::XPreparedStatement>
css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString& sql) override; SAL_CALL prepareStatement(const OUString& sql) override;
css::uno::Reference<css::sdbc::XPreparedStatement>
SAL_CALL prepareCall(const OUString& sql) override;
// no interface methods // no interface methods
css::uno::Reference< css::text::XTextDocument> const& acquireDoc(); css::uno::Reference<css::text::XTextDocument> const& acquireDoc();
void releaseDoc(); void releaseDoc();
class ODocHolder class ODocHolder
{ {
OWriterConnection* m_pConnection; OWriterConnection* m_pConnection;
css::uno::Reference< css::text::XTextDocument> m_xDoc; css::uno::Reference<css::text::XTextDocument> m_xDoc;
public: public:
ODocHolder(OWriterConnection* _pConnection) : m_pConnection(_pConnection) ODocHolder(OWriterConnection* _pConnection)
: m_pConnection(_pConnection)
{ {
m_xDoc = m_pConnection->acquireDoc(); m_xDoc = m_pConnection->acquireDoc();
} }
...@@ -156,10 +159,7 @@ public: ...@@ -156,10 +159,7 @@ public:
m_xDoc.clear(); m_xDoc.clear();
m_pConnection->releaseDoc(); m_pConnection->releaseDoc();
} }
const css::uno::Reference< css::text::XTextDocument>& getDoc() const const css::uno::Reference<css::text::XTextDocument>& getDoc() const { return m_xDoc; }
{
return m_xDoc;
}
}; };
}; };
} }
......
...@@ -26,13 +26,17 @@ namespace connectivity ...@@ -26,13 +26,17 @@ namespace connectivity
{ {
namespace writer namespace writer
{ {
class OWriterDatabaseMetaData : public component::OComponentDatabaseMetaData class OWriterDatabaseMetaData : public component::OComponentDatabaseMetaData
{ {
OUString SAL_CALL getURL() override; OUString SAL_CALL getURL() override;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTables(const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const css::uno::Sequence< OUString >& types) override; css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getTables(const css::uno::Any& catalog, const OUString& schemaPattern,
const OUString& tableNamePattern,
const css::uno::Sequence<OUString>& types) override;
protected: protected:
~OWriterDatabaseMetaData() override; ~OWriterDatabaseMetaData() override;
public: public:
OWriterDatabaseMetaData(file::OConnection* pConnection); OWriterDatabaseMetaData(file::OConnection* pConnection);
}; };
......
...@@ -41,26 +41,28 @@ namespace connectivity ...@@ -41,26 +41,28 @@ namespace connectivity
namespace writer namespace writer
{ {
/// @throws css::uno::Exception /// @throws css::uno::Exception
css::uno::Reference< css::uno::XInterface > css::uno::Reference<css::uno::XInterface>
ODriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); ODriver_CreateInstance(const css::uno::Reference<css::lang::XMultiServiceFactory>& _rxFactory);
class ODriver : public file::OFileDriver class ODriver : public file::OFileDriver
{ {
public: public:
ODriver(const css::uno::Reference< ODriver(const css::uno::Reference<css::uno::XComponentContext>& _rxContext)
css::uno::XComponentContext >& _rxContext) : : file::OFileDriver(_rxContext)
file::OFileDriver(_rxContext) {} {
}
/// @throws css::uno::RuntimeException /// @throws css::uno::RuntimeException
static OUString getImplementationName_Static(); static OUString getImplementationName_Static();
OUString SAL_CALL getImplementationName() override; OUString SAL_CALL getImplementationName() override;
// XDriver // XDriver
css::uno::Reference< css::sdbc::XConnection > SAL_CALL css::uno::Reference<css::sdbc::XConnection>
connect(const OUString& url, const css::uno::Sequence< SAL_CALL connect(const OUString& url,
css::beans::PropertyValue >& info) override; const css::uno::Sequence<css::beans::PropertyValue>& info) override;
sal_Bool SAL_CALL acceptsURL(const OUString& url) override; sal_Bool SAL_CALL acceptsURL(const OUString& url) override;
css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info) override; css::uno::Sequence<css::sdbc::DriverPropertyInfo> SAL_CALL getPropertyInfo(
const OUString& url, const css::uno::Sequence<css::beans::PropertyValue>& info) override;
}; };
} }
} }
......
...@@ -50,7 +50,6 @@ class XNumberFormats; ...@@ -50,7 +50,6 @@ class XNumberFormats;
} }
} }
namespace connectivity namespace connectivity
{ {
namespace writer namespace writer
...@@ -61,31 +60,30 @@ class OWriterConnection; ...@@ -61,31 +60,30 @@ class OWriterConnection;
class OWriterTable : public OWriterTable_BASE class OWriterTable : public OWriterTable_BASE
{ {
private: private:
std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset std::vector<sal_Int32>
m_aTypes; // holds all type for columns just to avoid to ask the propertyset
std::vector<sal_Int32> m_aPrecisions; // same as aboth std::vector<sal_Int32> m_aPrecisions; // same as aboth
std::vector<sal_Int32> m_aScales; std::vector<sal_Int32> m_aScales;
css::uno::Reference< css::text::XTextTable > m_xTable; css::uno::Reference<css::text::XTextTable> m_xTable;
OWriterConnection* m_pWriterConnection; OWriterConnection* m_pWriterConnection;
sal_Int32 m_nStartCol; sal_Int32 m_nStartCol;
sal_Int32 m_nDataCols; sal_Int32 m_nDataCols;
bool m_bHasHeaders; bool m_bHasHeaders;
css::uno::Reference< css::util::XNumberFormats > m_xFormats; css::uno::Reference<css::util::XNumberFormats> m_xFormats;
void fillColumns(); void fillColumns();
public: public:
OWriterTable(sdbcx::OCollection* _pTables, OWriterConnection* _pConnection, OWriterTable(sdbcx::OCollection* _pTables, OWriterConnection* _pConnection,
const OUString& Name, const OUString& Name, const OUString& Type);
const OUString& Type
);
bool fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, bool bRetrieveData) override; bool fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, bool bRetrieveData) override;
void SAL_CALL disposing() override; void SAL_CALL disposing() override;
// css::lang::XUnoTunnel // css::lang::XUnoTunnel
sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId) override; sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& rId) override;
static css::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); static css::uno::Sequence<sal_Int8> getUnoTunnelImplementationId();
void construct() override; void construct() override;
}; };
......
...@@ -32,10 +32,14 @@ class OWriterTables : public OWriterTables_BASE ...@@ -32,10 +32,14 @@ class OWriterTables : public OWriterTables_BASE
{ {
protected: protected:
sdbcx::ObjectType createObject(const OUString& rName) override; sdbcx::ObjectType createObject(const OUString& rName) override;
public: public:
OWriterTables(const css::uno::Reference<css::sdbc::XDatabaseMetaData>& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, OWriterTables(const css::uno::Reference<css::sdbc::XDatabaseMetaData>& _rMetaData,
const ::std::vector< OUString>& _rVector) : OWriterTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
{} const ::std::vector<OUString>& _rVector)
: OWriterTables_BASE(_rMetaData, _rParent, _rMutex, _rVector)
{
}
}; };
} }
} }
......
...@@ -2412,13 +2412,6 @@ connectivity/source/drivers/postgresql/pq_xview.cxx ...@@ -2412,13 +2412,6 @@ connectivity/source/drivers/postgresql/pq_xview.cxx
connectivity/source/drivers/postgresql/pq_xview.hxx connectivity/source/drivers/postgresql/pq_xview.hxx
connectivity/source/drivers/postgresql/pq_xviews.cxx connectivity/source/drivers/postgresql/pq_xviews.cxx
connectivity/source/drivers/postgresql/pq_xviews.hxx connectivity/source/drivers/postgresql/pq_xviews.hxx
connectivity/source/drivers/writer/WCatalog.cxx
connectivity/source/drivers/writer/WConnection.cxx
connectivity/source/drivers/writer/WDatabaseMetaData.cxx
connectivity/source/drivers/writer/WDriver.cxx
connectivity/source/drivers/writer/WTable.cxx
connectivity/source/drivers/writer/WTables.cxx
connectivity/source/drivers/writer/Wservices.cxx
connectivity/source/inc/AutoRetrievingBase.hxx connectivity/source/inc/AutoRetrievingBase.hxx
connectivity/source/inc/FDatabaseMetaDataResultSet.hxx connectivity/source/inc/FDatabaseMetaDataResultSet.hxx
connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx
...@@ -2592,12 +2585,6 @@ connectivity/source/inc/odbc/OTools.hxx ...@@ -2592,12 +2585,6 @@ connectivity/source/inc/odbc/OTools.hxx
connectivity/source/inc/odbc/odbcbasedllapi.hxx connectivity/source/inc/odbc/odbcbasedllapi.hxx
connectivity/source/inc/propertyids.hxx connectivity/source/inc/propertyids.hxx
connectivity/source/inc/resource/sharedresources.hxx connectivity/source/inc/resource/sharedresources.hxx
connectivity/source/inc/writer/WCatalog.hxx
connectivity/source/inc/writer/WConnection.hxx
connectivity/source/inc/writer/WDatabaseMetaData.hxx
connectivity/source/inc/writer/WDriver.hxx
connectivity/source/inc/writer/WTable.hxx
connectivity/source/inc/writer/WTables.hxx
connectivity/source/manager/mdrivermanager.cxx connectivity/source/manager/mdrivermanager.cxx
connectivity/source/manager/mdrivermanager.hxx connectivity/source/manager/mdrivermanager.hxx
connectivity/source/manager/mregistration.cxx connectivity/source/manager/mregistration.cxx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment