summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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>
Diffstat (limited to 'desktop')
-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
3 files changed, 186 insertions, 84 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);
}
}
}