sd/qa/inc/sdtiledrenderingtest.hxx | 39 ++ sd/qa/unit/sdtiledrenderingtest.cxx | 143 ++++++++++ sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 1 sd/qa/unit/tiledrendering/tiledrendering.cxx | 76 ++--- sd/qa/unit/tiledrendering/tiledrendering2.cxx | 8 sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx | 195 -------------- 6 files changed, 224 insertions(+), 238 deletions(-)
New commits: commit f5072b3a106330d22b9b68a4a519a8f7636778c1 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Mar 13 08:18:47 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Mar 19 09:30:17 2025 +0100 sd: move ViewCallback to Library_sdqahelper Allows not including .cxx files in Impress tests. [ Pick to co-25.04, to reduce conflicts vs master. ] Change-Id: I86cbe9d68800b28ceb4e98bccaccfba5ea164f78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183113 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.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..bad449ce56c7 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,145 @@ 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) +{ + 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 6525e920fbbb..3892b36b5a85 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> #include <unopage.hxx> @@ -57,6 +58,7 @@ #include <sfx2/sidebar/Sidebar.hxx> #include <vcl/BitmapTools.hxx> #include <vcl/filter/PngImageWriter.hxx> +#include <sfx2/lokhelper.hxx> #include <chrono> #include <cstdlib> @@ -567,9 +569,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(); @@ -589,10 +591,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(); @@ -623,7 +625,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(); @@ -645,7 +647,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); @@ -666,7 +668,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(); @@ -715,7 +717,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(); @@ -747,7 +749,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(); @@ -766,7 +768,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); @@ -795,7 +797,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(); @@ -835,7 +837,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>()); @@ -929,7 +931,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(); @@ -950,7 +952,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); @@ -960,7 +962,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); @@ -984,7 +986,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) { @@ -1077,7 +1079,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); @@ -1090,7 +1092,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(); @@ -1326,7 +1328,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()); @@ -1351,7 +1353,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentCallbacks) { {".uno:Author", uno::Any(u"LOK User1"_ustr)}, })); - ViewCallback aView1; + SdTestViewCallback aView1; int nView1 = SfxLokHelper::getView(); SfxLokHelper::createView(); @@ -1360,7 +1362,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); @@ -1459,7 +1461,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( @@ -1505,7 +1507,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( @@ -1542,7 +1544,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(); @@ -1550,7 +1552,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 @@ -1580,7 +1582,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(); @@ -1588,7 +1590,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 @@ -2090,11 +2092,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 { @@ -2158,7 +2160,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( @@ -2173,7 +2175,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( @@ -2236,7 +2238,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 @@ -2346,7 +2348,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); @@ -2647,7 +2649,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(); @@ -2665,7 +2667,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(); @@ -4368,7 +4370,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/tiledrendering2.cxx b/sd/qa/unit/tiledrendering/tiledrendering2.cxx index c8d30c78cb00..e7c065825fb4 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 insrerting a signature line for electronic (extrenal) signing: aArgs = { diff --git a/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx b/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx deleted file mode 100644 index 7b76445e3e76..000000000000 --- a/sd/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx +++ /dev/null @@ -1,195 +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) - { - 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: */