summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-24 11:25:27 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-15 13:41:04 +0200
commitabb8d6e97029b1e344de04db31e3f616360e52aa (patch)
tree514a28b9b4b152f9ba1901668026f2274e7205b2
parente10b8707d01ff2a31f0d62641eb45adc9f7fde92 (diff)
do not use text-based LOK callback internally
CallbackFlushHandler post-processes LOK messages, but for things like dropping useless invalidations it needs to know the rectangle or the view id, and since the only data it gets are string messages, it needs to convert those back to binary form. Which is slow with large numbers of messages. Add internal LOK callback variant that allows also passing specific data in the original binary form. And then use directly the binary data in CallbackFlushHandler. Change-Id: I8dd30d2ff9c09feadebc31a44d8e6a8ccc306504 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123627 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--desktop/inc/lib/init.hxx59
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx41
-rw-r--r--desktop/source/lib/init.cxx170
-rw-r--r--include/editeng/outliner.hxx2
-rw-r--r--include/sfx2/lokcallback.hxx41
-rw-r--r--include/sfx2/viewsh.hxx10
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx154
-rw-r--r--sc/source/ui/view/tabview5.cxx3
-rw-r--r--sd/qa/unit/tiledrendering/CallbackRecorder.hxx26
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx82
-rw-r--r--sfx2/source/view/lokhelper.cxx43
-rw-r--r--sfx2/source/view/viewimp.hxx3
-rw-r--r--sfx2/source/view/viewsh.cxx51
-rw-r--r--sw/qa/core/txtnode/txtnode.cxx31
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx147
15 files changed, 517 insertions, 346 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index eee6b0fb4d76..74e0ebb2eb3a 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -25,6 +25,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <tools/gen.hxx>
+#include <sfx2/lokcallback.hxx>
#include <sfx2/lokhelper.hxx>
#include <desktop/dllapi.h>
@@ -44,6 +45,12 @@ namespace desktop {
{
}
+ RectangleAndPart(const tools::Rectangle* pRect, int nPart)
+ : m_aRectangle( pRect ? *pRect : tools::Rectangle(0, 0, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips))
+ , m_nPart(nPart)
+ {
+ }
+
OString toString() const
{
if (m_nPart >= -1)
@@ -69,13 +76,13 @@ namespace desktop {
static RectangleAndPart Create(const std::string& rPayload);
};
- class DESKTOP_DLLPUBLIC CallbackFlushHandler final : public Idle
+ class DESKTOP_DLLPUBLIC CallbackFlushHandler final : public Idle, public SfxLokCallbackInterface
{
public:
explicit CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData);
virtual ~CallbackFlushHandler() override;
virtual void Invoke() override;
- static void callback(const int type, const char* payload, void* data);
+ // TODO This should be dropped and the binary libreOfficeKitViewCallback() variants should be called?
void queue(const int type, const char* data);
/// Disables callbacks on this handler. Must match with identical count
@@ -90,17 +97,33 @@ namespace desktop {
void addViewStates(int viewId);
void removeViewStates(int viewId);
+ // SfxLockCallbackInterface
+ 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:
struct CallbackData
{
- CallbackData(const std::string& payload)
- : PayloadString(payload)
+ CallbackData(const char* payload)
+ : PayloadString(payload ? payload : "(nil)")
{
}
- /// Parse and set the RectangleAndPart object and return it. Clobbers PayloadString.
- RectangleAndPart& setRectangleAndPart(const std::string& payload);
- /// Set a RectangleAndPart object and update PayloadString.
- void setRectangleAndPart(const RectangleAndPart& rRectAndPart);
+ CallbackData(const char* payload, int viewId)
+ : PayloadString(payload ? payload : "(nil)")
+ , PayloadObject(viewId)
+ {
+ }
+
+ CallbackData(const tools::Rectangle* pRect, int viewId)
+ : PayloadObject(RectangleAndPart(pRect, viewId))
+ { // PayloadString will be done on demand
+ }
+
+ const std::string& getPayload() const;
+ /// Update a RectangleAndPart object and update PayloadString if necessary.
+ void updateRectangleAndPart(const RectangleAndPart& rRectAndPart);
/// Return the parsed RectangleAndPart instance.
const RectangleAndPart& getRectangleAndPart() const;
/// Parse and set the JSON object and return it. Clobbers PayloadString.
@@ -110,23 +133,34 @@ namespace desktop {
/// Return the parsed JSON instance.
const boost::property_tree::ptree& getJson() const;
+ int getViewId() const;
+
+ bool isEmpty() const
+ {
+ return PayloadString.empty() && PayloadObject.which() == 0;
+ }
+ void clear()
+ {
+ PayloadString.clear();
+ PayloadObject = boost::blank();
+ }
+
/// Validate that the payload and parsed object match.
bool validate() const;
/// Returns true iff there is cached data.
bool isCached() const { return PayloadObject.which() != 0; }
- std::string PayloadString;
-
private:
+ mutable std::string PayloadString;
+
/// The parsed payload cache. Update validate() when changing this.
- boost::variant<boost::blank, RectangleAndPart, boost::property_tree::ptree> PayloadObject;
+ mutable boost::variant<boost::blank, RectangleAndPart, boost::property_tree::ptree, int> PayloadObject;
};
typedef std::vector<int> queue_type1;
typedef std::vector<CallbackData> queue_type2;
- private:
bool removeAll(int type);
bool removeAll(int type, const std::function<bool (const CallbackData&)>& rTestFunc);
bool removeAll(const std::function<bool (int, const CallbackData&)>& rTestFunc);
@@ -134,6 +168,7 @@ namespace desktop {
bool processWindowEvent(int type, CallbackData& aCallbackData);
queue_type2::iterator toQueue2(queue_type1::iterator);
queue_type2::reverse_iterator toQueue2(queue_type1::reverse_iterator);
+ void queue(const int type, CallbackData& data);
/** we frequently want to scan the queue, and mostly when we do so, we only care about the element type
so we split the queue in 2 to make the scanning cache friendly. */
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e592bfd24b9d..13c6c6938c0a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -167,6 +167,7 @@ public:
void testNotificationCompression();
void testTileInvalidationCompression();
void testPartInInvalidation();
+ void testBinaryCallback();
void testInput();
void testRedlineWriter();
void testTrackChanges();
@@ -233,6 +234,7 @@ public:
CPPUNIT_TEST(testNotificationCompression);
CPPUNIT_TEST(testTileInvalidationCompression);
CPPUNIT_TEST(testPartInInvalidation);
+ CPPUNIT_TEST(testBinaryCallback);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testRedlineWriter);
CPPUNIT_TEST(testTrackChanges);
@@ -1919,6 +1921,45 @@ void DesktopLOKTest::testPartInInvalidation()
}
}
+static void callbackBinaryCallbackTest(const int type, const char* payload, void* data)
+{
+ std::vector<std::tuple<int, std::string>>* notifs = static_cast<std::vector<std::tuple<int, std::string>>*>(data);
+ notifs->emplace_back(type, std::string(payload ? payload : "(nil)"));
+}
+
+void DesktopLOKTest::testBinaryCallback()
+{
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+
+ const tools::Rectangle rect1(Point(10,15),Size(20,25));
+ const std::string rect1String(rect1.toString().getStr());
+ // Very that using queue() and libreOfficeKitViewInvalidateTilesCallback() has the same result.
+ {
+ std::vector<std::tuple<int, std::string>> notifs;
+ std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackBinaryCallbackTest, &notifs));
+
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, rect1String.c_str());
+
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
+ CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), std::get<0>(notifs[0]));
+ CPPUNIT_ASSERT_EQUAL(rect1String, std::get<1>(notifs[0]));
+ }
+ {
+ std::vector<std::tuple<int, std::string>> notifs;
+ std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackBinaryCallbackTest, &notifs));
+
+ handler->libreOfficeKitViewInvalidateTilesCallback(&rect1, INT_MIN);
+
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
+ CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), std::get<0>(notifs[0]));
+ CPPUNIT_ASSERT_EQUAL(rect1String, std::get<1>(notifs[0]));
+ }
+}
+
void DesktopLOKTest::testDialogInput()
{
comphelper::LibreOfficeKit::setActive();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7e92549a7cb9..61ab75fc45d2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -509,6 +509,8 @@ static void unoAnyToJson(tools::JsonWriter& rJson, const char * pNodeName, const
}
}
+static int lcl_getViewId(const std::string& payload);
+
namespace desktop {
RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
@@ -579,23 +581,30 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
return aRet;
}
-RectangleAndPart& CallbackFlushHandler::CallbackData::setRectangleAndPart(const std::string& payload)
+const std::string& CallbackFlushHandler::CallbackData::getPayload() const
{
- setRectangleAndPart(RectangleAndPart::Create(payload));
-
- // Return reference to the cached object.
- return boost::get<RectangleAndPart>(PayloadObject);
+ if(PayloadString.empty())
+ {
+ // Do to-string conversion on demand, as many calls will get dropped without
+ // needing the string.
+ if(PayloadObject.which() == 1)
+ PayloadString = getRectangleAndPart().toString();
+ }
+ return PayloadString;
}
-void CallbackFlushHandler::CallbackData::setRectangleAndPart(const RectangleAndPart& rRectAndPart)
+void CallbackFlushHandler::CallbackData::updateRectangleAndPart(const RectangleAndPart& rRectAndPart)
{
- PayloadString = rRectAndPart.toString().getStr();
PayloadObject = rRectAndPart;
+ PayloadString.clear(); // will be set on demand if needed
}
const RectangleAndPart& CallbackFlushHandler::CallbackData::getRectangleAndPart() const
{
- assert(PayloadObject.which() == 1);
+ // TODO: In case of unittests, they do not pass invalidations in binary but as text messages.
+ // LO core should preferably always pass binary for performance.
+ if(PayloadObject.which() != 1)
+ PayloadObject = RectangleAndPart::Create(PayloadString);
return boost::get<RectangleAndPart>(PayloadObject);
}
@@ -628,6 +637,16 @@ const boost::property_tree::ptree& CallbackFlushHandler::CallbackData::getJson()
return boost::get<boost::property_tree::ptree>(PayloadObject);
}
+int CallbackFlushHandler::CallbackData::getViewId() const
+{
+ if (isCached())
+ {
+ assert(PayloadObject.which() == 3);
+ return boost::get<int>(PayloadObject);
+ }
+ return lcl_getViewId(getPayload());
+}
+
bool CallbackFlushHandler::CallbackData::validate() const
{
switch (PayloadObject.which())
@@ -638,7 +657,7 @@ bool CallbackFlushHandler::CallbackData::validate() const
// RectangleAndPart.
case 1:
- return getRectangleAndPart().toString().getStr() == PayloadString;
+ return getRectangleAndPart().toString().getStr() == getPayload();
// Json.
case 2:
@@ -646,9 +665,13 @@ bool CallbackFlushHandler::CallbackData::validate() const
std::stringstream aJSONStream;
boost::property_tree::write_json(aJSONStream, getJson(), false);
const std::string aExpected = boost::trim_copy(aJSONStream.str());
- return aExpected == PayloadString;
+ return aExpected == getPayload();
}
+ // View id.
+ case 3:
+ return getViewId() == lcl_getViewId( getPayload());
+
default:
assert(!"Unknown variant type; please add an entry to validate.");
}
@@ -656,11 +679,9 @@ bool CallbackFlushHandler::CallbackData::validate() const
return false;
}
-}
+} // namespace desktop
-namespace {
-
-bool lcl_isViewCallbackType(const int type)
+static bool lcl_isViewCallbackType(const int type)
{
switch (type)
{
@@ -676,7 +697,7 @@ bool lcl_isViewCallbackType(const int type)
}
}
-int lcl_getViewId(const std::string& payload)
+static int lcl_getViewId(const std::string& payload)
{
// this is a cheap way how to get the viewId from a JSON message; proper
// parsing is terribly expensive, and we just need the viewId here
@@ -700,12 +721,7 @@ int lcl_getViewId(const std::string& payload)
return 0;
}
-int lcl_getViewId(const desktop::CallbackFlushHandler::CallbackData& rCallbackData)
-{
- if (rCallbackData.isCached())
- return rCallbackData.getJson().get<int>("viewId");
- return lcl_getViewId(rCallbackData.PayloadString);
-}
+namespace {
std::string extractCertificate(const std::string & certificate)
{
@@ -1437,15 +1453,6 @@ CallbackFlushHandler::~CallbackFlushHandler()
Stop();
}
-void CallbackFlushHandler::callback(const int type, const char* payload, void* data)
-{
- CallbackFlushHandler* self = static_cast<CallbackFlushHandler*>(data);
- if (self)
- {
- self->queue(type, payload);
- }
-}
-
CallbackFlushHandler::queue_type2::iterator CallbackFlushHandler::toQueue2(CallbackFlushHandler::queue_type1::iterator pos)
{
int delta = std::distance(m_queue1.begin(), pos);
@@ -1458,13 +1465,35 @@ CallbackFlushHandler::queue_type2::reverse_iterator CallbackFlushHandler::toQueu
return m_queue2.rbegin() + delta;
}
+void CallbackFlushHandler::libreOfficeKitViewCallback(int nType, const char* pPayload)
+{
+ CallbackData callbackData(pPayload);
+ queue(nType, callbackData);
+}
+
+void CallbackFlushHandler::libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId)
+{
+ CallbackData callbackData(pPayload, nViewId);
+ queue(nType, callbackData);
+}
+
+void CallbackFlushHandler::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart)
+{
+ CallbackData callbackData(pRect, nPart);
+ queue(LOK_CALLBACK_INVALIDATE_TILES, callbackData);
+}
+
void CallbackFlushHandler::queue(const int type, const char* data)
{
+ CallbackData callbackData(data);
+ queue(type, callbackData);
+}
+
+void CallbackFlushHandler::queue(const int type, CallbackData& aCallbackData)
+{
comphelper::ProfileZone aZone("CallbackFlushHandler::queue");
- CallbackData aCallbackData(data ? data : "(nil)");
- const std::string& payload = aCallbackData.PayloadString;
- SAL_INFO("lok", "Queue: [" << type << "]: [" << payload << "] on " << m_queue1.size() << " entries.");
+ SAL_INFO("lok", "Queue: [" << type << "]: [" << aCallbackData.getPayload() << "] on " << m_queue1.size() << " entries.");
bool bIsChartActive = false;
if (type == LOK_CALLBACK_GRAPHIC_SELECTION)
@@ -1492,7 +1521,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
type != LOK_CALLBACK_TEXT_SELECTION_END &&
type != LOK_CALLBACK_REFERENCE_MARKS)
{
- SAL_INFO("lok", "Skipping while painting [" << type << "]: [" << payload << "].");
+ SAL_INFO("lok", "Skipping while painting [" << type << "]: [" << aCallbackData.getPayload() << "].");
return;
}
@@ -1503,15 +1532,15 @@ void CallbackFlushHandler::queue(const int type, const char* data)
// Suppress invalid payloads.
if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
- payload.find(", 0, 0, ") != std::string::npos &&
- payload.find("\"hyperlink\":\"\"") == std::string::npos &&
- payload.find("\"hyperlink\": {}") == std::string::npos)
+ aCallbackData.getPayload().find(", 0, 0, ") != std::string::npos &&
+ aCallbackData.getPayload().find("\"hyperlink\":\"\"") == std::string::npos &&
+ aCallbackData.getPayload().find("\"hyperlink\": {}") == std::string::npos)
{
// The cursor position is often the relative coordinates of the widget
// issuing it, instead of the absolute one that we expect.
// This is temporary however, and, once the control is created and initialized
// correctly, it eventually emits the correct absolute coordinates.
- SAL_INFO("lok", "Skipping invalid event [" << type << "]: [" << payload << "].");
+ SAL_INFO("lok", "Skipping invalid event [" << type << "]: [" << aCallbackData.getPayload() << "].");
return;
}
@@ -1547,30 +1576,30 @@ void CallbackFlushHandler::queue(const int type, const char* data)
{
const auto& pos = std::find(m_queue1.rbegin(), m_queue1.rend(), type);
auto pos2 = toQueue2(pos);
- if (pos != m_queue1.rend() && pos2->PayloadString == payload)
+ if (pos != m_queue1.rend() && pos2->getPayload() == aCallbackData.getPayload())
{
- SAL_INFO("lok", "Skipping queue duplicate [" << type << + "]: [" << payload << "].");
+ SAL_INFO("lok", "Skipping queue duplicate [" << type << + "]: [" << aCallbackData.getPayload() << "].");
return;
}
}
break;
}
- if (type == LOK_CALLBACK_TEXT_SELECTION && payload.empty())
+ if (type == LOK_CALLBACK_TEXT_SELECTION && aCallbackData.isEmpty())
{
const auto& posStart = std::find(m_queue1.rbegin(), m_queue1.rend(), LOK_CALLBACK_TEXT_SELECTION_START);
auto posStart2 = toQueue2(posStart);
if (posStart != m_queue1.rend())
- posStart2->PayloadString.clear();
+ posStart2->clear();
const auto& posEnd = std::find(m_queue1.rbegin(), m_queue1.rend(), LOK_CALLBACK_TEXT_SELECTION_END);
auto posEnd2 = toQueue2(posEnd);
if (posEnd != m_queue1.rend())
- posEnd2->PayloadString.clear();
+ posEnd2->clear();
}
// When payload is empty discards any previous state.
- if (payload.empty())
+ if (aCallbackData.isEmpty())
{
switch (type)
{
@@ -1581,7 +1610,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
case LOK_CALLBACK_INVALIDATE_TILES:
if (removeAll(type))
- SAL_INFO("lok", "Removed dups of [" << type << "]: [" << payload << "].");
+ SAL_INFO("lok", "Removed dups of [" << type << "]: [" << aCallbackData.getPayload() << "].");
break;
}
}
@@ -1604,7 +1633,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_RULER_UPDATE:
{
if (removeAll(type))
- SAL_INFO("lok", "Removed dups of [" << type << "]: [" << payload << "].");
+ SAL_INFO("lok", "Removed dups of [" << type << "]: [" << aCallbackData.getPayload() << "].");
}
break;
@@ -1623,13 +1652,13 @@ void CallbackFlushHandler::queue(const int type, const char* data)
// deleting the duplicate of visible cursor message can cause hyperlink popup not to show up on second/or more click on the same place.
// If the hyperlink is not empty we can bypass that to show the popup
const bool hyperLinkException = type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
- payload.find("\"hyperlink\":\"\"") == std::string::npos &&
- payload.find("\"hyperlink\": {}") == std::string::npos;
+ aCallbackData.getPayload().find("\"hyperlink\":\"\"") == std::string::npos &&
+ aCallbackData.getPayload().find("\"hyperlink\": {}") == std::string::npos;
if(!hyperLinkException)
{
- const int nViewId = lcl_getViewId(payload);
+ const int nViewId = aCallbackData.getViewId();
removeAll(type, [nViewId] (const CallbackData& elemData) {
- return (nViewId == lcl_getViewId(elemData));
+ return (nViewId == elemData.getViewId());
}
);
}
@@ -1646,16 +1675,16 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_STATE_CHANGED:
{
// Compare the state name=value and overwrite earlier entries with same name.
- const auto pos = payload.find('=');
+ const auto pos = aCallbackData.getPayload().find('=');
if (pos != std::string::npos)
{
- const std::string name = payload.substr(0, pos + 1);
+ const std::string name = aCallbackData.getPayload().substr(0, pos + 1);
// This is needed because otherwise it creates some problems when
// a save occurs while a cell is still edited in Calc.
if (name != ".uno:ModifiedStatus=")
{
removeAll(type, [&name] (const CallbackData& elemData) {
- return (elemData.PayloadString.compare(0, name.size(), name) == 0);
+ return (elemData.getPayload().compare(0, name.size(), name) == 0);
}
);
}
@@ -1672,8 +1701,8 @@ void CallbackFlushHandler::queue(const int type, const char* data)
{
// remove only selection ranges and 'EMPTY' messages
// always send 'INPLACE' and 'INPLACE EXIT' messages
- removeAll(type, [payload] (const CallbackData& elemData)
- { return (elemData.PayloadString.find("INPLACE") == std::string::npos); });
+ removeAll(type, [] (const CallbackData& elemData)
+ { return (elemData.getPayload().find("INPLACE") == std::string::npos); });
}
break;
}
@@ -1684,7 +1713,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
m_queue1.emplace_back(type);
m_queue2.emplace_back(aCallbackData);
SAL_INFO("lok", "Queued #" << (m_queue1.size() - 1) <<
- " [" << type << "]: [" << payload << "] to have " << m_queue1.size() << " entries.");
+ " [" << type << "]: [" << aCallbackData.getPayload() << "] to have " << m_queue1.size() << " entries.");
#ifdef DBG_UTIL
{
@@ -1698,7 +1727,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
auto it1 = m_queue1.begin();
auto it2 = m_queue2.begin();
for (; it1 != m_queue1.end(); ++it1, ++it2)
- oss << i++ << ": [" << *it1 << "] [" << it2->PayloadString << "].\n";
+ oss << i++ << ": [" << *it1 << "] [" << it2->getPayload() << "].\n";
SAL_INFO("lok", "Current Queue: " << oss.str());
assert(
std::all_of(
@@ -1718,12 +1747,10 @@ void CallbackFlushHandler::queue(const int type, const char* data)
bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& aCallbackData)
{
- const std::string& payload = aCallbackData.PayloadString;
-
- RectangleAndPart& rcNew = aCallbackData.setRectangleAndPart(payload);
+ RectangleAndPart rcNew = aCallbackData.getRectangleAndPart();
if (rcNew.isEmpty())
{
- SAL_INFO("lok", "Skipping invalid event [" << type << "]: [" << payload << "].");
+ SAL_INFO("lok", "Skipping invalid event [" << type << "]: [" << aCallbackData.getPayload() << "].");
return true;
}
@@ -1737,7 +1764,7 @@ bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
const RectangleAndPart& rcOld = pos2->getRectangleAndPart();
if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart))
{
- SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload
+ SAL_INFO("lok", "Skipping queue [" << type << "]: [" << aCallbackData.getPayload()
<< "] since all tiles need to be invalidated.");
return true;
}
@@ -1747,7 +1774,7 @@ bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
// If fully overlapping.
if (rcOld.m_aRectangle.IsInside(rcNew.m_aRectangle))
{
- SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload
+ SAL_INFO("lok", "Skipping queue [" << type << "]: [" << aCallbackData.getPayload()
<< "] since overlaps existing all-parts.");
return true;
}
@@ -1756,7 +1783,7 @@ bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
if (rcNew.isInfinite())
{
- SAL_INFO("lok", "Have Empty [" << type << "]: [" << payload
+ SAL_INFO("lok", "Have Empty [" << type << "]: [" << aCallbackData.getPayload()
<< "] so removing all with part " << rcNew.m_nPart << ".");
removeAll(LOK_CALLBACK_INVALIDATE_TILES, [&rcNew](const CallbackData& elemData) {
// Remove exiting if new is all-encompassing, or if of the same part.
@@ -1767,7 +1794,7 @@ bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
{
const auto rcOrig = rcNew;
- SAL_INFO("lok", "Have [" << type << "]: [" << payload << "] so merging overlapping.");
+ SAL_INFO("lok", "Have [" << type << "]: [" << aCallbackData.getPayload() << "] so merging overlapping.");
removeAll(LOK_CALLBACK_INVALIDATE_TILES,[&rcNew](const CallbackData& elemData) {
const RectangleAndPart& rcOld = elemData.getRectangleAndPart();
if (rcNew.m_nPart != -1 && rcOld.m_nPart != -1 && rcOld.m_nPart != rcNew.m_nPart)
@@ -1832,14 +1859,14 @@ bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
}
}
- aCallbackData.setRectangleAndPart(rcNew);
+ aCallbackData.updateRectangleAndPart(rcNew);
// Queue this one.
return false;
}
bool CallbackFlushHandler::processWindowEvent(int type, CallbackData& aCallbackData)
{
- const std::string& payload = aCallbackData.PayloadString;
+ const std::string& payload = aCallbackData.getPayload();
boost::property_tree::ptree& aTree = aCallbackData.setJson(payload);
const unsigned nLOKWindowId = aTree.get<unsigned>("id", 0);
@@ -2026,8 +2053,8 @@ void CallbackFlushHandler::Invoke()
for (; it1 != m_queue1.end(); ++it1, ++it2)
{
const int type = *it1;
- const auto& payload = it2->PayloadString;
- const int viewId = lcl_isViewCallbackType(type) ? lcl_getViewId(*it2) : -1;
+ const auto& payload = it2->getPayload();
+ const int viewId = lcl_isViewCallbackType(type) ? it2->getViewId() : -1;
if (viewId == -1)
{
@@ -3562,15 +3589,14 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
- pViewShell->registerLibreOfficeKitViewCallback(
- CallbackFlushHandler::callback, pDocument->mpCallbackFlushHandlers[nView].get());
+ pViewShell->setLibreOfficeKitViewCallback(pDocument->mpCallbackFlushHandlers[nView].get());
}
}
else
{
if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
- pViewShell->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ pViewShell->setLibreOfficeKitViewCallback(nullptr);
}
}
}
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 4fb4fa7a9f6b..72043ce25e2d 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -365,6 +365,8 @@ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
{
public:
virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) const = 0;
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const = 0;
virtual ViewShellId GetViewShellId() const = 0;
virtual ViewShellDocId GetDocId() const = 0;
/// Wrapper around SfxLokHelper::notifyOtherViews().
diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx
new file mode 100644
index 000000000000..4c40c5452c15
--- /dev/null
+++ b/include/sfx2/lokcallback.hxx
@@ -0,0 +1,41 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <sal/types.h>
+
+namespace tools
+{
+class Rectangle;
+}
+
+// An extended callback type that allows passing in also some binary data,
+// so that post-processing the messages does not require conversions
+// from and to strings.
+
+// TODO: It might possibly make sense to drop the generic type/payload function
+// and have only a dedicated function for each message type?
+
+class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SfxLokCallbackInterface
+{
+public:
+ virtual ~SfxLokCallbackInterface() {}
+ // LibreOfficeKitCallback equivalent.
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) = 0;
+ // Callback that explicitly provides view id (which is also included in the payload).
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) = 0;
+ // LOK_CALLBACK_INVALIDATE_TILES
+ // nPart is either part, -1 for all-parts, or INT_MIN if
+ // comphelper::LibreOfficeKit::isPartInInvalidation() is not set
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart)
+ = 0;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 1fd5a281f561..39ca5b6396c9 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -55,6 +55,7 @@ class SfxPrinter;
class Menu;
class NotifyEvent;
class SfxInPlaceClient;
+class SfxLokCallbackInterface;
namespace vcl { class PrinterController; }
namespace com::sun::star::datatransfer::clipboard { class XClipboardListener; }
@@ -332,10 +333,13 @@ public:
SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( false ); }
SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
- /// The actual per-view implementation of lok::Document::registerCallback().
- void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+ /// Set up a more efficient internal callback instead of LibreOfficeKitCallback.
+ void setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallback);
/// Invokes the registered callback, if there are any.
- void libreOfficeKitViewCallback(int nType, const char* pPayload) const override;
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const override;
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) const override;
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const override;
+
/// Set if we are doing tiled searching.
void setTiledSearching(bool bTiledSearching);
/// See lok::Document::getPart().
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index ccd0db94daa4..39571de2bed5 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -30,6 +30,7 @@
#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>
@@ -65,7 +66,10 @@ namespace
char const DATA_DIRECTORY[] = "/sc/qa/unit/tiledrendering/data/";
-class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+class ScTiledRenderingTest : public test::BootstrapFixture,
+ public unotest::MacrosTest,
+ public XmlTestTools,
+ public SfxLokCallbackInterface
{
public:
ScTiledRenderingTest();
@@ -178,10 +182,13 @@ 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;
@@ -214,7 +221,7 @@ void ScTiledRenderingTest::tearDown()
{
// The current view is unregistered here, multiple views have to be unregistered
// in the test function itself.
- pViewShell->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ pViewShell->setLibreOfficeKitViewCallback(nullptr);
}
}
mxComponent->dispose();
@@ -235,11 +242,6 @@ 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,7 +271,12 @@ static void lcl_convertRectangle(const OUString& rString, Rectangle& rRectangle)
}
*/
-void ScTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
+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)
{
switch (nType)
{
@@ -287,6 +294,10 @@ void ScTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
}
}
+void ScTiledRenderingTest::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*, int)
+{
+}
+
void ScTiledRenderingTest::testRowColumnSelections()
{
comphelper::LibreOfficeKit::setActive();
@@ -397,7 +408,7 @@ void ScTiledRenderingTest::testDocumentSize()
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
CPPUNIT_ASSERT(pViewShell);
- pViewShell->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this);
+ pViewShell->setLibreOfficeKitViewCallback(this);
// check initial document size
Size aDocSize = pModelObj->getDocumentSize();
@@ -558,7 +569,7 @@ struct TextSelectionMessage
};
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback final
+class ViewCallback final : public SfxLokCallbackInterface
{
SfxViewShell* mpViewShell;
int mnView;
@@ -593,7 +604,7 @@ public:
m_bViewLock(false)
{
mpViewShell = SfxViewShell::Current();
- mpViewShell->registerLibreOfficeKitViewCallback(&ViewCallback::callback, this);
+ mpViewShell->setLibreOfficeKitViewCallback(this);
mnView = SfxLokHelper::getView();
if (!bDeleteListenerOnDestruct)
mpViewShell = nullptr;
@@ -604,16 +615,16 @@ public:
if (mpViewShell)
{
SfxLokHelper::setView(mnView);
- mpViewShell->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ mpViewShell->setLibreOfficeKitViewCallback(nullptr);
}
}
- static void callback(int nType, const char* pPayload, void* pData)
+ void libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/)
{
- static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
+ libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
}
- void callbackImpl(int nType, const char* pPayload)
+ void libreOfficeKitViewCallback(int nType, const char* pPayload)
{
switch (nType)
{
@@ -660,28 +671,7 @@ public:
}
break;
case LOK_CALLBACK_INVALIDATE_TILES:
- {
- 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;
+ abort();
case LOK_CALLBACK_CELL_FORMULA:
{
m_sCellFormula = pPayload;
@@ -716,6 +706,20 @@ 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;
+ }
+ }
};
@@ -778,7 +782,7 @@ void ScTiledRenderingTest::testDocumentSizeChanged()
// Load a document that doesn't have much content.
createDoc("small.ods");
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(this);
// Go to the A30 cell -- that will extend the document size.
uno::Sequence<beans::PropertyValue> aPropertyValues =
@@ -880,7 +884,7 @@ void ScTiledRenderingTest::testColRowResize()
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
CPPUNIT_ASSERT(pViewShell);
- pViewShell->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this);
+ pViewShell->setLibreOfficeKitViewCallback(this);
ScDocument& rDoc = pDocSh->GetDocument();
@@ -1057,7 +1061,7 @@ void ScTiledRenderingTest::testCreateViewGraphicSelection()
CPPUNIT_ASSERT(aView1.m_bGraphicViewSelection);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testGraphicInvalidate()
@@ -1525,9 +1529,9 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
for (size_t i = 0; i < aBuffer1.size(); ++i)
CPPUNIT_ASSERT_EQUAL(aBuffer1[i], aBuffer2[i]);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testDisableUndoRepair()
@@ -1596,9 +1600,9 @@ void ScTiledRenderingTest::testDisableUndoRepair()
CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet2.GetItem(SID_UNDO)));
}
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testDocumentRepair()
@@ -1652,9 +1656,9 @@ void ScTiledRenderingTest::testDocumentRepair()
CPPUNIT_ASSERT_EQUAL(true, pItem2->GetValue());
}
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testLanguageStatus()
@@ -1706,9 +1710,9 @@ void ScTiledRenderingTest::testLanguageStatus()
CPPUNIT_ASSERT_EQUAL(aLangBolivia, pItem2->GetValue());
}
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testMultiViewCopyPaste()
@@ -1757,9 +1761,9 @@ void ScTiledRenderingTest::testMultiViewCopyPaste()
CPPUNIT_ASSERT_EQUAL(OUString("TestCopy1"), pDoc->GetString(ScAddress(0, 1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("TestCopy2"), pDoc->GetString(ScAddress(1, 1, 0)));
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testIMESupport()
@@ -1828,9 +1832,9 @@ void ScTiledRenderingTest::testFilterDlg()
CPPUNIT_ASSERT_EQUAL(false, pView2->GetViewFrame()->GetDispatcher()->IsLocked());
CPPUNIT_ASSERT_EQUAL(false, pView1->GetViewFrame()->GetDispatcher()->IsLocked());
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testFunctionDlg()
@@ -1865,9 +1869,9 @@ void ScTiledRenderingTest::testFunctionDlg()
CPPUNIT_ASSERT_EQUAL(false, pView1->GetViewFrame()->GetDispatcher()->IsLocked());
CPPUNIT_ASSERT_EQUAL(false, pView2->GetViewFrame()->GetDispatcher()->IsLocked());
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testSpellOnlineParameter()
@@ -2121,7 +2125,7 @@ void ScTiledRenderingTest::testRowColumnHeaders()
// view #1
ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
// view #2
@@ -2129,7 +2133,7 @@ void ScTiledRenderingTest::testRowColumnHeaders()
int nView2 = SfxLokHelper::getView();
ViewCallback aView2;
pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView2);
// ViewRowColumnHeaders test
SfxLokHelper::setView(nView1);
@@ -2160,9 +2164,9 @@ void ScTiledRenderingTest::testRowColumnHeaders()
CPPUNIT_ASSERT_EQUAL(aHeaders2, aHeaders2_2);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
// Helper structs for setup and testing of ScModelObj::getSheetGeometryData()
@@ -2385,14 +2389,14 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
// view #1
ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
// view #2
SfxLokHelper::createView();
int nView2 = SfxLokHelper::getView();
ViewCallback aView2;
pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ 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)
@@ -2424,9 +2428,9 @@ void ScTiledRenderingTest::testSheetGeometryDataInvariance()
}
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
@@ -2492,7 +2496,7 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
// view #1
ViewCallback aView1;
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &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,
@@ -2505,7 +2509,7 @@ void ScTiledRenderingTest::testSheetGeometryDataCorrectness()
/*bHidden*/ true, /*bFiltered*/ true, /*bGroups*/ true);
aSGData.parseTest(aGeomStr);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testDeleteCellMultilineContent()
@@ -2521,7 +2525,7 @@ void ScTiledRenderingTest::testDeleteCellMultilineContent()
// view #1
ViewCallback aView1;
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView1);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
aView1.m_sInvalidateHeader = "";
@@ -2539,7 +2543,7 @@ void ScTiledRenderingTest::testDeleteCellMultilineContent()
CPPUNIT_ASSERT_EQUAL(OString("row"), aView1.m_sInvalidateHeader);
sal_uInt16 nRow2Height = rDoc.GetRowHeight(static_cast<SCROW>(0), static_cast<SCTAB>(0), false);
CPPUNIT_ASSERT_EQUAL(nRow1Height, nRow2Height);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testPasteIntoWrapTextCell()
@@ -2561,7 +2565,7 @@ void ScTiledRenderingTest::testPasteIntoWrapTextCell()
CPPUNIT_ASSERT(pViewData);
ViewCallback aView;
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
@@ -2587,7 +2591,7 @@ void ScTiledRenderingTest::testPasteIntoWrapTextCell()
// SG invalidations for all
CPPUNIT_ASSERT_EQUAL(OString("all"), aView.m_sInvalidateSheetGeometry);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testSortAscendingDescending()
@@ -2599,7 +2603,7 @@ void ScTiledRenderingTest::testSortAscendingDescending()
ScDocument* pDoc = pModelObj->GetDocument();
ViewCallback aView;
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
// select the values in the first column
pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 551, 129, 1, MOUSE_LEFT, 0);
@@ -2712,7 +2716,7 @@ void ScTiledRenderingTest::testEditCursorBounds()
ScDocument* pDoc = pModelObj->GetDocument();
ViewCallback aView;
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView);
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
@@ -2745,7 +2749,7 @@ void ScTiledRenderingTest::testEditCursorBounds()
CPPUNIT_ASSERT_MESSAGE("Edit cursor must be in cell bounds!",
aCellBounds.IsInside(aView.m_aInvalidateCursorResult.getBounds()));
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testTextSelectionBounds()
@@ -2757,7 +2761,7 @@ void ScTiledRenderingTest::testTextSelectionBounds()
ScDocument* pDoc = pModelObj->GetDocument();
ViewCallback aView;
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(&aView);
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView);
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
@@ -2795,7 +2799,7 @@ void ScTiledRenderingTest::testTextSelectionBounds()
CPPUNIT_ASSERT_MESSAGE("Text selections must be in cell bounds!",
!aCellBounds.Intersection(aView.m_aTextSelectionResult.getBounds(0)).IsEmpty());
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void ScTiledRenderingTest::testSheetViewDataCrash()
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index c41f08b0aca1..1d9ba69d6619 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -336,8 +336,7 @@ void ScTabView::TabChanged( bool bSameTabButMoved )
// Invalidate first
tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
- OString sPayload = aRectangle.toString() + ", " + OString::number(aViewData.GetTabNo());
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr());
+ pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, aViewData.GetTabNo());
ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false);
diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
index 7e6c8a42d07d..6c4faf81edae 100644
--- a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
+++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
@@ -14,6 +14,7 @@
#include <comphelper/string.hxx>
#include <osl/conditn.hxx>
#include <sfx2/viewsh.hxx>
+#include <sfx2/lokcallback.hxx>
namespace
{
@@ -44,7 +45,7 @@ void lcl_convertRectangle(const OUString& rString, tools::Rectangle& rRectangle)
}
}
-struct CallbackRecorder
+struct CallbackRecorder : public SfxLokCallbackInterface
{
CallbackRecorder()
: m_bFound(true)
@@ -67,22 +68,16 @@ struct CallbackRecorder
/// For document size changed callback.
osl::Condition m_aDocumentSizeCondition;
- static void callback(int nType, const char* pPayload, void* pData)
+ void libreOfficeKitViewCallback(int nType, const char* pPayload) override
{
- static_cast<CallbackRecorder*>(pData)->processCallback(nType, pPayload);
+ libreOfficeKitViewCallback(nType, pPayload, -1);
}
-
- void processCallback(int nType, const char* pPayload)
+ void libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/) override
{
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- {
- OUString aPayload = OUString::createFromAscii(pPayload);
- if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
- lcl_convertRectangle(aPayload, m_aInvalidation);
- }
- break;
+ abort();
case LOK_CALLBACK_TEXT_SELECTION:
{
OUString aPayload = OUString::createFromAscii(pPayload);
@@ -136,9 +131,16 @@ struct CallbackRecorder
}
}
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
+ int /*nPart*/) override
+ {
+ if (pRect != nullptr && m_aInvalidation.IsEmpty())
+ m_aInvalidation = *pRect;
+ }
+
void registerCallbacksFor(SfxViewShell& rViewShell)
{
- rViewShell.registerLibreOfficeKitViewCallback(&CallbackRecorder::callback, this);
+ rViewShell.setLibreOfficeKitViewCallback(this);
}
};
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 5c852d854c90..211622a795bf 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -15,6 +15,7 @@
#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>
@@ -71,7 +72,7 @@ static std::ostream& operator<<(std::ostream& os, ViewShellId id)
return os;
}
-class SdTiledRenderingTest : public SdModelTestBase, public XmlTestTools
+class SdTiledRenderingTest : public SdModelTestBase, public XmlTestTools, public SfxLokCallbackInterface
{
public:
SdTiledRenderingTest();
@@ -193,10 +194,13 @@ 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;
@@ -258,11 +262,6 @@ 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
{
@@ -295,17 +294,17 @@ void lcl_convertRectangle(const OUString& rString, ::tools::Rectangle& rRectangl
} // end anonymous namespace
-void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
+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)
{
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- {
- OUString aPayload = OUString::createFromAscii(pPayload);
- if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
- lcl_convertRectangle(aPayload, m_aInvalidation);
- }
- break;
+ abort();
case LOK_CALLBACK_TEXT_SELECTION:
{
OUString aPayload = OUString::createFromAscii(pPayload);
@@ -355,6 +354,13 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
}
}
+void SdTiledRenderingTest::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
+ int /*nPart*/)
+{
+ if (pRect != nullptr && m_aInvalidation.IsEmpty())
+ m_aInvalidation = *pRect;
+}
+
xmlDocUniquePtr SdTiledRenderingTest::parseXmlDump()
{
if (m_pXmlBuffer)
@@ -394,7 +400,7 @@ void SdTiledRenderingTest::testRegisterCallback()
{
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this);
+ pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(this);
// Start text edit of the empty title shape.
SdPage* pActualPage = pViewShell->GetActualPage();
@@ -624,7 +630,7 @@ void SdTiledRenderingTest::testInsertDeletePage()
{
SdXImpressDocument* pXImpressDocument = createDoc("insert-delete.odp");
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this);
+ pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(this);
SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc();
CPPUNIT_ASSERT(pDoc);
@@ -876,7 +882,7 @@ void SdTiledRenderingTest::testResizeTableColumn()
namespace {
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback final
+class ViewCallback final : public SfxLokCallbackInterface
{
SfxViewShell* mpViewShell;
int mnView;
@@ -907,42 +913,27 @@ public:
m_bViewSelectionSet(false)
{
mpViewShell = SfxViewShell::Current();
- mpViewShell->registerLibreOfficeKitViewCallback(&ViewCallback::callback, this);
+ mpViewShell->setLibreOfficeKitViewCallback(this);
mnView = SfxLokHelper::getView();
}
~ViewCallback()
{
SfxLokHelper::setView(mnView);
- mpViewShell->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ mpViewShell->setLibreOfficeKitViewCallback(nullptr);
}
- static void callback(int nType, const char* pPayload, void* pData)
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override
{
- static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
+ libreOfficeKitViewCallback(nType, pPayload, -1);
}
- void callbackImpl(int nType, const char* pPayload)
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override
{
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- {
- m_bTilesInvalidated = true;
- OString text(pPayload);
- if (!text.startsWith("EMPTY"))
- {
- uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
- CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
- tools::Rectangle aInvalidationRect;
- aInvalidationRect.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;
+ abort();
case LOK_CALLBACK_GRAPHIC_SELECTION:
{
m_bGraphicSelectionInvalidated = true;
@@ -978,7 +969,7 @@ public:
std::stringstream aStream(pPayload);
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
- int nViewId = aTree.get_child("viewId").get_value<int>();
+ nViewId = aTree.get_child("viewId").get_value<int>();
m_aViewCursorInvalidations[nViewId] = true;
}
break;
@@ -987,7 +978,7 @@ public:
std::stringstream aStream(pPayload);
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
- const int nViewId = aTree.get_child("viewId").get_value<int>();
+ nViewId = aTree.get_child("viewId").get_value<int>();
m_aViewCursorVisibilities[nViewId] = OString("true") == pPayload;
}
break;
@@ -1006,6 +997,13 @@ public:
break;
}
}
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect,
+ int /*nPart*/) override
+ {
+ m_bTilesInvalidated = true;
+ if (pRect != nullptr)
+ m_aInvalidations.push_back(*pRect);
+ }
};
}
@@ -2455,7 +2453,7 @@ void SdTiledRenderingTest::testCutSelectionChange()
CPPUNIT_ASSERT(pXImpressDocument);
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this);
+ pViewShell->GetViewShellBase().setLibreOfficeKitViewCallback(this);
Scheduler::ProcessEventsToIdle();
// Select first text object
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 03a7c45dcae7..4f046bebf6eb 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -372,7 +372,8 @@ void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell c
return;
const OString aPayload = lcl_generateJSON(pThisView, rKey, rPayload);
- pOtherView->libreOfficeKitViewCallback(nType, aPayload.getStr());
+ const int viewId = SfxLokHelper::getView(pThisView);
+ pOtherView->libreOfficeKitViewCallback(nType, aPayload.getStr(), viewId);
}
void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView,
@@ -382,7 +383,8 @@ void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell c
if (DisableCallbacks::disabled())
return;
- pOtherView->libreOfficeKitViewCallback(nType, lcl_generateJSON(pThisView, rTree).getStr());
+ const int viewId = SfxLokHelper::getView(pThisView);
+ pOtherView->libreOfficeKitViewCallback(nType, lcl_generateJSON(pThisView, rTree).getStr(), viewId);
}
void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType, const OString& rKey,
@@ -394,6 +396,7 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType, co
// Cache the payload so we only have to generate it once, at most.
OString aPayload;
+ int viewId = -1;
const ViewShellDocId nCurrentDocId = pThisView->GetDocId();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
@@ -403,9 +406,12 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType, co
{
// Payload is only dependent on pThisView.
if (aPayload.isEmpty())
+ {
aPayload = lcl_generateJSON(pThisView, rKey, rPayload);
+ viewId = SfxLokHelper::getView(pThisView);
+ }
- pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr());
+ pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr(), viewId);
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
@@ -421,6 +427,7 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType,
// Cache the payload so we only have to generate it once, at most.
OString aPayload;
+ int viewId = -1;
const ViewShellDocId nCurrentDocId = pThisView->GetDocId();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
@@ -430,9 +437,12 @@ void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType,
{
// Payload is only dependent on pThisView.
if (aPayload.isEmpty())
+ {
aPayload = lcl_generateJSON(pThisView, rTree);
+ viewId = SfxLokHelper::getView(pThisView);
+ }
- pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr());
+ pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr(), viewId);
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
@@ -511,17 +521,8 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, tools::Rect
if (DisableCallbacks::disabled())
return;
- OStringBuffer aBuf(64);
- if (pRect)
- aBuf.append(pRect->toString());
- else
- aBuf.append("EMPTY");
- if (comphelper::LibreOfficeKit::isPartInInvalidation())
- {
- aBuf.append(", ");
- aBuf.append(static_cast<sal_Int32>(pThisView->getPart()));
- }
- pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, aBuf.makeStringAndClear().getStr());
+ const int nPart = comphelper::LibreOfficeKit::isPartInInvalidation() ? pThisView->getPart() : INT_MIN;
+ pThisView->libreOfficeKitViewInvalidateTilesCallback(pRect, nPart);
}
void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
@@ -534,8 +535,7 @@ void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, cons
for (int i = 0; i < pDoc->getParts(); ++i)
{
tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
- OString sPayload = aRectangle.toString() + ", " + OString::number(i);
- pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr());
+ pThisView->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, i);
}
}
pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, rPayload.getStr());
@@ -568,20 +568,21 @@ void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisVie
if (DisableCallbacks::disabled())
return;
- OString sPayload;
if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation())
{
OString sHyperlink = rHyperlink.isEmpty() ? "{}" : rHyperlink;
- sPayload = OStringLiteral("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView()) +
+ OString sPayload = OStringLiteral("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView()) +
"\", \"rectangle\": \"" + rRectangle +
"\", \"mispelledWord\": \"" + OString::number(bMispelledWord ? 1 : 0) +
"\", \"hyperlink\": " + sHyperlink + " }";
+ const int viewId = SfxLokHelper::getView();
+ pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sPayload.getStr(), viewId);
}
else
{
- sPayload = rRectangle;
+ OString sPayload = rRectangle;
+ pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sPayload.getStr());
}
- pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sPayload.getStr());
}
void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index c36187fb554d..faf796ca6f12 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -48,8 +48,7 @@ struct SfxViewShell_Impl
mutable std::unique_ptr<std::vector<SfxInPlaceClient*>> mpIPClients;
- LibreOfficeKitCallback m_pLibreOfficeKitViewCallback;
- void* m_pLibreOfficeKitViewData;
+ SfxLokCallbackInterface* m_pLibreOfficeKitViewCallback;
/// Set if we are in the middle of a tiled search.
bool m_bTiledSearching;
static sal_uInt32 m_nLastViewShellId;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 1119af3dc23d..d0d7e0e745ef 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -20,6 +20,7 @@
#include <config_features.h>
#include <sal/log.hxx>
+#include <rtl/strbuf.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>
#include <svl/whiter.hxx>
@@ -83,6 +84,7 @@
#include <sfx2/sfxsids.hrc>
#include <sfx2/objface.hxx>
#include <sfx2/lokhelper.hxx>
+#include <sfx2/lokcallback.hxx>
#include <openuriexternally.hxx>
#include <shellimpl.hxx>
@@ -222,7 +224,6 @@ SfxViewShell_Impl::SfxViewShell_Impl(SfxViewShellFlags const nFlags, ViewShellDo
, m_bHasPrintOptions(nFlags & SfxViewShellFlags::HAS_PRINTOPTIONS)
, m_nFamily(0xFFFF) // undefined, default set by TemplateDialog
, m_pLibreOfficeKitViewCallback(nullptr)
-, m_pLibreOfficeKitViewData(nullptr)
, m_bTiledSearching(false)
, m_nViewShellId(SfxViewShell_Impl::m_nLastViewShellId++)
, m_nDocId(nDocId)
@@ -1439,14 +1440,14 @@ bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
return pImpl->m_xAccExec->execute(aKey.GetKeyCode());
}
-void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pData)
+void SfxViewShell::setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallback)
{
+ pImpl->m_pLibreOfficeKitViewCallback = nullptr;
pImpl->m_pLibreOfficeKitViewCallback = pCallback;
- pImpl->m_pLibreOfficeKitViewData = pData;
afterCallbackRegistered();
- if (!pCallback)
+ if (!pImpl->m_pLibreOfficeKitViewCallback)
return;
// Ask other views to tell us about their cursors.
@@ -1459,10 +1460,10 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa
}
}
-void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) const
+static bool ignoreLibreOfficeKitViewCallback(int nType, const SfxViewShell_Impl* pImpl)
{
if (!comphelper::LibreOfficeKit::isActive())
- return;
+ return true;
if (comphelper::LibreOfficeKit::isTiledPainting())
{
@@ -1473,7 +1474,7 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c
break;
default:
// Reject e.g. invalidate during paint.
- return;
+ return true;
}
}
@@ -1487,12 +1488,44 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c
case LOK_CALLBACK_TEXT_SELECTION_END:
case LOK_CALLBACK_GRAPHIC_SELECTION:
case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
- return;
+ return true;
}
}
+ return false;
+}
+
+void SfxViewShell::libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const
+{
+ if (ignoreLibreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, pImpl.get()))
+ return;
+ if (pImpl->m_pLibreOfficeKitViewCallback)
+ pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewInvalidateTilesCallback(pRect, nPart);
+ else
+ SAL_INFO(
+ "sfx.view",
+ "SfxViewShell::libreOfficeKitViewInvalidateTilesCallback no callback set!");
+}
+
+void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) const
+{
+ if (ignoreLibreOfficeKitViewCallback(nType, pImpl.get()))
+ return;
+ if (pImpl->m_pLibreOfficeKitViewCallback)
+ pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewCallback(nType, pPayload, nViewId);
+ else
+ SAL_INFO(
+ "sfx.view",
+ "SfxViewShell::libreOfficeKitViewCallback no callback set! Dropped payload of type "
+ << lokCallbackTypeToString(nType) << ": [" << pPayload << ']');
+}
+
+void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) const
+{
+ if (ignoreLibreOfficeKitViewCallback(nType, pImpl.get()))
+ return;
if (pImpl->m_pLibreOfficeKitViewCallback)
- pImpl->m_pLibreOfficeKitViewCallback(nType, pPayload, pImpl->m_pLibreOfficeKitViewData);
+ pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewCallback(nType, pPayload);
else
SAL_INFO(
"sfx.view",
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index ff258d5c13b8..a63f4019a767 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -12,6 +12,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
+#include <sfx2/lokcallback.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/scheduler.hxx>
@@ -91,30 +92,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxNodeSplit)
namespace
{
-struct ViewCallback
+struct ViewCallback : public SfxLokCallbackInterface
{
int m_nInvalidations = 0;
- 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)
+ virtual void libreOfficeKitViewCallback(int, const char*) override {}
+ virtual void libreOfficeKitViewCallback(int, const char*, int) override {}
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*, int) override
{
- case LOK_CALLBACK_INVALIDATE_TILES:
- {
- ++m_nInvalidations;
- }
- break;
+ ++m_nInvalidations;
}
-}
+};
}
CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTitleFieldInvalidate)
@@ -131,8 +119,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTitleFieldInvalidate)
SwWrtShell* pWrtShell = pShell->GetWrtShell();
pWrtShell->SttEndDoc(/*bStt=*/false);
ViewCallback aCallback;
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&ViewCallback::callback,
- &aCallback);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&aCallback);
Scheduler::ProcessEventsToIdle();
aCallback.m_nInvalidations = 0;
@@ -148,7 +135,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTitleFieldInvalidate)
CPPUNIT_ASSERT_EQUAL(1, aCallback.m_nInvalidations);
// Tear down LOK.
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(nullptr);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index fb54b37bb3fd..b9232d63b343 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -40,6 +40,7 @@
#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>
@@ -74,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
+class SwTiledRenderingTest : public SwModelTestBase, public SfxLokCallbackInterface
{
public:
SwTiledRenderingTest();
@@ -240,10 +241,13 @@ 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.
@@ -293,7 +297,7 @@ void SwTiledRenderingTest::tearDown()
SwWrtShell* pWrtShell = pTextDocument->GetDocShell()->GetWrtShell();
if (pWrtShell)
{
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(nullptr);
}
}
mxComponent->dispose();
@@ -317,35 +321,18 @@ SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
return pTextDocument;
}
-void SwTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
+void SwTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/)
{
- static_cast<SwTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
+ libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
}
-void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
+void SwTiledRenderingTest::libreOfficeKitViewCallback(int nType, const char* pPayload)
{
OString aPayload(pPayload);
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- {
- 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;
+ abort();
case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
{
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
@@ -428,14 +415,24 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
}
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()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Insert a character at the beginning of the document.
pWrtShell->Insert("x");
@@ -617,7 +614,7 @@ void SwTiledRenderingTest::testSearch()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
std::size_t nNode = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
// First hit, in the second paragraph, before the shape.
@@ -682,7 +679,7 @@ void SwTiledRenderingTest::testSearchTextFrame()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
@@ -697,7 +694,7 @@ void SwTiledRenderingTest::testSearchTextFrameWrapAround()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
@@ -715,7 +712,7 @@ void SwTiledRenderingTest::testDocumentSizeChanged()
// Get the current document size.
SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
Size aSize = pXTextDocument->getDocumentSize();
// Delete the second page and see how the size changes.
@@ -731,7 +728,7 @@ void SwTiledRenderingTest::testSearchAll()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
@@ -749,7 +746,7 @@ void SwTiledRenderingTest::testSearchAllNotifications()
{
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Reset notification counter before search.
m_nSelectionBeforeSearchResult = 0;
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
@@ -776,7 +773,7 @@ void SwTiledRenderingTest::testPageDownInvalidation()
}));
pXTextDocument->initializeForTiledRendering(aPropertyValues);
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
comphelper::dispatchCommand(".uno:PageDown", uno::Sequence<beans::PropertyValue>());
// This was 2.
@@ -796,7 +793,7 @@ void SwTiledRenderingTest::testPartHash()
namespace {
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback final
+class ViewCallback final : public SfxLokCallbackInterface
{
SfxViewShell* mpViewShell;
int mnView;
@@ -843,32 +840,29 @@ public:
rBeforeInstallFunc(*this);
mpViewShell = pViewShell ? pViewShell : SfxViewShell::Current();
- mpViewShell->registerLibreOfficeKitViewCallback(&ViewCallback::callback, this);
+ mpViewShell->setLibreOfficeKitViewCallback(this);
mnView = SfxLokHelper::getView();
}
~ViewCallback()
{
SfxLokHelper::setView(mnView);
- mpViewShell->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ mpViewShell->setLibreOfficeKitViewCallback(nullptr);
}
- static void callback(int nType, const char* pPayload, void* pData)
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int /*nViewId*/) override
{
- static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
+ libreOfficeKitViewCallback(nType, pPayload); // the view id is also included in payload
}
- void callbackImpl(int nType, const char* pPayload)
+ virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override
{
OString aPayload(pPayload);
m_bCalled = true;
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
- {
- m_bTilesInvalidated = true;
- }
- break;
+ abort();
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
m_bOwnCursorInvalidated = true;
@@ -980,6 +974,11 @@ public:
break;
}
}
+ virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle*,
+ int) override
+ {
+ m_bTilesInvalidated = true;
+ }
};
class TestResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
@@ -1275,9 +1274,9 @@ void SwTiledRenderingTest::testUndoLimiting()
CPPUNIT_ASSERT(pWrtShell2->GetLastUndoInfo(nullptr, nullptr, &pWrtShell2->GetView()));
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void SwTiledRenderingTest::testUndoShapeLimiting()
@@ -1312,9 +1311,9 @@ void SwTiledRenderingTest::testUndoShapeLimiting()
rUndoManager.SetView(nullptr);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void SwTiledRenderingTest::testUndoDispatch()
@@ -1351,9 +1350,9 @@ void SwTiledRenderingTest::testUndoDispatch()
CPPUNIT_ASSERT(xFrame1 != xFrame2);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void SwTiledRenderingTest::testUndoRepairDispatch()
@@ -1393,9 +1392,9 @@ void SwTiledRenderingTest::testUndoRepairDispatch()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount());
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void SwTiledRenderingTest::testShapeTextUndoShells()
@@ -1511,7 +1510,7 @@ void SwTiledRenderingTest::testTrackChangesCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Turn on track changes and type "x".
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
@@ -1538,7 +1537,7 @@ void SwTiledRenderingTest::testRedlineUpdateCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Turn on track changes, type "xx" and delete the second one.
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
@@ -1816,9 +1815,9 @@ void SwTiledRenderingTest::testUndoRepairResult()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void SwTiledRenderingTest::testRedoRepairResult()
@@ -1854,9 +1853,9 @@ void SwTiledRenderingTest::testRedoRepairResult()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair);
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
namespace {
@@ -2007,9 +2006,9 @@ void SwTiledRenderingTest::testAllTrackedChanges()
}
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
void SwTiledRenderingTest::testDocumentRepair()
@@ -2057,9 +2056,9 @@ void SwTiledRenderingTest::testDocumentRepair()
}
SfxLokHelper::setView(nView1);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
SfxLokHelper::setView(nView2);
- SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr);
+ SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr);
}
namespace {
@@ -2328,7 +2327,7 @@ void SwTiledRenderingTest::testSplitNodeRedlineCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("splitnode_redline_callback.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// 1. test case
// Move cursor between the two tracked changes
@@ -2386,7 +2385,7 @@ void SwTiledRenderingTest::testDeleteNodeRedlineCallback()
// Load a document.
SwXTextDocument* pXTextDocument = createDoc("removenode_redline_callback.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// 1. test case
// Move cursor between the two tracked changes
@@ -2738,7 +2737,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()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Save the document.
utl::MediaDescriptor aMediaDescriptor;
@@ -2754,7 +2753,7 @@ void SwTiledRenderingTest::testHyperlink()
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
SwXTextDocument* pXTextDocument = createDoc("hyperlink.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
Point aStart = pShellCursor->GetSttPos();
@@ -2781,7 +2780,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButton()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -2854,7 +2853,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonEditing()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -2911,7 +2910,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonNoSelection()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -2964,7 +2963,7 @@ void SwTiledRenderingTest::testMoveShapeHandle()
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
pWrtShell->SelectObj(Point(), 0, pObject);
@@ -2997,7 +2996,7 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonNoItem()
pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Move the cursor to trigger displaying of the field button.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
@@ -3034,7 +3033,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()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
// Enter the table.
pWrtShell->Down(/*bSelect=*/false);
Scheduler::ProcessEventsToIdle();
@@ -3132,7 +3131,7 @@ void SwTiledRenderingTest::testBulletDeleteInvalidation()
pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(),
pWrtShell->GetLayout()->getFrameArea());
Scheduler::ProcessEventsToIdle();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
m_aInvalidations = tools::Rectangle();
// When pressing backspace in the last paragraph.
@@ -3162,7 +3161,7 @@ void SwTiledRenderingTest::testBulletNoNumInvalidation()
pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(),
pWrtShell->GetLayout()->getFrameArea());
Scheduler::ProcessEventsToIdle();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
m_aInvalidations = tools::Rectangle();
// When pressing backspace in the last paragraph to turn bullets off.
@@ -3199,7 +3198,7 @@ void SwTiledRenderingTest::testBulletMultiDeleteInvalidation()
pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(),
pWrtShell->GetLayout()->getFrameArea());
Scheduler::ProcessEventsToIdle();
- pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(this);
m_aInvalidations = tools::Rectangle();
// When selecting and deleting several bullets: select till the end of the 2nd para and delete.