summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ac0ca40d241d..351f1f12644f 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -28,7 +28,6 @@
#include <comphelper/propertyvalue.hxx>
#include <sfx2/childwin.hxx>
#include <sfx2/lokhelper.hxx>
-#include <sfx2/lokcallback.hxx>
#include <svx/svdpage.hxx>
#include <vcl/scheduler.hxx>
#include <vcl/vclevent.hxx>
@@ -37,6 +36,7 @@
#include <comphelper/string.hxx>
#include <tools/json_writer.hxx>
#include <docoptio.hxx>
+#include <test/lokcallback.hxx>
#include <chrono>
#include <cstddef>
@@ -62,10 +62,7 @@ namespace
constexpr OUStringLiteral DATA_DIRECTORY = u"/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();
@@ -180,22 +177,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)
{
}
@@ -240,6 +236,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)
{
@@ -269,12 +270,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)
{
@@ -292,10 +288,6 @@ void ScTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPa
}
}
-void ScTiledRenderingTest::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*, int)
-{
-}
-
void ScTiledRenderingTest::testRowColumnSelections()
{
comphelper::LibreOfficeKit::setActive();
@@ -406,7 +398,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();
@@ -567,7 +559,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;
@@ -590,6 +582,7 @@ public:
OString m_sInvalidateHeader;
OString m_sInvalidateSheetGeometry;
OString m_ShapeSelection;
+ TestLokCallbackWrapper m_callbackWrapper;
ViewCallback(bool bDeleteListenerOnDestruct=true)
: m_bOwnCursorInvalidated(false),
@@ -599,10 +592,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;
@@ -617,12 +611,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)
{
@@ -669,7 +663,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.SetLeft(aSeq[0].toInt32());
+ aInvalidationRect.SetTop(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;
@@ -704,20 +719,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;
- }
- }
};
@@ -780,7 +781,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 =
@@ -882,7 +883,7 @@ void ScTiledRenderingTest::testColRowResize()
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
CPPUNIT_ASSERT(pViewShell);
- pViewShell->setLibreOfficeKitViewCallback(this);
+ pViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
ScDocument& rDoc = pDocSh->GetDocument();
@@ -1949,6 +1950,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();
@@ -1969,8 +1972,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()
@@ -2123,7 +2128,6 @@ void ScTiledRenderingTest::testRowColumnHeaders()
// view #1
ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
// view #2
@@ -2131,7 +2135,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);
@@ -2387,14 +2390,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)
@@ -2494,7 +2495,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,
@@ -2523,7 +2523,6 @@ void ScTiledRenderingTest::testDeleteCellMultilineContent()
// view #1
ViewCallback aView1;
- SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
aView1.m_sInvalidateHeader = "";
@@ -2563,7 +2562,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());
@@ -2601,7 +2599,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);
@@ -2749,7 +2746,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);
@@ -2794,7 +2790,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 60092ba50ca1..306a90f8d3bd 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 2d354dc39b03..e2a0e8a46501 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -18,7 +18,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>
@@ -42,6 +41,7 @@
#include <svx/svdoutl.hxx>
#include <unotools/datetime.hxx>
#include <tools/UnitConversion.hxx>
+#include <test/lokcallback.hxx>
#include <DrawDocShell.hxx>
#include <ViewShellBase.hxx>
@@ -76,7 +76,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();
@@ -201,13 +201,10 @@ public:
CPPUNIT_TEST(testShapeEditInMultipleViews);
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;
@@ -223,6 +220,7 @@ private:
/// For document size changed callback.
osl::Condition m_aDocumentSizeCondition;
xmlBufferPtr m_pXmlBuffer;
+ TestLokCallbackWrapper m_callbackWrapper;
};
SdTiledRenderingTest::SdTiledRenderingTest()
@@ -230,7 +228,8 @@ SdTiledRenderingTest::SdTiledRenderingTest()
m_nPart(0),
m_nSelectionBeforeSearchResult(0),
m_nSelectionAfterSearchResult(0),
- m_pXmlBuffer(nullptr)
+ m_pXmlBuffer(nullptr),
+ m_callbackWrapper(&callback, this)
{
}
@@ -269,6 +268,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
{
@@ -301,17 +305,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);
@@ -361,13 +365,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)
@@ -407,7 +404,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();
@@ -637,7 +634,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);
@@ -889,7 +886,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;
@@ -908,6 +905,7 @@ public:
bool m_bViewSelectionSet;
boost::property_tree::ptree m_aCommentCallbackResult;
OString m_ShapeSelection;
+ TestLokCallbackWrapper m_callbackWrapper;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
@@ -917,10 +915,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();
}
@@ -930,17 +929,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.SetLeft(aSeq[0].toInt32());
+ aInvalidationRect.SetTop(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;
@@ -976,7 +990,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;
@@ -985,7 +999,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] = std::string_view("true") == pPayload;
}
break;
@@ -1004,13 +1018,6 @@ public:
break;
}
}
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
- int /*nPart*/) override
- {
- m_bTilesInvalidated = true;
- if (pRect != nullptr)
- m_aInvalidations.push_back(*pRect);
- }
};
}
@@ -2527,7 +2534,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 49472c25cecd..6dc5b55cc28f 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 3080b0bfd3f2..2bc101923b41 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -41,7 +41,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/BitmapReadAccess.hxx>
@@ -50,6 +49,7 @@
#include <unotools/mediadescriptor.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <test/lokcallback.hxx>
#include <drawdoc.hxx>
#include <ndtxt.hxx>
@@ -76,7 +76,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();
@@ -244,13 +244,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.
@@ -270,6 +267,7 @@ private:
OString m_sHyperlinkLink;
OString m_aFormFieldButton;
OString m_ShapeSelection;
+ TestLokCallbackWrapper m_callbackWrapper;
};
SwTiledRenderingTest::SwTiledRenderingTest()
@@ -279,7 +277,8 @@ SwTiledRenderingTest::SwTiledRenderingTest()
m_nInvalidations(0),
m_nRedlineTableSizeChanged(0),
m_nRedlineTableEntryModified(0),
- m_nTrackedChangeIndex(-1)
+ m_nTrackedChangeIndex(-1),
+ m_callbackWrapper(&callback, this)
{
}
@@ -324,18 +323,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 (std::string_view("EMPTY") == pPayload)
+ return;
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+ aInvalidation.SetLeft(aSeq[0].toInt32());
+ aInvalidation.SetTop(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));
@@ -418,24 +434,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();
@@ -619,7 +625,7 @@ void SwTiledRenderingTest::testSearch()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper);
SwNodeOffset nNode = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
// First hit, in the second paragraph, before the shape.
@@ -684,7 +690,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"))},
@@ -699,7 +705,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"))},
@@ -717,7 +723,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.
@@ -733,7 +739,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"))},
@@ -751,7 +757,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(
@@ -778,7 +784,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.
@@ -798,7 +804,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;
@@ -825,6 +831,7 @@ namespace {
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),
@@ -838,14 +845,15 @@ namespace {
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();
}
@@ -860,19 +868,22 @@ namespace {
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;
@@ -984,11 +995,6 @@ namespace {
break;
}
}
- virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*,
- int) override
- {
- m_bTilesInvalidated = true;
- }
};
class TestResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
@@ -1534,7 +1540,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);
@@ -1561,7 +1567,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);
@@ -2351,7 +2357,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
@@ -2409,7 +2415,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
@@ -2786,7 +2792,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;
@@ -2802,7 +2808,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();
@@ -2829,7 +2835,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);
@@ -2902,7 +2908,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);
@@ -2959,7 +2965,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);
@@ -3012,7 +3018,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);
@@ -3045,7 +3051,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);
@@ -3082,7 +3088,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();
@@ -3180,7 +3186,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.
@@ -3210,7 +3216,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.
@@ -3247,7 +3253,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: */