sd/qa/inc/sdtiledrenderingtest.hxx | 39 ++ sd/qa/unit/sdtiledrenderingtest.cxx | 146 ++++++++++ sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 1 sd/qa/unit/tiledrendering/tiledrendering.cxx | 74 ++--- sd/qa/unit/tiledrendering/tiledrendering2.cxx | 10 sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx | 198 -------------- 6 files changed, 227 insertions(+), 241 deletions(-)
New commits: commit 8edf379304b1a36c7f29dc2108ace489cb7ee151 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Mar 13 08:18:47 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Mar 13 09:21:37 2025 +0100 sd: move ViewCallback to Library_sdqahelper Allows not including .cxx files in Impress tests. Change-Id: I86cbe9d68800b28ceb4e98bccaccfba5ea164f78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182851 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sd/qa/inc/sdtiledrenderingtest.hxx b/sd/qa/inc/sdtiledrenderingtest.hxx index e4504a3a657d..877747cf08eb 100644 --- a/sd/qa/inc/sdtiledrenderingtest.hxx +++ b/sd/qa/inc/sdtiledrenderingtest.hxx @@ -11,6 +11,8 @@ #include <test/unoapixml_test.hxx> +#include <boost/property_tree/json_parser.hpp> + #include <osl/conditn.hxx> #include <test/lokcallback.hxx> @@ -51,6 +53,43 @@ protected: TestLokCallbackWrapper m_callbackWrapper; }; +/// A view callback tracks callbacks invoked on one specific view. +class SDQAHELPER_DLLPUBLIC SdTestViewCallback final +{ + SfxViewShell* mpViewShell; + int mnView; + +public: + bool m_bGraphicSelectionInvalidated; + bool m_bGraphicViewSelectionInvalidated; + /// Our current part, to be able to decide if a view cursor/selection is relevant for us. + int m_nPart; + bool m_bCursorVisibleChanged; + bool m_bCursorVisible; + bool m_bViewLock; + bool m_bTilesInvalidated; + std::vector<tools::Rectangle> m_aInvalidations; + std::map<int, bool> m_aViewCursorInvalidations; + std::map<int, bool> m_aViewCursorVisibilities; + bool m_bViewSelectionSet; + boost::property_tree::ptree m_aCommentCallbackResult; + OString m_ShapeSelection; + std::vector<std::string> m_aStateChanged; + std::map<std::string, boost::property_tree::ptree> m_aStateChanges; + TestLokCallbackWrapper m_callbackWrapper; + bool invalidatedAll; + int editModeOfInvalidation; + int partOfInvalidation; + + SdTestViewCallback(); + + ~SdTestViewCallback(); + + static void callback(int nType, const char* pPayload, void* pData); + + void callbackImpl(int nType, const char* pPayload); +}; + #endif // INCLUDED_SD_QA_INC_SDTILEDRENDERINGTEST_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/sdtiledrenderingtest.cxx b/sd/qa/unit/sdtiledrenderingtest.cxx index cf8eba78bf65..09607dfff428 100644 --- a/sd/qa/unit/sdtiledrenderingtest.cxx +++ b/sd/qa/unit/sdtiledrenderingtest.cxx @@ -9,8 +9,6 @@ #include <sdtiledrenderingtest.hxx> -#include <boost/property_tree/json_parser.hpp> - #include <comphelper/lok.hxx> #include <comphelper/string.hxx> #include <sfx2/lokhelper.hxx> @@ -199,4 +197,148 @@ xmlDocUniquePtr SdTiledRenderingTest::parseXmlDump() return xmlDocUniquePtr(xmlParseDoc(pCharBuffer)); } +SdTestViewCallback::SdTestViewCallback() + : m_bGraphicSelectionInvalidated(false) + , m_bGraphicViewSelectionInvalidated(false) + , m_nPart(0) + , m_bCursorVisibleChanged(false) + , m_bCursorVisible(false) + , m_bViewLock(false) + , m_bTilesInvalidated(false) + , m_bViewSelectionSet(false) + , m_callbackWrapper(&callback, this) + , invalidatedAll(false) + , editModeOfInvalidation(0) + , partOfInvalidation(0) +{ + mpViewShell = SfxViewShell::Current(); + mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper); + mnView = SfxLokHelper::getView(); + m_callbackWrapper.setLOKViewId(mnView); +} + +SdTestViewCallback::~SdTestViewCallback() +{ + SfxLokHelper::setView(mnView); + mpViewShell->setLibreOfficeKitViewCallback(nullptr); +} + +void SdTestViewCallback::callback(int nType, const char* pPayload, void* pData) +{ + static_cast<SdTestViewCallback*>(pData)->callbackImpl(nType, pPayload); +} + +void SdTestViewCallback::callbackImpl(int nType, const char* pPayload) +{ + switch (nType) + { + case LOK_CALLBACK_INVALIDATE_TILES: + { + m_bTilesInvalidated = true; + OString text(pPayload); + if (!text.startsWith("EMPTY")) + { + uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated( + OUString::createFromAscii(pPayload)); + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); + tools::Rectangle aInvalidationRect; + aInvalidationRect.SetLeft(aSeq[0].toInt32()); + aInvalidationRect.SetTop(aSeq[1].toInt32()); + aInvalidationRect.setWidth(aSeq[2].toInt32()); + aInvalidationRect.setHeight(aSeq[3].toInt32()); + m_aInvalidations.push_back(aInvalidationRect); + } + else + { + editModeOfInvalidation = mpViewShell->getEditMode(); + partOfInvalidation = mpViewShell->getPart(); + invalidatedAll = true; + } + } + break; + case LOK_CALLBACK_GRAPHIC_SELECTION: + { + m_bGraphicSelectionInvalidated = true; + m_ShapeSelection = OString(pPayload); + } + break; + case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + if (aTree.get_child("part").get_value<int>() == m_nPart) + // Ignore callbacks which are for a different part. + m_bGraphicViewSelectionInvalidated = true; + } + break; + case LOK_CALLBACK_CURSOR_VISIBLE: + { + m_bCursorVisibleChanged = true; + m_bCursorVisible = (std::string_view("true") == pPayload); + } + break; + case LOK_CALLBACK_VIEW_LOCK: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; + } + break; + case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + int nViewId = aTree.get_child("viewId").get_value<int>(); + m_aViewCursorInvalidations[nViewId] = true; + } + break; + case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + const int nViewId = aTree.get_child("viewId").get_value<int>(); + m_aViewCursorVisibilities[nViewId] = std::string_view("true") == pPayload; + } + break; + case LOK_CALLBACK_TEXT_VIEW_SELECTION: + { + m_bViewSelectionSet = true; + } + break; + case LOK_CALLBACK_COMMENT: + { + m_aCommentCallbackResult.clear(); + std::stringstream aStream(pPayload); + boost::property_tree::read_json(aStream, m_aCommentCallbackResult); + m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment"); + } + break; + case LOK_CALLBACK_STATE_CHANGED: + { + std::stringstream aStream(pPayload); + if (!aStream.str().starts_with("{")) + { + m_aStateChanged.push_back(aStream.str()); + break; + } + + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + auto it = aTree.find("commandName"); + if (it == aTree.not_found()) + { + break; + } + + std::string aCommandName = it->second.get_value<std::string>(); + m_aStateChanges[aCommandName] = aTree; + } + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index f801354221d6..9bcf2893fea9 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -8,7 +8,6 @@ */ #include <sdtiledrenderingtest.hxx> -#include "tiledrenderingmodeltestbase.cxx" #include <test/helper/transferable.hxx> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index a6c3714a3b75..738cd9d2cd73 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -8,7 +8,6 @@ */ #include <sdtiledrenderingtest.hxx> -#include "tiledrenderingmodeltestbase.cxx" #include <app.hrc> #include <test/helper/transferable.hxx> @@ -42,6 +41,8 @@ #include <ViewShell.hxx> #include <SlideshowLayerRenderer.hxx> #include <sdpage.hxx> +#include <unomodel.hxx> +#include <drawdoc.hxx> #include <undo/undomanager.hxx> #include <sfx2/request.hxx> @@ -56,6 +57,7 @@ #include <sfx2/sidebar/Sidebar.hxx> #include <vcl/BitmapTools.hxx> #include <vcl/filter/PngImageWriter.hxx> +#include <sfx2/lokhelper.hxx> #include <chrono> #include <cstdlib> @@ -592,9 +594,9 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testViewCursors) { // Create two views. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; SfxLokHelper::createView(); - ViewCallback aView2; + SdTestViewCallback aView2; // Select the shape in the second view. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -614,10 +616,10 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testViewCursorParts) { // Create two views. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); - ViewCallback aView2; + SdTestViewCallback aView2; // Select the shape in the second view. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -648,7 +650,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorViews) // Create the first view. SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp"); int nView1 = SfxLokHelper::getView(); - ViewCallback aView1; + SdTestViewCallback aView1; // Begin text edit on the only object on the slide. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -670,7 +672,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorViews) // Make sure that typing in the first view causes an invalidation in the // second view as well, even if the second view was created after begin // text edit in the first view. - ViewCallback aView2; + SdTestViewCallback aView2; // This failed: the second view didn't get a lock notification, even if the // first view already started text edit. CPPUNIT_ASSERT(aView2.m_bViewLock); @@ -691,7 +693,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorVisibility_SingleClick) // Load doc. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; // Begin text edit on the only object on the slide. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -740,7 +742,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorVisibility_DoubleClick) // Create the first view. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; // Begin text edit on the only object on the slide. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -772,7 +774,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorVisibility_MultiView) // Create the first view. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); const int nView1 = SfxLokHelper::getView(); - ViewCallback aView1; + SdTestViewCallback aView1; // Begin text edit on the only object on the slide. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -791,7 +793,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorVisibility_MultiView) CPPUNIT_ASSERT_EQUAL(false, aView1.m_aViewCursorVisibilities[nView2]); // Also check that the second view gets the notifications. - ViewCallback aView2; + SdTestViewCallback aView2; SfxLokHelper::setView(nView1); @@ -820,7 +822,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCursorVisibility_Escape) { // Load doc. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; // Begin text edit on the only object on the slide. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -860,7 +862,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testViewLock) { // Load a document that has a shape and create two views. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); @@ -954,7 +956,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCreateViewGraphicSelection) { // Load a document and register a callback. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; // Select the only shape in the document and assert that the graphic selection is changed. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -975,7 +977,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCreateViewGraphicSelection) // Check that when the first view has a shape selected and we register a // callback on the second view, then it gets a "graphic view selection". - ViewCallback aView2; + SdTestViewCallback aView2; // This failed, the created new view had no "view selection" of the first // view's selected shape. CPPUNIT_ASSERT(aView2.m_bGraphicViewSelectionInvalidated); @@ -985,7 +987,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCreateViewTextCursor) { // Load a document and register a callback. SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; // Begin text edit. pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB); @@ -1009,7 +1011,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCreateViewTextCursor) aView1.m_aViewCursorVisibilities.clear(); SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering({}); - ViewCallback aView2; + SdTestViewCallback aView2; bool bFoundCursor = false; for (const auto& rInvalidation : aView1.m_aViewCursorInvalidations) { @@ -1102,7 +1104,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPostKeyEventInvalidation) // Load a document and begin text edit on the first slide. SdXImpressDocument* pXImpressDocument = createDoc("2slides.odp"); CPPUNIT_ASSERT_EQUAL(0, pXImpressDocument->getPart()); - ViewCallback aView1; + SdTestViewCallback aView1; sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdrView* pView = pViewShell->GetView(); pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); @@ -1115,7 +1117,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPostKeyEventInvalidation) // Create a second view and begin text edit there as well, in parallel. SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering({}); - ViewCallback aView2; + SdTestViewCallback aView2; pXImpressDocument->setPart(1); sd::ViewShell* pViewShell2 = pXImpressDocument->GetDocShell()->GetViewShell(); SdrView* pView2 = pViewShell2->GetView(); @@ -1351,7 +1353,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testShowAndUseGridCallbacks) SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); - ViewCallback aView; + SdTestViewCallback aView; dispatchCommand(mxComponent, ".uno:GridVisible", uno::Sequence<beans::PropertyValue>()); CPPUNIT_ASSERT(std::find(aView.m_aStateChanged.begin(), aView.m_aStateChanged.end(), ".uno:GridVisible=true") != aView.m_aStateChanged.end()); @@ -1376,7 +1378,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentCallbacks) { {".uno:Author", uno::Any(u"LOK User1"_ustr)}, })); - ViewCallback aView1; + SdTestViewCallback aView1; int nView1 = SfxLokHelper::getView(); SfxLokHelper::createView(); @@ -1385,7 +1387,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentCallbacks) {".uno:Author", uno::Any(u"LOK User2"_ustr)}, })); pXImpressDocument->initializeForTiledRendering(aArgs); - ViewCallback aView2; + SdTestViewCallback aView2; int nView2 = SfxLokHelper::getView(); SfxLokHelper::setView(nView1); @@ -1484,7 +1486,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentChangeImpress) {".uno:Author", uno::Any(u"LOK User1"_ustr)}, })); - ViewCallback aView1; + SdTestViewCallback aView1; // Add a new comment aArgs = comphelper::InitPropertySequence( @@ -1530,7 +1532,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentChangeDraw) {".uno:Author", uno::Any(u"LOK User1"_ustr)}, })); - ViewCallback aView1; + SdTestViewCallback aView1; // Add a new comment aArgs = comphelper::InitPropertySequence( @@ -1567,7 +1569,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testMultiViewInsertDeletePage) { // Load the document. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; int nView1 = SfxLokHelper::getView(); uno::Sequence<beans::PropertyValue> aArgs; SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc(); @@ -1575,7 +1577,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testMultiViewInsertDeletePage) // Create second view SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering(aArgs); - ViewCallback aView2; + SdTestViewCallback aView2; int nView2 = SfxLokHelper::getView(); // the document has 8 slides @@ -1605,7 +1607,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testMultiViewInsertDeletePage2) { // Load the document. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; int nView1 = SfxLokHelper::getView(); uno::Sequence<beans::PropertyValue> aArgs; SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc(); @@ -1613,7 +1615,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testMultiViewInsertDeletePage2) // Create second view SfxLokHelper::createView(); pXImpressDocument->initializeForTiledRendering(aArgs); - ViewCallback aView2; + SdTestViewCallback aView2; int nView2 = SfxLokHelper::getView(); // the document has 8 slides @@ -2115,11 +2117,11 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testGetViewRenderState) SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); int nFirstViewId = SfxLokHelper::getView(); - ViewCallback aView1; + SdTestViewCallback aView1; CPPUNIT_ASSERT_EQUAL("S;Default"_ostr, pXImpressDocument->getViewRenderState()); // Create a second view SfxLokHelper::createView(); - ViewCallback aView2; + SdTestViewCallback aView2; CPPUNIT_ASSERT_EQUAL("S;Default"_ostr, pXImpressDocument->getViewRenderState()); // Set to dark scheme { @@ -2183,7 +2185,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testThemeViewSeparation) } SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); int nFirstViewId = SfxLokHelper::getView(); - ViewCallback aView1; + SdTestViewCallback aView1; // Switch first view to light scheme { uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -2198,7 +2200,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testThemeViewSeparation) // Create second view SfxLokHelper::createView(); int nSecondViewId = SfxLokHelper::getView(); - ViewCallback aView2; + SdTestViewCallback aView2; // Set second view to dark scheme { uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -2261,7 +2263,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testInsertDeletePageInvalidation) { // Load the document. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; CPPUNIT_ASSERT_EQUAL(8, pXImpressDocument->getParts()); // Insert slide @@ -2371,7 +2373,7 @@ void lcl_extractHandleParameters(std::string_view selection, sal_uInt32& id, sal CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testMoveShapeHandle) { SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); - ViewCallback aView1; + SdTestViewCallback aView1; sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pPage = pViewShell->GetActualPage(); SdrObject* pObject = pPage->GetObj(0); @@ -2672,7 +2674,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarHide) { // Given an impress document, with a visible sidebar: createDoc("dummy.odp"); - ViewCallback aView; + SdTestViewCallback aView; sfx2::sidebar::Sidebar::Setup(u""); Scheduler::ProcessEventsToIdle(); aView.m_aStateChanges.clear(); @@ -2690,7 +2692,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarHide) CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testStartPresentation) { SdXImpressDocument* pXImpressDocument = createDoc("test.ppsx"); - ViewCallback aView; + SdTestViewCallback aView; CPPUNIT_ASSERT(pXImpressDocument->GetDoc()->GetStartWithPresentation()); Scheduler::ProcessEventsToIdle(); diff --git a/sd/qa/unit/tiledrendering/tiledrendering2.cxx b/sd/qa/unit/tiledrendering/tiledrendering2.cxx index 935d21f07324..a76db12e24f6 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering2.cxx @@ -8,7 +8,6 @@ */ #include <sdtiledrenderingtest.hxx> -#include "tiledrenderingmodeltestbase.cxx" #include <sfx2/sidebar/Sidebar.hxx> #include <vcl/scheduler.hxx> @@ -18,12 +17,15 @@ #include <DrawDocShell.hxx> #include <ViewShell.hxx> +#include <unomodel.hxx> + +using namespace css; CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarSwitchDeck) { // Given an impress document, with a visible sidebar (ModifyPage deck): createDoc("dummy.odp"); - ViewCallback aView; + SdTestViewCallback aView; sfx2::sidebar::Sidebar::Setup(u""); Scheduler::ProcessEventsToIdle(); aView.m_aStateChanges.clear(); @@ -54,7 +56,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testInsertSignatureLineExternal) sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell(); sd::View* pView = pViewShell->GetView(); pView->SetAuthor("myauthor"); - ViewCallback aView; + SdTestViewCallback aView; // When inserting a signature line for electronic (external) signing: aArgs = { @@ -114,7 +116,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testNotesViewInvalidations) { // Given a document with 2 slides. SdXImpressDocument* pXImpressDocument = createDoc("NotesView.odp"); - ViewCallback aView; + SdTestViewCallback aView; CPPUNIT_ASSERT_EQUAL(2, pXImpressDocument->getParts()); // Switching to the second slide. diff --git a/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx b/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx deleted file mode 100644 index 45e4f1bf080e..000000000000 --- a/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx +++ /dev/null @@ -1,198 +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/. - */ - -#include <test/unoapixml_test.hxx> - -#include <boost/property_tree/json_parser.hpp> -#include <LibreOfficeKit/LibreOfficeKitEnums.h> -#include <comphelper/string.hxx> -#include <sfx2/lokhelper.hxx> -#include <test/lokcallback.hxx> -#include <comphelper/lok.hxx> -#include <osl/conditn.hxx> -#include <drawdoc.hxx> -#include <unomodel.hxx> -#include <o3tl/string_view.hxx> - -using namespace css; - -/// A view callback tracks callbacks invoked on one specific view. -class ViewCallback final -{ - SfxViewShell* mpViewShell; - int mnView; - -public: - bool m_bGraphicSelectionInvalidated; - bool m_bGraphicViewSelectionInvalidated; - /// Our current part, to be able to decide if a view cursor/selection is relevant for us. - int m_nPart; - bool m_bCursorVisibleChanged; - bool m_bCursorVisible; - bool m_bViewLock; - bool m_bTilesInvalidated; - std::vector<tools::Rectangle> m_aInvalidations; - std::map<int, bool> m_aViewCursorInvalidations; - std::map<int, bool> m_aViewCursorVisibilities; - bool m_bViewSelectionSet; - boost::property_tree::ptree m_aCommentCallbackResult; - OString m_ShapeSelection; - std::vector<std::string> m_aStateChanged; - std::map<std::string, boost::property_tree::ptree> m_aStateChanges; - TestLokCallbackWrapper m_callbackWrapper; - bool invalidatedAll; - int editModeOfInvalidation; - int partOfInvalidation; - - ViewCallback() - : m_bGraphicSelectionInvalidated(false) - , m_bGraphicViewSelectionInvalidated(false) - , m_nPart(0) - , m_bCursorVisibleChanged(false) - , m_bCursorVisible(false) - , m_bViewLock(false) - , m_bTilesInvalidated(false) - , m_bViewSelectionSet(false) - , m_callbackWrapper(&callback, this) - , invalidatedAll(false) - , editModeOfInvalidation(0) - , partOfInvalidation(0) - { - mpViewShell = SfxViewShell::Current(); - mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper); - mnView = SfxLokHelper::getView(); - m_callbackWrapper.setLOKViewId(mnView); - } - - ~ViewCallback() - { - SfxLokHelper::setView(mnView); - mpViewShell->setLibreOfficeKitViewCallback(nullptr); - } - - static void callback(int nType, const char* pPayload, void* pData) - { - static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); - } - - void callbackImpl(int nType, const char* pPayload) - { - switch (nType) - { - case LOK_CALLBACK_INVALIDATE_TILES: - { - m_bTilesInvalidated = true; - OString text(pPayload); - if (!text.startsWith("EMPTY")) - { - uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated( - OUString::createFromAscii(pPayload)); - CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); - tools::Rectangle aInvalidationRect; - aInvalidationRect.SetLeft(aSeq[0].toInt32()); - aInvalidationRect.SetTop(aSeq[1].toInt32()); - aInvalidationRect.setWidth(aSeq[2].toInt32()); - aInvalidationRect.setHeight(aSeq[3].toInt32()); - m_aInvalidations.push_back(aInvalidationRect); - } - else - { - editModeOfInvalidation = mpViewShell->getEditMode(); - partOfInvalidation = mpViewShell->getPart(); - invalidatedAll = true; - } - } - break; - case LOK_CALLBACK_GRAPHIC_SELECTION: - { - m_bGraphicSelectionInvalidated = true; - m_ShapeSelection = OString(pPayload); - } - break; - case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: - { - std::stringstream aStream(pPayload); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - if (aTree.get_child("part").get_value<int>() == m_nPart) - // Ignore callbacks which are for a different part. - m_bGraphicViewSelectionInvalidated = true; - } - break; - case LOK_CALLBACK_CURSOR_VISIBLE: - { - m_bCursorVisibleChanged = true; - m_bCursorVisible = (std::string_view("true") == pPayload); - } - break; - case LOK_CALLBACK_VIEW_LOCK: - { - std::stringstream aStream(pPayload); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; - } - break; - case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: - { - std::stringstream aStream(pPayload); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - int nViewId = aTree.get_child("viewId").get_value<int>(); - m_aViewCursorInvalidations[nViewId] = true; - } - break; - case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: - { - std::stringstream aStream(pPayload); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - const int nViewId = aTree.get_child("viewId").get_value<int>(); - m_aViewCursorVisibilities[nViewId] = std::string_view("true") == pPayload; - } - break; - case LOK_CALLBACK_TEXT_VIEW_SELECTION: - { - m_bViewSelectionSet = true; - } - break; - case LOK_CALLBACK_COMMENT: - { - m_aCommentCallbackResult.clear(); - std::stringstream aStream(pPayload); - boost::property_tree::read_json(aStream, m_aCommentCallbackResult); - m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment"); - } - break; - case LOK_CALLBACK_STATE_CHANGED: - { - std::stringstream aStream(pPayload); - if (!aStream.str().starts_with("{")) - { - m_aStateChanged.push_back(aStream.str()); - break; - } - - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - auto it = aTree.find("commandName"); - if (it == aTree.not_found()) - { - break; - } - - std::string aCommandName = it->second.get_value<std::string>(); - m_aStateChanges[aCommandName] = aTree; - } - break; - } - } -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */