summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-10-21 12:09:56 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-22 15:54:18 +0200
commit5a2f4971c8e3f7c6b2caaad353ec1c2593499692 (patch)
tree1be8458bb9460d50fe3c7940da829b74c31299a7
parentaa1c19e2a366cff3d91e4455dde500a4011a3279 (diff)
revert unittests to use plain text-based LibreOfficeKitCallback
At least for now it seems that the more complex SfxLokCallbackInterface is just an unnecessary complication for unit tests. The performance doesn't matter, and handling all the specialized callbacks makes things more complicated. In the future it'd be also useful to make the tests (optionally?) use also CallbackFlushHandler as the provider of the messages, in order to test CallbackFlushHandler more thoroughly, so perhaps in the end it makes more sense to keep unit tests using the plain text interface. This reverts unittest-related parts of 3b729db05553c1a6d461fb41c89 and adds a smaller wrapper callback class that converts messages from SfxLokCallbackInterface to LibreOfficeKitCallback format. Change-Id: I6c14f0be4ed7b777444b131140be54188d309cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124004 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--include/test/lokcallback.hxx39
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx105
-rw-r--r--sd/qa/unit/tiledrendering/CallbackRecorder.hxx29
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx89
-rw-r--r--sw/qa/core/txtnode/txtnode.cxx30
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx120
-rw-r--r--test/Library_test.mk1
-rw-r--r--test/source/lokcallback.cxx55
8 files changed, 293 insertions, 175 deletions
diff --git a/include/test/lokcallback.hxx b/include/test/lokcallback.hxx
new file mode 100644
index 000000000000..988ce7688e93
--- /dev/null
+++ b/include/test/lokcallback.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+#include <test/testdllapi.hxx>
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
+#include <sfx2/lokcallback.hxx>
+
+/**
+A helper to convert SfxLokCallbackInterface to a LIbreOfficeKitCallback for tests.
+
+It reimplements the specialized callbacks and converts them to the generic type/payload
+callback.
+*/
+
+class OOO_DLLPUBLIC_TEST TestLokCallbackWrapper : public SfxLokCallbackInterface
+{
+public:
+ TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data);
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override;
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override;
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
+ int nPart) override;
+
+private:
+ void callCallback(int nType, const char* pPayload);
+ LibreOfficeKitCallback m_callback;
+ void* m_data;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 39571de2bed5..82287bfb2441 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -30,7 +30,6 @@
#include <comphelper/propertyvalue.hxx>
#include <sfx2/childwin.hxx>
#include <sfx2/lokhelper.hxx>
-#include <sfx2/lokcallback.hxx>
#include <svx/svdpage.hxx>
#include <vcl/svapp.hxx>
#include <vcl/scheduler.hxx>
@@ -41,6 +40,7 @@
#include <comphelper/string.hxx>
#include <tools/json_writer.hxx>
#include <docoptio.hxx>
+#include <test/lokcallback.hxx>
#include <chrono>
#include <cstddef>
@@ -66,10 +66,7 @@ namespace
char const DATA_DIRECTORY[] = "/sc/qa/unit/tiledrendering/data/";
-class ScTiledRenderingTest : public test::BootstrapFixture,
- public unotest::MacrosTest,
- public XmlTestTools,
- public SfxLokCallbackInterface
+class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
{
public:
ScTiledRenderingTest();
@@ -182,22 +179,21 @@ public:
CPPUNIT_TEST(testSheetViewDataCrash);
CPPUNIT_TEST_SUITE_END();
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override;
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override;
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int nPart) override;
-
private:
ScModelObj* createDoc(const char* pName);
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
/// document size changed callback.
osl::Condition m_aDocSizeCondition;
Size m_aDocumentSize;
uno::Reference<lang::XComponent> mxComponent;
+ TestLokCallbackWrapper m_callbackWrapper;
};
ScTiledRenderingTest::ScTiledRenderingTest()
+ : m_callbackWrapper(&callback, this)
{
}
@@ -242,6 +238,11 @@ ScModelObj* ScTiledRenderingTest::createDoc(const char* pName)
return pModelObj;
}
+void ScTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
+{
+ static_cast<ScTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
+}
+
/* TODO when needed...
static std::vector<OUString> lcl_convertSeparated(const OUString& rString, sal_Unicode nSeparator)
{
@@ -271,12 +272,7 @@ static void lcl_convertRectangle(const OUString& rString, Rectangle& rRectangle)
}
*/
-void ScTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload, int)
-{
- libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
-}
-
-void ScTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload)
+void ScTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
{
switch (nType)
{
@@ -294,10 +290,6 @@ void ScTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPa
}
}
-void ScTiledRenderingTest::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*, int)
-{
-}
-
void ScTiledRenderingTest::testRowColumnSelections()
{
comphelper::LibreOfficeKit::setActive();
@@ -408,7 +400,7 @@ void ScTiledRenderingTest::testDocumentSize()
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
CPPUNIT_ASSERT(pViewShell);
- pViewShell->setLibreOfficeKitViewCallback(this);
+ pViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// check initial document size
Size aDocSize = pModelObj->getDocumentSize();
@@ -569,7 +561,7 @@ struct TextSelectionMessage
};
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback final : public SfxLokCallbackInterface
+class ViewCallback final
{
SfxViewShell* mpViewShell;
int mnView;
@@ -592,6 +584,7 @@ public:
OString m_sInvalidateHeader;
OString m_sInvalidateSheetGeometry;
OString m_ShapeSelection;
+ TestLokCallbackWrapper m_callbackWrapper;
ViewCallback(bool bDeleteListenerOnDestruct=true)
: m_bOwnCursorInvalidated(false),
@@ -601,10 +594,11 @@ public:
m_bGraphicViewSelection(false),
m_bFullInvalidateTiles(false),
m_bInvalidateTiles(false),
- m_bViewLock(false)
+ m_bViewLock(false),
+ m_callbackWrapper(&callback, this)
{
mpViewShell = SfxViewShell::Current();
- mpViewShell->setLibreOfficeKitViewCallback(this);
+ mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
mnView = SfxLokHelper::getView();
if (!bDeleteListenerOnDestruct)
mpViewShell = nullptr;
@@ -619,12 +613,12 @@ public:
}
}
- void libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/)
+ static void callback(int nType, const char* pPayload, void* pData)
{
- libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
+ static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
}
- void libreOfficeKitViewCallback(int nType, const char* pPayload)
+ void callbackImpl(int nType, const char* pPayload)
{
switch (nType)
{
@@ -671,7 +665,28 @@ public:
}
break;
case LOK_CALLBACK_INVALIDATE_TILES:
- abort();
+ {
+ OString text(pPayload);
+ if (text.startsWith("EMPTY"))
+ {
+ m_bFullInvalidateTiles = true;
+ }
+ else
+ {
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+ tools::Rectangle aInvalidationRect;
+ aInvalidationRect.setX(aSeq[0].toInt32());
+ aInvalidationRect.setY(aSeq[1].toInt32());
+ aInvalidationRect.setWidth(aSeq[2].toInt32());
+ aInvalidationRect.setHeight(aSeq[3].toInt32());
+ m_aInvalidations.push_back(aInvalidationRect);
+ if (aSeq.getLength() == 5)
+ m_aInvalidationsParts.push_back(aSeq[4].toInt32());
+ m_bInvalidateTiles = true;
+ }
+ }
+ break;
case LOK_CALLBACK_CELL_FORMULA:
{
m_sCellFormula = pPayload;
@@ -706,20 +721,6 @@ public:
}
}
}
- void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart)
- {
- if (pRect == nullptr)
- {
- m_bFullInvalidateTiles = true;
- }
- else
- {
- m_aInvalidations.push_back(*pRect);
- if(nPart >= -1)
- m_aInvalidationsParts.push_back(nPart);
- m_bInvalidateTiles = true;
- }
- }
};
@@ -782,7 +783,7 @@ void ScTiledRenderingTest::testDocumentSizeChanged()
// Load a document that doesn't have much content.
createDoc("small.ods");
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(this);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Go to the A30 cell -- that will extend the document size.
uno::Sequence<beans::PropertyValue> aPropertyValues =
@@ -884,7 +885,7 @@ void ScTiledRenderingTest::testColRowResize()
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
CPPUNIT_ASSERT(pViewShell);
- pViewShell->setLibreOfficeKitViewCallback(this);
+ pViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
ScDocument& rDoc = pDocSh->GetDocument();
@@ -1951,6 +1952,8 @@ void ScTiledRenderingTest::testPageDownInvalidation()
void ScTiledRenderingTest::testSheetChangeInvalidation()
{
comphelper::LibreOfficeKit::setActive();
+ const bool oldPartInInvalidation = comphelper::LibreOfficeKit::isPartInInvalidation();
+ comphelper::LibreOfficeKit::setPartInInvalidation(true);
ScModelObj* pModelObj = createDoc("two_sheets.ods");
ScViewData* pViewData = ScDocShell::GetViewData();
@@ -1971,8 +1974,10 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1310720, 268435456), aView1.m_aInvalidations[0]);
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), aView1.m_aInvalidations[1]);
- CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidationsParts.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidationsParts.size());
CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), aView1.m_aInvalidationsParts[0]);
+ CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), aView1.m_aInvalidationsParts[1]);
+ comphelper::LibreOfficeKit::setPartInInvalidation(oldPartInInvalidation);
}
void ScTiledRenderingTest::testInsertDeletePageInvalidation()
@@ -2125,7 +2130,6 @@ void ScTiledRenderingTest::testRowColumnHeaders()
// view #1
ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
// view #2
@@ -2133,7 +2137,6 @@ void ScTiledRenderingTest::testRowColumnHeaders()
int nView2 = SfxLokHelper::getView();
ViewCallback aView2;
pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView2);
// ViewRowColumnHeaders test
SfxLokHelper::setView(nView1);
@@ -2389,14 +2392,12 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
// view #1
ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
// view #2
SfxLokHelper::createView();
int nView2 = SfxLokHelper::getView();
ViewCallback aView2;
pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView2);
// Try with the default empty document once (nIdx = 0) and then with sheet geometry settings (nIdx = 1)
for (size_t nIdx = 0; nIdx < 2; ++nIdx)
@@ -2496,7 +2497,6 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
// view #1
ViewCallback aView1;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
// with the default empty sheet and test the JSON encoding.
OString aGeomDefaultStr = pModelObj->getSheetGeometryData(/*bColumns*/ true, /*bRows*/ true, /*bSizes*/ true,
@@ -2525,7 +2525,6 @@ void ScTiledRenderingTest::testDeleteCellMultilineContent()
// view #1
ViewCallback aView1;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
aView1.m_sInvalidateHeader = "";
@@ -2565,7 +2564,6 @@ void ScTiledRenderingTest::testPasteIntoWrapTextCell()
CPPUNIT_ASSERT(pViewData);
ViewCallback aView;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
@@ -2603,7 +2601,6 @@ void ScTiledRenderingTest::testSortAscendingDescending()
ScDocument* pDoc = pModelObj->GetDocument();
ViewCallback aView;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
// select the values in the first column
pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 551, 129, 1, MOUSE_LEFT, 0);
@@ -2716,7 +2713,6 @@ void ScTiledRenderingTest::testEditCursorBounds()
ScDocument* pDoc = pModelObj->GetDocument();
ViewCallback aView;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView);
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
@@ -2761,7 +2757,6 @@ void ScTiledRenderingTest::testTextSelectionBounds()
ScDocument* pDoc = pModelObj->GetDocument();
ViewCallback aView;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView);
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
index 6c4faf81edae..a10a1659699d 100644
--- a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
+++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
@@ -14,7 +14,7 @@
#include <comphelper/string.hxx>
#include <osl/conditn.hxx>
#include <sfx2/viewsh.hxx>
-#include <sfx2/lokcallback.hxx>
+#include <test/lokcallback.hxx>
namespace
{
@@ -45,7 +45,7 @@ void lcl_convertRectangle(const OUString& rString, tools::Rectangle& rRectangle)
}
}
-struct CallbackRecorder : public SfxLokCallbackInterface
+struct CallbackRecorder
{
CallbackRecorder()
: m_bFound(true)
@@ -53,6 +53,7 @@ struct CallbackRecorder : public SfxLokCallbackInterface
, m_nSelectionBeforeSearchResult(0)
, m_nSelectionAfterSearchResult(0)
, m_nSearchResultCount(0)
+ , m_callbackWrapper(&callback, this)
{
}
@@ -67,17 +68,24 @@ struct CallbackRecorder : public SfxLokCallbackInterface
int m_nSearchResultCount;
/// For document size changed callback.
osl::Condition m_aDocumentSizeCondition;
+ TestLokCallbackWrapper m_callbackWrapper;
- void libreOfficeKitViewCallback(int nType, const char* pPayload) override
+ static void callback(int nType, const char* pPayload, void* pData)
{
- libreOfficeKitViewCallback(nType, pPayload, -1);
+ static_cast<CallbackRecorder*>(pData)->processCallback(nType, pPayload);
}
- void libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/) override
+
+ void processCallback(int nType, const char* pPayload)
{
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- abort();
+ {
+ OUString aPayload = OUString::createFromAscii(pPayload);
+ if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
+ lcl_convertRectangle(aPayload, m_aInvalidation);
+ }
+ break;
case LOK_CALLBACK_TEXT_SELECTION:
{
OUString aPayload = OUString::createFromAscii(pPayload);
@@ -131,16 +139,9 @@ struct CallbackRecorder : public SfxLokCallbackInterface
}
}
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int /*nPart*/) override
- {
- if (pRect != nullptr && m_aInvalidation.IsEmpty())
- m_aInvalidation = *pRect;
- }
-
void registerCallbacksFor(SfxViewShell& rViewShell)
{
- rViewShell.setLibreOfficeKitViewCallback(this);
+ rViewShell.setLibreOfficeKitViewCallback(&m_callbackWrapper);
}
};
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 211622a795bf..63c8a75e0d96 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -15,7 +15,6 @@
#include <boost/property_tree/json_parser.hpp>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <sfx2/lokhelper.hxx>
-#include <sfx2/lokcallback.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/dispatchcommand.hxx>
#include <comphelper/processfactory.hxx>
@@ -40,6 +39,7 @@
#include <svx/svdoutl.hxx>
#include <unotools/datetime.hxx>
#include <tools/UnitConversion.hxx>
+#include <test/lokcallback.hxx>
#include <DrawDocShell.hxx>
#include <ViewShellBase.hxx>
@@ -72,7 +72,7 @@ static std::ostream& operator<<(std::ostream& os, ViewShellId id)
return os;
}
-class SdTiledRenderingTest : public SdModelTestBase, public XmlTestTools, public SfxLokCallbackInterface
+class SdTiledRenderingTest : public SdModelTestBase, public XmlTestTools
{
public:
SdTiledRenderingTest();
@@ -194,13 +194,10 @@ public:
CPPUNIT_TEST_SUITE_END();
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override;
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override;
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int nPart) override;
-
private:
SdXImpressDocument* createDoc(const char* pName, const uno::Sequence<beans::PropertyValue>& rArguments = uno::Sequence<beans::PropertyValue>());
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
xmlDocUniquePtr parseXmlDump();
uno::Reference<lang::XComponent> mxComponent;
@@ -216,6 +213,7 @@ private:
/// For document size changed callback.
osl::Condition m_aDocumentSizeCondition;
xmlBufferPtr m_pXmlBuffer;
+ TestLokCallbackWrapper m_callbackWrapper;
};
SdTiledRenderingTest::SdTiledRenderingTest()
@@ -223,7 +221,8 @@ SdTiledRenderingTest::SdTiledRenderingTest()
m_nPart(0),
m_nSelectionBeforeSearchResult(0),
m_nSelectionAfterSearchResult(0),
- m_pXmlBuffer(nullptr)
+ m_pXmlBuffer(nullptr),
+ m_callbackWrapper(&callback, this)
{
}
@@ -262,6 +261,11 @@ SdXImpressDocument* SdTiledRenderingTest::createDoc(const char* pName, const uno
return pImpressDocument;
}
+void SdTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
+{
+ static_cast<SdTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
+}
+
namespace
{
@@ -294,17 +298,17 @@ void lcl_convertRectangle(const OUString& rString, ::tools::Rectangle& rRectangl
} // end anonymous namespace
-void SdTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/)
-{
- libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
-}
-
-void SdTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload)
+void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
{
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- abort();
+ {
+ OUString aPayload = OUString::createFromAscii(pPayload);
+ if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
+ lcl_convertRectangle(aPayload, m_aInvalidation);
+ }
+ break;
case LOK_CALLBACK_TEXT_SELECTION:
{
OUString aPayload = OUString::createFromAscii(pPayload);
@@ -354,13 +358,6 @@ void SdTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPa
}
}
-void SdTiledRenderingTest::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int /*nPart*/)
-{
- if (pRect != nullptr && m_aInvalidation.IsEmpty())
- m_aInvalidation = *pRect;
-}
-
xmlDocUniquePtr SdTiledRenderingTest::parseXmlDump()
{
if (m_pXmlBuffer)
@@ -400,7 +397,7 @@ void SdTiledRenderingTest::testRegisterCallback()
{
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(this);
+ pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Start text edit of the empty title shape.
SdPage* pActualPage = pViewShell->GetActualPage();
@@ -630,7 +627,7 @@ void SdTiledRenderingTest::testInsertDeletePage()
{
SdXImpressDocument* pXImpressDocument = createDoc("insert-delete.odp");
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(this);
+ pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(&m_callbackWrapper);
SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc();
CPPUNIT_ASSERT(pDoc);
@@ -882,7 +879,7 @@ void SdTiledRenderingTest::testResizeTableColumn()
namespace {
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback final : public SfxLokCallbackInterface
+class ViewCallback final
{
SfxViewShell* mpViewShell;
int mnView;
@@ -901,6 +898,7 @@ public:
bool m_bViewSelectionSet;
boost::property_tree::ptree m_aCommentCallbackResult;
OString m_ShapeSelection;
+ TestLokCallbackWrapper m_callbackWrapper;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
@@ -910,10 +908,11 @@ public:
m_bCursorVisible(false),
m_bViewLock(false),
m_bTilesInvalidated(false),
- m_bViewSelectionSet(false)
+ m_bViewSelectionSet(false),
+ m_callbackWrapper(&callback, this)
{
mpViewShell = SfxViewShell::Current();
- mpViewShell->setLibreOfficeKitViewCallback(this);
+ mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
mnView = SfxLokHelper::getView();
}
@@ -923,17 +922,32 @@ public:
mpViewShell->setLibreOfficeKitViewCallback(nullptr);
}
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override
+ static void callback(int nType, const char* pPayload, void* pData)
{
- libreOfficeKitViewCallback(nType, pPayload, -1);
+ static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
}
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override
+ void callbackImpl(int nType, const char* pPayload)
{
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- abort();
+ {
+ 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.setX(aSeq[0].toInt32());
+ aInvalidationRect.setY(aSeq[1].toInt32());
+ aInvalidationRect.setWidth(aSeq[2].toInt32());
+ aInvalidationRect.setHeight(aSeq[3].toInt32());
+ m_aInvalidations.push_back(aInvalidationRect);
+ }
+ }
+ break;
case LOK_CALLBACK_GRAPHIC_SELECTION:
{
m_bGraphicSelectionInvalidated = true;
@@ -969,7 +983,7 @@ public:
std::stringstream aStream(pPayload);
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
- nViewId = aTree.get_child("viewId").get_value<int>();
+ int nViewId = aTree.get_child("viewId").get_value<int>();
m_aViewCursorInvalidations[nViewId] = true;
}
break;
@@ -978,7 +992,7 @@ public:
std::stringstream aStream(pPayload);
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
- nViewId = aTree.get_child("viewId").get_value<int>();
+ const int nViewId = aTree.get_child("viewId").get_value<int>();
m_aViewCursorVisibilities[nViewId] = OString("true") == pPayload;
}
break;
@@ -997,13 +1011,6 @@ public:
break;
}
}
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int /*nPart*/) override
- {
- m_bTilesInvalidated = true;
- if (pRect != nullptr)
- m_aInvalidations.push_back(*pRect);
- }
};
}
@@ -2453,7 +2460,7 @@ void SdTiledRenderingTest::testCutSelectionChange()
CPPUNIT_ASSERT(pXImpressDocument);
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(this);
+ pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(&m_callbackWrapper);
Scheduler::ProcessEventsToIdle();
// Select first text object
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 7ea6f7f6bbed..78eecb14a631 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -12,9 +12,9 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
-#include <sfx2/lokcallback.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/scheduler.hxx>
+#include <test/lokcallback.hxx>
#include <IDocumentStatistics.hxx>
#include <fmtanchr.hxx>
@@ -92,17 +92,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxNodeSplit)
namespace
{
-struct ViewCallback : public SfxLokCallbackInterface
+struct ViewCallback
{
int m_nInvalidations = 0;
- virtual void libreOfficeKitViewCallback(int, const char*) override {}
- virtual void libreOfficeKitViewCallback(int, const char*, int) override {}
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*, int) override
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
+};
+
+void ViewCallback::callback(int nType, const char* pPayload, void* pData)
+{
+ static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
+}
+
+void ViewCallback::callbackImpl(int nType, const char* /*pPayload*/)
+{
+ switch (nType)
{
- ++m_nInvalidations;
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ {
+ ++m_nInvalidations;
+ }
+ break;
}
-};
+}
}
CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTitleFieldInvalidate)
@@ -119,7 +132,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTitleFieldInvalidate)
SwWrtShell* pWrtShell = pShell->GetWrtShell();
pWrtShell->SttEndDoc(/*bStt=*/false);
ViewCallback aCallback;
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&aCallback);
+ TestLokCallbackWrapper aCallbackWrapper(&ViewCallback::callback, &aCallback);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&aCallbackWrapper);
Scheduler::ProcessEventsToIdle();
aCallback.m_nInvalidations = 0;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 73e38f2f8973..475e64fb3393 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -40,7 +40,6 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/lokhelper.hxx>
-#include <sfx2/lokcallback.hxx>
#include <vcl/scheduler.hxx>
#include <vcl/vclevent.hxx>
#include <vcl/bitmapaccess.hxx>
@@ -49,6 +48,7 @@
#include <unotools/mediadescriptor.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <test/lokcallback.hxx>
#include <drawdoc.hxx>
#include <ndtxt.hxx>
@@ -75,7 +75,7 @@ static std::ostream& operator<<(std::ostream& os, ViewShellId id)
}
/// Testsuite for the SwXTextDocument methods implementing the vcl::ITiledRenderable interface.
-class SwTiledRenderingTest : public SwModelTestBase, public SfxLokCallbackInterface
+class SwTiledRenderingTest : public SwModelTestBase
{
public:
SwTiledRenderingTest();
@@ -241,13 +241,10 @@ public:
CPPUNIT_TEST(testMoveShapeHandle);
CPPUNIT_TEST_SUITE_END();
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override;
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override;
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int nPart) override;
-
private:
SwXTextDocument* createDoc(const char* pName = nullptr);
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
// First invalidation.
tools::Rectangle m_aInvalidation;
/// Union of all invalidations.
@@ -267,6 +264,7 @@ private:
OString m_sHyperlinkLink;
OString m_aFormFieldButton;
OString m_ShapeSelection;
+ TestLokCallbackWrapper m_callbackWrapper;
};
SwTiledRenderingTest::SwTiledRenderingTest()
@@ -276,7 +274,8 @@ SwTiledRenderingTest::SwTiledRenderingTest()
m_nInvalidations(0),
m_nRedlineTableSizeChanged(0),
m_nRedlineTableEntryModified(0),
- m_nTrackedChangeIndex(-1)
+ m_nTrackedChangeIndex(-1),
+ m_callbackWrapper(&callback, this)
{
}
@@ -321,18 +320,35 @@ SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
return pTextDocument;
}
-void SwTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/)
+void SwTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
{
- libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
+ static_cast<SwTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
}
-void SwTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload)
+void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
{
OString aPayload(pPayload);
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- abort();
+ {
+ tools::Rectangle aInvalidation;
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ if (OString("EMPTY") == pPayload)
+ return;
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+ aInvalidation.setX(aSeq[0].toInt32());
+ aInvalidation.setY(aSeq[1].toInt32());
+ aInvalidation.setWidth(aSeq[2].toInt32());
+ aInvalidation.setHeight(aSeq[3].toInt32());
+ if (m_aInvalidation.IsEmpty())
+ {
+ m_aInvalidation = aInvalidation;
+ }
+ m_aInvalidations.Union(aInvalidation);
+ ++m_nInvalidations;
+ }
+ break;
case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
{
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
@@ -415,24 +431,14 @@ void SwTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPa
}
break;
}
-}
-void SwTiledRenderingTest::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int /*nPart*/)
-{
- if(pRect == nullptr)
- return;
- if (m_aInvalidation.IsEmpty())
- m_aInvalidation = *pRect;
- m_aInvalidations.Union(*pRect);
- ++m_nInvalidations;
}
void SwTiledRenderingTest::testRegisterCallback()
{
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Insert a character at the beginning of the document.
pWrtShell->Insert("x");
pWrtShell->GetSfxViewShell()->flushPendingLOKInvalidateTiles();
@@ -615,7 +621,7 @@ void SwTiledRenderingTest::testSearch()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
std::size_t nNode = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
// First hit, in the second paragraph, before the shape.
@@ -680,7 +686,7 @@ void SwTiledRenderingTest::testSearchTextFrame()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
@@ -695,7 +701,7 @@ void SwTiledRenderingTest::testSearchTextFrameWrapAround()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
@@ -713,7 +719,7 @@ void SwTiledRenderingTest::testDocumentSizeChanged()
// Get the current document size.
SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
Size aSize = pXTextDocument->getDocumentSize();
// Delete the second page and see how the size changes.
@@ -729,7 +735,7 @@ void SwTiledRenderingTest::testSearchAll()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
@@ -747,7 +753,7 @@ void SwTiledRenderingTest::testSearchAllNotifications()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Reset notification counter before search.
m_nSelectionBeforeSearchResult = 0;
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
@@ -774,7 +780,7 @@ void SwTiledRenderingTest::testPageDownInvalidation()
}));
pXTextDocument->initializeForTiledRendering(aPropertyValues);
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
comphelper::dispatchCommand(".uno:PageDown", uno::Sequence<beans::PropertyValue>());
// This was 2.
@@ -794,7 +800,7 @@ void SwTiledRenderingTest::testPartHash()
namespace {
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback final : public SfxLokCallbackInterface
+class ViewCallback final
{
SfxViewShell* mpViewShell;
int mnView;
@@ -821,6 +827,7 @@ public:
boost::property_tree::ptree m_aRedlineTableModified;
/// Post-it / annotation payload.
boost::property_tree::ptree m_aComment;
+ TestLokCallbackWrapper m_callbackWrapper;
ViewCallback(SfxViewShell* pViewShell = nullptr, std::function<void(ViewCallback&)> const & rBeforeInstallFunc = {})
: m_bOwnCursorInvalidated(false),
@@ -834,14 +841,15 @@ public:
m_bGraphicViewSelection(false),
m_bGraphicSelection(false),
m_bViewLock(false),
- m_bCalled(false)
+ m_bCalled(false),
+ m_callbackWrapper(&callback, this)
{
// Because one call-site wants to set the bool fields up before the callback is installed
if (rBeforeInstallFunc)
rBeforeInstallFunc(*this);
mpViewShell = pViewShell ? pViewShell : SfxViewShell::Current();
- mpViewShell->setLibreOfficeKitViewCallback(this);
+ mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
mnView = SfxLokHelper::getView();
}
@@ -856,19 +864,22 @@ public:
mpViewShell->flushPendingLOKInvalidateTiles();
}
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/) override
+ static void callback(int nType, const char* pPayload, void* pData)
{
- libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
+ static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
}
- virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override
+ void callbackImpl(int nType, const char* pPayload)
{
OString aPayload(pPayload);
m_bCalled = true;
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- abort();
+ {
+ m_bTilesInvalidated = true;
+ }
+ break;
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
m_bOwnCursorInvalidated = true;
@@ -980,11 +991,6 @@ public:
break;
}
}
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*,
- int) override
- {
- m_bTilesInvalidated = true;
- }
};
class TestResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
@@ -1518,7 +1524,7 @@ void SwTiledRenderingTest::testTrackChangesCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Turn on track changes and type "x".
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
@@ -1545,7 +1551,7 @@ void SwTiledRenderingTest::testRedlineUpdateCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Turn on track changes, type "xx" and delete the second one.
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
@@ -2336,7 +2342,7 @@ void SwTiledRenderingTest::testSplitNodeRedlineCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("splitnode_redline_callback.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// 1. test case
// Move cursor between the two tracked changes
@@ -2394,7 +2400,7 @@ void SwTiledRenderingTest::testDeleteNodeRedlineCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("removenode_redline_callback.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// 1. test case
// Move cursor between the two tracked changes
@@ -2746,7 +2752,7 @@ void SwTiledRenderingTest::testRedlineNotificationDuringSave()
// It's an empty document, just settings.xml and content.xml are custom.
SwXTextDocument* pXTextDocument = createDoc("redline-notification-during-save.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Save the document.
utl::MediaDescriptor aMediaDescriptor;
@@ -2762,7 +2768,7 @@ void SwTiledRenderingTest::testHyperlink()
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
SwXTextDocument* pXTextDocument = createDoc("hyperlink.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
Point aStart = pShellCursor->GetSttPos();
@@ -2789,7 +2795,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButton()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -2862,7 +2868,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonEditing()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -2919,7 +2925,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonNoSelection()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -2972,7 +2978,7 @@ void SwTiledRenderingTest::testMoveShapeHandle()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
pWrtShell->SelectObj(Point(), 0, pObject);
@@ -3005,7 +3011,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonNoItem()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -3042,7 +3048,7 @@ void SwTiledRenderingTest::testTablePaintInvalidate()
// Load a document with a table in it.
SwXTextDocument* pXTextDocument = createDoc("table-paint-invalidate.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
// Enter the table.
pWrtShell->Down(/*bSelect=*/false);
Scheduler::ProcessEventsToIdle();
@@ -3140,7 +3146,7 @@ void SwTiledRenderingTest::testBulletDeleteInvalidation()
pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(),
pWrtShell->GetLayout()->getFrameArea());
Scheduler::ProcessEventsToIdle();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
m_aInvalidations = tools::Rectangle();
// When pressing backspace in the last paragraph.
@@ -3170,7 +3176,7 @@ void SwTiledRenderingTest::testBulletNoNumInvalidation()
pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(),
pWrtShell->GetLayout()->getFrameArea());
Scheduler::ProcessEventsToIdle();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
m_aInvalidations = tools::Rectangle();
// When pressing backspace in the last paragraph to turn bullets off.
@@ -3207,7 +3213,7 @@ void SwTiledRenderingTest::testBulletMultiDeleteInvalidation()
pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(),
pWrtShell->GetLayout()->getFrameArea());
Scheduler::ProcessEventsToIdle();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
m_aInvalidations = tools::Rectangle();
// When selecting and deleting several bullets: select till the end of the 2nd para and delete.
diff --git a/test/Library_test.mk b/test/Library_test.mk
index 4be059857a84..8b1fd214490d 100644
--- a/test/Library_test.mk
+++ b/test/Library_test.mk
@@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/htmltesttools \
test/source/screenshot_test \
test/source/unoapi_property_testers \
+ test/source/lokcallback \
test/source/helper/form \
test/source/helper/shape \
test/source/helper/transferable \
diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx
new file mode 100644
index 000000000000..912fe2d8c807
--- /dev/null
+++ b/test/source/lokcallback.cxx
@@ -0,0 +1,55 @@
+/* -*- 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/lokcallback.hxx>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <rtl/strbuf.hxx>
+#include <tools/gen.hxx>
+#include <comphelper/lok.hxx>
+
+TestLokCallbackWrapper::TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data)
+ : m_callback(callback)
+ , m_data(data)
+{
+}
+
+inline void TestLokCallbackWrapper::callCallback(int nType, const char* pPayload)
+{
+ m_callback(nType, pPayload, m_data);
+}
+
+void TestLokCallbackWrapper::libreOfficeKitViewCallback(int nType, const char* pPayload)
+{
+ callCallback(nType, pPayload);
+}
+
+void TestLokCallbackWrapper::libreOfficeKitViewCallback(int nType, const char* pPayload,
+ int /*nViewId*/)
+{
+ callCallback(nType, pPayload); // the view id is also included in payload
+}
+
+void TestLokCallbackWrapper::libreOfficeKitViewInvalidateTilesCallback(
+ const tools::Rectangle* pRect, int nPart)
+{
+ OStringBuffer buf(64);
+ if (pRect)
+ buf.append(pRect->toString());
+ else
+ buf.append("EMPTY");
+ if (comphelper::LibreOfficeKit::isPartInInvalidation())
+ {
+ buf.append(", ");
+ buf.append(static_cast<sal_Int32>(nPart));
+ }
+ callCallback(LOK_CALLBACK_INVALIDATE_TILES, buf.makeStringAndClear().getStr());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */