diff --git a/sd/CppunitTest_sd_ui_func.mk b/sd/CppunitTest_sd_ui_func.mk new file mode 100644 index 000000000000..bad465b194d5 --- /dev/null +++ b/sd/CppunitTest_sd_ui_func.mk @@ -0,0 +1,88 @@ +# -*- 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,sd_ui_func)) + +$(eval $(call gb_CppunitTest_use_externals,sd_ui_func,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sd_ui_func)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sd_ui_func, \ + sd/qa/ui/func/func \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sd_ui_func, \ + basegfx \ + canvastools \ + comphelper \ + cppcanvas \ + cppu \ + cppuhelper \ + docmodel \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + i18nutil \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sd \ + sfx \ + sot \ + subsequenttest \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_set_include,sd_ui_func,\ + -I$(SRCDIR)/sd/inc \ + -I$(SRCDIR)/sd/source/ui/inc \ + -I$(SRCDIR)/sd/source/ui/slidesorter/inc \ + -I$(SRCDIR)/sd/qa/unit \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sd_ui_func)) + +$(eval $(call gb_CppunitTest_use_ure,sd_ui_func)) +$(eval $(call gb_CppunitTest_use_vcl,sd_ui_func)) + +$(eval $(call gb_CppunitTest_use_rdb,sd_ui_func,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sd_ui_func,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sd_ui_func)) + +$(eval $(call gb_CppunitTest_add_arguments,sd_ui_func, \ + -env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index aefdbb587dd4..048e2743a835 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -45,6 +45,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sd,\ CppunitTest_sd_layout_tests \ CppunitTest_sd_misc_tests \ CppunitTest_sd_uiimpress \ + CppunitTest_sd_ui_func \ CppunitTest_sd_html_export_tests \ CppunitTest_sd_activex_controls_tests \ CppunitTest_sd_pdf_import_test \ diff --git a/sd/qa/ui/func/func.cxx b/sd/qa/ui/func/func.cxx new file mode 100644 index 000000000000..f6df8fcc8857 --- /dev/null +++ b/sd/qa/ui/func/func.cxx @@ -0,0 +1,88 @@ +/* -*- 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 + +#include +#include + +#include +#include + +#include +#include +#include +#include + +using namespace com::sun::star; + +namespace +{ +/// Covers sd/source/ui/func/ fixes. +class Test : public SdModelTestBase +{ +public: + Test() + : SdModelTestBase(u"/sd/qa/unit/data/"_ustr) + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testNoneToBullet) +{ + // Given a document with a shape, the only paragraph has a numbering of type "none": + createSdImpressDoc("odp/none-to-bullet.odp"); + sd::ViewShell* pViewShell = getSdDocShell()->GetViewShell(); + SdPage* pPage = pViewShell->GetActualPage(); + SdrObject* pShape = pPage->GetObj(0); + CPPUNIT_ASSERT(pShape); + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pShape, pView->GetSdrPageView()); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(!pView->IsTextEdit()); + + // When turning the "none" numbering to a bullet: + // Start text edit: + auto pImpressDocument = dynamic_cast(mxComponent.get()); + typeString(pImpressDocument, u"x"); + CPPUNIT_ASSERT(pView->IsTextEdit()); + // Do the switch: + dispatchCommand(mxComponent, u".uno:DefaultBullet"_ustr, {}); + // End text edit: + typeKey(pImpressDocument, KEY_ESCAPE); + + // Then make sure we switch to a bullet with reasonable defaults: + CPPUNIT_ASSERT(!pView->IsTextEdit()); + uno::Reference xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + uno::Reference xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference xParagraph(getParagraphFromShape(0, xShape), + uno::UNO_QUERY); + // Check the list level 1 properties: + uno::Reference xNumberingRules; + xParagraph->getPropertyValue(u"NumberingRules"_ustr) >>= xNumberingRules; + comphelper::SequenceAsHashMap aNumberingRule(xNumberingRules->getByIndex(0)); + sal_Int32 nLeftMargin{}; + aNumberingRule[u"LeftMargin"_ustr] >>= nLeftMargin; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1200 + // - Actual : 0 + // i.e. there was no left margin at all, first and later lines did not match on the left hand + // side. + CPPUNIT_ASSERT_EQUAL(static_cast(1200), nLeftMargin); + sal_Int32 nFirstLineOffset{}; + aNumberingRule[u"FirstLineOffset"_ustr] >>= nFirstLineOffset; + CPPUNIT_ASSERT_EQUAL(static_cast(-900), nFirstLineOffset); +} +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/data/odp/none-to-bullet.odp b/sd/qa/unit/data/odp/none-to-bullet.odp new file mode 100644 index 000000000000..3526ae3916cf Binary files /dev/null and b/sd/qa/unit/data/odp/none-to-bullet.odp differ diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 8a398520e6a8..135245767d03 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include using namespace ::com::sun::star; @@ -184,6 +186,23 @@ public: return pXmlDoc; } + + void typeString(SdXImpressDocument* rImpressDocument, std::u16string_view rStr) + { + for (const char16_t c : rStr) + { + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0); + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0); + Scheduler::ProcessEventsToIdle(); + } + } + + void typeKey(SdXImpressDocument* rImpressDocument, const sal_uInt16 nKey) + { + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, nKey); + rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, nKey); + Scheduler::ProcessEventsToIdle(); + } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 98b1cdb01974..215af8589928 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -80,8 +80,6 @@ public: } void checkCurrentPageNumber(sal_uInt16 nNum); - void typeString(SdXImpressDocument* rImpressDocument, std::u16string_view rStr); - void typeKey(SdXImpressDocument* rImpressDocument, const sal_uInt16 nKey); void insertStringToObject(sal_uInt16 nObj, std::u16string_view rStr, bool bUseEscape); sd::slidesorter::SlideSorterViewShell* getSlideSorterViewShell(); void lcl_search(const OUString& rKey, bool bFindAll = false, bool bBackwards = false); @@ -99,23 +97,6 @@ void SdUiImpressTest::checkCurrentPageNumber(sal_uInt16 nNum) CPPUNIT_ASSERT_EQUAL(nNum, nPageNumber); } -void SdUiImpressTest::typeKey(SdXImpressDocument* rImpressDocument, const sal_uInt16 nKey) -{ - rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, nKey); - rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, nKey); - Scheduler::ProcessEventsToIdle(); -} - -void SdUiImpressTest::typeString(SdXImpressDocument* rImpressDocument, std::u16string_view rStr) -{ - for (const char16_t c : rStr) - { - rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0); - rImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0); - Scheduler::ProcessEventsToIdle(); - } -} - void SdUiImpressTest::insertStringToObject(sal_uInt16 nObj, std::u16string_view rStr, bool bUseEscape) { diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx index ef4dd373fcbc..ecb7c5377a1b 100644 --- a/sd/source/ui/func/fuolbull.cxx +++ b/sd/source/ui/func/fuolbull.cxx @@ -206,7 +206,13 @@ void FuBulletAndPosition::SetCurrentBulletsNumbering(SfxRequest& rReq) { if(nActNumLvl & nMask) { - const SvxNumberFormat& aFmt(aTmpRule.GetLevel(i)); + SvxNumberFormat aFmt(aTmpRule.GetLevel(i)); + if (nSId == FN_SVX_SET_BULLET) + { + // If changing to a bullet, then make its format and indent has a good + // default, similar to what the master page offers: + SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(i, aFmt); + } pNumRule->SetLevel(i, aFmt); } nMask <<= 1;