svx/source/dialog/fntctrl.cxx | 34 ++++++++++++++---------------- sw/CppunitTest_sw_uibase_unit.mk | 31 +++++++++++++++++++++++++++ sw/Module_sw.mk | 4 +++ sw/inc/dbmgr.hxx | 17 +++++++++++++++ sw/qa/unit/uibase.cxx | 44 +++++++++++++++++++++++++++++++++++++++ sw/source/uibase/dbui/dbmgr.cxx | 18 +++++---------- 6 files changed, 118 insertions(+), 30 deletions(-)
New commits: commit 226804c8f7d2306562380283edfd919a88863807 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Dec 19 21:22:02 2017 +0100 svx: CleanAndCheckEmpty() can be in the anonymous namespace Change-Id: I51c636559aee10791102e70b5507fdab3c9a4e11 Reviewed-on: https://gerrit.libreoffice.org/46819 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index f41889f3b766..39e044447301 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -122,6 +122,22 @@ void setFont(const SvxFont& rNewFont, SvxFont& rImplFont) rImplFont.SetAlignment(ALIGN_BASELINE); } +/* + * removes line feeds and carriage returns from string + * returns if param is empty + */ +bool CleanAndCheckEmpty(OUString& rText) +{ + bool bEmpty = true; + for (sal_Int32 i = 0; i < rText.getLength(); ++i) + { + if (0xa == rText[i] || 0xd == rText[i]) + rText = rText.replaceAt(i, 1, " "); + else + bEmpty = false; + } + return bEmpty; +} } // end anonymous namespace class FontPrevWin_Impl @@ -612,24 +628,6 @@ void SvxFontPrevWindow::UseResourceText() pImpl->mbUseResText = true; } -/* - * removes line feeds and carriage returns from string - * returns if param is empty - */ -bool CleanAndCheckEmpty(OUString& rText) -{ - bool bEmpty = true; - for (sal_Int32 i = 0; i < rText.getLength(); ++i) - { - if (0xa == rText[i] || 0xd == rText[i]) - rText = rText.replaceAt(i, 1, " "); - else - bEmpty = false; - } - return bEmpty; -} - - void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { ApplySettings(rRenderContext); commit 28ddaf520da56701508acc258cf1d90f26134d28 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Dec 19 21:21:32 2017 +0100 tdf#98168 sw: add mail merge from xlsx testcase Commit 83b43ef2223b66484e0e90e7b614886e06f955b5 (sw mail merge: add support for the new 'writer' connectivity driver, 2017-07-18) fixed this, with: > If we are at it, also accept xlsx next to xls. But there was no test for that part. Change-Id: Iffbd4d21e52700d38dc0a83cb5540fa10c062944 Reviewed-on: https://gerrit.libreoffice.org/46818 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits