summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connectivity/Library_dbtools.mk1
-rw-r--r--connectivity/inc/simpledbt/charset_s.hxx (renamed from connectivity/source/simpledbt/charset_s.hxx)0
-rw-r--r--connectivity/inc/simpledbt/parser_s.hxx (renamed from connectivity/source/simpledbt/parser_s.hxx)0
-rw-r--r--connectivity/source/commontools/dbtools.cxx15
-rw-r--r--connectivity/source/simpledbt/charset_s.cxx2
-rw-r--r--connectivity/source/simpledbt/dbtfactory.cxx4
-rw-r--r--connectivity/source/simpledbt/parser_s.cxx2
-rw-r--r--include/connectivity/dbtools.hxx17
-rw-r--r--include/svx/dbcharsethelper.hxx13
-rw-r--r--include/svx/dbtoolsclient.hxx164
-rw-r--r--sc/source/ui/docshell/docsh8.cxx1
-rw-r--r--svx/Library_svx.mk2
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/source/fmcomp/fmgridcl.cxx7
-rw-r--r--svx/source/fmcomp/gridcell.cxx5
-rw-r--r--svx/source/fmcomp/gridctrl.cxx1
-rw-r--r--svx/source/form/dbcharsethelper.cxx13
-rw-r--r--svx/source/form/dbtoolsclient.cxx310
-rw-r--r--svx/source/form/filtnav.cxx7
-rw-r--r--svx/source/form/fmdocumentclassification.cxx1
-rw-r--r--svx/source/form/fmpgeimp.cxx5
-rw-r--r--svx/source/form/fmshimp.cxx11
-rw-r--r--svx/source/form/fmtools.cxx2
-rw-r--r--svx/source/form/fmundo.cxx10
-rw-r--r--svx/source/form/fmvwimp.cxx13
-rw-r--r--svx/source/form/formcontrolfactory.cxx7
-rw-r--r--svx/source/form/formcontroller.cxx26
-rw-r--r--svx/source/form/sqlparserclient.cxx14
-rw-r--r--svx/source/form/tabwin.cxx5
-rw-r--r--svx/source/inc/fmshimp.hxx2
-rw-r--r--svx/source/inc/sqlparserclient.hxx15
-rw-r--r--svx/source/inc/tabwin.hxx7
-rw-r--r--sw/CppunitTest_sw_uwriter.mk2
-rw-r--r--sw/Library_sw.mk3
-rw-r--r--sw/Library_swui.mk2
-rw-r--r--sw/inc/dbmgr.hxx7
-rw-r--r--sw/inc/swdbtoolsclient.hxx69
-rw-r--r--sw/source/ui/dbui/dbinsdlg.cxx5
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx30
-rw-r--r--sw/source/uibase/dbui/swdbtoolsclient.cxx232
-rw-r--r--sw/source/uibase/utlui/initui.cxx3
41 files changed, 126 insertions, 910 deletions
diff --git a/connectivity/Library_dbtools.mk b/connectivity/Library_dbtools.mk
index 7170dc008e49..d0fc36c842e0 100644
--- a/connectivity/Library_dbtools.mk
+++ b/connectivity/Library_dbtools.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_Library_set_componentfile,dbtools,connectivity/source/dbtools/d
$(eval $(call gb_Library_set_include,dbtools,\
$$(INCLUDE) \
+ -I$(SRCDIR)/connectivity/inc \
-I$(SRCDIR)/connectivity/source/inc \
))
diff --git a/connectivity/source/simpledbt/charset_s.hxx b/connectivity/inc/simpledbt/charset_s.hxx
index 25aa2bfc7630..25aa2bfc7630 100644
--- a/connectivity/source/simpledbt/charset_s.hxx
+++ b/connectivity/inc/simpledbt/charset_s.hxx
diff --git a/connectivity/source/simpledbt/parser_s.hxx b/connectivity/inc/simpledbt/parser_s.hxx
index 359ab25c6366..359ab25c6366 100644
--- a/connectivity/source/simpledbt/parser_s.hxx
+++ b/connectivity/inc/simpledbt/parser_s.hxx
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 4f5e3950a573..557e4286a1a7 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -82,6 +82,9 @@
#include "resource/sharedresources.hxx"
#include <connectivity/OSubComponent.hxx>
+#include "simpledbt/parser_s.hxx"
+#include "simpledbt/charset_s.hxx"
+
#include <algorithm>
#include <iterator>
#include <set>
@@ -1973,6 +1976,18 @@ void getBooleanComparisonPredicate( const OUString& _rExpression, const bool _bV
}
}
+simple::ISQLParser* createSQLParser(
+ const Reference< XComponentContext >& rxContext,
+ const IParseContext* _pContext )
+{
+ return new OSimpleSQLParser(rxContext, _pContext);
+}
+
+simple::IDataAccessCharSet* createCharsetHelper( )
+{
+ return new ODataAccessCharSet;
+}
+
} // namespace dbtools
namespace connectivity
diff --git a/connectivity/source/simpledbt/charset_s.cxx b/connectivity/source/simpledbt/charset_s.cxx
index 2843b674e6f9..261a46a59c8f 100644
--- a/connectivity/source/simpledbt/charset_s.cxx
+++ b/connectivity/source/simpledbt/charset_s.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "charset_s.hxx"
+#include "simpledbt/charset_s.hxx"
namespace connectivity
diff --git a/connectivity/source/simpledbt/dbtfactory.cxx b/connectivity/source/simpledbt/dbtfactory.cxx
index cead9fab7fe8..85fca69453e7 100644
--- a/connectivity/source/simpledbt/dbtfactory.cxx
+++ b/connectivity/source/simpledbt/dbtfactory.cxx
@@ -20,10 +20,10 @@
#include <connectivity/virtualdbtools.hxx>
#include <connectivity/formattedcolumnvalue.hxx>
+#include "simpledbt/parser_s.hxx"
+#include "simpledbt/charset_s.hxx"
#include "dbtfactory.hxx"
-#include "parser_s.hxx"
#include "staticdbtools_s.hxx"
-#include "charset_s.hxx"
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
diff --git a/connectivity/source/simpledbt/parser_s.cxx b/connectivity/source/simpledbt/parser_s.cxx
index eddae295e7cb..e9194af045bf 100644
--- a/connectivity/source/simpledbt/parser_s.cxx
+++ b/connectivity/source/simpledbt/parser_s.cxx
@@ -18,7 +18,7 @@
*/
#include <connectivity/virtualdbtools.hxx>
-#include "parser_s.hxx"
+#include "simpledbt/parser_s.hxx"
#include "parsenode_s.hxx"
using namespace ::com::sun::star::uno;
diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx
index 73e20b2006ab..26bdeb708b42 100644
--- a/include/connectivity/dbtools.hxx
+++ b/include/connectivity/dbtools.hxx
@@ -74,6 +74,16 @@ namespace task {
} } }
+namespace connectivity
+{
+ class IParseContext;
+ namespace simple
+ {
+ class ISQLParser;
+ class IDataAccessCharSet;
+ }
+}
+
namespace dbtools
{
@@ -786,6 +796,13 @@ namespace dbtools
OUStringBuffer& _out_rSQLPredicate
);
+ OOO_DLLPUBLIC_DBTOOLS ::connectivity::simple::ISQLParser* createSQLParser(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::connectivity::IParseContext* _pContext
+ );
+
+ OOO_DLLPUBLIC_DBTOOLS ::connectivity::simple::IDataAccessCharSet* createCharsetHelper( );
+
} // namespace dbtools
diff --git a/include/svx/dbcharsethelper.hxx b/include/svx/dbcharsethelper.hxx
index bb31411538fd..367698857d8a 100644
--- a/include/svx/dbcharsethelper.hxx
+++ b/include/svx/dbcharsethelper.hxx
@@ -19,9 +19,9 @@
#ifndef INCLUDED_SVX_DBCHARSETHELPER_HXX
#define INCLUDED_SVX_DBCHARSETHELPER_HXX
-#include <svx/svxdllapi.h>
-#include <svx/dbtoolsclient.hxx>
+#include <svx/svxdllapi.h>
+#include <connectivity/virtualdbtools.hxx>
namespace svxform
{
@@ -30,22 +30,17 @@ namespace svxform
//= ODataAccessCharsetHelper
- class SVX_DLLPUBLIC ODataAccessCharsetHelper : public ODbtoolsClient
+ class SVX_DLLPUBLIC ODataAccessCharsetHelper
{
protected:
mutable ::rtl::Reference< ::connectivity::simple::IDataAccessCharSet > m_xCharsetHelper;
- protected:
- virtual bool ensureLoaded() const SAL_OVERRIDE;
-
public:
ODataAccessCharsetHelper( );
inline sal_Int32 getSupportedTextEncodings( ::std::vector< rtl_TextEncoding >& _rEncs ) const
{
- if ( ensureLoaded() )
- return m_xCharsetHelper->getSupportedTextEncodings( _rEncs );
- return 0;
+ return m_xCharsetHelper->getSupportedTextEncodings( _rEncs );
}
};
diff --git a/include/svx/dbtoolsclient.hxx b/include/svx/dbtoolsclient.hxx
deleted file mode 100644
index 5905ecd30680..000000000000
--- a/include/svx/dbtoolsclient.hxx
+++ /dev/null
@@ -1,164 +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_SVX_DBTOOLSCLIENT_HXX
-#define INCLUDED_SVX_DBTOOLSCLIENT_HXX
-
-#include <connectivity/virtualdbtools.hxx>
-#include <osl/mutex.hxx>
-#include <osl/module.h>
-#include <svx/svxdllapi.h>
-#include <tools/solar.h>
-#include <unotools/sharedunocomponent.hxx>
-
-namespace svxform
-{
- typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection;
-
- /** base class for classes which want to use dbtools features with load-on-call
- of the dbtools lib.
- */
- class SVX_DLLPUBLIC ODbtoolsClient
- {
- private:
- static sal_Int32 s_nClients;
- static oslModule s_hDbtoolsModule;
- static ::connectivity::simple::createDataAccessToolsFactoryFunction
- s_pFactoryCreationFunc;
-
- mutable bool m_bCreateAlready;
-
- private:
- mutable ::rtl::Reference< ::connectivity::simple::IDataAccessToolsFactory > m_xDataAccessFactory;
-
- protected:
- ODbtoolsClient();
- virtual ~ODbtoolsClient();
-
- virtual bool ensureLoaded() const;
-
- protected:
- const ::rtl::Reference< ::connectivity::simple::IDataAccessToolsFactory >&
- getFactory() const { return m_xDataAccessFactory; }
-
- private:
- static void registerClient();
- static void revokeClient();
- };
-
- class SVX_DLLPUBLIC OStaticDataAccessTools : public ODbtoolsClient
- {
- protected:
- mutable ::rtl::Reference< ::connectivity::simple::IDataAccessTools > m_xDataAccessTools;
-
- protected:
- virtual bool ensureLoaded() const SAL_OVERRIDE;
-
- public:
- OStaticDataAccessTools();
-
- const ::rtl::Reference< ::connectivity::simple::IDataAccessTools >& getDataAccessTools() const { return m_xDataAccessTools; }
-
- ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
- bool _bAllowDefault
- ) const;
-
- sal_Int32 getDefaultNumberFormat(
- const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xColumn,
- const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _xTypes,
- const ::com::sun::star::lang::Locale& _rLocale );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
- const OUString& _rDataSourceName,
- const OUString& _rUser,
- const OUString& _rPwd,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
- ) const;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext,
- bool _bSetAsActiveConnection
- ) const;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
- const;
-
- void TransferFormComponentProperties(
- const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
- const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
- const ::com::sun::star::lang::Locale& _rLocale
- ) const;
-
- ::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
- ) const;
-
- /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
- @param _rxCursorSet the property set
- */
- bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
-
- /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
- @param _rxCursorSet the property set
- */
- bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
- getFieldsByCommandDescriptor(
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
- const sal_Int32 _nCommandType,
- const OUString& _rCommand,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
- ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
- );
-
- bool isEmbeddedInDatabase(
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
- );
-
- bool isEmbeddedInDatabase(
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent
- );
- };
-
- class SVX_DLLPUBLIC DBToolsObjectFactory : public ODbtoolsClient
- {
- public:
- DBToolsObjectFactory();
- virtual ~DBToolsObjectFactory();
-
- ::std::unique_ptr< ::dbtools::FormattedColumnValue > createFormattedColumnValue(
- const css::uno::Reference<css::uno::XComponentContext>& _rContext,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
- );
- };
-
-} // namespace svxform
-
-
-#endif // INCLUDED_SVX_DBTOOLSCLIENT_HXX
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 9a9aeff443f1..193f50498d6f 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -27,6 +27,7 @@
#include <comphelper/types.hxx>
#include <ucbhelper/content.hxx>
#include <svx/txenctab.hxx>
+#include <unotools/sharedunocomponent.hxx>
#if HAVE_FEATURE_DBCONNECTIVITY
#include <svx/dbcharsethelper.hxx>
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index f1c0c2ba54fe..db5ab90c463e 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -46,6 +46,8 @@ $(eval $(call gb_Library_use_libraries,svx,\
comphelper \
cppuhelper \
cppu \
+ $(call gb_Helper_optional,DBCONNECTIVITY, \
+ dbtools) \
drawinglayer \
editeng \
fwe \
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 1586bd5d9cb7..1c619c6e3ca3 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -418,7 +418,6 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/form/dataaccessdescriptor \
svx/source/form/datalistener \
svx/source/form/datanavi \
- svx/source/form/dbtoolsclient \
svx/source/form/delayedevent \
svx/source/form/fmcontrolbordermanager \
svx/source/form/fmcontrollayout \
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index f905336585ac..a7af35a61b03 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -86,6 +86,7 @@ using namespace ::com::sun::star::container;
using namespace ::cppu;
using namespace ::svxform;
using namespace ::svx;
+using namespace ::dbtools;
OUString FieldServiceFromId(sal_Int32 nID)
{
@@ -274,7 +275,7 @@ sal_Int8 FmGridHeader::ExecuteDrop( const ExecuteDropEvent& _rEvt )
try
{
OUString sSignificantSource( sDatasource.isEmpty() ? sDatabaseLocation : sDatasource );
- xConnection = OStaticDataAccessTools().getConnection_withFeedback(sSignificantSource, OUString(), OUString(),
+ xConnection = getConnection_withFeedback(sSignificantSource, OUString(), OUString(),
static_cast<FmGridControl*>(GetParent())->getContext() );
}
catch(NoSuchElementException&)
@@ -386,7 +387,7 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
try
{
// need number formats
- Reference< XNumberFormatsSupplier > xSupplier = OStaticDataAccessTools().getNumberFormats(xConnection, true);
+ Reference< XNumberFormatsSupplier > xSupplier = getNumberFormats(xConnection, true);
Reference< XNumberFormats > xNumberFormats;
if (xSupplier.is())
xNumberFormats = xSupplier->getNumberFormats();
@@ -912,7 +913,7 @@ void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMe
// ein paar Properties hinueberretten
Reference< XPropertySet > xReplaced( xCols->getByIndex( nPos ), UNO_QUERY );
- OStaticDataAccessTools().TransferFormComponentProperties(
+ TransferFormComponentProperties(
xReplaced, xNewCol, Application::GetSettings().GetUILanguageTag().getLocale() );
xCols->replaceByIndex( nPos, makeAny( xNewCol ) );
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 7e194f6bc5ca..b5bda2378e40 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -1803,9 +1803,8 @@ OUString DbPatternField::GetFormatText(const Reference< ::com::sun::star::sdb::X
if ( !rpFormatter.get() )
{
- DBToolsObjectFactory aFactory;
- rpFormatter = aFactory.createFormattedColumnValue(
- m_xContext, getCursor(), Reference< XPropertySet >( _rxField, UNO_QUERY ) );
+ rpFormatter = ::std::unique_ptr< FormattedColumnValue> (
+ new FormattedColumnValue(m_xContext, getCursor(), Reference< XPropertySet >( _rxField, UNO_QUERY ) ) );
OSL_ENSURE( rpFormatter.get(), "DbPatternField::Init: no value formatter!" );
}
else
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 84a3bde94af9..0960111ef01a 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -21,7 +21,6 @@
#include "fmhelp.hrc"
#include <svx/gridctrl.hxx>
#include "gridcell.hxx"
-#include "svx/dbtoolsclient.hxx"
#include "svx/fmtools.hxx"
#include <svtools/stringtransfer.hxx>
#include <connectivity/dbtools.hxx>
diff --git a/svx/source/form/dbcharsethelper.cxx b/svx/source/form/dbcharsethelper.cxx
index f401592e9644..326f955e3003 100644
--- a/svx/source/form/dbcharsethelper.cxx
+++ b/svx/source/form/dbcharsethelper.cxx
@@ -19,21 +19,16 @@
#include "svx/dbcharsethelper.hxx"
+#include <connectivity/dbtools.hxx>
+
+using namespace ::dbtools;
namespace svxform
{
ODataAccessCharsetHelper::ODataAccessCharsetHelper( )
{
- }
-
-
- bool ODataAccessCharsetHelper::ensureLoaded() const
- {
- if ( !ODbtoolsClient::ensureLoaded() )
- return false;
- m_xCharsetHelper = getFactory()->createCharsetHelper( );
- return m_xCharsetHelper.is();
+ m_xCharsetHelper = createCharsetHelper();
}
diff --git a/svx/source/form/dbtoolsclient.cxx b/svx/source/form/dbtoolsclient.cxx
deleted file mode 100644
index 7306e62b4330..000000000000
--- a/svx/source/form/dbtoolsclient.cxx
+++ /dev/null
@@ -1,310 +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/sdbc/XDataSource.hpp>
-#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
-#include <com/sun/star/sdb/SQLContext.hpp>
-#include "svx/dbtoolsclient.hxx"
-#include <osl/diagnose.h>
-#include <rtl/instance.hxx>
-#include <connectivity/formattedcolumnvalue.hxx>
-
-
-namespace svxform
-{
-
-
- using namespace ::connectivity::simple;
- 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;
- using namespace ::com::sun::star::container;
-
-
- //= ODbtoolsClient
-
-
- namespace
- {
- struct theODbtoolsClientMutex : public rtl::Static< osl::Mutex, theODbtoolsClientMutex> {};
- }
-
- sal_Int32 ODbtoolsClient::s_nClients = 0;
- oslModule ODbtoolsClient::s_hDbtoolsModule = NULL;
- createDataAccessToolsFactoryFunction
- ODbtoolsClient::s_pFactoryCreationFunc = NULL;
-
-
- ODbtoolsClient::ODbtoolsClient()
- {
- m_bCreateAlready = false;
- }
-
-
- bool ODbtoolsClient::ensureLoaded() const
- {
- if ( !m_bCreateAlready )
- {
- m_bCreateAlready = true;
-
- registerClient();
- if ( s_pFactoryCreationFunc )
- { // loading the lib succeeded
- void* pUntypedFactory = (*s_pFactoryCreationFunc)();
- IDataAccessToolsFactory* pDBTFactory = static_cast< IDataAccessToolsFactory* >( pUntypedFactory );
- OSL_ENSURE( pDBTFactory, "ODbtoolsClient::ODbtoolsClient: no factory returned!" );
- if ( pDBTFactory )
- {
- m_xDataAccessFactory = pDBTFactory;
- // by definition, the factory was acquired once
- m_xDataAccessFactory->release();
- }
- }
- }
- return m_xDataAccessFactory.is();
- }
-
-
- ODbtoolsClient::~ODbtoolsClient()
- {
- // clear the factory _before_ revoking the client
- // (the revocation may unload the DBT lib)
- m_xDataAccessFactory = NULL;
- // revoke the client
- if ( m_bCreateAlready )
- revokeClient();
- }
-
-#if HAVE_FEATURE_DESKTOP
-#ifndef DISABLE_DYNLOADING
- extern "C" { static void SAL_CALL thisModule() {} }
-#else
- extern "C" void * createDataAccessToolsFactory();
-#endif
-#endif
-
- void ODbtoolsClient::registerClient()
- {
- ::osl::MutexGuard aGuard(theODbtoolsClientMutex::get());
- if (1 == ++s_nClients)
- {
- OSL_ENSURE(NULL == s_hDbtoolsModule, "ODbtoolsClient::registerClient: inconsistence: already have a module!");
- OSL_ENSURE(NULL == s_pFactoryCreationFunc, "ODbtoolsClient::registerClient: inconsistence: already have a factory function!");
-
-#if HAVE_FEATURE_DESKTOP
-#ifndef DISABLE_DYNLOADING
-
- // load the dbtools library
- s_hDbtoolsModule = osl_loadModuleRelative(
- &thisModule, OUString(DBTOOLS_DLL_NAME).pData, 0);
- OSL_ENSURE(NULL != s_hDbtoolsModule, "ODbtoolsClient::registerClient: could not load the dbtools library!");
- if (NULL != s_hDbtoolsModule)
- {
- // get the symbol for the method creating the factory
- const OUString sFactoryCreationFunc( "createDataAccessToolsFactory" );
- // reinterpret_cast<createDataAccessToolsFactoryFunction>
- s_pFactoryCreationFunc = reinterpret_cast<createDataAccessToolsFactoryFunction>(
- osl_getFunctionSymbol(s_hDbtoolsModule, sFactoryCreationFunc.pData));
-
- if (NULL == s_pFactoryCreationFunc)
- { // did not find the symbol
- OSL_FAIL("ODbtoolsClient::registerClient: could not find the symbol for creating the factory!");
- osl_unloadModule(s_hDbtoolsModule);
- s_hDbtoolsModule = NULL;
- }
- }
-#else
- s_pFactoryCreationFunc = createDataAccessToolsFactory;
-#endif
-#endif
- }
- }
-
-
- void ODbtoolsClient::revokeClient()
- {
- ::osl::MutexGuard aGuard(theODbtoolsClientMutex::get());
- if (0 == --s_nClients)
- {
-#ifndef DISABLE_DYNLOADING
- s_pFactoryCreationFunc = NULL;
- if (s_hDbtoolsModule)
- osl_unloadModule(s_hDbtoolsModule);
-#endif
- s_hDbtoolsModule = NULL;
- }
-
- OSL_ENSURE(s_nClients >= 0,"Illegall call of revokeClient()");
- }
-
- OStaticDataAccessTools::OStaticDataAccessTools()
- {
- }
-
-
-
- bool OStaticDataAccessTools::ensureLoaded() const
- {
- if ( !ODbtoolsClient::ensureLoaded() )
- return false;
- m_xDataAccessTools = getFactory()->getDataAccessTools();
- return m_xDataAccessTools.is();
- }
-
-
- Reference< XNumberFormatsSupplier > OStaticDataAccessTools::getNumberFormats(const Reference< XConnection>& _rxConn, bool _bAllowDefault) const
- {
- Reference< XNumberFormatsSupplier > xReturn;
- if ( ensureLoaded() )
- xReturn = m_xDataAccessTools->getNumberFormats(_rxConn, _bAllowDefault);
- return xReturn;
- }
-
-
- sal_Int32 OStaticDataAccessTools::getDefaultNumberFormat( const Reference< XPropertySet >& _xColumn, const Reference< XNumberFormatTypes >& _xTypes, const css::lang::Locale& _rLocale )
- {
- sal_Int32 nReturn = 0;
- if ( ensureLoaded() )
- nReturn = m_xDataAccessTools->getDefaultNumberFormat( _xColumn, _xTypes, _rLocale );
- return nReturn;
- }
-
-
- Reference< XConnection> OStaticDataAccessTools::getConnection_withFeedback(const OUString& _rDataSourceName,
- const OUString& _rUser, const OUString& _rPwd, const Reference<XComponentContext>& _rxContext) const
- {
- Reference< XConnection > xReturn;
- if ( ensureLoaded() )
- xReturn = m_xDataAccessTools->getConnection_withFeedback(_rDataSourceName, _rUser, _rPwd, _rxContext);
- return xReturn;
- }
-
-
- Reference< XConnection > OStaticDataAccessTools::connectRowset( const Reference< XRowSet >& _rxRowSet,
- const Reference< XComponentContext >& _rxContext, bool _bSetAsActiveConnection ) const
- {
- Reference< XConnection > xReturn;
- if ( ensureLoaded() )
- xReturn = m_xDataAccessTools->connectRowset( _rxRowSet, _rxContext, _bSetAsActiveConnection );
- return xReturn;
- }
-
-
- Reference< XConnection > OStaticDataAccessTools::getRowSetConnection(const Reference< XRowSet >& _rxRowSet) const
- {
- Reference< XConnection > xReturn;
- if ( ensureLoaded() )
- xReturn = m_xDataAccessTools->getRowSetConnection(_rxRowSet);
- return xReturn;
- }
-
- void OStaticDataAccessTools::TransferFormComponentProperties(const Reference< XPropertySet>& _rxOld,
- const Reference< XPropertySet>& _rxNew, const css::lang::Locale& _rLocale) const
- {
- if ( ensureLoaded() )
- m_xDataAccessTools->TransferFormComponentProperties(_rxOld, _rxNew, _rLocale);
- }
-
- Reference< XDataSource > OStaticDataAccessTools::getDataSource( const OUString& _rsRegisteredName, const Reference< XComponentContext>& _rxContext ) const
- {
- Reference< XDataSource > xReturn;
- if ( ensureLoaded() )
- xReturn = m_xDataAccessTools->getDataSource(_rsRegisteredName,_rxContext);
- return xReturn;
- }
-
- bool OStaticDataAccessTools::canInsert(const Reference< XPropertySet>& _rxCursorSet) const
- {
- bool bRet = false;
- if ( ensureLoaded() )
- bRet = m_xDataAccessTools->canInsert( _rxCursorSet );
- return bRet;
- }
-
- bool OStaticDataAccessTools::canUpdate(const Reference< XPropertySet>& _rxCursorSet) const
- {
- bool bRet = false;
- if ( ensureLoaded() )
- bRet = m_xDataAccessTools->canUpdate( _rxCursorSet );
- return bRet;
- }
-
-
- Reference< XNameAccess > OStaticDataAccessTools::getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
- const sal_Int32 _nCommandType, const OUString& _rCommand,
- Reference< XComponent >& _rxKeepFieldsAlive, ::dbtools::SQLExceptionInfo* _pErrorInfo )
- {
- Reference< XNameAccess > aFields;
- if ( ensureLoaded() )
- aFields = m_xDataAccessTools->getFieldsByCommandDescriptor( _rxConnection, _nCommandType,
- _rCommand, _rxKeepFieldsAlive, _pErrorInfo );
-
- return aFields;
- }
-
-
- bool OStaticDataAccessTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
- {
- bool bReturn = false;
- if ( ensureLoaded() )
- bReturn = m_xDataAccessTools->isEmbeddedInDatabase( _rxComponent, _rxActualConnection );
- return bReturn;
- }
-
-
- bool OStaticDataAccessTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent )
- {
- bool bReturn = false;
- if ( ensureLoaded() )
- {
- Reference< XConnection > xDummy;
- bReturn = m_xDataAccessTools->isEmbeddedInDatabase( _rxComponent, xDummy );
- }
- return bReturn;
- }
-
- DBToolsObjectFactory::DBToolsObjectFactory()
- {
- }
-
-
- DBToolsObjectFactory::~DBToolsObjectFactory()
- {
- }
-
-
- ::std::unique_ptr< ::dbtools::FormattedColumnValue > DBToolsObjectFactory::createFormattedColumnValue(
- const Reference<XComponentContext>& _rContext, const Reference< XRowSet >& _rxRowSet, const Reference< XPropertySet >& _rxColumn )
- {
- ::std::unique_ptr< ::dbtools::FormattedColumnValue > pValue;
- if ( ensureLoaded() )
- pValue = getFactory()->createFormattedColumnValue( _rContext, _rxRowSet, _rxColumn );
- return pValue;
- }
-
-
-} // namespace svxform
-
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx
index 03132a72c56b..45a926f4bdb0 100644
--- a/svx/source/form/filtnav.cxx
+++ b/svx/source/form/filtnav.cxx
@@ -68,7 +68,7 @@
using namespace ::svxform;
using namespace ::connectivity::simple;
using namespace ::connectivity;
-
+using namespace ::dbtools;
namespace svxform
@@ -865,13 +865,12 @@ bool FmFilterModel::ValidateText(FmFilterItem* pItem, OUString& rText, OUString&
{
Reference< XFormController > xFormController( pFormItem->GetController() );
// obtain the connection of the form belonging to the controller
- OStaticDataAccessTools aStaticTools;
Reference< XRowSet > xRowSet( xFormController->getModel(), UNO_QUERY_THROW );
- Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( xRowSet ) );
+ Reference< XConnection > xConnection( getConnection( xRowSet ) );
// obtain a number formatter for this connection
// TODO: shouldn't this be cached?
- Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats( xConnection, true );
+ Reference< XNumberFormatsSupplier > xFormatSupplier = getNumberFormats( xConnection, true );
Reference< XNumberFormatter > xFormatter( NumberFormatter::create( comphelper::getProcessComponentContext() ), UNO_QUERY_THROW );
xFormatter->attachNumberFormatsSupplier( xFormatSupplier );
diff --git a/svx/source/form/fmdocumentclassification.cxx b/svx/source/form/fmdocumentclassification.cxx
index cc8440aeb50f..ade7433a9217 100644
--- a/svx/source/form/fmdocumentclassification.cxx
+++ b/svx/source/form/fmdocumentclassification.cxx
@@ -19,7 +19,6 @@
#include "fmdocumentclassification.hxx"
-#include "svx/dbtoolsclient.hxx"
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx
index 7c7edd7a3111..71c246ca35c4 100644
--- a/svx/source/form/fmpgeimp.cxx
+++ b/svx/source/form/fmpgeimp.cxx
@@ -28,7 +28,6 @@
#include "formcontrolfactory.hxx"
#include "svx/svditer.hxx"
#include "svx/fmresids.hrc"
-#include "svx/dbtoolsclient.hxx"
#include "treevisitor.hxx"
#include <com/sun/star/sdb/CommandType.hpp>
@@ -49,6 +48,7 @@
#include <comphelper/uno3.hxx>
#include <comphelper/types.hxx>
#include <unotools/streamwrap.hxx>
+#include <connectivity/dbtools.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -63,6 +63,7 @@ using ::com::sun::star::container::XMap;
using ::com::sun::star::container::EnumerableMap;
using ::com::sun::star::drawing::XControlShape;
using namespace ::svxform;
+using namespace ::dbtools;
FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage )
@@ -575,7 +576,7 @@ Reference< XForm > FmFormPageImpl::findFormForDataSource(
Reference< XConnection > xFormConnection;
xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ) >>= xFormConnection;
if ( !xFormConnection.is() )
- OStaticDataAccessTools().isEmbeddedInDatabase( xFormProps, xFormConnection );
+ isEmbeddedInDatabase( xFormProps, xFormConnection );
if (xFormConnection.is())
{
Reference< XChild > xConnAsChild(xFormConnection, UNO_QUERY);
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index 120bfb174e75..e03d9a076051 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -268,6 +268,7 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::script;
using namespace ::svxform;
using namespace ::svx;
+using namespace ::dbtools;
//= helper
@@ -1627,7 +1628,7 @@ bool FmXFormShell::GetY2KState(sal_uInt16& n)
Reference< XRowSet> xDB(xForm, UNO_QUERY);
DBG_ASSERT(xDB.is(), "FmXFormShell::GetY2KState : current form has no dbform-interface !");
- Reference< XNumberFormatsSupplier> xSupplier( getNumberFormats(OStaticDataAccessTools().getRowSetConnection(xDB), false));
+ Reference< XNumberFormatsSupplier> xSupplier( getNumberFormats(getConnection(xDB), false));
if (xSupplier.is())
{
Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
@@ -1658,7 +1659,7 @@ void FmXFormShell::SetY2KState(sal_uInt16 n)
Reference< XRowSet > xActiveRowSet( xActiveForm, UNO_QUERY );
if ( xActiveRowSet.is() )
{
- Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getRowSetConnection( xActiveRowSet ), false ) );
+ Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getConnection( xActiveRowSet ), false ) );
if (xSupplier.is())
{
Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
@@ -1698,7 +1699,7 @@ void FmXFormShell::SetY2KState(sal_uInt16 n)
Reference< XRowSet> xElementAsRowSet( xCurrentElement, UNO_QUERY );
if ( xElementAsRowSet.is() )
{
- Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getRowSetConnection( xElementAsRowSet ), false ) );
+ Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getConnection( xElementAsRowSet ), false ) );
if (!xSupplier.is())
continue;
@@ -2106,7 +2107,7 @@ void FmXFormShell::startListening()
return;
Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
- if (xDatabaseForm.is() && getRowSetConnection(xDatabaseForm).is())
+ if (xDatabaseForm.is() && getConnection(xDatabaseForm).is())
{
Reference< XPropertySet> xActiveFormSet(m_xActiveForm, UNO_QUERY);
if (xActiveFormSet.is())
@@ -3826,7 +3827,7 @@ namespace
try
{
Reference< XConnection > xConn;
- if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) )
+ if ( isEmbeddedInDatabase( _rxLoadable.get(), xConn ) )
return true;
// is there already a active connection
diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx
index 4b7bfadd3b4c..40217b7a71e4 100644
--- a/svx/source/form/fmtools.cxx
+++ b/svx/source/form/fmtools.cxx
@@ -21,7 +21,6 @@
#include "fmprop.hrc"
#include "fmservs.hxx"
#include "svx/fmtools.hxx"
-#include "svx/dbtoolsclient.hxx"
#include "svx/fmglob.hxx"
#include <com/sun/star/awt/LineEndFormat.hpp>
@@ -96,7 +95,6 @@ using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::form;
using namespace ::svxform;
-using namespace ::connectivity::simple;
namespace
diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx
index 131481633058..f692c5038652 100644
--- a/svx/source/form/fmundo.cxx
+++ b/svx/source/form/fmundo.cxx
@@ -24,7 +24,6 @@
#include <sal/macros.h>
#include "fmundo.hxx"
#include "fmpgeimp.hxx"
-#include "svx/dbtoolsclient.hxx"
#include "svx/svditer.hxx"
#include "fmobj.hxx"
#include "fmprop.hrc"
@@ -42,6 +41,7 @@
#include <com/sun/star/form/binding/XBindableValue.hpp>
#include <com/sun/star/form/binding/XListEntrySink.hpp>
#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
#include "svx/fmtools.hxx"
#include <svl/macitem.hxx>
@@ -54,6 +54,7 @@
#include <osl/mutex.hxx>
#include <comphelper/property.hxx>
#include <comphelper/uno3.hxx>
+#include <connectivity/dbtools.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt;
@@ -65,7 +66,9 @@ using namespace ::com::sun::star::form;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::reflection;
using namespace ::com::sun::star::form::binding;
+using namespace ::com::sun::star::sdbc;
using namespace ::svxform;
+using namespace ::dbtools;
#include <com/sun/star/script/XScriptListener.hpp>
@@ -945,11 +948,14 @@ void FmXUndoEnvironment::RemoveElement(const Reference< XInterface >& _rxElement
Reference< XForm > xForm( _rxElement, UNO_QUERY );
Reference< XPropertySet > xFormProperties( xForm, UNO_QUERY );
if ( xFormProperties.is() )
- if ( !::svxform::OStaticDataAccessTools().isEmbeddedInDatabase( _rxElement ) )
+ {
+ Reference< XConnection > xDummy;
+ if ( !isEmbeddedInDatabase( _rxElement, xDummy ) )
// (if there is a connection in the context of the component, setting
// a new connection would be vetoed, anyway)
// #i34196#
xFormProperties->setPropertyValue( FM_PROP_ACTIVE_CONNECTION, Any() );
+ }
}
Reference< XIndexContainer > xContainer( _rxElement, UNO_QUERY );
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index c90075277c2f..af8af5cf1436 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -84,12 +84,14 @@
#include <vcl/msgbox.hxx>
#include <vcl/stdtext.hxx>
#include <osl/mutex.hxx>
+#include <connectivity/dbtools.hxx>
#include <algorithm>
using namespace ::comphelper;
using namespace ::svx;
using namespace ::svxform;
+using namespace ::dbtools;
using namespace ::com::sun::star;
using ::com::sun::star::uno::Exception;
@@ -692,7 +694,7 @@ IMPL_LINK(FmXFormView, OnActivate, void*, /*EMPTYTAG*/)
// only database forms are to be activated
Reference< XRowSet > xForm(xController->getModel(), UNO_QUERY);
- if ( !xForm.is() || !OStaticDataAccessTools().getRowSetConnection( xForm ).is() )
+ if ( !xForm.is() || !getConnection( xForm ).is() )
continue;
Reference< XPropertySet > xFormSet( xForm, UNO_QUERY );
@@ -1152,11 +1154,11 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
// obtain the data source
if ( !xDataSource.is() )
- xDataSource = OStaticDataAccessTools().getDataSource( sDataSource, comphelper::getProcessComponentContext() );
+ xDataSource = getDataSource( sDataSource, comphelper::getProcessComponentContext() );
// and the connection, if necessary
if ( !xConnection.is() )
- xConnection.reset( OStaticDataAccessTools().getConnection_withFeedback(
+ xConnection.reset( getConnection_withFeedback(
sDataSource,
OUString(),
OUString(),
@@ -1184,7 +1186,6 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
return NULL;
}
- OStaticDataAccessTools aDBATools;
Reference< XComponent > xKeepFieldsAlive;
// go
try
@@ -1192,7 +1193,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
// determine the table/query field which we should create a control for
Reference< XPropertySet > xField;
- Reference< XNameAccess > xFields = aDBATools.getFieldsByCommandDescriptor(
+ Reference< XNameAccess > xFields = getFieldsByCommandDescriptor(
xConnection, nCommandType, sCommand, xKeepFieldsAlive );
if (xFields.is() && xFields->hasByName(sFieldName))
@@ -1200,7 +1201,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
if ( !xField.is() )
return NULL;
- Reference< XNumberFormatsSupplier > xSupplier( aDBATools.getNumberFormats( xConnection, false ), UNO_SET_THROW );
+ Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( xConnection, false ), UNO_SET_THROW );
Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW );
OUString sLabelPostfix;
diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx
index 17b7613ea000..5827999cfc39 100644
--- a/svx/source/form/formcontrolfactory.cxx
+++ b/svx/source/form/formcontrolfactory.cxx
@@ -18,7 +18,6 @@
*/
-#include "svx/dbtoolsclient.hxx"
#include "formcontrolfactory.hxx"
#include "fmcontrollayout.hxx"
#include "fmprop.hrc"
@@ -46,9 +45,11 @@
#include <unotools/syslocale.hxx>
#include <tools/gen.hxx>
#include <tools/diagnose_ex.h>
+#include <connectivity/dbtools.hxx>
#include <set>
+using namespace ::dbtools;
namespace svxform
{
@@ -212,7 +213,7 @@ namespace svxform
Reference< XPropertySet > xDsProperties;
if ( !sDataSourceName.isEmpty() )
- xDsProperties.set(OStaticDataAccessTools().getDataSource( sDataSourceName, _rContext ), css::uno::UNO_QUERY);
+ xDsProperties.set(getDataSource( sDataSourceName, _rContext ), css::uno::UNO_QUERY);
if ( xDsProperties.is() )
xDsProperties->getPropertyValue("Info") >>= aInfo;
}
@@ -573,7 +574,7 @@ namespace svxform
}
else
{
- nFormatKey = OStaticDataAccessTools().getDefaultNumberFormat(
+ nFormatKey = getDefaultNumberFormat(
_rxDatabaseField,
Reference< XNumberFormatTypes >( _rxNumberFormats, UNO_QUERY ),
SvtSysLocale().GetLanguageTag().getLocale()
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
index 94dd18139c27..3497bd05de1e 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -77,6 +77,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <connectivity/IParseContext.hxx>
+#include <connectivity/dbtools.hxx>
#include <toolkit/controls/unocontrol.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/debug.hxx>
@@ -94,6 +95,7 @@ using namespace ::com::sun::star;
using namespace ::comphelper;
using namespace ::connectivity;
using namespace ::connectivity::simple;
+using namespace ::dbtools;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
@@ -788,12 +790,11 @@ void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) cons
case FM_ATTR_FILTER:
{
OUStringBuffer aFilter;
- OStaticDataAccessTools aStaticTools;
- Reference<XConnection> xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY)));
+ Reference<XConnection> xConnection(getConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY)));
if (xConnection.is())
{
Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData());
- Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats( xConnection, true ) );
+ Reference< XNumberFormatsSupplier> xFormatSupplier( getNumberFormats( xConnection, true ) );
Reference< XNumberFormatter> xFormatter = NumberFormatter::create(m_xComponentContext);
xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
@@ -2557,8 +2558,7 @@ void FormController::loaded(const EventObject& rEvent) throw( RuntimeException,
::osl::MutexGuard aGuard( m_aMutex );
Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY);
// do we have a connected data source
- OStaticDataAccessTools aStaticTools;
- if (xForm.is() && aStaticTools.getRowSetConnection(xForm).is())
+ if (xForm.is() && getConnection(xForm).is())
{
Reference< XPropertySet > xSet(xForm, UNO_QUERY);
if (xSet.is())
@@ -2567,8 +2567,8 @@ void FormController::loaded(const EventObject& rEvent) throw( RuntimeException,
sal_Int32 aVal2 = 0;
::cppu::enum2int(aVal2,aVal);
m_bCycle = !aVal.hasValue() || aVal2 == TabulatorCycle_RECORDS;
- m_bCanUpdate = aStaticTools.canUpdate(xSet);
- m_bCanInsert = aStaticTools.canInsert(xSet);
+ m_bCanUpdate = canUpdate(xSet);
+ m_bCanInsert = canInsert(xSet);
m_bCurrentRecordModified = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED));
m_bCurrentRecordNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW));
@@ -3054,7 +3054,7 @@ void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
// create the composer
Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY);
- Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm));
+ Reference< XConnection > xConnection(getConnection(xForm));
if (xForm.is())
{
try
@@ -3103,8 +3103,7 @@ void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
::comphelper::UStringMixEqual aCompare(xMetaData->storesMixedCaseQuotedIdentifiers());
// need to parse criteria localized
- OStaticDataAccessTools aStaticTools;
- Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, true));
+ Reference< XNumberFormatsSupplier> xFormatSupplier( getNumberFormats(xConnection, true));
Reference< XNumberFormatter> xFormatter = NumberFormatter::create(m_xComponentContext);
xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
Locale aAppLocale = Application::GetSettings().GetUILanguageTag().getLocale();
@@ -3233,8 +3232,7 @@ void FormController::startFiltering()
{
OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
- OStaticDataAccessTools aStaticTools;
- Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) );
+ Reference< XConnection > xConnection( getConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) );
if ( !xConnection.is() )
// nothing to do - can't filter a form which is not connected
return;
@@ -3256,7 +3254,7 @@ void FormController::startFiltering()
// the control we have to activate after replacement
Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData());
- Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, true);
+ Reference< XNumberFormatsSupplier > xFormatSupplier = getNumberFormats(xConnection, true);
Reference< XNumberFormatter > xFormatter = NumberFormatter::create(m_xComponentContext);
xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
@@ -3911,7 +3909,7 @@ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent&
// the request
ParametersRequest aRequest;
aRequest.Parameters = aEvent.Parameters;
- aRequest.Connection = OStaticDataAccessTools().getRowSetConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
+ aRequest.Connection = getConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest));
Reference< XInteractionRequest > xParamRequest(pParamRequest);
// some knittings
diff --git a/svx/source/form/sqlparserclient.cxx b/svx/source/form/sqlparserclient.cxx
index f9c40e850f49..b374c8eaf876 100644
--- a/svx/source/form/sqlparserclient.cxx
+++ b/svx/source/form/sqlparserclient.cxx
@@ -20,25 +20,19 @@
#include "sqlparserclient.hxx"
#include "svx/ParseContext.hxx"
+#include <connectivity/dbtools.hxx>
+
+using namespace ::dbtools;
namespace svxform
{
-
-
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
OSQLParserClient::OSQLParserClient(const Reference< XComponentContext >& rxContext)
{
m_xContext = rxContext;
- }
-
- bool OSQLParserClient::ensureLoaded() const
- {
- if ( !ODbtoolsClient::ensureLoaded() )
- return false;
- m_xParser = getFactory()->createSQLParser(m_xContext,getParseContext());
- return m_xParser.is();
+ m_xParser = createSQLParser(m_xContext, getParseContext());
}
diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx
index 6328a455c68c..6ef3e8537f21 100644
--- a/svx/source/form/tabwin.cxx
+++ b/svx/source/form/tabwin.cxx
@@ -36,7 +36,6 @@
#include "fmhelp.hrc"
#include <svx/fmshell.hxx>
#include "fmshimp.hxx"
-#include "svx/dbtoolsclient.hxx"
#include <svx/fmpage.hxx>
#include "fmpgeimp.hxx"
@@ -70,6 +69,7 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star;
using namespace ::svxform;
using namespace ::svx;
+using namespace ::dbtools;
namespace {
@@ -322,9 +322,8 @@ void FmFieldWin::UpdateContent(const ::com::sun::star::uno::Reference< ::com::su
m_nObjectType = ::comphelper::getINT32(xSet->getPropertyValue(FM_PROP_COMMANDTYPE));
// get the connection of the form
- OStaticDataAccessTools aTools;
m_aConnection.reset(
- aTools.connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessComponentContext(), true ),
+ connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessComponentContext(), true ),
SharedConnection::NoTakeOwnership
);
// TODO: When incompatible changes (such as extending the "virtualdbtools" interface by ensureRowSetConnection)
diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx
index b274ae4cce8f..f687c791d440 100644
--- a/svx/source/inc/fmshimp.hxx
+++ b/svx/source/inc/fmshimp.hxx
@@ -55,7 +55,6 @@
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/compbase6.hxx>
#include <unotools/configitem.hxx>
-#include "svx/dbtoolsclient.hxx"
#include "formcontrolling.hxx"
#include "fmdocumentclassification.hxx"
@@ -146,7 +145,6 @@ class FmFormView;
class FmFormObj;
class SVX_DLLPUBLIC FmXFormShell : public FmXFormShell_BASE
,public FmXFormShell_CFGBASE
- ,public ::svxform::OStaticDataAccessTools
,public ::svx::IControllerFeatureInvalidation
{
friend class FmFormView;
diff --git a/svx/source/inc/sqlparserclient.hxx b/svx/source/inc/sqlparserclient.hxx
index 635c6797d21f..fc5152a1c523 100644
--- a/svx/source/inc/sqlparserclient.hxx
+++ b/svx/source/inc/sqlparserclient.hxx
@@ -20,20 +20,15 @@
#ifndef INCLUDED_SVX_SOURCE_INC_SQLPARSERCLIENT_HXX
#define INCLUDED_SVX_SOURCE_INC_SQLPARSERCLIENT_HXX
-#include "svx/dbtoolsclient.hxx"
#include "svx/ParseContext.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
+#include <connectivity/virtualdbtools.hxx>
namespace svxform
{
-
-
-
//= OSQLParserClient
- class SVX_DLLPUBLIC OSQLParserClient : public ODbtoolsClient
- ,public ::svxform::OParseContextClient
+ class SVX_DLLPUBLIC OSQLParserClient : public ::svxform::OParseContextClient
{
private:
@@ -45,7 +40,6 @@ namespace svxform
protected:
OSQLParserClient(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext);
- virtual bool ensureLoaded() const SAL_OVERRIDE;
protected:
inline ::rtl::Reference< ::connectivity::simple::ISQLParseNode > predicateTree(
@@ -55,10 +49,7 @@ namespace svxform
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField
) const
{
- ::rtl::Reference< ::connectivity::simple::ISQLParseNode > xReturn;
- if ( ensureLoaded() )
- xReturn = m_xParser->predicateTree(_rErrorMessage, _rStatement, _rxFormatter, _rxField);
- return xReturn;
+ return m_xParser->predicateTree(_rErrorMessage, _rStatement, _rxFormatter, _rxField);
}
};
diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx
index 368da9823251..c059544ea0db 100644
--- a/svx/source/inc/tabwin.hxx
+++ b/svx/source/inc/tabwin.hxx
@@ -28,7 +28,7 @@
#include <comphelper/propmultiplex.hxx>
#include <svtools/transfer.hxx>
-#include "svx/dbtoolsclient.hxx"
+#include <connectivity/dbtools.hxx>
class FmFieldWin;
@@ -70,12 +70,11 @@ public:
class FmFieldWin :public SfxFloatingWindow
,public SfxControllerItem
,public ::comphelper::OPropertyChangeListener
- ,public ::svxform::OStaticDataAccessTools
{
::osl::Mutex m_aMutex;
FmFieldWinListBox* pListBox;
FmFieldWinData* pData;
- ::svxform::SharedConnection
+ ::dbtools::SharedConnection
m_aConnection;
OUString m_aDatabaseName,
m_aObjectName;
@@ -102,7 +101,7 @@ public:
void FillInfo( SfxChildWinInfo& rInfo ) const SAL_OVERRIDE;
const OUString& GetDatabaseName() const { return m_aDatabaseName; }
- ::svxform::SharedConnection GetConnection() const { return m_aConnection; }
+ ::dbtools::SharedConnection GetConnection() const { return m_aConnection; }
const OUString& GetObjectName() const { return m_aObjectName; }
sal_Int32 GetObjectType() const { return m_nObjectType; }
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 );