include/unotest/macros_test.hxx | 5 sc/qa/unit/tiledrendering/tiledrendering.cxx | 22 ---- sw/qa/core/crsr/crsr.cxx | 19 --- sw/qa/extras/layout/layout.cxx | 107 ++++++++------------ sw/qa/extras/uiwriter/uiwriter.cxx | 140 ++++++++++++--------------- sw/qa/extras/uiwriter/uiwriter2.cxx | 131 ++++++++++--------------- unotest/source/cpp/macros_test.cxx | 20 +++ xmloff/qa/unit/text.cxx | 19 --- 8 files changed, 195 insertions(+), 268 deletions(-)
New commits: commit 8ff147f200e6514bbc7e7d7b5ca91694b9234bfc Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Jan 17 14:32:49 2020 +0100 Commit: Pranam Lashkari <lpra...@collabora.com> CommitDate: Tue Mar 16 05:46:15 2021 +0100 Clean up duplicated command dispatch test functionality Used in both Writer and Calc at few different places, so host it in unotest/. Change-Id: I013e6df471deb8693cf4ae62f0958b12e16fda7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86972 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112395 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Pranam Lashkari <lpra...@collabora.com> diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx index aa098d6a2178..b62526faf9f5 100644 --- a/include/unotest/macros_test.hxx +++ b/include/unotest/macros_test.hxx @@ -36,6 +36,11 @@ public: css::uno::Reference< css::lang::XComponent > loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString(), const css::uno::Sequence<css::beans::PropertyValue>& rExtra_args = css::uno::Sequence<css::beans::PropertyValue>() ); + static void + dispatchCommand(const css::uno::Reference<css::lang::XComponent>& xComponent, + const OUString& rCommand, + const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues); + protected: css::uno::Reference< css::frame::XDesktop2> mxDesktop; void setUpNssGpg(const test::Directories& rDirectories, const OUString& rTestName); diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 158754d51ffc..cfcefe7ccd71 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -594,20 +594,6 @@ void ScTiledRenderingTest::testSpellOnlineRenderParameter() CPPUNIT_ASSERT_EQUAL(!bSet, pDoc->GetDocOptions().IsAutoSpell()); } -void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rArguments) -{ - uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); - CPPUNIT_ASSERT(xController.is()); - uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xFrame.is()); - - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); - CPPUNIT_ASSERT(xDispatchHelper.is()); - - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rArguments); -} - void ScTiledRenderingTest::testTextViewSelection() { comphelper::LibreOfficeKit::setActive(); @@ -621,7 +607,7 @@ void ScTiledRenderingTest::testTextViewSelection() // Create a selection on two cells in the second view, that's a text selection in LOK terms. aView1.m_bTextViewSelectionInvalidated = false; - lcl_dispatchCommand(mxComponent, ".uno:GoRightSel", {}); + dispatchCommand(mxComponent, ".uno:GoRightSel", {}); Scheduler::ProcessEventsToIdle(); // Make sure the first view got its notification. CPPUNIT_ASSERT(aView1.m_bTextViewSelectionInvalidated); @@ -640,7 +626,7 @@ void ScTiledRenderingTest::testDocumentSizeChanged() { comphelper::makePropertyValue("ToPoint", OUString("$A$30")), }; - lcl_dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); + dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); Scheduler::ProcessEventsToIdle(); // Assert that the size in the payload is not 0. CPPUNIT_ASSERT(m_aDocumentSize.getWidth() > 0); @@ -1687,7 +1673,7 @@ void ScTiledRenderingTest::testSpellOnlineParameter() { comphelper::makePropertyValue("Enable", uno::makeAny(!bSet)), }; - lcl_dispatchCommand(mxComponent, ".uno:SpellOnline", params); + dispatchCommand(mxComponent, ".uno:SpellOnline", params); CPPUNIT_ASSERT_EQUAL(!bSet, pDoc->GetDocOptions().IsAutoSpell()); // set the same state as now and we don't expect any change (no-toggle) @@ -1695,7 +1681,7 @@ void ScTiledRenderingTest::testSpellOnlineParameter() { comphelper::makePropertyValue("Enable", uno::makeAny(!bSet)), }; - lcl_dispatchCommand(mxComponent, ".uno:SpellOnline", params); + dispatchCommand(mxComponent, ".uno:SpellOnline", params); CPPUNIT_ASSERT_EQUAL(!bSet, pDoc->GetDocOptions().IsAutoSpell()); } diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx index 6adf93042f0b..75f9de1018f3 100644 --- a/sw/qa/core/crsr/crsr.cxx +++ b/sw/qa/core/crsr/crsr.cxx @@ -29,25 +29,6 @@ class SwCoreCrsrTest : public SwModelTestBase { }; -namespace -{ -void dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, - const uno::Sequence<beans::PropertyValue>& rPropertyValues) -{ - uno::Reference<frame::XController> xController - = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); - CPPUNIT_ASSERT(xController.is()); - uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xFrame.is()); - - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); - CPPUNIT_ASSERT(xDispatchHelper.is()); - - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); -} -} - CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testFindReplace) { loadURL("private:factory/swriter", nullptr); diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 28ee6095792d..714ef6dea0dc 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -63,23 +63,6 @@ SwDoc* SwLayoutWriter::createDoc(const char* pName) return pTextDoc->GetDocShell()->GetDoc(); } -static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, - const OUString& rCommand, - const uno::Sequence<beans::PropertyValue>& rPropertyValues) -{ - uno::Reference<frame::XController> xController - = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); - CPPUNIT_ASSERT(xController.is()); - uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xFrame.is()); - - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); - CPPUNIT_ASSERT(xDispatchHelper.is()); - - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); -} - // this is a member because our test classes have protected members :( void SwLayoutWriter::CheckRedlineFootnotesHidden() { @@ -120,7 +103,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFootnotes) // verify after load CheckRedlineFootnotesHidden(); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -198,7 +181,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFootnotes) assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[3]", "Portion", "o"); // verify after hide - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); CheckRedlineFootnotesHidden(); @@ -237,7 +220,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) pWrtShell->SplitNode(false); pWrtShell->Insert("ghi"); - lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); // delete redline inside fly pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); @@ -259,7 +242,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -273,7 +256,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", "ahi"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -335,7 +318,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -350,7 +333,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) xmlXPathFreeObject(pXmlObj); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -411,7 +394,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -425,7 +408,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", "ahi"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -515,7 +498,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) pWrtShell->SplitNode(false); pWrtShell->Insert("ghi"); - lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); // delete redline inside fly pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); @@ -537,7 +520,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -553,7 +536,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", "ahi"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -617,7 +600,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -635,7 +618,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) xmlXPathFreeObject(pXmlObj); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -698,7 +681,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -714,7 +697,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", "ahi"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -810,7 +793,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) pWrtShell->SplitNode(false); pWrtShell->Insert("ghi"); - lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); // delete redline inside fly pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); @@ -840,7 +823,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -860,7 +843,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) "PortionType::FootnoteNum"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -945,7 +928,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -967,7 +950,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) xmlXPathFreeObject(pXmlObj); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1053,7 +1036,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -1073,7 +1056,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) "PortionType::FootnoteNum"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1247,7 +1230,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) pWrtShell->SplitNode(false); pWrtShell->Insert("pqr"); - lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); // delete redline inside fly2 pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); @@ -1280,7 +1263,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -1308,7 +1291,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1422,7 +1405,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -1437,7 +1420,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) xmlXPathFreeObject(pXmlObj); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1549,7 +1532,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -1577,7 +1560,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1711,7 +1694,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) pWrtShell->SplitNode(false); pWrtShell->Insert("pqr"); - lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); // delete redline inside fly2 pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); @@ -1729,7 +1712,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); xmlDocPtr pXmlDoc = parseLayoutDump(); @@ -1754,7 +1737,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1836,7 +1819,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint()); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1851,7 +1834,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) xmlXPathFreeObject(pXmlObj); } - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -1952,7 +1935,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineSections) // verify after load CheckRedlineSectionsHidden(); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); @@ -2000,7 +1983,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineSections) assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[3]/Text[2]", "Portion", "lah"); // verify after hide - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); @@ -2024,7 +2007,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foar"); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); @@ -2061,7 +2044,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables) assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "Portion", "ar"); // verify after hide - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); @@ -2140,7 +2123,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineCharAttributes) // verify after load CheckRedlineCharAttributesHidden(); - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); @@ -2230,7 +2213,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineCharAttributes) assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[5]", "Portion", "baz"); // verify after hide - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); @@ -2258,7 +2241,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineShowHideFootnotePagination) "zzz. zzz zzzz zzzz7 zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); // hide redlines - all still visible footnotes move to page 1 - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -2267,7 +2250,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineShowHideFootnotePagination) assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 0); // show again - should now get the same result as on loading - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -2881,8 +2864,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf127606) // tdf#127606: now it's possible to change formatting of numbering // increase font size (220 -> 260) - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Grow", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Grow", {}); pViewShell->Reformat(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index bdac0ce90ebf..d56f678f7e08 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -4132,20 +4132,6 @@ void SwUiWriterTest::testShapeAnchorUndo() CPPUNIT_ASSERT_EQUAL(pObject->GetLogicRect(), aOrigLogicRect); } -static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues) -{ - uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); - CPPUNIT_ASSERT(xController.is()); - uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xFrame.is()); - - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); - CPPUNIT_ASSERT(xDispatchHelper.is()); - - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); -} - CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134252) { load(DATA_DIRECTORY, "tdf134252.fodt"); @@ -4162,13 +4148,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134252) uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); // select all with section - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString()); - lcl_dispatchCommand(mxComponent, ".uno:Delete", {}); + dispatchCommand(mxComponent, ".uno:Delete", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); @@ -4176,28 +4162,28 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134252) CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString()); // this would crash - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString()); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString()); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); @@ -4226,18 +4212,18 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134250) CPPUNIT_ASSERT(xTextContent->getAnchor()->getString().endsWith("bar")); // select all with table at start -> 3 times - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Copy", {}); - lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Copy", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); // this would crash in 2 different ways - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); @@ -4246,20 +4232,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134250) // Without the fix in place, section's content would have been gone after undo CPPUNIT_ASSERT(xTextContent->getAnchor()->getString().endsWith("bar")); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); CPPUNIT_ASSERT(xTextContent->getAnchor()->getString().endsWith("bar")); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); @@ -4275,7 +4261,7 @@ void SwUiWriterTest::testDde() pWrtShell->Insert("asdf"); pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 4, /*bBasicCall=*/false); uno::Sequence<beans::PropertyValue> aPropertyValues; - lcl_dispatchCommand(mxComponent, ".uno:Copy", aPropertyValues); + dispatchCommand(mxComponent, ".uno:Copy", aPropertyValues); // Go before the selection and paste as a DDE link. pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); @@ -4283,7 +4269,7 @@ void SwUiWriterTest::testDde() { {"SelectedFormat", uno::makeAny(static_cast<sal_uInt32>(SotClipboardFormatId::LINK))} }); - lcl_dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aPropertyValues); + dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aPropertyValues); // Make sure that the document starts with a field now, and its expanded string value contains asdf. const uno::Reference< text::XTextRange > xField = getRun(getParagraph(1), 1); @@ -4300,14 +4286,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf132160) CPPUNIT_ASSERT(pTextDoc); // this would crash due to delete redline starting with ToX - lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); // this would crash due to insert redline ending on table node - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); } //IdleTask class to add a low priority Idle task @@ -4410,12 +4396,12 @@ void SwUiWriterTest::testUnicodeNotationToggle() sOriginalDocString = pWrtShell->GetCursor()->GetNode().GetTextNode()->GetText(); CPPUNIT_ASSERT_EQUAL(OUString("uU+002b"), sOriginalDocString); - lcl_dispatchCommand(mxComponent, ".uno:UnicodeNotationToggle", aPropertyValues); + dispatchCommand(mxComponent, ".uno:UnicodeNotationToggle", aPropertyValues); sExpectedString = "u+"; sDocString = pWrtShell->GetCursor()->GetNode().GetTextNode()->GetText(); CPPUNIT_ASSERT_EQUAL( sDocString, sExpectedString ); - lcl_dispatchCommand(mxComponent, ".uno:UnicodeNotationToggle", aPropertyValues); + dispatchCommand(mxComponent, ".uno:UnicodeNotationToggle", aPropertyValues); sDocString = pWrtShell->GetCursor()->GetNode().GetTextNode()->GetText(); CPPUNIT_ASSERT_EQUAL( sDocString, sOriginalDocString ); } @@ -4428,17 +4414,17 @@ void SwUiWriterTest::testTdf133967() CPPUNIT_ASSERT(pTextDoc); CPPUNIT_ASSERT_EQUAL(6, getPages()); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); Scheduler::ProcessEventsToIdle(); for (sal_Int32 i = 0; i < 10; ++i) { - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); } @@ -4456,13 +4442,13 @@ void SwUiWriterTest::testTdf132187() CPPUNIT_ASSERT(pTextDoc); CPPUNIT_ASSERT_EQUAL(1, getPages()); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Copy", {}); - lcl_dispatchCommand(mxComponent, ".uno:GoToEndOfDoc", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Copy", {}); + dispatchCommand(mxComponent, ".uno:GoToEndOfDoc", {}); for (sal_Int32 i = 0; i < 10; ++i) { - lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); Scheduler::ProcessEventsToIdle(); } @@ -5325,12 +5311,12 @@ void SwUiWriterTest::testClassificationPaste() // Classified source, not classified destination. uno::Sequence<beans::PropertyValue> aInternalOnly = comphelper::InitPropertySequence({{"Name", uno::makeAny(OUString("Internal Only"))}}); - lcl_dispatchCommand(xSourceComponent, ".uno:ClassificationApply", aInternalOnly); + dispatchCommand(xSourceComponent, ".uno:ClassificationApply", aInternalOnly); CPPUNIT_ASSERT_EQUAL(int(SfxClassificationCheckPasteResult::TargetDocNotClassified), checkShells(pSourceShell, pDestinationShell)); // Classified source and classified destination -- internal only has a higher level than confidential. uno::Sequence<beans::PropertyValue> aConfidential = comphelper::InitPropertySequence({{"Name", uno::makeAny(OUString("Confidential"))}}); - lcl_dispatchCommand(mxComponent, ".uno:ClassificationApply", aConfidential); + dispatchCommand(mxComponent, ".uno:ClassificationApply", aConfidential); CPPUNIT_ASSERT_EQUAL(int(SfxClassificationCheckPasteResult::DocClassificationTooLow), checkShells(pSourceShell, pDestinationShell)); xSourceComponent->dispose(); @@ -5347,7 +5333,7 @@ void SwUiWriterTest::testSmallCaps() pWrtShell->SelAll(); // Dispatch the command to make them formatted small capitals. - lcl_dispatchCommand(mxComponent, ".uno:SmallCaps", {}); + dispatchCommand(mxComponent, ".uno:SmallCaps", {}); // This was css::style::CaseMap::NONE as the shell didn't handle the command. CPPUNIT_ASSERT_EQUAL(css::style::CaseMap::SMALLCAPS, getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharCaseMap")); @@ -5570,9 +5556,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134436) uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); // select all 3 times, table at the start - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); @@ -5580,14 +5566,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134436) CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText()); // first, the section doesn't get deleted - lcl_dispatchCommand(mxComponent, ".uno:Delete", {}); + dispatchCommand(mxComponent, ".uno:Delete", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); @@ -5595,14 +5581,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134436) CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText()); // second, the section does get deleted because point is at the end - lcl_dispatchCommand(mxComponent, ".uno:Delete", {}); + dispatchCommand(mxComponent, ".uno:Delete", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); @@ -5610,21 +5596,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf134436) CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText()); // the problem was that the section was not deleted on Redo - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); CPPUNIT_ASSERT_EQUAL(OUString("a\nb\n"), pWrtShell->GetCursor()->GetText()); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); @@ -5683,7 +5669,7 @@ void SwUiWriterTest::testRedlineParam() { {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[0]->GetId()))} })); - lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); + dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); // This failed: the parameter wasn't handled so the next change (zzz) was @@ -5696,7 +5682,7 @@ void SwUiWriterTest::testRedlineParam() { {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[1]->GetId()))} }); - lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); + dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); pShellCursor = pWrtShell->getShellCursor(false); CPPUNIT_ASSERT_EQUAL(OUString("zzz"), pShellCursor->GetText()); @@ -5707,7 +5693,7 @@ void SwUiWriterTest::testRedlineParam() { {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[1]->GetId()))} }); - lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); + dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); pShellCursor = pWrtShell->getShellCursor(false); @@ -5744,7 +5730,7 @@ void SwUiWriterTest::testRedlineViewAuthor() CPPUNIT_ASSERT_EQUAL(aAuthor, pRedline->GetAuthorString()); // Insert a comment and assert that SwView::SetRedlineAuthor() affects this as well. - lcl_dispatchCommand(mxComponent, ".uno:.uno:InsertAnnotation", {}); + dispatchCommand(mxComponent, ".uno:.uno:InsertAnnotation", {}); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); @@ -5849,7 +5835,7 @@ void SwUiWriterTest::testLandscape() uno::Sequence<beans::PropertyValue> aPropertyValues( comphelper::InitPropertySequence({ { "AttributePage.Landscape", uno::Any(true) } })); - lcl_dispatchCommand(mxComponent, ".uno:AttributePage", aPropertyValues); + dispatchCommand(mxComponent, ".uno:AttributePage", aPropertyValues); Scheduler::ProcessEventsToIdle(); // Assert that the document model was modified. @@ -6000,12 +5986,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf132944) CPPUNIT_ASSERT_EQUAL(1, getPages()); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Delete", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Delete", {}); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(1, getPages()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); Scheduler::ProcessEventsToIdle(); // Without the fix in place, the document would have had 2 pages @@ -6219,7 +6205,7 @@ void SwUiWriterTest::testCreateDocxAnnotation() {"Text", uno::makeAny(aSomeText)}, {"Author", uno::makeAny(OUString("me"))}, }); - lcl_dispatchCommand(mxComponent, ".uno:InsertAnnotation", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertAnnotation", aPropertyValues); // Save it as DOCX & load it again reload("Office Open XML Text", "create-docx-annotation.docx"); @@ -6273,7 +6259,7 @@ void SwUiWriterTest::testTdf112025() OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "fdo112025-insert.docx"; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({{ "Name", uno::makeAny(insertFileid) }})); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); // something has been inserted + an additional paragraph CPPUNIT_ASSERT_GREATER(numberOfParagraphs, getParagraphs()); @@ -6293,7 +6279,7 @@ void SwUiWriterTest::testTdf72942() OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "fdo72942-insert.docx"; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({{ "Name", uno::makeAny(insertFileid) }})); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); // check styles of paragraphs added from [fdo72942.docx] const uno::Reference< text::XTextRange > xRun1 = getRun(getParagraph(1), 1); @@ -6354,7 +6340,7 @@ void SwUiWriterTest::testTdf113877() { const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list.odt"; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); } const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); @@ -6387,7 +6373,7 @@ void SwUiWriterTest::testTdf113877NoMerge() { const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); } const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); @@ -6426,7 +6412,7 @@ void SwUiWriterTest::testTdf113877_default_style() { const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); } const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); @@ -6458,7 +6444,7 @@ void SwUiWriterTest::testTdf113877_Standard_style() { const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); } const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); @@ -6866,7 +6852,7 @@ void SwUiWriterTest::testTdf108048() { "PageNumber", uno::makeAny(sal_uInt16(6)) }, // Even number to avoid auto-inserted blank page { "PageNumberFilled", uno::makeAny(true) }, }); - lcl_dispatchCommand(mxComponent, ".uno:InsertBreak", aPropertyValues); + dispatchCommand(mxComponent, ".uno:InsertBreak", aPropertyValues); CPPUNIT_ASSERT_EQUAL(2, getParagraphs()); CPPUNIT_ASSERT_EQUAL(2, getPages()); @@ -7384,12 +7370,12 @@ void SwUiWriterTest::testSpellOnlineParameter() bool bSet = pOpt->IsOnlineSpell(); uno::Sequence<beans::PropertyValue> params = comphelper::InitPropertySequence({{"Enable", uno::makeAny(!bSet)}}); - lcl_dispatchCommand(mxComponent, ".uno:SpellOnline", params); + dispatchCommand(mxComponent, ".uno:SpellOnline", params); CPPUNIT_ASSERT_EQUAL(!bSet, pOpt->IsOnlineSpell()); // set the same state as now and we don't expect any change (no-toggle) params = comphelper::InitPropertySequence({{"Enable", uno::makeAny(!bSet)}}); - lcl_dispatchCommand(mxComponent, ".uno:SpellOnline", params); + dispatchCommand(mxComponent, ".uno:SpellOnline", params); CPPUNIT_ASSERT_EQUAL(!bSet, pOpt->IsOnlineSpell()); } @@ -7489,7 +7475,7 @@ void SwUiWriterTest::testInsertPdf() uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence({ {"FileName", uno::Any(m_directories.getURLFromSrc(DATA_DIRECTORY) + "hello-world.pdf")} })); - lcl_dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs); + dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs); // Save and load cycle utl::TempFile aTempFile; diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 7890dbf22b4b..ae508ec3ec60 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -81,23 +81,6 @@ protected: SwDoc* createDoc(const char* pName = nullptr); }; -static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, - const OUString& rCommand, - const uno::Sequence<beans::PropertyValue>& rPropertyValues) -{ - uno::Reference<frame::XController> xController - = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); - CPPUNIT_ASSERT(xController.is()); - uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xFrame.is()); - - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); - CPPUNIT_ASSERT(xDispatchHelper.is()); - - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); -} - SwDoc* SwUiWriterTest2::createDoc(const char* pName) { if (!pName) @@ -122,7 +105,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf47471_paraStyleBackground) pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->EndPara(/*bSelect=*/true); - lcl_dispatchCommand(mxComponent, ".uno:ResetAttributes", {}); + dispatchCommand(mxComponent, ".uno:ResetAttributes", {}); // the background color should revert to the color for 00Background style CPPUNIT_ASSERT_EQUAL(sal_Int32(14605542), getProperty<sal_Int32>(getParagraph(2), "FillColor")); @@ -156,21 +139,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf131684) CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); //Use selectAll 3 times in a row - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); - lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); // without the fix, it crashes - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); // check that the text frame has the correct upper @@ -206,8 +189,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdfChangeNumberingListAutoFormat) // tdf#127606: now it's possible to change formatting of numbering // increase font size (220 -> 260) - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Grow", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Grow", {}); pViewShell->Reformat(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -955,11 +938,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf64242_optimizeTable) pWrtShell->SelTable(); //select the whole table - lcl_dispatchCommand(mxComponent, ".uno:SetOptimalColumnWidth", {}); + dispatchCommand(mxComponent, ".uno:SetOptimalColumnWidth", {}); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Width: optimize", origWidth, getProperty<double>(xTextTable, "Width"), nToleranceW); - lcl_dispatchCommand(mxComponent, ".uno:SetMinimalColumnWidth", {}); + dispatchCommand(mxComponent, ".uno:SetMinimalColumnWidth", {}); CPPUNIT_ASSERT_MESSAGE("Table Width: minimized", (origWidth - nToleranceW) > getProperty<double>(xTextTable, "Width")); @@ -967,12 +950,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf64242_optimizeTable) sal_Int32 nToleranceH = origRowHeight * .01; CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Row Height", double(3441), origRowHeight, nToleranceH); - lcl_dispatchCommand(mxComponent, ".uno:SetOptimalRowHeight", {}); + dispatchCommand(mxComponent, ".uno:SetOptimalRowHeight", {}); double optimalRowHeight = getProperty<double>(xTableRows->getByIndex(2), "Height"); CPPUNIT_ASSERT_MESSAGE("Row Height: optimized", (origRowHeight - nToleranceH) > optimalRowHeight); - lcl_dispatchCommand(mxComponent, ".uno:SetMinimalRowHeight", {}); + dispatchCommand(mxComponent, ".uno:SetMinimalRowHeight", {}); double minimalRowHeight = getProperty<double>(xTableRows->getByIndex(2), "Height"); CPPUNIT_ASSERT_MESSAGE("Row Height: minimized", (optimalRowHeight - nToleranceH) > minimalRowHeight); @@ -999,7 +982,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126784_distributeSelectedColumns) //Select column 1 and 2 pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); - lcl_dispatchCommand(mxComponent, ".uno:DistributeColumns", {}); + dispatchCommand(mxComponent, ".uno:DistributeColumns", {}); aSeq = getProperty<uno::Sequence<text::TableColumnSeparator>>(xTableRows->getByIndex(0), "TableColumnSeparators"); @@ -1196,7 +1179,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf105413) { "Style", uno::makeAny(OUString("Heading 1")) }, { "FamilyName", uno::makeAny(OUString("ParagraphStyles")) }, }); - lcl_dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues); + dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues); CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(getParagraph(3), "ParaStyleName")); @@ -1404,7 +1387,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf122893) for (int i = 1; i < 4; ++i) { CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(i), "ParaAdjust")); - lcl_dispatchCommand(mxComponent, ".uno:SpacePara1", {}); + dispatchCommand(mxComponent, ".uno:SpacePara1", {}); } // turn on red-lining and show changes @@ -1426,8 +1409,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf122893) pWrtShell->Down(/*bSelect=*/false); pWrtShell->EndPara(/*bSelect=*/false); - lcl_dispatchCommand(mxComponent, ".uno:CenterPara", {}); - lcl_dispatchCommand(mxComponent, ".uno:SpacePara2", {}); + dispatchCommand(mxComponent, ".uno:CenterPara", {}); + dispatchCommand(mxComponent, ".uno:SpacePara2", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<sal_Int32>(getParagraph(3), "ParaAdjust")); // center-aligned @@ -1480,7 +1463,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf122901) pWrtShell->Down(/*bSelect=*/false); pWrtShell->EndPara(/*bSelect=*/false); - lcl_dispatchCommand(mxComponent, ".uno:ParaspaceIncrease", {}); + dispatchCommand(mxComponent, ".uno:ParaspaceIncrease", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(101), getProperty<sal_Int32>(getParagraph(3), "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(101), @@ -1543,7 +1526,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf52391) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); - lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); const uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1); // this was "Portion1", because the tracked background color of Portion1 was @@ -1570,7 +1553,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126206) } // reject tracked changes - lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); // bold text again xText = getParagraph(1)->getText(); @@ -1602,14 +1585,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101873) { "SearchItem.SearchString", uno::makeAny(OUString("fig")) }, { "SearchItem.Backward", uno::makeAny(false) }, })); - lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aFirst); - lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aFirst); + dispatchCommand(mxComponent, ".uno:ExecuteSearch", aFirst); + dispatchCommand(mxComponent, ".uno:ExecuteSearch", aFirst); uno::Sequence<beans::PropertyValue> aSecond(comphelper::InitPropertySequence({ { "SearchItem.SearchString", uno::makeAny(OUString("something")) }, { "SearchItem.Backward", uno::makeAny(false) }, })); - lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aSecond); + dispatchCommand(mxComponent, ".uno:ExecuteSearch", aSecond); // Without the accompanying fix in place, this test would have failed with "Expected: something; // Actual:", i.e. searching for "something" failed, even if it was inserted above. @@ -1643,7 +1626,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTextFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a text form field - lcl_dispatchCommand(mxComponent, ".uno:TextFormField", {}); + dispatchCommand(mxComponent, ".uno:TextFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -1659,13 +1642,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTextFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), xPara->getString()); // Undo insertion - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); xPara.set(getParagraph(1)); CPPUNIT_ASSERT(xPara->getString().isEmpty()); // Redo insertion - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); xPara.set(getParagraph(1)); CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), xPara->getString()); @@ -1681,7 +1664,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testCheckboxFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a checkbox form field - lcl_dispatchCommand(mxComponent, ".uno:CheckBoxFormField", {}); + dispatchCommand(mxComponent, ".uno:CheckBoxFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -1697,11 +1680,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testCheckboxFormFieldInsertion) CPPUNIT_ASSERT(!pCheckBox->IsChecked()); // Undo insertion - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Redo insertion - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); aIter = pMarkAccess->getAllMarksBegin(); CPPUNIT_ASSERT(aIter != pMarkAccess->getAllMarksEnd()); @@ -1720,7 +1703,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDropDownFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a drop-down form field - lcl_dispatchCommand(mxComponent, ".uno:DropDownFormField", {}); + dispatchCommand(mxComponent, ".uno:DropDownFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -1737,11 +1720,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDropDownFormFieldInsertion) CPPUNIT_ASSERT(bool(pResult == pParameters->end())); // Undo insertion - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Redo insertion - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); aIter = pMarkAccess->getAllMarksBegin(); CPPUNIT_ASSERT(aIter != pMarkAccess->getAllMarksEnd()); @@ -1760,21 +1743,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testMixedFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert fields - lcl_dispatchCommand(mxComponent, ".uno:TextFormField", {}); - lcl_dispatchCommand(mxComponent, ".uno:CheckBoxFormField", {}); - lcl_dispatchCommand(mxComponent, ".uno:DropDownFormField", {}); + dispatchCommand(mxComponent, ".uno:TextFormField", {}); + dispatchCommand(mxComponent, ".uno:CheckBoxFormField", {}); + dispatchCommand(mxComponent, ".uno:DropDownFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pMarkAccess->getAllMarksCount()); // Undo insertion - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Redo insertion - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pMarkAccess->getAllMarksCount()); } @@ -2015,7 +1998,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf106843) SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); // try to turn off red-lining - lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); // but the protection doesn't allow it CPPUNIT_ASSERT_MESSAGE("redlining should be on", @@ -2215,7 +2198,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120338) getProperty<OUString>(getParagraph(11), "ParaStyleName")); // reject tracked paragraph adjustments - lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(2), "ParaAdjust")); // left @@ -2255,7 +2238,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120338_multiple_paragraph_join) getProperty<OUString>(getParagraph(3), "ParaStyleName")); // reject tracked paragraph styles - lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(getParagraph(1), "ParaStyleName")); @@ -2320,7 +2303,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDateFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a date form field - lcl_dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); + dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -2336,11 +2319,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDateFormFieldInsertion) CPPUNIT_ASSERT_EQUAL(OUString(vEnSpaces, 5), xPara->getString()); // Undo insertion - lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Redo insertion - lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + dispatchCommand(mxComponent, ".uno:Redo", {}); aIter = pMarkAccess->getAllMarksBegin(); CPPUNIT_ASSERT(aIter != pMarkAccess->getAllMarksEnd()); pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>(*aIter); @@ -2357,7 +2340,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDateFormFieldContentOperations) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a date form field - lcl_dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); + dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -2390,7 +2373,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDateFormFieldCurrentDateHandling) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a date form field - lcl_dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); + dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -2444,7 +2427,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDateFormFieldCurrentDateInvalidation) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); // Insert a date form field - lcl_dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); + dispatchCommand(mxComponent, ".uno:DatePickerFormField", {}); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); // Check whether the fieldmark is created @@ -2572,17 +2555,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf118311) { "SearchItem.SearchString", uno::makeAny(OUString("a")) }, { "SearchItem.Backward", uno::makeAny(false) }, })); - lcl_dispatchCommand(mxComponent, ".uno:ExecuteSearch", aSearch); + dispatchCommand(mxComponent, ".uno:ExecuteSearch", aSearch); // .uno:Cut doesn't remove the table, only the selected content of the first cell - lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); xmlDocPtr pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "//page[1]//body/tab"); // .uno:SelectAll selects the whole table, and UNO command Cut cuts it - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -2698,7 +2681,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf90069) sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); - lcl_dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {}); + dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {}); pWrtShell->Down(false); pWrtShell->Insert("foo"); diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx index e25fc8fd2f67..0066160a985b 100644 --- a/unotest/source/cpp/macros_test.cxx +++ b/unotest/source/cpp/macros_test.cxx @@ -13,6 +13,8 @@ #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/document/MacroExecMode.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <cppunit/TestAssert.h> #include <rtl/ustrbuf.hxx> @@ -21,6 +23,7 @@ #include <osl/file.hxx> #include <osl/process.h> #include <osl/thread.h> +#include <comphelper/processfactory.hxx> using namespace css; @@ -115,6 +118,23 @@ void MacrosTest::tearDownNssGpg() (void)this; #endif } + +void MacrosTest::dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, + const OUString& rCommand, + const uno::Sequence<beans::PropertyValue>& rPropertyValues) +{ + uno::Reference<frame::XController> xController + = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); + CPPUNIT_ASSERT(xController.is()); + uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFrame.is()); + + uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); + uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); + CPPUNIT_ASSERT(xDispatchHelper.is()); + + xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 73e03fa8aa8e..d64411284c6c 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -63,30 +63,13 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMailMergeInEditeng) CPPUNIT_ASSERT(getComponent().is()); } -static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, - const OUString& rCommand, - const uno::Sequence<beans::PropertyValue>& rPropertyValues) -{ - uno::Reference<frame::XController> xController - = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); - CPPUNIT_ASSERT(xController.is()); - uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xFrame.is()); - - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); - CPPUNIT_ASSERT(xDispatchHelper.is()); - - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); -} - CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentResolved) { getComponent() = loadFromDesktop("private:factory/swriter"); uno::Sequence<beans::PropertyValue> aCommentProps = comphelper::InitPropertySequence({ { "Text", uno::makeAny(OUString("comment")) }, }); - lcl_dispatchCommand(getComponent(), ".uno:InsertAnnotation", aCommentProps); + dispatchCommand(getComponent(), ".uno:InsertAnnotation", aCommentProps); uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits