summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/CppunitTest_sw_uibase_unit.mk31
-rw-r--r--sw/Module_sw.mk4
-rw-r--r--sw/inc/dbmgr.hxx17
-rw-r--r--sw/qa/unit/uibase.cxx44
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx18
5 files changed, 102 insertions, 12 deletions
diff --git a/sw/CppunitTest_sw_uibase_unit.mk b/sw/CppunitTest_sw_uibase_unit.mk
new file mode 100644
index 000000000000..03a780a156ce
--- /dev/null
+++ b/sw/CppunitTest_sw_uibase_unit.mk
@@ -0,0 +1,31 @@
+# -*- 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_CppunitTest_CppunitTest,sw_uibase_unit))
+
+$(eval $(call gb_CppunitTest_use_external,sw_uibase_unit,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sw_uibase_unit))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_uibase_unit, \
+ sw/qa/unit/uibase \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_uibase_unit, \
+ sal \
+ sw \
+ tl \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_uibase_unit,\
+ -I$(SRCDIR)/sw/inc \
+ $$(INCLUDE) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 472eac81ad93..4ef524d1fd94 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -48,6 +48,10 @@ $(eval $(call gb_Module_add_targets,sw,\
endif
+$(eval $(call gb_Module_add_check_targets,sw,\
+ CppunitTest_sw_uibase_unit \
+))
+
$(eval $(call gb_Module_add_slowcheck_targets,sw,\
$(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \
CppunitTest_sw_uwriter) \
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 098e1a26f7f7..932d3c165eed 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -473,6 +473,23 @@ public:
void RevokeNotUsedConnections();
};
+namespace sw
+{
+enum class DBConnURIType
+{
+ UNKNOWN = 0,
+ ODB,
+ CALC,
+ DBASE,
+ FLAT,
+ MSJET,
+ MSACE,
+ WRITER
+};
+
+DBConnURIType SW_DLLPUBLIC GetDBunoType(const INetURLObject &rURL);
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unit/uibase.cxx b/sw/qa/unit/uibase.cxx
new file mode 100644
index 000000000000..188916da35a2
--- /dev/null
+++ b/sw/qa/unit/uibase.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <tools/urlobj.hxx>
+
+#include <dbmgr.hxx>
+
+namespace
+{
+/// Test suite for unit tests covering uibase code.
+class Test : public CppUnit::TestFixture
+{
+public:
+ void testTdf98168();
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testTdf98168);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void Test::testTdf98168()
+{
+ INetURLObject aURL("file:///tmp/test.xlsx");
+ // This was sw::DBConnURIType::UNKNOWN, xlsx was not recognized.
+ CPPUNIT_ASSERT_EQUAL(sw::DBConnURIType::CALC, sw::GetDBunoType(aURL));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 5132a0b75e3b..1f18380bb916 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -144,6 +144,7 @@
#include <officecfg/Office/Common.hxx>
using namespace ::com::sun::star;
+using namespace sw;
#define DB_SEP_SPACE 0
#define DB_SEP_TAB 1
@@ -2555,18 +2556,8 @@ uno::Sequence<OUString> SwDBManager::GetExistingDatabaseNames()
return xDBContext->getElementNames();
}
-namespace {
-enum class DBConnURIType {
- UNKNOWN = 0,
- ODB,
- CALC,
- DBASE,
- FLAT,
- MSJET,
- MSACE,
- WRITER
-};
-
+namespace sw
+{
DBConnURIType GetDBunoType(const INetURLObject &rURL)
{
OUString sExt(rURL.GetExtension());
@@ -2607,7 +2598,10 @@ DBConnURIType GetDBunoType(const INetURLObject &rURL)
#endif
return type;
}
+}
+namespace
+{
uno::Any GetDBunoURI(const INetURLObject &rURL, DBConnURIType& rType)
{
uno::Any aURLAny;