From c478d1b3cc371d3b9e8147ff57347f99d25c565e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 17 Jul 2017 08:02:54 +0200 Subject: Implement mail merge data source from Writer tables This is a combination of 17 commits: connectivity: add initial writer backend Similar to the calc one. As a first step the Driver and the Connection interfaces are implemented, though the later has some stubs. (cherry picked from commit 69068f2228147ca0d252762612edbcab0713cdfa) connectivity writer driver: initial DatabaseMetaData implementation With this the list of tables is visible in Data Sources. (cherry picked from commit d7ac239793905564d2754edc52611930b6ba2cdc) connectivity writer driver: add Catalog implementation But leave OWriterCatalog::refreshTables() as a stub for now. (cherry picked from commit 6fb3e3a9c1dd1aec8a1ba90fea51e32048e609bf) connectivity writer driver: add Tables implementation But leave OWriterTables::createObject() as a stub for now. (cherry picked from commit 60020f61339e5836f5a481909c1183af2734f569) connectivity writer driver: add Table implementation Gets rid of the stub warnings in OWriterTables::createObject(). (cherry picked from commit bec2da98c74dc4c02561641862de15e5d2630fa2) connectivity writer driver: add Columns implementation Gets rid of the stub warnings in OWriterTable::refreshColumns(). (cherry picked from commit a11ddfdcf3f5021cbeb0f065694d875bb748dc76) connectivity writer driver: add PreparedStatement implementation Gets rid of the stub warnings in OWriterConnection::prepareStatement(). (cherry picked from commit ac3c24bec925dd53f07b2827dab0d71c0dbaedee) Conflicts: connectivity/source/drivers/writer/WConnection.cxx connectivity writer driver: add ResultSet implementation Now column headers and table data show up on the UI. (cherry picked from commit a93c89894feb663df37609c95d4db523120c0bc1) connectivity writer driver: add Statement implementation Gets rid of the OWriterConnection::createStatement() stub warning. This is the last interface which was not supported by the writer driver, as far as I see. (cherry picked from commit cad0d8df38cf390d0615668ce2ab7c8f7ee42cde) connectivity writer driver: mention Writer in display name It was just "Document" to be consistent with Calc's "Spreadsheet", but it's confusing as we have a Text driver as well. (cherry picked from commit 5445de1432fd65fb3ef613d1dafd2bbb9b99b265) dbaccess: introduce DATASOURCE_TYPE::DST_WRITER By mostly reusing the spreadsheet code. This way the UI allows creating a data source where the backend is a Writer document (containing at least one Writer table). (cherry picked from commit 36f2df84fcfc21038b4d20df38a9e5addfcbde3f) sw mail merge: add support for the new 'writer' connectivity driver By mapping the .odt, .sxw, .doc and .docx extensions to sdbc:writer:. If we are at it, also accept xlsx next to xls. (cherry picked from commit 83b43ef2223b66484e0e90e7b614886e06f955b5) Conflicts: sw/inc/dbui.hrc sw/source/uibase/dbui/dbmgr.cxx sw mailmerge: add writer data source testcase Fails with commit 83b43ef2223b66484e0e90e7b614886e06f955b5 (sw mail merge: add support for the new 'writer' connectivity driver, 2017-07-18) reverted. (cherry picked from commit d9b0108e3af7244179bcc7b07db9d0826c3ac8a6) connectivity: merge OCalcResultSet and OWriterResultSet Into a single OComponentResultSet, as both of them just provide data source functionality based on a file loaded into an LO component, so they can share code. (cherry picked from commit e473d49acc127ece76eb31cb3610e3950f35d9d9) Conflicts: connectivity/source/drivers/component/CResultSet.cxx connectivity/source/drivers/writer/WResultSet.cxx connectivity/source/inc/writer/WResultSet.hxx connectivity: merge OCalcStatement and OWriterStatement Into a single OComponentStatement, as both of them just provide statement functionality based on a file loaded into an LO component, so they can share code. (cherry picked from commit 4073bc15d1aa1b46b2e0953d6316f2ab6a23dc87) connectivity: merge OCalcPreparedStatement and OWriterPreparedStatement Into a single OComponentPreparedStatement, as both of them just provide prepared statement functionality based on a file loaded into an LO component, so they can share code. (cherry picked from commit 196ee66d4aab62678a8cfb762379909bdda16051) connectivity: merge OCalcColumns and OWriterColumns Turns out createObject() only needs the base class OFileTable, and then these can be shared. (cherry picked from commit d3d9292a0fb414e6721b2f3b12b7e283caed946d) Change-Id: I6e8a83155dbbbc3d85794e190c2e710d01902017 Reviewed-on: https://gerrit.libreoffice.org/40231 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky --- Repository.mk | 1 + connectivity/Configuration_writer.mk | 20 + connectivity/Library_calc.mk | 4 - connectivity/Library_file.mk | 4 + connectivity/Library_writer.mk | 49 +++ connectivity/Module_connectivity.mk | 2 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 44 +++ connectivity/source/drivers/calc/CColumns.cxx | 46 --- connectivity/source/drivers/calc/CConnection.cxx | 8 +- .../source/drivers/calc/CPreparedStatement.cxx | 34 -- connectivity/source/drivers/calc/CResultSet.cxx | 175 --------- connectivity/source/drivers/calc/CStatement.cxx | 34 -- connectivity/source/drivers/calc/CTable.cxx | 4 +- connectivity/source/drivers/component/CColumns.cxx | 45 +++ .../drivers/component/CPreparedStatement.cxx | 34 ++ .../source/drivers/component/CResultSet.cxx | 175 +++++++++ .../source/drivers/component/CStatement.cxx | 34 ++ connectivity/source/drivers/writer/WCatalog.cxx | 63 ++++ connectivity/source/drivers/writer/WConnection.cxx | 257 +++++++++++++ .../source/drivers/writer/WDatabaseMetaData.cxx | 325 ++++++++++++++++ connectivity/source/drivers/writer/WDriver.cxx | 90 +++++ connectivity/source/drivers/writer/WTable.cxx | 420 +++++++++++++++++++++ connectivity/source/drivers/writer/WTables.cxx | 50 +++ connectivity/source/drivers/writer/Wservices.cxx | 102 +++++ .../source/drivers/writer/writer.component | 17 + connectivity/source/inc/calc/CColumns.hxx | 46 --- .../source/inc/calc/CPreparedStatement.hxx | 43 --- connectivity/source/inc/calc/CResultSet.hxx | 83 ---- connectivity/source/inc/calc/CStatement.hxx | 43 --- connectivity/source/inc/component/CColumns.hxx | 47 +++ .../source/inc/component/CPreparedStatement.hxx | 44 +++ connectivity/source/inc/component/CResultSet.hxx | 84 +++++ connectivity/source/inc/component/CStatement.hxx | 44 +++ connectivity/source/inc/writer/WCatalog.hxx | 45 +++ connectivity/source/inc/writer/WConnection.hxx | 170 +++++++++ .../source/inc/writer/WDatabaseMetaData.hxx | 52 +++ connectivity/source/inc/writer/WDriver.hxx | 58 +++ connectivity/source/inc/writer/WTable.hxx | 116 ++++++ connectivity/source/inc/writer/WTables.hxx | 45 +++ dbaccess/inc/dbaccess_helpid.hrc | 1 + dbaccess/source/core/misc/dsntypes.cxx | 4 +- dbaccess/source/inc/dsntypes.hxx | 3 +- dbaccess/source/ui/dlg/AutoControls.src | 5 + dbaccess/source/ui/dlg/ConnectionHelper.cxx | 13 +- dbaccess/source/ui/dlg/ConnectionPage.cxx | 4 + dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx | 2 +- dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx | 2 +- dbaccess/source/ui/dlg/DbAdminImpl.cxx | 1 + dbaccess/source/ui/dlg/dbadminsetup.src | 4 +- dbaccess/source/ui/dlg/dbwiz.cxx | 1 + dbaccess/source/ui/dlg/dbwizsetup.cxx | 10 +- dbaccess/source/ui/inc/dbu_dlg.hrc | 4 +- dbaccess/source/ui/inc/dbwizsetup.hxx | 2 +- include/sal/log-areas.dox | 1 + postprocess/CustomTarget_registry.mk | 6 + postprocess/Rdb_services.mk | 1 + sw/CppunitTest_sw_mailmerge.mk | 1 + sw/inc/dbmgr.hxx | 3 +- sw/inc/dbui.hrc | 2 + .../mailmerge/data/10-testing-addresses-writer.odt | Bin 0 -> 12849 bytes sw/qa/extras/mailmerge/data/writer-mail-merge.odt | Bin 0 -> 8410 bytes sw/qa/extras/mailmerge/mailmerge.cxx | 14 + sw/source/ui/dbui/dbui.src | 10 +- sw/source/uibase/dbui/dbmgr.cxx | 19 +- 64 files changed, 2536 insertions(+), 534 deletions(-) create mode 100644 connectivity/Configuration_writer.mk create mode 100644 connectivity/Library_writer.mk create mode 100644 connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu delete mode 100644 connectivity/source/drivers/calc/CColumns.cxx delete mode 100644 connectivity/source/drivers/calc/CPreparedStatement.cxx delete mode 100644 connectivity/source/drivers/calc/CResultSet.cxx delete mode 100644 connectivity/source/drivers/calc/CStatement.cxx create mode 100644 connectivity/source/drivers/component/CColumns.cxx create mode 100644 connectivity/source/drivers/component/CPreparedStatement.cxx create mode 100644 connectivity/source/drivers/component/CResultSet.cxx create mode 100644 connectivity/source/drivers/component/CStatement.cxx create mode 100644 connectivity/source/drivers/writer/WCatalog.cxx create mode 100644 connectivity/source/drivers/writer/WConnection.cxx create mode 100644 connectivity/source/drivers/writer/WDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/writer/WDriver.cxx create mode 100644 connectivity/source/drivers/writer/WTable.cxx create mode 100644 connectivity/source/drivers/writer/WTables.cxx create mode 100644 connectivity/source/drivers/writer/Wservices.cxx create mode 100644 connectivity/source/drivers/writer/writer.component delete mode 100644 connectivity/source/inc/calc/CColumns.hxx delete mode 100644 connectivity/source/inc/calc/CPreparedStatement.hxx delete mode 100644 connectivity/source/inc/calc/CResultSet.hxx delete mode 100644 connectivity/source/inc/calc/CStatement.hxx create mode 100644 connectivity/source/inc/component/CColumns.hxx create mode 100644 connectivity/source/inc/component/CPreparedStatement.hxx create mode 100644 connectivity/source/inc/component/CResultSet.hxx create mode 100644 connectivity/source/inc/component/CStatement.hxx create mode 100644 connectivity/source/inc/writer/WCatalog.hxx create mode 100644 connectivity/source/inc/writer/WConnection.hxx create mode 100644 connectivity/source/inc/writer/WDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/writer/WDriver.hxx create mode 100644 connectivity/source/inc/writer/WTable.hxx create mode 100644 connectivity/source/inc/writer/WTables.hxx create mode 100644 sw/qa/extras/mailmerge/data/10-testing-addresses-writer.odt create mode 100644 sw/qa/extras/mailmerge/data/writer-mail-merge.odt diff --git a/Repository.mk b/Repository.mk index 6eade9020edd..3635ccfadada 100644 --- a/Repository.mk +++ b/Repository.mk @@ -480,6 +480,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,writer, \ $(call gb_Helper_optional,SCRIPTING,vbaswobj) \ wpftwriter \ writerfilter \ + $(call gb_Helper_optional,DBCONNECTIVITY,writer) \ )) # cli_cppuhelper is NONE even though it is actually in URE because it is CliNativeLibrary diff --git a/connectivity/Configuration_writer.mk b/connectivity/Configuration_writer.mk new file mode 100644 index 000000000000..c14030b11cc5 --- /dev/null +++ b/connectivity/Configuration_writer.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_Configuration_Configuration,driver_writer)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_writer,connectivity/registry/writer,\ + org/openoffice/Office/DataAccess/Drivers-writer.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_writer,connectivity/registry/writer,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_calc.mk b/connectivity/Library_calc.mk index a2b355813412..0c0d2ad4bc0c 100644 --- a/connectivity/Library_calc.mk +++ b/connectivity/Library_calc.mk @@ -40,12 +40,8 @@ $(eval $(call gb_Library_use_libraries,calc,\ )) $(eval $(call gb_Library_add_exception_objects,calc,\ - connectivity/source/drivers/calc/CResultSet \ - connectivity/source/drivers/calc/CStatement \ - connectivity/source/drivers/calc/CPreparedStatement \ connectivity/source/drivers/calc/CDatabaseMetaData \ connectivity/source/drivers/calc/CCatalog \ - connectivity/source/drivers/calc/CColumns \ connectivity/source/drivers/calc/CTable \ connectivity/source/drivers/calc/CTables \ connectivity/source/drivers/calc/CConnection \ diff --git a/connectivity/Library_file.mk b/connectivity/Library_file.mk index 765b13bf9998..ba07f5031909 100644 --- a/connectivity/Library_file.mk +++ b/connectivity/Library_file.mk @@ -42,6 +42,10 @@ $(eval $(call gb_Library_use_libraries,file,\ )) $(eval $(call gb_Library_add_exception_objects,file,\ + connectivity/source/drivers/component/CColumns \ + connectivity/source/drivers/component/CPreparedStatement \ + connectivity/source/drivers/component/CResultSet \ + connectivity/source/drivers/component/CStatement \ connectivity/source/drivers/file/FCatalog \ connectivity/source/drivers/file/FColumns \ connectivity/source/drivers/file/FConnection \ diff --git a/connectivity/Library_writer.mk b/connectivity/Library_writer.mk new file mode 100644 index 000000000000..d07f572a3227 --- /dev/null +++ b/connectivity/Library_writer.mk @@ -0,0 +1,49 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# 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/. +# + +$(eval $(call gb_Library_Library,writer)) + +$(eval $(call gb_Library_set_componentfile,writer,connectivity/source/drivers/writer/writer)) + +$(eval $(call gb_Library_use_external,writer,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,writer)) + +$(eval $(call gb_Library_set_include,writer,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_libraries,writer,\ + cppu \ + cppuhelper \ + svl \ + tl \ + utl \ + sal \ + salhelper \ + dbtools \ + file \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,writer,\ + connectivity/source/drivers/writer/WCatalog \ + connectivity/source/drivers/writer/WConnection \ + connectivity/source/drivers/writer/WDatabaseMetaData \ + connectivity/source/drivers/writer/WDriver \ + connectivity/source/drivers/writer/WTable \ + connectivity/source/drivers/writer/WTables \ + connectivity/source/drivers/writer/Wservices \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk index aee317867501..c9275b0f6883 100644 --- a/connectivity/Module_connectivity.mk +++ b/connectivity/Module_connectivity.mk @@ -16,6 +16,7 @@ $(eval $(call gb_Module_add_targets,connectivity,\ Configuration_flat \ Configuration_mysql \ Configuration_odbc \ + Configuration_writer \ Library_calc \ Library_dbase \ Library_dbpool2 \ @@ -25,6 +26,7 @@ $(eval $(call gb_Module_add_targets,connectivity,\ Library_mysql \ $(if $(filter ANDROID IOS,$(OS)),,Library_odbc) \ Library_sdbc2 \ + Library_writer \ )) $(eval $(call gb_Module_add_l10n_targets,connectivity,\ diff --git a/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000000..69ed08e1c63d --- /dev/null +++ b/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,44 @@ + + + + + + + com.sun.star.comp.sdbc.writer.ODriver + + + Writer Document + + + + + true + + + + + + + true + + + + + true + + + + + application/vnd.oasis.opendocument.text + + + + + + diff --git a/connectivity/source/drivers/calc/CColumns.cxx b/connectivity/source/drivers/calc/CColumns.cxx deleted file mode 100644 index 3cd002cd3681..000000000000 --- a/connectivity/source/drivers/calc/CColumns.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#include "calc/CColumns.hxx" -#include "calc/CTable.hxx" -#include - -using namespace connectivity::calc; -using namespace connectivity; -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::container; - - -sdbcx::ObjectType OCalcColumns::createObject(const OUString& _rName) -{ - OCalcTable* pTable = static_cast(m_pTable); - ::rtl::Reference aCols = pTable->getTableColumns(); - - OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); - sdbcx::ObjectType xRet; - if(aIter != aCols->get().end()) - xRet = sdbcx::ObjectType(*aIter,UNO_QUERY); - return xRet; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx index a315bc6b7c45..75746504ef97 100644 --- a/connectivity/source/drivers/calc/CConnection.cxx +++ b/connectivity/source/drivers/calc/CConnection.cxx @@ -28,8 +28,8 @@ #include #include #include -#include "calc/CPreparedStatement.hxx" -#include "calc/CStatement.hxx" +#include "component/CPreparedStatement.hxx" +#include "component/CStatement.hxx" #include #include #include @@ -239,7 +239,7 @@ Reference< XStatement > SAL_CALL OCalcConnection::createStatement( ) throw(SQLE checkDisposed(OConnection_BASE::rBHelper.bDisposed); - Reference< XStatement > xReturn = new OCalcStatement(this); + Reference< XStatement > xReturn = new connectivity::component::OComponentStatement(this); m_aStatements.push_back(WeakReferenceHelper(xReturn)); return xReturn; } @@ -252,7 +252,7 @@ Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareStatement( cons checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OCalcPreparedStatement* pStmt = new OCalcPreparedStatement(this); + auto pStmt = new connectivity::component::OComponentPreparedStatement(this); Reference< XPreparedStatement > xHoldAlive = pStmt; pStmt->construct(sql); m_aStatements.push_back(WeakReferenceHelper(*pStmt)); diff --git a/connectivity/source/drivers/calc/CPreparedStatement.cxx b/connectivity/source/drivers/calc/CPreparedStatement.cxx deleted file mode 100644 index 96eb9a2672a8..000000000000 --- a/connectivity/source/drivers/calc/CPreparedStatement.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#include "calc/CPreparedStatement.hxx" -#include "calc/CResultSet.hxx" - -using namespace connectivity::calc; -using namespace connectivity::file; -using namespace com::sun::star::uno; - -OResultSet* OCalcPreparedStatement::createResultSet() -{ - return new OCalcResultSet(this,m_aSQLIterator); -} - -IMPLEMENT_SERVICE_INFO(OCalcPreparedStatement,"com.sun.star.sdbc.driver.calc.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/calc/CResultSet.cxx b/connectivity/source/drivers/calc/CResultSet.cxx deleted file mode 100644 index dc175865151e..000000000000 --- a/connectivity/source/drivers/calc/CResultSet.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#include -#include "calc/CResultSet.hxx" -#include -#include -#include -#include -#include - -using namespace ::comphelper; -using namespace connectivity::calc; -using namespace connectivity::file; -using namespace ::cppu; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; - - -OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator) - : file::OResultSet(pStmt,_aSQLIterator) - ,m_bBookmarkable(true) -{ - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, cppu::UnoType::get()); -} - -OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException, std::exception) -{ - return OUString("com.sun.star.sdbcx.calc.ResultSet"); -} - -Sequence< OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException, std::exception) -{ - Sequence< OUString > aSupported(2); - aSupported[0] = "com.sun.star.sdbc.ResultSet"; - aSupported[1] = "com.sun.star.sdbcx.ResultSet"; - return aSupported; -} - -sal_Bool SAL_CALL OCalcResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception) -{ - return cppu::supportsService(this, _rServiceName); -} - -Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) -{ - Any aRet = OResultSet::queryInterface(rType); - return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType); -} - - Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException, std::exception) -{ - return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes()); -} - - -// XRowLocate -Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException, std::exception) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); -} - -sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false; - - return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true); -} - -sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false; - - Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false); - - return relative(rows); -} - - -sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException, std::exception) -{ - return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL; -} - -sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException, std::exception) -{ - return true; -} - -sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - return comphelper::getINT32(bookmark); -} - -// XDeleteRows -Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException, std::exception) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this ); - return Sequence< sal_Int32 >(); -} - -bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/) -{ - // Calc table has no index - return false; -} - -::cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper() -{ - return *OCalcResultSet_BASE3::getArrayHelper(); -} - -::cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const -{ - Sequence< Property > aProps; - describeProperties(aProps); - return new ::cppu::OPropertyArrayHelper(aProps); -} - - -void SAL_CALL OCalcResultSet::acquire() throw() -{ - OCalcResultSet_BASE2::acquire(); -} - -void SAL_CALL OCalcResultSet::release() throw() -{ - OCalcResultSet_BASE2::release(); -} - -css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OCalcResultSet::getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/calc/CStatement.cxx b/connectivity/source/drivers/calc/CStatement.cxx deleted file mode 100644 index 15d4e45a04b8..000000000000 --- a/connectivity/source/drivers/calc/CStatement.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#include "calc/CStatement.hxx" -#include "calc/CResultSet.hxx" - -using namespace connectivity::calc; -using namespace connectivity::file; -using namespace com::sun::star::uno; - -OResultSet* OCalcStatement::createResultSet() -{ - return new OCalcResultSet(this,m_aSQLIterator); -} - -IMPLEMENT_SERVICE_INFO(OCalcStatement,"com.sun.star.sdbc.driver.calc.Statement","com.sun.star.sdbc.Statement"); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index cae94275f944..5b73750b9af0 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -36,7 +36,7 @@ #include #include #include "calc/CConnection.hxx" -#include "calc/CColumns.hxx" +#include "component/CColumns.hxx" #include #include #include @@ -622,7 +622,7 @@ void OCalcTable::refreshColumns() if(m_pColumns) m_pColumns->reFill(aVector); else - m_pColumns = new OCalcColumns(this,m_aMutex,aVector); + m_pColumns = new component::OComponentColumns(this,m_aMutex,aVector); } void OCalcTable::refreshIndexes() diff --git a/connectivity/source/drivers/component/CColumns.cxx b/connectivity/source/drivers/component/CColumns.cxx new file mode 100644 index 000000000000..68dcba53d9f4 --- /dev/null +++ b/connectivity/source/drivers/component/CColumns.cxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "component/CColumns.hxx" +#include "file/FTable.hxx" +#include + +using namespace connectivity::component; +using namespace connectivity; +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::container; + + +sdbcx::ObjectType OComponentColumns::createObject(const OUString& _rName) +{ + ::rtl::Reference aCols = m_pTable->getTableColumns(); + + OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); + sdbcx::ObjectType xRet; + if(aIter != aCols->get().end()) + xRet = sdbcx::ObjectType(*aIter,UNO_QUERY); + return xRet; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/component/CPreparedStatement.cxx b/connectivity/source/drivers/component/CPreparedStatement.cxx new file mode 100644 index 000000000000..a2b1161fb7cb --- /dev/null +++ b/connectivity/source/drivers/component/CPreparedStatement.cxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "component/CPreparedStatement.hxx" +#include "component/CResultSet.hxx" + +using namespace connectivity::component; +using namespace connectivity::file; +using namespace com::sun::star::uno; + +OResultSet* OComponentPreparedStatement::createResultSet() +{ + return new connectivity::component::OComponentResultSet(this,m_aSQLIterator); +} + +IMPLEMENT_SERVICE_INFO(OComponentPreparedStatement,"com.sun.star.sdbc.driver.component.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/component/CResultSet.cxx b/connectivity/source/drivers/component/CResultSet.cxx new file mode 100644 index 000000000000..989839d61437 --- /dev/null +++ b/connectivity/source/drivers/component/CResultSet.cxx @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include +#include "component/CResultSet.hxx" +#include +#include +#include +#include +#include + +using namespace ::comphelper; +using namespace connectivity::component; +using namespace connectivity::file; +using namespace ::cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; + + +OComponentResultSet::OComponentResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator) + : file::OResultSet(pStmt,_aSQLIterator) + ,m_bBookmarkable(true) +{ + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, cppu::UnoType::get()); +} + +OUString SAL_CALL OComponentResultSet::getImplementationName( ) throw ( RuntimeException, std::exception) +{ + return OUString("com.sun.star.sdbcx.component.ResultSet"); +} + +Sequence< OUString > SAL_CALL OComponentResultSet::getSupportedServiceNames( ) throw( RuntimeException, std::exception) +{ + Sequence< OUString > aSupported(2); + aSupported[0] = "com.sun.star.sdbc.ResultSet"; + aSupported[1] = "com.sun.star.sdbcx.ResultSet"; + return aSupported; +} + +sal_Bool SAL_CALL OComponentResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception) +{ + return cppu::supportsService(this, _rServiceName); +} + +Any SAL_CALL OComponentResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) +{ + Any aRet = OResultSet::queryInterface(rType); + return aRet.hasValue() ? aRet : OComponentResultSet_BASE::queryInterface(rType); +} + + Sequence< Type > SAL_CALL OComponentResultSet::getTypes( ) throw( RuntimeException, std::exception) +{ + return ::comphelper::concatSequences(OResultSet::getTypes(),OComponentResultSet_BASE::getTypes()); +} + + +// XRowLocate +Any SAL_CALL OComponentResultSet::getBookmark( ) throw( SQLException, RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); +} + +sal_Bool SAL_CALL OComponentResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false; + + return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true); +} + +sal_Bool SAL_CALL OComponentResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false; + + Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false); + + return relative(rows); +} + + +sal_Int32 SAL_CALL OComponentResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException, std::exception) +{ + return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL; +} + +sal_Bool SAL_CALL OComponentResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException, std::exception) +{ + return true; +} + +sal_Int32 SAL_CALL OComponentResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + return comphelper::getINT32(bookmark); +} + +// XDeleteRows +Sequence< sal_Int32 > SAL_CALL OComponentResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this ); + return Sequence< sal_Int32 >(); +} + +bool OComponentResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/) +{ + // Writer or Calc table has no index + return false; +} + +::cppu::IPropertyArrayHelper & OComponentResultSet::getInfoHelper() +{ + return *OComponentResultSet_BASE3::getArrayHelper(); +} + +::cppu::IPropertyArrayHelper* OComponentResultSet::createArrayHelper() const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} + + +void SAL_CALL OComponentResultSet::acquire() throw() +{ + OComponentResultSet_BASE2::acquire(); +} + +void SAL_CALL OComponentResultSet::release() throw() +{ + OComponentResultSet_BASE2::release(); +} + +css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OComponentResultSet::getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/component/CStatement.cxx b/connectivity/source/drivers/component/CStatement.cxx new file mode 100644 index 000000000000..a83ff8587e20 --- /dev/null +++ b/connectivity/source/drivers/component/CStatement.cxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "component/CStatement.hxx" +#include "component/CResultSet.hxx" + +using namespace connectivity::component; +using namespace connectivity::file; +using namespace com::sun::star::uno; + +OResultSet* OComponentStatement::createResultSet() +{ + return new connectivity::component::OComponentResultSet(this,m_aSQLIterator); +} + +IMPLEMENT_SERVICE_INFO(OComponentStatement,"com.sun.star.sdbc.driver.component.Statement","com.sun.star.sdbc.Statement"); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WCatalog.cxx b/connectivity/source/drivers/writer/WCatalog.cxx new file mode 100644 index 000000000000..0cf4a1626e40 --- /dev/null +++ b/connectivity/source/drivers/writer/WCatalog.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WCatalog.hxx" +#include "writer/WTables.hxx" + +#include +#include + +#include + +#include "writer/WConnection.hxx" + +using namespace ::com::sun::star; + +namespace connectivity +{ +namespace writer +{ + +OWriterCatalog::OWriterCatalog(OWriterConnection* pConnection) : file::OFileCatalog(pConnection) +{ +} + +void OWriterCatalog::refreshTables() +{ + TStringVector aVector; + uno::Sequence aTypes; + OWriterConnection::ODocHolder aDocHolder(static_cast(m_pConnection)); + uno::Reference< sdbc::XResultSet > xResult = m_xMetaData->getTables(uno::Any(), "%", "%", aTypes); + + if (xResult.is()) + { + uno::Reference< sdbc::XRow > xRow(xResult, uno::UNO_QUERY); + while (xResult->next()) + aVector.push_back(xRow->getString(3)); + } + if (m_pTables) + m_pTables->reFill(aVector); + else + m_pTables = new OWriterTables(m_xMetaData, *this, m_aMutex, aVector); +} + +} // namespace writer +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WConnection.cxx b/connectivity/source/drivers/writer/WConnection.cxx new file mode 100644 index 000000000000..8b46b949965c --- /dev/null +++ b/connectivity/source/drivers/writer/WConnection.cxx @@ -0,0 +1,257 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WConnection.hxx" +#include "writer/WDatabaseMetaData.hxx" +#include "writer/WCatalog.hxx" +#include "writer/WDriver.hxx" +#include "resource/sharedresources.hxx" +#include "resource/common_res.hrc" +#include +#include +#include +#include +#include "component/CPreparedStatement.hxx" +#include "component/CStatement.hxx" +#include +#include +#include +#include + +typedef connectivity::file::OConnection OConnection_BASE; + +using namespace ::com::sun::star; + +namespace connectivity +{ +namespace writer +{ + +OWriterConnection::OWriterConnection(ODriver* _pDriver) : OConnection(_pDriver),m_nDocCount(0) +{ + // m_aFilenameExtension is not used +} + +OWriterConnection::~OWriterConnection() +{ +} + +void OWriterConnection::construct(const OUString& url,const uno::Sequence< beans::PropertyValue >& info) throw(sdbc::SQLException, uno::RuntimeException, uno::DeploymentException, std::exception) +{ + // open file + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + OUString aDSN(url.copy(nLen+1)); + + m_aFileName = aDSN; + INetURLObject aURL; + aURL.SetSmartProtocol(INetProtocol::File); + { + SvtPathOptions aPathOptions; + m_aFileName = aPathOptions.SubstituteVariable(m_aFileName); + } + aURL.SetSmartURL(m_aFileName); + if (aURL.GetProtocol() == INetProtocol::NotValid) + { + // don't pass invalid URL to loadComponentFromURL + throw sdbc::SQLException(); + } + m_aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE); + + m_sPassword.clear(); + const char pPwd[] = "password"; + + const beans::PropertyValue* pIter = info.getConstArray(); + const beans::PropertyValue* pEnd = pIter + info.getLength(); + for (; pIter != pEnd; ++pIter) + { + if (pIter->Name == pPwd) + { + pIter->Value >>= m_sPassword; + break; + } + } // for(;pIter != pEnd;++pIter) + ODocHolder aDocHolder(this); // just to test that the doc can be loaded + acquireDoc(); +} + +uno::Reference const& OWriterConnection::acquireDoc() +{ + if (m_xDoc.is()) + { + osl_atomic_increment(&m_nDocCount); + return m_xDoc; + } + // open read-only as long as updating isn't implemented + uno::Sequence aArgs(2); + aArgs[0].Name = "Hidden"; + aArgs[0].Value <<= true; + aArgs[1].Name = "ReadOnly"; + aArgs[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; + } + + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(getDriver()->getComponentContext()); + uno::Reference< lang::XComponent > xComponent; + uno::Any aLoaderException; + try + { + xComponent = xDesktop->loadComponentFromURL( + m_aFileName, "_blank", 0, aArgs); + } + catch (const uno::Exception&) + { + aLoaderException = ::cppu::getCaughtException(); + } + + m_xDoc.set(xComponent, uno::UNO_QUERY); + + // if the URL is not a text document, throw the exception here + // instead of at the first access to it + if (!m_xDoc.is()) + { + if (aLoaderException.hasValue()) + { + uno::Exception aLoaderError; + OSL_VERIFY(aLoaderException >>= aLoaderError); + + SAL_WARN("connectivity.writer", "empty m_xDoc, exception type: " << aLoaderException.getValueTypeName() << ", error message: " << aLoaderError.Message); + } + + const OUString sError(m_aResources.getResourceStringWithSubstitution( + STR_COULD_NOT_LOAD_FILE, + "$filename$", m_aFileName + )); + ::dbtools::throwGenericSQLException(sError, *this); + } + osl_atomic_increment(&m_nDocCount); + m_xCloseVetoButTerminateListener.set(new CloseVetoButTerminateListener); + m_xCloseVetoButTerminateListener->start(m_xDoc, xDesktop); + return m_xDoc; +} + +void OWriterConnection::releaseDoc() +{ + if (osl_atomic_decrement(&m_nDocCount) == 0) + { + if (m_xCloseVetoButTerminateListener.is()) + { + m_xCloseVetoButTerminateListener->stop(); // dispose m_xDoc + m_xCloseVetoButTerminateListener.clear(); + } + m_xDoc.clear(); + } +} + +void OWriterConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + m_nDocCount = 0; + if (m_xCloseVetoButTerminateListener.is()) + { + m_xCloseVetoButTerminateListener->stop(); // dispose m_xDoc + m_xCloseVetoButTerminateListener.clear(); + } + m_xDoc.clear(); + + OConnection::disposing(); +} + +// XServiceInfo + + +IMPLEMENT_SERVICE_INFO(OWriterConnection, "com.sun.star.sdbc.drivers.writer.Connection", "com.sun.star.sdbc.Connection") + + +uno::Reference< sdbc::XDatabaseMetaData > SAL_CALL OWriterConnection::getMetaData() throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + uno::Reference< sdbc::XDatabaseMetaData > xMetaData = m_xMetaData; + if (!xMetaData.is()) + { + xMetaData = new OWriterDatabaseMetaData(this); + m_xMetaData = xMetaData; + } + + return xMetaData; +} + + +css::uno::Reference< css::sdbcx::XTablesSupplier > OWriterConnection::createCatalog() +{ + ::osl::MutexGuard aGuard(m_aMutex); + uno::Reference< css::sdbcx::XTablesSupplier > xTab = m_xCatalog; + if (!xTab.is()) + { + OWriterCatalog* pCat = new OWriterCatalog(this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} + + +uno::Reference< sdbc::XStatement > SAL_CALL OWriterConnection::createStatement() throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + uno::Reference xReturn = new component::OComponentStatement(this); + m_aStatements.push_back(uno::WeakReferenceHelper(xReturn)); + return xReturn; +} + + +uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareStatement(const OUString& sql) throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + auto pStmt = new component::OComponentPreparedStatement(this); + uno::Reference xHoldAlive = pStmt; + pStmt->construct(sql); + m_aStatements.push_back(uno::WeakReferenceHelper(*pStmt)); + return pStmt; +} + + +uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareCall(const OUString& /*sql*/) throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + ::dbtools::throwFeatureNotImplementedSQLException("XConnection::prepareCall", *this); + return nullptr; +} + +} // namespace writer +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WDatabaseMetaData.cxx b/connectivity/source/drivers/writer/WDatabaseMetaData.cxx new file mode 100644 index 000000000000..730b085cb110 --- /dev/null +++ b/connectivity/source/drivers/writer/WDatabaseMetaData.cxx @@ -0,0 +1,325 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WDatabaseMetaData.hxx" +#include "writer/WConnection.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FDatabaseMetaDataResultSet.hxx" +#include +#include + +using namespace connectivity::file; +using namespace ::com::sun::star; + +namespace connectivity +{ +namespace writer +{ + +OWriterDatabaseMetaData::OWriterDatabaseMetaData(OConnection* pConnection) :ODatabaseMetaData(pConnection) +{ +} + +OWriterDatabaseMetaData::~OWriterDatabaseMetaData() +{ +} + +uno::Reference OWriterDatabaseMetaData::impl_getTypeInfo_throw() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); + uno::Reference xRef = pResult; + + static ODatabaseMetaDataResultSet::ORows aRows; + if (aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow; + + aRows.reserve(6); + aRow.reserve(18); + + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); + aRow.push_back(new ORowSetValueDecorator(sdbc::DataType::VARCHAR)); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)65535)); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); // ORowSetValue((sal_Int32)ColumnValue::NULLABLE) + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)sdbc::ColumnSearch::CHAR)); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(OUString("DECIMAL")); + aRow[2] = new ORowSetValueDecorator(sdbc::DataType::DECIMAL); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(OUString("BOOL")); + aRow[2] = new ORowSetValueDecorator(sdbc::DataType::BIT); + aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = new ORowSetValueDecorator((sal_Int32)15); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(OUString("DATE")); + aRow[2] = new ORowSetValueDecorator(sdbc::DataType::DATE); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(OUString("TIME")); + aRow[2] = new ORowSetValueDecorator(sdbc::DataType::TIME); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ORowSetValueDecorator(OUString("TIMESTAMP")); + aRow[2] = new ORowSetValueDecorator(sdbc::DataType::TIMESTAMP); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + } + + pResult->setRows(aRows); + return xRef; +} + + +uno::Reference SAL_CALL OWriterDatabaseMetaData::getColumns( + const uno::Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern, + const OUString& columnNamePattern) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + uno::Reference xTables = m_pConnection->createCatalog(); + if (!xTables.is()) + throw sdbc::SQLException(); + + uno::Reference xNames = xTables->getTables(); + if (!xNames.is()) + throw sdbc::SQLException(); + + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(19); + + aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + + uno::Sequence aTabNames(xNames->getElementNames()); + const OUString* pTabIter = aTabNames.getConstArray(); + const OUString* pTabEnd = pTabIter + aTabNames.getLength(); + for (; pTabIter != pTabEnd; ++pTabIter) + { + if (match(tableNamePattern,*pTabIter,'\0')) + { + uno::Reference xTable(xNames->getByName(*pTabIter), uno::UNO_QUERY_THROW); + aRow[3] = new ORowSetValueDecorator(*pTabIter); + + uno::Reference xColumns = xTable->getColumns(); + if (!xColumns.is()) + throw sdbc::SQLException(); + + uno::Sequence aColNames(xColumns->getElementNames()); + + const OUString* pColumnIter = aColNames.getConstArray(); + const OUString* pEnd = pColumnIter + aColNames.getLength(); + uno::Reference xColumn; + for (sal_Int32 i=1; pColumnIter != pEnd; ++pColumnIter,++i) + { + if (match(columnNamePattern,*pColumnIter,'\0')) + { + aRow[4] = new ORowSetValueDecorator(*pColumnIter); + + xColumns->getByName(*pColumnIter) >>= xColumn; + OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); + aRow[5] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); + aRow[6] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))); + aRow[7] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); + // aRow[8] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); + aRow[9] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); + aRow[11] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); + // aRow[12] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); + aRow[13] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); + // aRow[14] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); + // aRow[15] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); + switch (sal_Int32(aRow[5]->getValue())) + { + case sdbc::DataType::CHAR: + case sdbc::DataType::VARCHAR: + aRow[16] = new ORowSetValueDecorator((sal_Int32)254); + break; + case sdbc::DataType::LONGVARCHAR: + aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); + break; + default: + aRow[16] = new ORowSetValueDecorator((sal_Int32)0); + } + aRow[17] = new ORowSetValueDecorator(i); + switch (sal_Int32(aRow[11]->getValue())) + { + case sdbc::ColumnValue::NO_NULLS: + aRow[18] = new ORowSetValueDecorator(OUString("NO")); + break; + case sdbc::ColumnValue::NULLABLE: + aRow[18] = new ORowSetValueDecorator(OUString("YES")); + break; + default: + aRow[18] = new ORowSetValueDecorator(OUString()); + } + aRows.push_back(aRow); + } + } + } + } + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); + uno::Reference xRef = pResult; + pResult->setRows(aRows); + + return xRef; +} + + +OUString SAL_CALL OWriterDatabaseMetaData::getURL() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + return "sdbc:writer:" + m_pConnection->getURL(); +} + + +sal_Int32 SAL_CALL OWriterDatabaseMetaData::getMaxBinaryLiteralLength() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + return SAL_MAX_INT32; +} + + +sal_Int32 SAL_CALL OWriterDatabaseMetaData::getMaxCharLiteralLength() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + return SAL_MAX_INT32; +} + +sal_Int32 SAL_CALL OWriterDatabaseMetaData::getMaxColumnNameLength() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + return SAL_MAX_INT32; +} + +sal_Int32 SAL_CALL OWriterDatabaseMetaData::getMaxColumnsInIndex() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + return 1; +} + +sal_Int32 SAL_CALL OWriterDatabaseMetaData::getMaxColumnsInTable() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + return 256; +} + +uno::Reference SAL_CALL OWriterDatabaseMetaData::getTables( + const uno::Any& /*catalog*/, const OUString& /*schemaPattern*/, + const OUString& tableNamePattern, const uno::Sequence< OUString >& types) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables); + uno::Reference xRef = pResult; + + // check if ORowSetValue type is given + // when no types are given then we have to return all tables e.g. TABLE + + OUString aTable("TABLE"); + + bool bTableFound = true; + sal_Int32 nLength = types.getLength(); + if (nLength) + { + bTableFound = false; + + const OUString* pIter = types.getConstArray(); + const OUString* pEnd = pIter + nLength; + for (; pIter != pEnd; ++pIter) + { + if (*pIter == aTable) + { + bTableFound = true; + break; + } + } + } + if (!bTableFound) + return xRef; + + // get the table names from the document + + OWriterConnection::ODocHolder aDocHolder(static_cast(m_pConnection)); + uno::Reference xDoc(aDocHolder.getDoc(), uno::UNO_QUERY); + if (!xDoc.is()) + throw sdbc::SQLException(); + uno::Reference xTables = xDoc->getTextTables(); + if (!xTables.is()) + throw sdbc::SQLException(); + uno::Sequence aTableNames = xTables->getElementNames(); + + ODatabaseMetaDataResultSet::ORows aRows; + sal_Int32 nTableCount = aTableNames.getLength(); + for (sal_Int32 nTable=0; nTablesetRows(aRows); + + return xRef; +} + +} // namespace writer +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WDriver.cxx b/connectivity/source/drivers/writer/WDriver.cxx new file mode 100644 index 000000000000..2e3d81be5a5b --- /dev/null +++ b/connectivity/source/drivers/writer/WDriver.cxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WDriver.hxx" +#include "writer/WConnection.hxx" +#include +#include +#include "resource/sharedresources.hxx" +#include "resource/common_res.hrc" +#include + +using namespace connectivity::file; +using namespace ::com::sun::star; + +namespace connectivity +{ +namespace writer +{ + +OUString ODriver::getImplementationName_Static() throw(uno::RuntimeException) +{ + return OUString("com.sun.star.comp.sdbc.writer.ODriver"); +} + +OUString SAL_CALL ODriver::getImplementationName() throw(uno::RuntimeException, std::exception) +{ + return getImplementationName_Static(); +} + +uno::Reference< css::uno::XInterface > SAL_CALL +ODriver_CreateInstance(const uno::Reference< + lang::XMultiServiceFactory >& _rxFactory) throw( css::uno::Exception ) +{ + return *(new ODriver(comphelper::getComponentContext(_rxFactory))); +} + +uno::Reference< sdbc::XConnection > SAL_CALL ODriver::connect(const OUString& url, + const uno::Sequence< beans::PropertyValue >& info) throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (ODriver_BASE::rBHelper.bDisposed) + throw lang::DisposedException(); + + if (! acceptsURL(url)) + return nullptr; + + OWriterConnection* pCon = new OWriterConnection(this); + pCon->construct(url, info); + uno::Reference< sdbc::XConnection > xCon = pCon; + m_xConnections.push_back(uno::WeakReferenceHelper(*pCon)); + + return xCon; +} + +sal_Bool SAL_CALL ODriver::acceptsURL(const OUString& url) throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + return url.startsWith("sdbc:writer:"); +} + +uno::Sequence< sdbc::DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo(const OUString& url, const uno::Sequence< beans::PropertyValue >& /*info*/) throw(sdbc::SQLException, uno::RuntimeException, std::exception) +{ + if (!acceptsURL(url)) + { + SharedResources aResources; + const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); + ::dbtools::throwGenericSQLException(sMessage,*this); + } + return uno::Sequence< sdbc::DriverPropertyInfo >(); +} + +} // namespace writer +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WTable.cxx b/connectivity/source/drivers/writer/WTable.cxx new file mode 100644 index 000000000000..b8facb1d14cf --- /dev/null +++ b/connectivity/source/drivers/writer/WTable.cxx @@ -0,0 +1,420 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WTable.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "writer/WConnection.hxx" +#include "component/CColumns.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; + +static void lcl_GetDataArea(const uno::Reference& xTable, sal_Int32& rColumnCount, sal_Int32& rRowCount) +{ + uno::Reference xColumns(xTable->getColumns(), uno::UNO_QUERY); + if (xColumns.is()) + rColumnCount = xColumns->getCount(); + + uno::Reference xRows(xTable->getRows(), uno::UNO_QUERY); + if (xRows.is()) + rRowCount = xRows->getCount() - 1; // first row (headers) is not counted + +} + +static void lcl_GetColumnInfo(const uno::Reference& xTable, + sal_Int32 nDocColumn, sal_Int32 nStartRow, bool bHasHeaders, + OUString& rName, sal_Int32& rDataType, bool& rCurrency) +{ + uno::Reference xCellRange(xTable, uno::UNO_QUERY); + // get column name from first row, if range contains headers + if (bHasHeaders) + { + uno::Reference xHeaderText(xCellRange->getCellByPosition(nDocColumn, nStartRow), uno::UNO_QUERY); + if (xHeaderText.is()) + rName = xHeaderText->getString(); + } + + rCurrency = false; + rDataType = sdbc::DataType::VARCHAR; +} + + +static void lcl_SetValue(connectivity::ORowSetValue& rValue, const uno::Reference& xTable, + sal_Int32 nStartCol, sal_Int32 nStartRow, bool bHasHeaders, + sal_Int32 nDBRow, sal_Int32 nDBColumn) +{ + sal_Int32 nDocColumn = nStartCol + nDBColumn - 1; // database counts from 1 + sal_Int32 nDocRow = nStartRow + nDBRow - 1; + if (bHasHeaders) + ++nDocRow; + + uno::Reference xCellRange(xTable, uno::UNO_QUERY); + const uno::Reference xCell = xCellRange->getCellByPosition(nDocColumn, nDocRow); + if (xCell.is()) + { + const uno::Reference xText(xCell, uno::UNO_QUERY); + if (xText.is()) + rValue = xText->getString(); + } +} + +namespace connectivity +{ +namespace writer +{ + +void OWriterTable::fillColumns() +{ + if (!m_xTable.is()) + throw sdbc::SQLException(); + + OUString aTypeName; + ::comphelper::UStringMixEqual aCase(m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); + const bool bStoresMixedCaseQuotedIdentifiers = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(); + + for (sal_Int32 i = 0; i < m_nDataCols; i++) + { + OUString aColumnName; + sal_Int32 eType = sdbc::DataType::OTHER; + bool bCurrency = false; + + lcl_GetColumnInfo(m_xTable, m_nStartCol + i, m_nStartRow, m_bHasHeaders, + aColumnName, eType, bCurrency); + + sal_Int32 nPrecision = 0; //! ... + sal_Int32 nDecimals = 0; //! ... + + switch (eType) + { + case sdbc::DataType::VARCHAR: + aTypeName = "VARCHAR"; + break; + case sdbc::DataType::DECIMAL: + aTypeName = "DECIMAL"; + break; + case sdbc::DataType::BIT: + aTypeName = "BOOL"; + break; + case sdbc::DataType::DATE: + aTypeName = "DATE"; + break; + case sdbc::DataType::TIME: + aTypeName = "TIME"; + break; + case sdbc::DataType::TIMESTAMP: + aTypeName = "TIMESTAMP"; + break; + default: + SAL_WARN("connectivity.writer", "missing type name"); + aTypeName.clear(); + } + + // check if the column name already exists + OUString aAlias = aColumnName; + OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); + sal_Int32 nExprCnt = 0; + while (aFind != m_aColumns->get().end()) + { + (aAlias = aColumnName) += OUString::number(++nExprCnt); + aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); + } + + sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias, aTypeName, OUString(),OUString(), + sdbc::ColumnValue::NULLABLE, nPrecision, nDecimals, + eType, false, false, bCurrency, + bStoresMixedCaseQuotedIdentifiers, + m_CatalogName, getSchema(), getName()); + uno::Reference< XPropertySet> xCol = pColumn; + m_aColumns->get().push_back(xCol); + m_aTypes.push_back(eType); + m_aPrecisions.push_back(nPrecision); + m_aScales.push_back(nDecimals); + } +} + + +OWriterTable::OWriterTable(sdbcx::OCollection* _pTables, OWriterConnection* _pConnection, + const OUString& Name, + const OUString& Type, + const OUString& Description, + const OUString& SchemaName, + const OUString& CatalogName + ) : OWriterTable_BASE(_pTables,_pConnection,Name, + Type, + Description, + SchemaName, + CatalogName) + ,m_pWriterConnection(_pConnection) + ,m_nStartCol(0) + ,m_nStartRow(0) + ,m_nDataCols(0) + ,m_nDataRows(0) + ,m_bHasHeaders(false) + ,m_aNullDate(::Date::EMPTY) +{ +} + +void OWriterTable::construct() +{ + uno::Reference xDoc = m_pWriterConnection->acquireDoc(); + if (xDoc.is()) + { + uno::Reference xTextTablesSupplier(xDoc, uno::UNO_QUERY); + uno::Reference xTables = xTextTablesSupplier->getTextTables(); + if (xTables.is() && xTables->hasByName(m_Name)) + { + m_xTable.set(xTables->getByName(m_Name), uno::UNO_QUERY); + if (m_xTable.is()) + { + lcl_GetDataArea(m_xTable, m_nDataCols, m_nDataRows); + m_bHasHeaders = true; + } + } + + uno::Reference xSupp(xDoc, uno::UNO_QUERY); + if (xSupp.is()) + m_xFormats = xSupp->getNumberFormats(); + } + + fillColumns(); + + refreshColumns(); +} + +void OWriterTable::refreshColumns() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + TStringVector aVector; + + OSQLColumns::Vector::const_iterator aEnd = m_aColumns->get().end(); + for (OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin(); aIter != aEnd; ++aIter) + aVector.push_back(uno::Reference(*aIter, uno::UNO_QUERY)->getName()); + + if (m_pColumns) + m_pColumns->reFill(aVector); + else + m_pColumns = new component::OComponentColumns(this, m_aMutex, aVector); +} + +void OWriterTable::refreshIndexes() +{ + // Writer table has no index +} + + +void SAL_CALL OWriterTable::disposing() +{ + OFileTable::disposing(); + ::osl::MutexGuard aGuard(m_aMutex); + m_aColumns = nullptr; + if (m_pWriterConnection) + m_pWriterConnection->releaseDoc(); + m_pWriterConnection = nullptr; + +} + +uno::Sequence< uno::Type > SAL_CALL OWriterTable::getTypes() throw(css::uno::RuntimeException, std::exception) +{ + uno::Sequence< uno::Type > aTypes = file::OTable_TYPEDEF::getTypes(); + std::vector aOwnTypes; + aOwnTypes.reserve(aTypes.getLength()); + + const uno::Type* pBegin = aTypes.getConstArray(); + const uno::Type* pEnd = pBegin + aTypes.getLength(); + for (; pBegin != pEnd; ++pBegin) + { + if (!(*pBegin == cppu::UnoType::get()|| + *pBegin == cppu::UnoType::get()|| + *pBegin == cppu::UnoType::get()|| + *pBegin == cppu::UnoType::get()|| + *pBegin == cppu::UnoType::get())) + aOwnTypes.push_back(*pBegin); + } + aOwnTypes.push_back(cppu::UnoType::get()); + + return uno::Sequence< uno::Type >(aOwnTypes.data(), aOwnTypes.size()); +} + + +uno::Any SAL_CALL OWriterTable::queryInterface(const uno::Type& rType) throw(css::uno::RuntimeException, std::exception) +{ + if (rType == cppu::UnoType::get()|| + rType == cppu::UnoType::get()|| + rType == cppu::UnoType::get()|| + rType == cppu::UnoType::get()|| + rType == cppu::UnoType::get()) + return uno::Any(); + + const uno::Any aRet = ::cppu::queryInterface(rType,static_cast< css::lang::XUnoTunnel*>(this)); + return aRet.hasValue() ? aRet : file::OTable_TYPEDEF::queryInterface(rType); +} + + +uno::Sequence< sal_Int8 > OWriterTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId implId; + + return implId.getImplementationId(); +} + +sal_Int64 OWriterTable::getSomething(const uno::Sequence< sal_Int8 >& rId) throw(css::uno::RuntimeException, std::exception) +{ + return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16)) + ? reinterpret_cast< sal_Int64 >(this) + : OWriterTable_BASE::getSomething(rId); +} + +sal_Int32 OWriterTable::getCurrentLastPos() const +{ + return m_nDataRows; +} + +bool OWriterTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) +{ + // prepare positioning: + + sal_uInt32 nNumberOfRecords = m_nDataRows; + sal_uInt32 nTempPos = m_nFilePos; + m_nFilePos = nCurPos; + + switch (eCursorPosition) + { + case IResultSetHelper::NEXT: + m_nFilePos++; + break; + case IResultSetHelper::PRIOR: + if (m_nFilePos > 0) + m_nFilePos--; + break; + case IResultSetHelper::FIRST: + m_nFilePos = 1; + break; + case IResultSetHelper::LAST: + m_nFilePos = nNumberOfRecords; + break; + case IResultSetHelper::RELATIVE1: + m_nFilePos = (m_nFilePos + nOffset < 0) ? 0L + : (sal_uInt32)(m_nFilePos + nOffset); + break; + case IResultSetHelper::ABSOLUTE1: + case IResultSetHelper::BOOKMARK: + m_nFilePos = (sal_uInt32)nOffset; + break; + } + + if (m_nFilePos > (sal_Int32)nNumberOfRecords) + m_nFilePos = (sal_Int32)nNumberOfRecords + 1; + + if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1) + goto Error; + else + { + //! read buffer / setup row object etc? + } + goto End; + +Error: + switch (eCursorPosition) + { + case IResultSetHelper::PRIOR: + case IResultSetHelper::FIRST: + m_nFilePos = 0; + break; + case IResultSetHelper::LAST: + case IResultSetHelper::NEXT: + case IResultSetHelper::ABSOLUTE1: + case IResultSetHelper::RELATIVE1: + if (nOffset > 0) + m_nFilePos = nNumberOfRecords + 1; + else if (nOffset < 0) + m_nFilePos = 0; + break; + case IResultSetHelper::BOOKMARK: + m_nFilePos = nTempPos; // previous position + } + // aStatus.Set(SDB_STAT_NO_DATA_FOUND); + return false; + +End: + nCurPos = m_nFilePos; + return true; +} + +bool OWriterTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, + bool bRetrieveData) +{ + // read the bookmark + + _rRow->setDeleted(false); + *(_rRow->get())[0] = m_nFilePos; + + if (!bRetrieveData) + return true; + + // fields + + OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin(); + OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end(); + const OValueRefVector::Vector::size_type nCount = _rRow->get().size(); + for (OValueRefVector::Vector::size_type i = 1; aIter != aEnd && i < nCount; + ++aIter, i++) + { + if ((_rRow->get())[i]->isBound()) + { + lcl_SetValue((_rRow->get())[i]->get(), m_xTable, m_nStartCol, m_nStartRow, m_bHasHeaders, + m_nFilePos, i); + } + } + return true; +} + +void OWriterTable::FileClose() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + OWriterTable_BASE::FileClose(); +} + +} // namespace writer +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WTables.cxx b/connectivity/source/drivers/writer/WTables.cxx new file mode 100644 index 000000000000..685a5b778c54 --- /dev/null +++ b/connectivity/source/drivers/writer/WTables.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WTables.hxx" + +#include + +#include + +#include +#include "file/FCatalog.hxx" +#include "file/FConnection.hxx" +#include "writer/WCatalog.hxx" +#include "writer/WTable.hxx" + +using namespace ::com::sun::star; + +namespace connectivity +{ +namespace writer +{ + +sdbcx::ObjectType OWriterTables::createObject(const OUString& rName) +{ + OWriterTable* pTable = new OWriterTable(this, static_cast(static_cast(m_rParent).getConnection()), rName, "TABLE"); + sdbcx::ObjectType xRet = pTable; + pTable->construct(); + return xRet; +} + +} // namespace writer +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/Wservices.cxx b/connectivity/source/drivers/writer/Wservices.cxx new file mode 100644 index 000000000000..4e439bece7e0 --- /dev/null +++ b/connectivity/source/drivers/writer/Wservices.cxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include "writer/WDriver.hxx" +#include + +using namespace com::sun::star; + +typedef uno::Reference< lang::XSingleServiceFactory > (SAL_CALL* createFactoryFunc) +( + const uno::Reference< lang::XMultiServiceFactory >& rServiceManager, + const OUString& rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const uno::Sequence< OUString >& rServiceNames, + rtl_ModuleCount* +); + + +struct ProviderRequest +{ + uno::Reference< lang::XSingleServiceFactory > xRet; + uno::Reference< lang::XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(static_cast(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + bool CREATE_PROVIDER( + const OUString& Implname, + const uno::Sequence< OUString >& Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + { + try + { + xRet = creator(xServiceManager, sImplementationName,Factory, Services,nullptr); + } + catch (...) + { + } + } + return xRet.is(); + } + + void* getProvider() const + { + return xRet.get(); + } +}; + + +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL connectivity_writer_component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* /*pRegistryKey*/) +{ + void* pRet = nullptr; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + connectivity::writer::ODriver::getImplementationName_Static(), + connectivity::writer::ODriver::getSupportedServiceNames_Static(), + connectivity::writer::ODriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if (aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/writer.component b/connectivity/source/drivers/writer/writer.component new file mode 100644 index 000000000000..3bf9d6e79292 --- /dev/null +++ b/connectivity/source/drivers/writer/writer.component @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/connectivity/source/inc/calc/CColumns.hxx b/connectivity/source/inc/calc/CColumns.hxx deleted file mode 100644 index f178e80a396c..000000000000 --- a/connectivity/source/inc/calc/CColumns.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCOLUMNS_HXX - -#include "file/FColumns.hxx" - -namespace connectivity -{ - namespace calc - { - class OCalcColumns : public file::OColumns - { - protected: - virtual sdbcx::ObjectType createObject(const OUString& _rName) override; - public: - OCalcColumns(file::OFileTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector - ) : file::OColumns(_pTable,_rMutex,_rVector) - {} - - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCOLUMNS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/calc/CPreparedStatement.hxx b/connectivity/source/inc/calc/CPreparedStatement.hxx deleted file mode 100644 index 91507792dc10..000000000000 --- a/connectivity/source/inc/calc/CPreparedStatement.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CPREPAREDSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CPREPAREDSTATEMENT_HXX - -#include "file/FPreparedStatement.hxx" - -namespace connectivity -{ - namespace calc - { - class OConnection; - class OCalcPreparedStatement : public file::OPreparedStatement - { - protected: - virtual file::OResultSet* createResultSet() override; - public: - OCalcPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){} - DECLARE_SERVICE_INFO(); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CPREPAREDSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/calc/CResultSet.hxx b/connectivity/source/inc/calc/CResultSet.hxx deleted file mode 100644 index aa8278a41417..000000000000 --- a/connectivity/source/inc/calc/CResultSet.hxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CRESULTSET_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CRESULTSET_HXX - -#include "file/FResultSet.hxx" -#include -#include -#include - -namespace connectivity -{ - namespace calc - { - class OCalcResultSet; - // these typedef's are only necessary for the compiler - typedef ::cppu::ImplHelper2< css::sdbcx::XRowLocate, - css::sdbcx::XDeleteRows> OCalcResultSet_BASE; - typedef file::OResultSet OCalcResultSet_BASE2; - typedef ::comphelper::OPropertyArrayUsageHelper OCalcResultSet_BASE3; - - - class OCalcResultSet : public OCalcResultSet_BASE2, - public OCalcResultSet_BASE, - public OCalcResultSet_BASE3 - { - bool m_bBookmarkable; - protected: - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier> &_xIndex) override; - public: - DECLARE_SERVICE_INFO(); - - OCalcResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); - - private: - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; - //XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override; - // XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) override; - - // XRowLocate - virtual css::uno::Any SAL_CALL getBookmark( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& first, const css::uno::Any& second ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - // XDeleteRows - virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; - - virtual bool isRowDeleted() const override { return false; } - - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CRESULTSET_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/calc/CStatement.hxx b/connectivity/source/inc/calc/CStatement.hxx deleted file mode 100644 index e9a3d552eab0..000000000000 --- a/connectivity/source/inc/calc/CStatement.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CSTATEMENT_HXX - -#include "file/FStatement.hxx" - -namespace connectivity -{ - namespace calc - { - class OConnection; - class OCalcStatement : public file::OStatement - { - protected: - virtual file::OResultSet* createResultSet() override; - public: - OCalcStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} - DECLARE_SERVICE_INFO(); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/component/CColumns.hxx b/connectivity/source/inc/component/CColumns.hxx new file mode 100644 index 000000000000..3ecec1d0b637 --- /dev/null +++ b/connectivity/source/inc/component/CColumns.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CCOLUMNS_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CCOLUMNS_HXX + +#include "file/FColumns.hxx" + +namespace connectivity +{ + namespace component + { + /// Columns implementation for Writer tables and Calc sheets. + class OOO_DLLPUBLIC_FILE OComponentColumns : public file::OColumns + { + protected: + virtual sdbcx::ObjectType createObject(const OUString& _rName) override; + public: + OComponentColumns(file::OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector + ) : file::OColumns(_pTable,_rMutex,_rVector) + {} + + }; + } +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CCOLUMNS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/component/CPreparedStatement.hxx b/connectivity/source/inc/component/CPreparedStatement.hxx new file mode 100644 index 000000000000..55f8bf9f84c0 --- /dev/null +++ b/connectivity/source/inc/component/CPreparedStatement.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CPREPAREDSTATEMENT_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CPREPAREDSTATEMENT_HXX + +#include "file/FPreparedStatement.hxx" + +namespace connectivity +{ + namespace component + { + class OConnection; + /// Prepared statement implementation for Writer tables and Calc sheets. + class OOO_DLLPUBLIC_FILE OComponentPreparedStatement : public file::OPreparedStatement + { + protected: + virtual file::OResultSet* createResultSet() override; + public: + OComponentPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){} + DECLARE_SERVICE_INFO(); + }; + } +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CPREPAREDSTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/component/CResultSet.hxx b/connectivity/source/inc/component/CResultSet.hxx new file mode 100644 index 000000000000..b9fc94d03437 --- /dev/null +++ b/connectivity/source/inc/component/CResultSet.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CRESULTSET_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CRESULTSET_HXX + +#include "file/FResultSet.hxx" +#include +#include +#include + +namespace connectivity +{ + namespace component + { + class OComponentResultSet; + // these typedef's are only necessary for the compiler + typedef ::cppu::ImplHelper2< css::sdbcx::XRowLocate, + css::sdbcx::XDeleteRows> OComponentResultSet_BASE; + typedef file::OResultSet OComponentResultSet_BASE2; + typedef ::comphelper::OPropertyArrayUsageHelper OComponentResultSet_BASE3; + + + /// ResultSet implementation for Writer tables and Calc sheets. + class OOO_DLLPUBLIC_FILE OComponentResultSet : public OComponentResultSet_BASE2, + public OComponentResultSet_BASE, + public OComponentResultSet_BASE3 + { + bool m_bBookmarkable; + protected: + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier> &_xIndex) override; + public: + DECLARE_SERVICE_INFO(); + + OComponentResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); + + private: + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) override; + + // XRowLocate + virtual css::uno::Any SAL_CALL getBookmark( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& first, const css::uno::Any& second ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + // XDeleteRows + virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + + virtual bool isRowDeleted() const override { return false; } + + }; + } +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CRESULTSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/component/CStatement.hxx b/connectivity/source/inc/component/CStatement.hxx new file mode 100644 index 000000000000..695d92a4e225 --- /dev/null +++ b/connectivity/source/inc/component/CStatement.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CSTATEMENT_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CSTATEMENT_HXX + +#include "file/FStatement.hxx" + +namespace connectivity +{ + namespace component + { + class OConnection; + /// Statement implementation for Writer tables and Calc sheets. + class OOO_DLLPUBLIC_FILE OComponentStatement : public file::OStatement + { + protected: + virtual file::OResultSet* createResultSet() override; + public: + OComponentStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} + DECLARE_SERVICE_INFO(); + }; + } +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CSTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WCatalog.hxx b/connectivity/source/inc/writer/WCatalog.hxx new file mode 100644 index 000000000000..b1ba9a582714 --- /dev/null +++ b/connectivity/source/inc/writer/WCatalog.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCATALOG_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCATALOG_HXX + +#include "file/FCatalog.hxx" + +namespace connectivity +{ +namespace writer +{ + +class OWriterConnection; +class OWriterCatalog : public file::OFileCatalog +{ +public: + void refreshTables() override; + +public: + OWriterCatalog(OWriterConnection* _pCon); +}; + +} // namespace writer +} // namespace connectivity + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCATALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WConnection.hxx b/connectivity/source/inc/writer/WConnection.hxx new file mode 100644 index 000000000000..d0aaaa911ba4 --- /dev/null +++ b/connectivity/source/inc/writer/WConnection.hxx @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCONNECTION_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCONNECTION_HXX + +#include +#include "file/FConnection.hxx" +#include +#include +#include +#include + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace text +{ +class XTextDocument; +} +} +} +} + +namespace utl +{ +class CloseVeto; +} + + +namespace connectivity +{ +namespace writer +{ +class ODriver; +class OWriterConnection : public file::OConnection +{ + // the spreadsheet document: + css::uno::Reference< css::text::XTextDocument > m_xDoc; + OUString m_sPassword; + OUString m_aFileName; + oslInterlockedCount m_nDocCount; + + class CloseVetoButTerminateListener : public cppu::WeakComponentImplHelper + { + private: + /// close listener that vetoes so nobody else disposes m_xDoc + std::unique_ptr m_pCloseListener; + /// but also listen to XDesktop and if app is terminating anyway, dispose m_xDoc while + /// its still possible to do so properly + css::uno::Reference m_xDesktop; + osl::Mutex m_aMutex; + public: + CloseVetoButTerminateListener() + : cppu::WeakComponentImplHelper(m_aMutex) + { + } + + void start(const css::uno::Reference& rCloseable, + const css::uno::Reference& rDesktop) + { + m_xDesktop = rDesktop; + m_xDesktop->addTerminateListener(this); + m_pCloseListener.reset(new utl::CloseVeto(rCloseable, true)); + } + + void stop() + { + m_pCloseListener.reset(); + if (!m_xDesktop.is()) + return; + m_xDesktop->removeTerminateListener(this); + m_xDesktop.clear(); + } + + // XTerminateListener + virtual void SAL_CALL queryTermination(const css::lang::EventObject& /*rEvent*/) throw(css::frame::TerminationVetoException, css::uno::RuntimeException, std::exception) override + { + } + + virtual void SAL_CALL notifyTermination(const css::lang::EventObject& /*rEvent*/) throw(css::uno::RuntimeException, std::exception) override + { + stop(); + } + + virtual void SAL_CALL disposing() throw(css::uno::RuntimeException, std::exception) override + { + stop(); + cppu::WeakComponentImplHelperBase::disposing(); + } + + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + const bool bShutDown = (rEvent.Source == m_xDesktop); + if (bShutDown) + stop(); + } + }; + + rtl::Reference m_xCloseVetoButTerminateListener; + +public: + OWriterConnection(ODriver* _pDriver); + virtual ~OWriterConnection() override; + + virtual void construct(const OUString& _rUrl, + const css::uno::Sequence< css::beans::PropertyValue >& _rInfo) throw( css::sdbc::SQLException, css::uno::RuntimeException, css::uno::DeploymentException, std::exception) override; + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XConnection + virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog() override; + virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString& sql) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString& sql) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + + // no interface methods + css::uno::Reference< css::text::XTextDocument> const& acquireDoc(); + void releaseDoc(); + + class ODocHolder + { + OWriterConnection* m_pConnection; + css::uno::Reference< css::text::XTextDocument> m_xDoc; + public: + ODocHolder(OWriterConnection* _pConnection) : m_pConnection(_pConnection) + { + m_xDoc = m_pConnection->acquireDoc(); + } + ~ODocHolder() + { + m_xDoc.clear(); + m_pConnection->releaseDoc(); + } + const css::uno::Reference< css::text::XTextDocument>& getDoc() const + { + return m_xDoc; + } + }; +}; +} +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCONNECTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WDatabaseMetaData.hxx b/connectivity/source/inc/writer/WDatabaseMetaData.hxx new file mode 100644 index 000000000000..ef499f1c9880 --- /dev/null +++ b/connectivity/source/inc/writer/WDatabaseMetaData.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDATABASEMETADATA_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDATABASEMETADATA_HXX + +#include "file/FDatabaseMetaData.hxx" + +namespace connectivity +{ +namespace writer +{ + +class OWriterDatabaseMetaData : public file::ODatabaseMetaData +{ + virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() override; + virtual OUString SAL_CALL getURL() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns(const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL getMaxColumnNameLength() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInTable() throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual 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) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; +protected: + virtual ~OWriterDatabaseMetaData() override; +public: + OWriterDatabaseMetaData(file::OConnection* pConnection); +}; + +} // namespace writer +} // namespace connectivity + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDATABASEMETADATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WDriver.hxx b/connectivity/source/inc/writer/WDriver.hxx new file mode 100644 index 000000000000..0e6075b0d1ff --- /dev/null +++ b/connectivity/source/inc/writer/WDriver.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDRIVER_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDRIVER_HXX + +#include "file/FDriver.hxx" + +#include + +namespace connectivity +{ +namespace writer +{ +/// @throws css::uno::Exception +css::uno::Reference< css::uno::XInterface > SAL_CALL +ODriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) throw( css::uno::Exception ); + +class ODriver : public file::OFileDriver +{ +public: + ODriver(const css::uno::Reference< + css::uno::XComponentContext >& _rxContext) : + file::OFileDriver(_rxContext) {} + + /// @throws css::uno::RuntimeException + static OUString getImplementationName_Static() throw(css::uno::RuntimeException); + OUString SAL_CALL getImplementationName() throw(css::uno::RuntimeException, std::exception) override; + + // XDriver + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL + connect(const OUString& url, const css::uno::Sequence< + css::beans::PropertyValue >& info) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual sal_Bool SAL_CALL acceptsURL(const OUString& url) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; + virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override; +}; +} +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDRIVER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WTable.hxx b/connectivity/source/inc/writer/WTable.hxx new file mode 100644 index 000000000000..e0c5d2045402 --- /dev/null +++ b/connectivity/source/inc/writer/WTable.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WTABLE_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WTABLE_HXX + +#include "file/FTable.hxx" +#include + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace text +{ +class XTextTable; +} +} +} +} + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace util +{ +class XNumberFormats; +} +} +} +} + + +namespace connectivity +{ +namespace writer +{ +typedef file::OFileTable OWriterTable_BASE; +class OWriterConnection; + +class OWriterTable : public OWriterTable_BASE +{ +private: + std::vector m_aTypes; // holds all type for columns just to avoid to ask the propertyset + std::vector m_aPrecisions; // same as aboth + std::vector m_aScales; + css::uno::Reference< css::text::XTextTable > m_xTable; + OWriterConnection* m_pWriterConnection; + sal_Int32 m_nStartCol; + sal_Int32 m_nStartRow; + sal_Int32 m_nDataCols; + sal_Int32 m_nDataRows; + bool m_bHasHeaders; + css::uno::Reference< css::util::XNumberFormats > m_xFormats; + ::Date m_aNullDate; + + void fillColumns(); + +protected: + virtual void FileClose() override; +public: + virtual void refreshColumns() override; + virtual void refreshIndexes() override; + +public: + OWriterTable(sdbcx::OCollection* _pTables, OWriterConnection* _pConnection, + const OUString& Name, + const OUString& Type, + const OUString& Description = OUString(), + const OUString& SchemaName = OUString(), + const OUString& CatalogName = OUString() + ); + + virtual sal_Int32 getCurrentLastPos() const override; + virtual bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) override; + virtual bool fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, bool bRetrieveData) override; + + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) throw(css::uno::RuntimeException, std::exception) override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() throw(css::uno::RuntimeException, std::exception) override; + virtual void SAL_CALL disposing() override; + + // css::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& aIdentifier) throw(css::uno::RuntimeException, std::exception) override; + static css::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + void construct() override; +}; + +} // namespace writer +} // namespace connectivity + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WTABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WTables.hxx b/connectivity/source/inc/writer/WTables.hxx new file mode 100644 index 000000000000..0f9b61e0de3e --- /dev/null +++ b/connectivity/source/inc/writer/WTables.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WTABLES_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WTABLES_HXX + +#include "file/FTables.hxx" + +namespace connectivity +{ +namespace writer +{ +typedef file::OTables OWriterTables_BASE; + +class OWriterTables : public OWriterTables_BASE +{ +protected: + virtual sdbcx::ObjectType createObject(const OUString& _rName) override; +public: + OWriterTables(const css::uno::Reference& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const TStringVector& _rVector) : OWriterTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) + {} +}; +} +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WTABLES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/inc/dbaccess_helpid.hrc b/dbaccess/inc/dbaccess_helpid.hrc index 086bf7f4d40a..36fe8399efed 100644 --- a/dbaccess/inc/dbaccess_helpid.hrc +++ b/dbaccess/inc/dbaccess_helpid.hrc @@ -100,6 +100,7 @@ #define HID_DSADMIN_MSACCESS_MDB_FILE "DBACCESS_HID_DSADMIN_MSACCESS_MDB_FILE" #define HID_DSADMIN_FLAT_PATH "DBACCESS_HID_DSADMIN_FLAT_PATH" #define HID_DSADMIN_CALC_PATH "DBACCESS_HID_DSADMIN_CALC_PATH" +#define HID_DSADMIN_WRITER_PATH "DBACCESS_HID_DSADMIN_WRITER_PATH" #define HID_DSADMIN_ORACLE_DATABASE "DBACCESS_HID_DSADMIN_ORACLE_DATABASE" #define HID_APP_TABLE_TREE "DBACCESS_HID_APP_TABLE_TREE" diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 0414b77e2219..a478f6c6fb63 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -388,6 +388,7 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(const OUString& _rDsn) const const KnownPrefix aKnowPrefixes[] = { KnownPrefix( "sdbc:calc:", DST_CALC, false ), + KnownPrefix( "sdbc:writer:", DST_WRITER, false ), KnownPrefix( "sdbc:flat:", DST_FLAT, false ), KnownPrefix( "sdbc:odbc:", DST_ODBC, false ), KnownPrefix( "sdbc:dbase:", DST_DBASE, false ), @@ -436,7 +437,8 @@ void ODsnTypeCollection::fillPageIds(const OUString& _sURL,::std::vectordetermineType(m_eType); - if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) ) + if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_WRITER == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) ) { if( pathExists(sURL, true) == PATH_NOT_EXIST ) { diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx index fa8d31fbfcd3..ac673a4b5638 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx @@ -149,6 +149,10 @@ namespace dbaui m_pFT_Connection->SetText(OUString(ModuleRes(STR_CALC_PATH_OR_FILE))); m_pConnectionURL->SetHelpId(HID_DSADMIN_CALC_PATH); break; + case ::dbaccess::DST_WRITER: + m_pFT_Connection->SetText(OUString(ModuleRes(STR_WRITER_PATH_OR_FILE))); + m_pConnectionURL->SetHelpId(HID_DSADMIN_WRITER_PATH); + break; case ::dbaccess::DST_ADO: m_pFT_Connection->SetText(OUString(ModuleRes(STR_COMMONURL))); break; diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index edad0abe55ea..8daeaed35163 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -687,7 +687,7 @@ using namespace ::com::sun::star; callModifiedHdl(); } - VclPtr OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr OSpreadSheetConnectionPageSetup::CreateDocumentOrSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { return VclPtr::Create( pParent, _rAttrSet ); } diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx index cbdb3e273e4e..9aff6bb8d5bf 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx @@ -40,7 +40,7 @@ namespace dbaui { public: virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) override; - static VclPtr CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr CreateDocumentOrSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); OSpreadSheetConnectionPageSetup(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); virtual ~OSpreadSheetConnectionPageSetup() override; virtual void dispose() override; diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 2490f0eaf31c..04d204379331 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -479,6 +479,7 @@ OUString ODbDataSourceAdministrationHelper::getConnectionURL() const case ::dbaccess::DST_DBASE: case ::dbaccess::DST_FLAT: case ::dbaccess::DST_CALC: + case ::dbaccess::DST_WRITER: break; case ::dbaccess::DST_MSACCESS: case ::dbaccess::DST_MSACCESS_2007: diff --git a/dbaccess/source/ui/dlg/dbadminsetup.src b/dbaccess/source/ui/dlg/dbadminsetup.src index d798978cb21b..a4903c5dc4d1 100644 --- a/dbaccess/source/ui/dlg/dbadminsetup.src +++ b/dbaccess/source/ui/dlg/dbadminsetup.src @@ -74,9 +74,9 @@ String STR_PAGETITLE_ODBC Text[ en-US ] = "Set up ODBC connection" ; }; -String STR_PAGETITLE_SPREADSHEET +String STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET { - Text[ en-US ] = "Set up Spreadsheet connection" ; + Text[ en-US ] = "Set up Writer Document or Spreadsheet connection" ; }; String STR_PAGETITLE_AUTHENTIFICATION diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index 669a607c669a..3ff5645621f2 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -156,6 +156,7 @@ WizardTypes::WizardState ODbTypeWizDialog::determineNextState( WizardState _nCur case ::dbaccess::DST_MSACCESS_2007: case ::dbaccess::DST_JDBC: case ::dbaccess::DST_CALC: + case ::dbaccess::DST_WRITER: nNextState = WZS_INVALID_STATE; break; case ::dbaccess::DST_DBASE: diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 9e33bc439e79..4e09735c5c5f 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -120,7 +120,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(vcl::Window* _pParent , m_sRM_OracleText( ModuleRes( STR_PAGETITLE_ORACLE ) ) , m_sRM_MySQLText( ModuleRes( STR_PAGETITLE_MYSQL ) ) , m_sRM_ODBCText( ModuleRes( STR_PAGETITLE_ODBC ) ) - , m_sRM_SpreadSheetText( ModuleRes( STR_PAGETITLE_SPREADSHEET ) ) + , m_sRM_DocumentOrSpreadSheetText( ModuleRes( STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET ) ) , m_sRM_AuthentificationText( ModuleRes( STR_PAGETITLE_AUTHENTIFICATION ) ) , m_sRM_FinalText( ModuleRes( STR_PAGETITLE_FINAL ) ) , m_sWorkPath( SvtPathOptions().GetWorkPath() ) @@ -240,8 +240,8 @@ OUString ODbTypeWizDialogSetup::getStateDisplayName( WizardState _nState ) const case PAGE_DBSETUPWIZARD_ODBC: sRoadmapItem = m_sRM_ODBCText; break; - case PAGE_DBSETUPWIZARD_SPREADSHEET: - sRoadmapItem = m_sRM_SpreadSheetText; + case PAGE_DBSETUPWIZARD_DOCUMENT_OR_SPREADSHEET: + sRoadmapItem = m_sRM_DocumentOrSpreadSheetText; break; case PAGE_DBSETUPWIZARD_AUTHENTIFICATION: sRoadmapItem = m_sRM_AuthentificationText; @@ -520,8 +520,8 @@ VclPtr ODbTypeWizDialogSetup::createPage(WizardState _nState) pPage = OLDAPConnectionPageSetup::CreateLDAPTabPage(this,*m_pOutSet); break; - case PAGE_DBSETUPWIZARD_SPREADSHEET: /// first user defined driver - pPage = OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage(this,*m_pOutSet); + case PAGE_DBSETUPWIZARD_DOCUMENT_OR_SPREADSHEET: + pPage = OSpreadSheetConnectionPageSetup::CreateDocumentOrSpreadSheetTabPage(this,*m_pOutSet); break; case PAGE_DBSETUPWIZARD_MSACCESS: diff --git a/dbaccess/source/ui/inc/dbu_dlg.hrc b/dbaccess/source/ui/inc/dbu_dlg.hrc index 3fb205315fa8..960c175a3ff6 100644 --- a/dbaccess/source/ui/inc/dbu_dlg.hrc +++ b/dbaccess/source/ui/inc/dbu_dlg.hrc @@ -79,7 +79,7 @@ #define STR_NAME_OF_ODBC_DATASOURCE RID_STR_DLG_START + 48 #define STR_MYSQL_DATABASE_NAME RID_STR_DLG_START + 49 #define STR_ORACLE_DATABASE_NAME RID_STR_DLG_START + 50 - // FREE +#define STR_WRITER_PATH_OR_FILE RID_STR_DLG_START + 51 #define STR_MSACCESS_MDB_FILE RID_STR_DLG_START + 52 #define STR_COMMONURL RID_STR_DLG_START + 53 #define STR_DATABASEDEFAULTNAME RID_STR_DLG_START + 54 @@ -108,7 +108,7 @@ #define STR_PAGETITLE_ORACLE RID_STR_DLG_START + 76 #define STR_PAGETITLE_MYSQL RID_STR_DLG_START + 77 #define STR_PAGETITLE_ODBC RID_STR_DLG_START + 78 -#define STR_PAGETITLE_SPREADSHEET RID_STR_DLG_START + 79 +#define STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET RID_STR_DLG_START + 79 #define STR_PAGETITLE_AUTHENTIFICATION RID_STR_DLG_START + 80 #define STR_PAGETITLE_MYSQL_NATIVE RID_STR_DLG_START + 81 #define STR_PAGETITLE_FINAL RID_STR_DLG_START + 82 diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx index 31b08dfa0bd5..99df1376475e 100644 --- a/dbaccess/source/ui/inc/dbwizsetup.hxx +++ b/dbaccess/source/ui/inc/dbwizsetup.hxx @@ -77,7 +77,7 @@ private: OUString m_sRM_OracleText; OUString m_sRM_MySQLText; OUString m_sRM_ODBCText; - OUString m_sRM_SpreadSheetText; + OUString m_sRM_DocumentOrSpreadSheetText; OUString m_sRM_AuthentificationText; OUString m_sRM_FinalText; INetURLObject m_aDocURL; diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index bd4ab2f1240e..6dcd82b3dea6 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -85,6 +85,7 @@ certain functionality. @li @c connectivity.odbc @li @c connectivity.parse @li @c connectivity.postgresql +@li @c connectivity.writer @section comphelper diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index 6ee4597fb69f..231cbb63cc22 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -417,6 +417,12 @@ postprocess_FILES_writer := \ $(postprocess_MOD)/org/openoffice/Office/Embedding-writer.xcu \ $(postprocess_MOD)/org/openoffice/Setup-writer.xcu +ifeq (DBCONNECTIVITY,$(filter DBCONNECTIVITY,$(BUILD_TYPE))) +postprocess_FILES_writer += \ + $(call gb_XcuModuleTarget_get_target,connectivity/registry/writer)/org/openoffice/Office/DataAccess/Drivers-writer.xcu +postprocess_DRIVERS += writer +endif + postprocess_DEPS_xsltfilter := main postprocess_OPTDEPS_xsltfilter := calc writer postprocess_FILES_xsltfilter := \ diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index cd952135cc96..9fce3c6c37f5 100644 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -268,6 +268,7 @@ $(eval $(call gb_Rdb_add_components,services,\ connectivity/source/drivers/jdbc/jdbc \ ) \ connectivity/source/manager/sdbc2 \ + connectivity/source/drivers/writer/writer \ dbaccess/source/ext/macromigration/dbmm \ dbaccess/source/filter/xml/dbaxml \ dbaccess/util/dba \ diff --git a/sw/CppunitTest_sw_mailmerge.mk b/sw/CppunitTest_sw_mailmerge.mk index 8d2a3f8ac75e..7826c312ddb2 100644 --- a/sw/CppunitTest_sw_mailmerge.mk +++ b/sw/CppunitTest_sw_mailmerge.mk @@ -39,6 +39,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_mailmerge, \ configmgr/source/configmgr \ connectivity/source/cpool/dbpool2 \ connectivity/source/drivers/calc/calc \ + connectivity/source/drivers/writer/writer \ connectivity/source/manager/sdbc2 \ dbaccess/source/filter/xml/dbaxml \ dbaccess/util/dba \ diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 7a3d6d124ba6..09a077200454 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -293,7 +293,8 @@ public: DBCONN_DBASE, DBCONN_FLAT, DBCONN_MSJET, - DBCONN_MSACE + DBCONN_MSACE, + DBCONN_WRITER }; /// MailMergeEvent source diff --git a/sw/inc/dbui.hrc b/sw/inc/dbui.hrc index 5557fa379612..61fb0b6b432d 100644 --- a/sw/inc/dbui.hrc +++ b/sw/inc/dbui.hrc @@ -40,6 +40,7 @@ #define ST_PUNCTUATION (RC_DBUI_BEGIN + 14) #define ST_TEXT (RC_DBUI_BEGIN + 15) #define RA_SALUTATION (RC_DBUI_BEGIN + 16) +#define STR_FILTER_SXW (RC_DBUI_BEGIN + 17) #define RA_PUNCTUATION (RC_DBUI_BEGIN + 18) #define ST_TITLE_MALE (RC_DBUI_BEGIN + 19) #define ST_TITLE_FEMALE (RC_DBUI_BEGIN + 20) @@ -82,6 +83,7 @@ #define ST_FINISH (RC_DBUI_BEGIN + 57) #define ST_ADDRESSLIST (RC_DBUI_BEGIN + 58) #define ST_EXCLUDE (RC_DBUI_BEGIN + 59) +#define STR_FILTER_DOC (RC_DBUI_BEGIN + 60) // ImageList #define ILIST (RC_DBUI_BEGIN + 62) diff --git a/sw/qa/extras/mailmerge/data/10-testing-addresses-writer.odt b/sw/qa/extras/mailmerge/data/10-testing-addresses-writer.odt new file mode 100644 index 000000000000..40b61eda3bbb Binary files /dev/null and b/sw/qa/extras/mailmerge/data/10-testing-addresses-writer.odt differ diff --git a/sw/qa/extras/mailmerge/data/writer-mail-merge.odt b/sw/qa/extras/mailmerge/data/writer-mail-merge.odt new file mode 100644 index 000000000000..f3d42f6b4781 Binary files /dev/null and b/sw/qa/extras/mailmerge/data/writer-mail-merge.odt differ diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index 0c356526de26..a239f2c1ca17 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -420,6 +420,20 @@ DECLARE_FILE_MAILMERGE_TEST(testSimpleMailMerge, "simple-mail-merge.odt", "10-te } } +DECLARE_FILE_MAILMERGE_TEST(testWriterDataSource, "writer-mail-merge.odt", "10-testing-addresses-writer.odt", "testing-addresses-writer") +{ + // This failed as the .odt data source was mapped to the jdbc: protocol. + executeMailMerge(); + for (int doc = 0; doc < 10; ++doc) + { + loadMailMergeDocument(doc); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(OUString("Fixed text."), getRun(getParagraph(1), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("lastname" + OUString::number(doc + 1)), getRun(getParagraph(2), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("Another fixed text."), getRun(getParagraph(3), 1)->getString()); + } +} + DECLARE_FILE_MAILMERGE_TEST(test2Pages, "simple-mail-merge-2pages.odt", "10-testing-addresses.ods", "testing-addresses") { executeMailMerge(); diff --git a/sw/source/ui/dbui/dbui.src b/sw/source/ui/dbui/dbui.src index 3962a253e0c7..fa50541d277f 100644 --- a/sw/source/ui/dbui/dbui.src +++ b/sw/source/ui/dbui/dbui.src @@ -60,13 +60,21 @@ String STR_FILTER_SXC { Text [ en-US ] = "%PRODUCTNAME Calc (*.ods;*.sxc)" ; }; +String STR_FILTER_SXW +{ + Text [ en-US ] = "%PRODUCTNAME Writer (*.odt;*.sxw)" ; +}; String STR_FILTER_DBF { Text [ en-US ] = "dBase (*.dbf)" ; }; String STR_FILTER_XLS { - Text [ en-US ] = "Microsoft Excel (*.xls)" ; + Text [ en-US ] = "Microsoft Excel (*.xls;*.xlsx)" ; +}; +String STR_FILTER_DOC +{ + Text [ en-US ] = "Microsoft Word (*.doc;*.docx)" ; }; String STR_FILTER_TXT { diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 991b6127c251..876f4c22166a 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2581,8 +2581,10 @@ OUString SwDBManager::LoadAndRegisterDataSource(SwDocShell* pDocShell) OUString sFilterAllData(SW_RES(STR_FILTER_ALL_DATA)); OUString sFilterSXB(SW_RES(STR_FILTER_SXB)); OUString sFilterSXC(SW_RES(STR_FILTER_SXC)); + OUString sFilterSXW(SW_RES(STR_FILTER_SXW)); OUString sFilterDBF(SW_RES(STR_FILTER_DBF)); OUString sFilterXLS(SW_RES(STR_FILTER_XLS)); + OUString sFilterDOC(SW_RES(STR_FILTER_DOC)); OUString sFilterTXT(SW_RES(STR_FILTER_TXT)); OUString sFilterCSV(SW_RES(STR_FILTER_CSV)); #ifdef _WIN32 @@ -2590,12 +2592,14 @@ OUString SwDBManager::LoadAndRegisterDataSource(SwDocShell* pDocShell) OUString sFilterACCDB(SW_RES(STR_FILTER_ACCDB)); #endif xFltMgr->appendFilter( sFilterAll, "*" ); - xFltMgr->appendFilter( sFilterAllData, "*.ods;*.sxc;*.dbf;*.xls;*.txt;*.csv"); + xFltMgr->appendFilter( sFilterAllData, "*.ods;*.sxc;*.odt;*.sxw;*.dbf;*.xls;*.xlsx;*.doc;*.docx;*.txt;*.csv"); xFltMgr->appendFilter( sFilterSXB, "*.odb" ); xFltMgr->appendFilter( sFilterSXC, "*.ods;*.sxc" ); + xFltMgr->appendFilter( sFilterSXW, "*.odt;*.sxw" ); xFltMgr->appendFilter( sFilterDBF, "*.dbf" ); - xFltMgr->appendFilter( sFilterXLS, "*.xls" ); + xFltMgr->appendFilter( sFilterXLS, "*.xls;*.xlsx" ); + xFltMgr->appendFilter( sFilterDOC, "*.doc;*.docx" ); xFltMgr->appendFilter( sFilterTXT, "*.txt" ); xFltMgr->appendFilter( sFilterCSV, "*.csv" ); #ifdef _WIN32 @@ -2636,13 +2640,21 @@ SwDBManager::DBConnURITypes SwDBManager::GetDBunoURI(const OUString &rURI, uno:: } else if(sExt.equalsIgnoreAsciiCase("sxc") || sExt.equalsIgnoreAsciiCase("ods") - || sExt.equalsIgnoreAsciiCase("xls")) + || sExt.equalsIgnoreAsciiCase("xls") + || sExt.equalsIgnoreAsciiCase("xlsx")) { OUString sDBURL("sdbc:calc:"); sDBURL += aURL.GetMainURL(INetURLObject::NO_DECODE); aURLAny <<= sDBURL; type = DBCONN_CALC; } + else if (sExt.equalsIgnoreAsciiCase("sxw") || sExt.equalsIgnoreAsciiCase("odt") || sExt.equalsIgnoreAsciiCase("doc") || sExt.equalsIgnoreAsciiCase("docx")) + { + OUString sDBURL("sdbc:writer:"); + sDBURL += aURL.GetMainURL(INetURLObject::NO_DECODE); + aURLAny <<= sDBURL; + type = DBCONN_WRITER; + } else if(sExt.equalsIgnoreAsciiCase("dbf")) { aURL.removeSegment(); @@ -2709,6 +2721,7 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const switch (type) { case DBCONN_UNKNOWN: case DBCONN_CALC: + case DBCONN_WRITER: break; case DBCONN_ODB: bStore = false; -- cgit v1.2.3