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. Change-Id: Id043f7742fdb2006d4f88526ef4d055a6d8dee82 Reviewed-on: https://gerrit.libreoffice.org/40033 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
parent
d62d7803ad
commit
69068f2228
14 changed files with 809 additions and 0 deletions
|
@ -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
|
||||
|
|
20
connectivity/Configuration_writer.mk
Normal file
20
connectivity/Configuration_writer.mk
Normal file
|
@ -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:
|
45
connectivity/Library_writer.mk
Normal file
45
connectivity/Library_writer.mk
Normal file
|
@ -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:
|
|
@ -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,\
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* 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/.
|
||||
-->
|
||||
<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<node oor:name="Installed" install:module="writer">
|
||||
<node oor:name="sdbc:writer:*" oor:op="replace">
|
||||
<prop oor:name="Driver">
|
||||
<value>com.sun.star.comp.sdbc.writer.ODriver</value>
|
||||
</prop>
|
||||
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Document</value>
|
||||
</prop>
|
||||
<node oor:name="Features">
|
||||
<node oor:name="EscapeDateTime" oor:op="replace">
|
||||
<prop oor:name="Value" oor:type="xs:boolean">
|
||||
<value>true</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
<node oor:name="MetaData">
|
||||
<node oor:name="SupportsBrowsing" oor:op="replace">
|
||||
<prop oor:name="Value" oor:type="xs:boolean">
|
||||
<value>true</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="FileSystemBased" oor:op="replace">
|
||||
<prop oor:name="Value" oor:type="xs:boolean">
|
||||
<value>true</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="MediaType" oor:op="replace">
|
||||
<prop oor:name="Value" oor:type="xs:string">
|
||||
<value>application/vnd.oasis.opendocument.text</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</oor:component-data>
|
252
connectivity/source/drivers/writer/WConnection.cxx
Normal file
252
connectivity/source/drivers/writer/WConnection.cxx
Normal file
|
@ -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 <com/sun/star/lang/DisposedException.hpp>
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
#include <com/sun/star/text/XTextDocument.hpp>
|
||||
#include <tools/urlobj.hxx>
|
||||
#include <unotools/pathoptions.hxx>
|
||||
#include <connectivity/dbexception.hxx>
|
||||
#include <cppuhelper/exc_hlp.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
|
||||
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<text::XTextDocument> 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<beans::PropertyValue> 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: */
|
90
connectivity/source/drivers/writer/WDriver.cxx
Normal file
90
connectivity/source/drivers/writer/WDriver.cxx
Normal file
|
@ -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 <com/sun/star/lang/DisposedException.hpp>
|
||||
#include <connectivity/dbexception.hxx>
|
||||
#include "resource/sharedresources.hxx"
|
||||
#include "resource/common_res.hrc"
|
||||
#include <comphelper/processfactory.hxx>
|
||||
|
||||
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: */
|
102
connectivity/source/drivers/writer/Wservices.cxx
Normal file
102
connectivity/source/drivers/writer/Wservices.cxx
Normal file
|
@ -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 <cppuhelper/factory.hxx>
|
||||
|
||||
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<lang::XMultiServiceFactory*>(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: */
|
17
connectivity/source/drivers/writer/writer.component
Normal file
17
connectivity/source/drivers/writer/writer.component
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* 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/.
|
||||
-->
|
||||
|
||||
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
|
||||
prefix="connectivity_writer"
|
||||
xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.comp.sdbc.writer.ODriver">
|
||||
<service name="com.sun.star.sdbc.Driver"/>
|
||||
<service name="com.sun.star.sdbcx.Driver"/>
|
||||
</implementation>
|
||||
</component>
|
170
connectivity/source/inc/writer/WConnection.hxx
Normal file
170
connectivity/source/inc/writer/WConnection.hxx
Normal file
|
@ -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 <memory>
|
||||
#include "file/FConnection.hxx"
|
||||
#include <com/sun/star/frame/XDesktop2.hpp>
|
||||
#include <com/sun/star/frame/XTerminateListener.hpp>
|
||||
#include <com/sun/star/uno/DeploymentException.hpp>
|
||||
#include <unotools/closeveto.hxx>
|
||||
|
||||
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<css::frame::XTerminateListener>
|
||||
{
|
||||
private:
|
||||
/// close listener that vetoes so nobody else disposes m_xDoc
|
||||
std::unique_ptr<utl::CloseVeto> 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<css::frame::XDesktop2> m_xDesktop;
|
||||
osl::Mutex m_aMutex;
|
||||
public:
|
||||
CloseVetoButTerminateListener()
|
||||
: cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aMutex)
|
||||
{
|
||||
}
|
||||
|
||||
void start(const css::uno::Reference<css::uno::XInterface>& rCloseable,
|
||||
const css::uno::Reference<css::frame::XDesktop2>& 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<CloseVetoButTerminateListener> 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: */
|
58
connectivity/source/inc/writer/WDriver.hxx
Normal file
58
connectivity/source/inc/writer/WDriver.hxx
Normal file
|
@ -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 <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
|
||||
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: */
|
|
@ -87,6 +87,7 @@ certain functionality.
|
|||
@li @c connectivity.odbc
|
||||
@li @c connectivity.parse
|
||||
@li @c connectivity.postgresql
|
||||
@li @c connectivity.writer
|
||||
|
||||
@section comphelper
|
||||
|
||||
|
|
|
@ -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 := \
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue