diff --git a/Repository.mk b/Repository.mk
index b7afbb1e06b7..6329a4eac6a5 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -502,6 +502,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_writer.mk b/connectivity/Library_writer.mk
new file mode 100644
index 000000000000..95ae50cfcad6
--- /dev/null
+++ b/connectivity/Library_writer.mk
@@ -0,0 +1,45 @@
+# -*- 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/WConnection \
+ connectivity/source/drivers/writer/WDriver \
+ 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 efb057ff4ba4..067d883a232b 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Configuration_flat \
Configuration_mysql \
Configuration_odbc \
+ Configuration_writer \
Library_calc \
Library_dbase \
Library_dbpool2 \
@@ -30,6 +31,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..b35de87833e3
--- /dev/null
+++ b/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ com.sun.star.comp.sdbc.writer.ODriver
+
+
+ Document
+
+
+
+
+ true
+
+
+
+
+
+
+ true
+
+
+
+
+ true
+
+
+
+
+ application/vnd.oasis.opendocument.text
+
+
+
+
+
+
diff --git a/connectivity/source/drivers/writer/WConnection.cxx b/connectivity/source/drivers/writer/WConnection.cxx
new file mode 100644
index 000000000000..212e29400bea
--- /dev/null
+++ b/connectivity/source/drivers/writer/WConnection.cxx
@@ -0,0 +1,252 @@
+/* -*- 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/WDriver.hxx"
+#include "resource/sharedresources.hxx"
+#include "resource/common_res.hrc"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace connectivity::file;
+
+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)
+{
+ // 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::DecodeMechanism::NONE);
+
+ 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()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ uno::Reference< sdbc::XDatabaseMetaData > xMetaData = m_xMetaData;
+ if (!xMetaData.is())
+ {
+ SAL_WARN("connectivity.writer", "TODO implement OWriterConnection::getMetaData()");
+ }
+
+ return xMetaData;
+}
+
+
+css::uno::Reference< sdbcx::XTablesSupplier > OWriterConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ uno::Reference< sdbcx::XTablesSupplier > xTab = m_xCatalog;
+ if (!xTab.is())
+ {
+ SAL_WARN("connectivity.writer", "TODO implement OWriterConnection::createCatalog()");
+ }
+ return xTab;
+}
+
+
+uno::Reference< sdbc::XStatement > SAL_CALL OWriterConnection::createStatement()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ uno::Reference< sdbc::XStatement > xReturn;
+ SAL_WARN("connectivity.writer", "TODO implement OWriterConnection::createStatement()");
+ m_aStatements.push_back(uno::WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+
+
+uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareStatement(const OUString& /*sql*/)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ SAL_WARN("connectivity.writer", "TODO implement OWriterConnection::prepareStatement()");
+
+ return nullptr;
+}
+
+
+uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareCall(const OUString& /*sql*/)
+{
+ ::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/WDriver.cxx b/connectivity/source/drivers/writer/WDriver.cxx
new file mode 100644
index 000000000000..3406d8589434
--- /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()
+{
+ return OUString("com.sun.star.comp.sdbc.writer.ODriver");
+}
+
+OUString SAL_CALL ODriver::getImplementationName()
+{
+ return getImplementationName_Static();
+}
+
+uno::Reference< css::uno::XInterface > SAL_CALL
+ODriver_CreateInstance(const uno::Reference<
+ lang::XMultiServiceFactory >& _rxFactory)
+{
+ return *(new ODriver(comphelper::getComponentContext(_rxFactory)));
+}
+
+uno::Reference< sdbc::XConnection > SAL_CALL ODriver::connect(const OUString& url,
+ const uno::Sequence< beans::PropertyValue >& info)
+{
+ ::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)
+{
+ return url.startsWith("sdbc:writer:");
+}
+
+uno::Sequence< sdbc::DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo(const OUString& url, const uno::Sequence< beans::PropertyValue >& /*info*/)
+{
+ 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/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/writer/WConnection.hxx b/connectivity/source/inc/writer/WConnection.hxx
new file mode 100644
index 000000000000..682a33319b38
--- /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*/) override
+ {
+ }
+
+ virtual void SAL_CALL notifyTermination(const css::lang::EventObject& /*rEvent*/) override
+ {
+ stop();
+ }
+
+ virtual void SAL_CALL disposing() 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) override;
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing() override;
+
+ // XConnection
+ virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override;
+ virtual css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog() override;
+ virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override;
+ virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString& sql) override;
+ virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString& sql) 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/WDriver.hxx b/connectivity/source/inc/writer/WDriver.hxx
new file mode 100644
index 000000000000..0ca53a411c84
--- /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);
+
+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();
+ OUString SAL_CALL getImplementationName() override;
+
+ // XDriver
+ virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL
+ connect(const OUString& url, const css::uno::Sequence<
+ css::beans::PropertyValue >& info) override;
+ virtual sal_Bool SAL_CALL acceptsURL(const OUString& url) override;
+ virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info) override;
+};
+}
+}
+
+#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WDRIVER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index cad1e42ad0a4..b657c0b37764 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -87,6 +87,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 87792b6f062e..9ddb084a6ae7 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -418,6 +418,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 31203f553343..487d7e3c46af 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -263,6 +263,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 \