diff options
author | Matthew Nicholls <matthew.nicholls95@hotmail.co.uk> | 2015-04-01 15:43:32 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2015-04-14 14:29:02 +0000 |
commit | b7bb34d74c5c764844f5b87483d09a61d3088695 (patch) | |
tree | c2e0827ed5ffe194ef51a8204b67d298c6741b50 /sw | |
parent | 7b68534ab0d322522ee5f64250526050187b6a9c (diff) |
tdf#88710 Kill svx dbtoolsclient
Removes dynamic loading logic described in tdf#84315, similar thing
removed in swdbtoolsclient.
Change-Id: I8762102a7263e6933354c2ff6f9978929b760f6e
Reviewed-on: https://gerrit.libreoffice.org/15147
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_uwriter.mk | 2 | ||||
-rw-r--r-- | sw/Library_sw.mk | 3 | ||||
-rw-r--r-- | sw/Library_swui.mk | 2 | ||||
-rw-r--r-- | sw/inc/dbmgr.hxx | 7 | ||||
-rw-r--r-- | sw/inc/swdbtoolsclient.hxx | 69 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbinsdlg.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 30 | ||||
-rw-r--r-- | sw/source/uibase/dbui/swdbtoolsclient.cxx | 232 | ||||
-rw-r--r-- | sw/source/uibase/utlui/initui.cxx | 3 |
9 files changed, 17 insertions, 336 deletions
diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk index 9f4e9f947297..f690515bef08 100644 --- a/sw/CppunitTest_sw_uwriter.mk +++ b/sw/CppunitTest_sw_uwriter.mk @@ -27,6 +27,8 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uwriter, \ comphelper \ cppu \ cppuhelper \ + $(call gb_Helper_optional,DBCONNECTIVITY, \ + dbtools) \ drawinglayer \ editeng \ i18nlangtag \ diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index ceaf6eb6fe04..673585acc543 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -53,6 +53,8 @@ $(eval $(call gb_Library_use_libraries,sw,\ comphelper \ cppu \ cppuhelper \ + $(call gb_Helper_optional,DBCONNECTIVITY, \ + dbtools) \ drawinglayer \ editeng \ i18nlangtag \ @@ -766,7 +768,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/dbui/mailmergechildwindow \ sw/source/uibase/dbui/mailmergehelper \ sw/source/uibase/dbui/mmconfigitem \ - sw/source/uibase/dbui/swdbtoolsclient \ sw/source/uibase/uno/unomailmerge \ )) endif diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index d9fb3f756a65..6738e3c9af5a 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -50,6 +50,8 @@ $(eval $(call gb_Library_use_libraries,swui,\ comphelper \ cppu \ cppuhelper \ + $(call gb_Helper_optional,DBCONNECTIVITY, \ + dbtools) \ editeng \ i18nlangtag \ i18nutil \ diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 1ad4ad0a8b5e..30aa2875d7ea 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -73,7 +73,6 @@ class SfxProgress; class ListBox; class Button; class SvNumberFormatter; -class SwDbtoolsClient; class SwXMailMerge; class SwMailMergeConfigItem; class SwCalc; @@ -186,8 +185,6 @@ class SW_DLLPUBLIC SwDBManager { friend class SwConnectionDisposedListener_Impl; - static SwDbtoolsClient* pDbtoolsClient; - OUString sEMailAddrFld; ///< Mailing: Column name of email address. OUString sSubject; ///< Mailing: Subject OUString sAttached; ///< Mailing: Attached Files. @@ -372,10 +369,6 @@ public: static OUString LoadAndRegisterDataSource(const OUString& rURI, const OUString *pPrefix = 0, const OUString *pDestDir = 0, const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > *pSettings = 0); - static SwDbtoolsClient& GetDbtoolsClient(); - /// has to be called from _FinitUI() - static void RemoveDbtoolsClient(); - /** try to get the data source from the given connection through the XChild interface. If this is not possible, the data source will be created through its name. @param _xConnection diff --git a/sw/inc/swdbtoolsclient.hxx b/sw/inc/swdbtoolsclient.hxx deleted file mode 100644 index 923835acd278..000000000000 --- a/sw/inc/swdbtoolsclient.hxx +++ /dev/null @@ -1,69 +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_SW_INC_SWDBTOOLSCLIENT_HXX -#define INCLUDED_SW_INC_SWDBTOOLSCLIENT_HXX - -#include <connectivity/virtualdbtools.hxx> -#include <osl/mutex.hxx> -#include <osl/module.h> -#include "swdllapi.h" - -/* - Client to use the dbtools library as load-on-call -*/ -class SW_DLLPUBLIC SwDbtoolsClient -{ -private: - ::rtl::Reference< ::connectivity::simple::IDataAccessTools > m_xDataAccessTools; - ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion > m_xAccessTypeConversion; - ::rtl::Reference< ::connectivity::simple::IDataAccessToolsFactory > m_xDataAccessFactory; - - SAL_DLLPRIVATE static void registerClient(); - SAL_DLLPRIVATE static void revokeClient(); - SAL_DLLPRIVATE void getFactory(); - - SAL_DLLPRIVATE ::rtl::Reference< ::connectivity::simple::IDataAccessTools > getDataAccessTools(); - SAL_DLLPRIVATE ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion > getAccessTypeConversion(); - -public: - SwDbtoolsClient(); - ~SwDbtoolsClient(); - - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource( - const OUString& _rsRegisteredName, - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext - ); - - sal_Int32 getDefaultNumberFormat( - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn, - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _rxTypes, - const ::com::sun::star::lang::Locale& _rLocale - ); - - OUString getFormattedValue( - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn, - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& _rxFormatter, - const ::com::sun::star::lang::Locale& _rLocale, - const ::com::sun::star::util::Date& _rNullDate - ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index daf8855fd5b6..29aa77145fdb 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -54,7 +54,6 @@ #include <editeng/brushitem.hxx> #include <editeng/boxitem.hxx> #include <svx/rulritem.hxx> -#include <swdbtoolsclient.hxx> #include <tabledlg.hxx> #include <fmtclds.hxx> #include <tabcol.hxx> @@ -76,6 +75,7 @@ #include <swmodule.hxx> #include <poolfmt.hxx> #include <crsskip.hxx> +#include <connectivity/dbtools.hxx> #include <dbui.hrc> @@ -94,6 +94,7 @@ #include <boost/scoped_ptr.hpp> #include <swuiexp.hxx> +using namespace ::dbtools; using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -318,7 +319,7 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView, } else { - pNew->nDBNumFmt = SwDBManager::GetDbtoolsClient().getDefaultNumberFormat(xCol, + pNew->nDBNumFmt = getDefaultNumberFormat(xCol, xDocNumberFormatTypes, LanguageTag( rSh.GetCurLang() ).getLocale()); } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 3f15fd3f89e5..34de5d205ab6 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -48,7 +48,6 @@ #include <sfx2/filedlghelper.hxx> #include <sfx2/viewfrm.hxx> #include <dbconfig.hxx> -#include <swdbtoolsclient.hxx> #include <pagedesc.hxx> #include <vcl/lstbox.hxx> #include <unotools/tempfile.hxx> @@ -110,6 +109,8 @@ #include <com/sun/star/util/XNumberFormatTypes.hpp> #include <editeng/langitem.hxx> #include <svl/numuno.hxx> +#include <connectivity/dbtools.hxx> +#include <connectivity/dbconversion.hxx> #include <unomailmerge.hxx> #include <sfx2/event.hxx> @@ -144,6 +145,7 @@ using namespace ::osl; using namespace ::svx; +using namespace ::dbtools; using namespace ::com::sun::star; using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; @@ -1692,7 +1694,7 @@ sal_uLong SwDBManager::GetColumnFmt( uno::Reference< XDataSource> xSource, OSL_FAIL("no FormatKey property found"); } if(bUseDefault) - nRet = SwDBManager::GetDbtoolsClient().getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale); + nRet = getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale); } return nRet; } @@ -1749,7 +1751,7 @@ uno::Reference< sdbc::XConnection> SwDBManager::GetConnection(const OUString& rD Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); try { - Reference<XCompletedConnection> xComplConnection(SwDBManager::GetDbtoolsClient().getDataSource(rDataSource, xContext),UNO_QUERY); + Reference<XCompletedConnection> xComplConnection(getDataSource(rDataSource, xContext),UNO_QUERY); if ( xComplConnection.is() ) { rxSource.set(xComplConnection,UNO_QUERY); @@ -1857,8 +1859,7 @@ OUString SwDBManager::GetDBField(uno::Reference<XPropertySet> xColumnProps, try { - SwDbtoolsClient& aClient = SwDBManager::GetDbtoolsClient(); - sRet = aClient.getFormattedValue( + sRet = DBTypeConversion::getFormattedValue( xColumnProps, rDBFormatData.xFormatter, rDBFormatData.aLocale, @@ -2835,7 +2836,7 @@ void SwDBManager::InsertText(SwWrtShell& rSh, if(xChild.is()) xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY); if(!xSource.is()) - xSource = SwDBManager::GetDbtoolsClient().getDataSource(sDataSource, xContext); + xSource = getDataSource(sDataSource, xContext); uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY ); SwDBData aDBData; aDBData.sDataSource = sDataSource; @@ -2866,21 +2867,6 @@ void SwDBManager::InsertText(SwWrtShell& rSh, } } -SwDbtoolsClient* SwDBManager::pDbtoolsClient = NULL; - -SwDbtoolsClient& SwDBManager::GetDbtoolsClient() -{ - if ( !pDbtoolsClient ) - pDbtoolsClient = new SwDbtoolsClient; - return *pDbtoolsClient; -} - -void SwDBManager::RemoveDbtoolsClient() -{ - delete pDbtoolsClient; - pDbtoolsClient = 0; -} - uno::Reference<XDataSource> SwDBManager::getDataSourceAsParent(const uno::Reference< XConnection>& _xConnection,const OUString& _sDataSourceName) { uno::Reference<XDataSource> xSource; @@ -2890,7 +2876,7 @@ uno::Reference<XDataSource> SwDBManager::getDataSourceAsParent(const uno::Refere if ( xChild.is() ) xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY); if ( !xSource.is() ) - xSource = SwDBManager::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessComponentContext()); + xSource = getDataSource(_sDataSourceName, ::comphelper::getProcessComponentContext()); } catch(const Exception&) { diff --git a/sw/source/uibase/dbui/swdbtoolsclient.cxx b/sw/source/uibase/dbui/swdbtoolsclient.cxx deleted file mode 100644 index a7bc6d911f83..000000000000 --- a/sw/source/uibase/dbui/swdbtoolsclient.cxx +++ /dev/null @@ -1,232 +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 <com/sun/star/sdbc/XConnection.hpp> -#include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#include <com/sun/star/sdbc/XDataSource.hpp> -#include <com/sun/star/sdb/SQLContext.hpp> -#include <swdbtoolsclient.hxx> -#include <osl/diagnose.h> -#include <tools/solar.h> - -using namespace ::connectivity::simple; -using namespace ::com::sun::star; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdb; - -//= SwDbtoolsClient - -namespace -{ - - // this namespace contains access to all static members of the class SwDbtoolsClient - // to make the initialize of the dll a little bit faster - - ::osl::Mutex& getDbtoolsClientMutex() - { - static ::osl::Mutex aMutex; - return aMutex; - } - - sal_Int32& getDbToolsClientClients() - { - static sal_Int32 nClients = 0; - return nClients; - } - - oslModule& getDbToolsClientModule() - { - static oslModule hDbtoolsModule = NULL; - return hDbtoolsModule; - } - - createDataAccessToolsFactoryFunction& getDbToolsClientFactoryFunction() - { - static createDataAccessToolsFactoryFunction pFactoryCreationFunc = NULL; - return pFactoryCreationFunc; - } - -} - -SwDbtoolsClient::SwDbtoolsClient() -{ -} - -SwDbtoolsClient::~SwDbtoolsClient() -{ - if(m_xDataAccessFactory.is()) - { - // clear the factory _before_ revoking the client - // (the revocation may unload the DBT lib) - m_xDataAccessFactory = NULL; - // revoke the client - revokeClient(); - } -} - -#if HAVE_FEATURE_DESKTOP -#ifndef DISABLE_DYNLOADING -extern "C" { static void SAL_CALL thisModule() {} } -#else -extern "C" void * createDataAccessToolsFactory(); -#endif -#endif - -void SwDbtoolsClient::registerClient() -{ - ::osl::MutexGuard aGuard(getDbtoolsClientMutex()); - if (1 == ++getDbToolsClientClients()) - { - OSL_ENSURE(NULL == getDbToolsClientModule(), "SwDbtoolsClient::registerClient: inconsistence: already have a module!"); - OSL_ENSURE(NULL == getDbToolsClientFactoryFunction(), "SwDbtoolsClient::registerClient: inconsistence: already have a factory function!"); - -#if HAVE_FEATURE_DESKTOP -#ifndef DISABLE_DYNLOADING - const OUString sModuleName(DBTOOLS_DLL_NAME); - - // load the dbtools library - getDbToolsClientModule() = osl_loadModuleRelative( - &thisModule, sModuleName.pData, 0); - OSL_ENSURE(NULL != getDbToolsClientModule(), "SwDbtoolsClient::registerClient: could not load the dbtools library!"); - if (NULL != getDbToolsClientModule()) - { - // get the symbol for the method creating the factory - const OUString sFactoryCreationFunc("createDataAccessToolsFactory"); - // reinterpret_cast<createDataAccessToolsFactoryFunction> removed for gcc permissive - getDbToolsClientFactoryFunction() = reinterpret_cast< createDataAccessToolsFactoryFunction >( - osl_getFunctionSymbol(getDbToolsClientModule(), sFactoryCreationFunc.pData)); - - if (NULL == getDbToolsClientFactoryFunction()) - { // did not find the symbol - OSL_FAIL("SwDbtoolsClient::registerClient: could not find the symbol for creating the factory!"); - osl_unloadModule(getDbToolsClientModule()); - getDbToolsClientModule() = NULL; - } - } -#else - getDbToolsClientFactoryFunction() = createDataAccessToolsFactory; -#endif -#endif - } -} - -void SwDbtoolsClient::revokeClient() -{ - ::osl::MutexGuard aGuard(getDbtoolsClientMutex()); - if (0 == --getDbToolsClientClients()) - { -#ifndef DISABLE_DYNLOADING - getDbToolsClientFactoryFunction() = NULL; - if (getDbToolsClientModule()) - osl_unloadModule(getDbToolsClientModule()); -#endif - getDbToolsClientModule() = NULL; - } -} - -void SwDbtoolsClient::getFactory() -{ - if(!m_xDataAccessFactory.is()) - { - registerClient(); - if(getDbToolsClientFactoryFunction()) - { // loading the lib succeeded - void* pUntypedFactory = (*getDbToolsClientFactoryFunction())(); - IDataAccessToolsFactory* pDBTFactory = static_cast<IDataAccessToolsFactory*>(pUntypedFactory); - OSL_ENSURE(pDBTFactory, "SwDbtoolsClient::SwDbtoolsClient: no factory returned!"); - if (pDBTFactory) - { - m_xDataAccessFactory = pDBTFactory; - // by definition, the factory was acquired once - m_xDataAccessFactory->release(); - } - } - } -} - -::rtl::Reference< ::connectivity::simple::IDataAccessTools > - SwDbtoolsClient::getDataAccessTools() -{ - if(!m_xDataAccessTools.is()) - { - getFactory(); - if(m_xDataAccessFactory.is()) - m_xDataAccessTools = m_xDataAccessFactory->getDataAccessTools(); - } - return m_xDataAccessTools; -} - -::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion > - SwDbtoolsClient::getAccessTypeConversion() -{ - if(!m_xAccessTypeConversion.is()) - { - getFactory(); - if(m_xDataAccessFactory.is()) - m_xAccessTypeConversion = m_xDataAccessFactory->getTypeConversionHelper(); - } - return m_xAccessTypeConversion; -} - -Reference< XDataSource > SwDbtoolsClient::getDataSource( - const OUString& rRegisteredName, - const Reference<XComponentContext>& rxContext - ) -{ - Reference< XDataSource > xRet; - ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools(); - if(xAccess.is()) - xRet = xAccess->getDataSource(rRegisteredName, rxContext); - return xRet; -} - -sal_Int32 SwDbtoolsClient::getDefaultNumberFormat( - const Reference< XPropertySet >& rxColumn, - const Reference< XNumberFormatTypes >& rxTypes, - const lang::Locale& rLocale - ) -{ - sal_Int32 nRet = -1; - ::rtl::Reference< ::connectivity::simple::IDataAccessTools > xAccess = getDataAccessTools(); - if(xAccess.is()) - nRet = xAccess->getDefaultNumberFormat( rxColumn, rxTypes, rLocale); - return nRet; -} - -OUString SwDbtoolsClient::getFormattedValue( - const uno::Reference< beans::XPropertySet>& _rxColumn, - const uno::Reference< util::XNumberFormatter>& _rxFormatter, - const lang::Locale& _rLocale, - const util::Date& _rNullDate - ) - -{ - ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion > xConversion = - getAccessTypeConversion(); - OUString sRet; - if(xConversion.is()) - sRet = xConversion->getFormattedValue(_rxColumn, _rxFormatter, _rLocale, _rNullDate); - return sRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx index 9a8833da456c..94d7a8d76263 100644 --- a/sw/source/uibase/utlui/initui.cxx +++ b/sw/source/uibase/utlui/initui.cxx @@ -148,9 +148,6 @@ std::vector<OUString>* pAuthFieldTypeList = 0; void _FinitUI() { -#if HAVE_FEATURE_DBCONNECTIVITY - SwDBManager::RemoveDbtoolsClient(); -#endif delete SwViewShell::GetShellRes(); SwViewShell::SetShellRes( 0 ); |