desktop/inc/lib/init.hxx                     |   16 +++-
 desktop/qa/desktop_lib/test_desktop_lib.cxx  |   96 +++++++++++++--------------
 desktop/source/lib/init.cxx                  |   51 +++++++++++---
 include/editeng/outliner.hxx                 |    2 
 include/sfx2/lokcallback.hxx                 |    3 
 include/sfx2/viewsh.hxx                      |    2 
 include/test/lokcallback.hxx                 |    4 -
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   12 ++-
 sc/source/ui/view/tabview5.cxx               |    2 
 sfx2/source/view/lokhelper.cxx               |    5 -
 sfx2/source/view/viewsh.cxx                  |    4 -
 test/source/lokcallback.cxx                  |    4 -
 12 files changed, 125 insertions(+), 76 deletions(-)

New commits:
commit 2ce5ee9f20ee5bf17ccd0135c1c891bee803e5c1
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Mon Aug 29 09:07:33 2022 +0200
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Fri Oct 21 15:10:09 2022 +0200

    lok: masterpage: use EditMode as parameter in invalidation callback
    
    Change-Id: I3905fc9e6376ca1cef3e438e7a5f229d3720b1f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138961
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Henry Castro <hcas...@collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 7346e51ff159..b3b433854517 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -43,6 +43,7 @@ namespace desktop {
     {
         tools::Rectangle m_aRectangle;
         int m_nPart;
+        int m_nMode;
 
         // This is the "EMPTY" rectangle, which somewhat confusingly actually 
means
         // to drop all rectangles (see LOK_CALLBACK_INVALIDATE_TILES 
documentation),
@@ -51,12 +52,14 @@ namespace desktop {
 
         RectangleAndPart()
             : m_nPart(INT_MIN)  // -1 is reserved to mean "all parts".
+            , m_nMode(0)
         {
         }
 
-        RectangleAndPart(const tools::Rectangle* pRect, int nPart)
+        RectangleAndPart(const tools::Rectangle* pRect, int nPart, int nMode)
             : m_aRectangle( pRect ? SanitizedRectangle(*pRect) : 
emptyAllRectangle)
             , m_nPart(nPart)
+            , m_nMode(nMode)
         {
         }
 
@@ -64,7 +67,7 @@ namespace desktop {
         {
             if (m_nPart >= -1)
                 return (isInfinite() ? "EMPTY" : m_aRectangle.toString())
-                    + ", " + OString::number(m_nPart);
+                    + ", " + OString::number(m_nPart) + ", " + 
OString::number(m_nMode);
             else
                 return (isInfinite() ? "EMPTY" : m_aRectangle.toString());
         }
@@ -116,7 +119,7 @@ namespace desktop {
         // SfxLockCallbackInterface
         virtual void libreOfficeKitViewCallback(int nType, const char* 
pPayload) override;
         virtual void libreOfficeKitViewCallbackWithViewId(int nType, const 
char* pPayload, int nViewId) override;
-        virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) override;
+        virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart, int nMode) override;
         virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
         virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) override;
         virtual void libreOfficeKitViewAddPendingInvalidateTiles() override;
@@ -137,7 +140,12 @@ namespace desktop {
             }
 
             CallbackData(const tools::Rectangle* pRect, int viewId)
-                : PayloadObject(RectangleAndPart(pRect, viewId))
+                : PayloadObject(RectangleAndPart(pRect, viewId, 0))
+            { // PayloadString will be done on demand
+            }
+
+            CallbackData(const tools::Rectangle* pRect, int part, int mode)
+                : PayloadObject(RectangleAndPart(pRect, part, mode))
             { // PayloadString will be done on demand
             }
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 0475e6c460e4..d14030c2f376 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1789,11 +1789,11 @@ void DesktopLOKTest::testTileInvalidationCompression()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-100, -50, 500, 650, 
0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "100, 100, 200, 200, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-100, -50, 500, 650, 0, 
0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "100, 100, 200, 200, 0, 
0");
 
         Scheduler::ProcessEventsToIdle();
 
@@ -1801,7 +1801,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 
         size_t i = 0;
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 400, 600, 0"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 400, 600, 0, 0"), 
std::get<1>(notifs[i++]));
     }
 
     // Part Number
@@ -1810,11 +1810,11 @@ void DesktopLOKTest::testTileInvalidationCompression()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 1"); // 
Different part
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 0, 0, 2"); // 
Invalid
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 200, 200, 
0"); // Inside first
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
1"); // Invalid
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 1, 0"); 
// Different part
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 0, 0, 2, 0"); // 
Invalid
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 200, 200, 
0, 0"); // Inside first
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
1, 0"); // Invalid
 
         Scheduler::ProcessEventsToIdle();
 
@@ -1822,10 +1822,10 @@ void DesktopLOKTest::testTileInvalidationCompression()
 
         size_t i = 0;
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 200, 200, 1"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 200, 200, 1, 0"), 
std::get<1>(notifs[i++]));
 
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 239, 239, 0"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 239, 239, 0, 0"), 
std::get<1>(notifs[i++]));
     }
 
     // All Parts
@@ -1834,14 +1834,14 @@ void DesktopLOKTest::testTileInvalidationCompression()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0"); // 0
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 1"); // 
1: Different part
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 0, 0, -1"); // 
Invalid
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 200, 200, 
-1"); // 0: All parts
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
-1"); // Invalid
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-100, -100, 1200, 1200, 
-1"); // 0: All parts
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 3"); // 
Overlapped
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "1000, 1000, 1239, 1239, 
2"); // 1: Unique region
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0, 0"); 
// 0
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 1, 0"); 
// 1: Different part
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 0, 0, -1, 0"); // 
Invalid
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 200, 200, 
-1, 0"); // 0: All parts
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
-1, 0"); // Invalid
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-100, -100, 1200, 1200, 
-1, 0"); // 0: All parts
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 3, 0"); 
// Overlapped
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "1000, 1000, 1239, 1239, 
2, 0"); // 1: Unique region
 
         Scheduler::ProcessEventsToIdle();
 
@@ -1849,10 +1849,10 @@ void DesktopLOKTest::testTileInvalidationCompression()
 
         size_t i = 0;
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 1100, 1100, -1"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 1100, 1100, -1, 0"), 
std::get<1>(notifs[i++]));
 
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("1000, 1000, 1239, 1239, 2"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("1000, 1000, 1239, 1239, 2, 0"), 
std::get<1>(notifs[i++]));
     }
 
     // All Parts (partial)
@@ -1861,14 +1861,14 @@ void DesktopLOKTest::testTileInvalidationCompression()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 0"); // 0
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 100, 100, 1"); // 
1: Different part
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 0, 0, -1"); // 
Invalid
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "150, 150, 50, 50, -1"); 
// 2: All-parts
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
-1"); // Invalid
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "150, 150, 40, 40, 3"); 
// Overlapped w/ 2
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 4"); // 
3: Unique
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "1000, 1000, 1239, 1239, 
1"); // 4: Unique
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 0, 0"); 
// 0
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 100, 100, 1, 0"); 
// 1: Different part
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 0, 0, -1, 0"); // 
Invalid
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "150, 150, 50, 50, -1, 
0"); // 2: All-parts
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
-1, 0"); // Invalid
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "150, 150, 40, 40, 3, 
0"); // Overlapped w/ 2
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 200, 200, 4, 0"); 
// 3: Unique
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "1000, 1000, 1239, 1239, 
1, 0"); // 4: Unique
 
         Scheduler::ProcessEventsToIdle();
 
@@ -1876,19 +1876,19 @@ void DesktopLOKTest::testTileInvalidationCompression()
 
         size_t i = 0;
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 200, 200, 0"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 200, 200, 0, 0"), 
std::get<1>(notifs[i++]));
 
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 100, 100, 1"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 100, 100, 1, 0"), 
std::get<1>(notifs[i++]));
 
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("150, 150, 50, 50, -1"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("150, 150, 50, 50, -1, 0"), 
std::get<1>(notifs[i++]));
 
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 200, 200, 4"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 200, 200, 4, 0"), 
std::get<1>(notifs[i++]));
 
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("1000, 1000, 1239, 1239, 1"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("1000, 1000, 1239, 1239, 1, 0"), 
std::get<1>(notifs[i++]));
     }
 
     // Merge with "EMPTY"
@@ -1897,11 +1897,11 @@ void DesktopLOKTest::testTileInvalidationCompression()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "EMPTY, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 240, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 300, 300, 
0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "EMPTY, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 240, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 300, 300, 
0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 
0, 0");
 
         Scheduler::ProcessEventsToIdle();
 
@@ -1909,7 +1909,7 @@ void DesktopLOKTest::testTileInvalidationCompression()
 
         size_t i = 0;
         CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), 
std::get<0>(notifs[i]));
-        CPPUNIT_ASSERT_EQUAL(std::string("EMPTY, 0"), 
std::get<1>(notifs[i++]));
+        CPPUNIT_ASSERT_EQUAL(std::string("EMPTY, 0, 0"), 
std::get<1>(notifs[i++]));
     }
 }
 
@@ -1958,8 +1958,8 @@ void DesktopLOKTest::testPartInInvalidation()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 0, 0");
 
         Scheduler::ProcessEventsToIdle();
 
@@ -1977,8 +1977,8 @@ void DesktopLOKTest::testPartInInvalidation()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0");
-        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 1");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0, 0");
+        handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 1, 0");
 
         Scheduler::ProcessEventsToIdle();
 
@@ -2019,7 +2019,7 @@ void DesktopLOKTest::testBinaryCallback()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackBinaryCallbackTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->libreOfficeKitViewInvalidateTilesCallback(&rect1, INT_MIN);
+        handler->libreOfficeKitViewInvalidateTilesCallback(&rect1, INT_MIN, 0);
 
         Scheduler::ProcessEventsToIdle();
 
@@ -2033,7 +2033,7 @@ void DesktopLOKTest::testBinaryCallback()
         std::unique_ptr<CallbackFlushHandler> handler(new 
CallbackFlushHandler(pDocument, callbackBinaryCallbackTest, &notifs));
         handler->setViewId(SfxLokHelper::getView());
 
-        handler->libreOfficeKitViewInvalidateTilesCallback(nullptr, INT_MIN);
+        handler->libreOfficeKitViewInvalidateTilesCallback(nullptr, INT_MIN, 
0);
 
         Scheduler::ProcessEventsToIdle();
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8b93b9815a8f..c2e8a285663a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -67,6 +67,7 @@
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/scopeguard.hxx>
 #include <comphelper/threadpool.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 
 #include <com/sun/star/document/MacroExecMode.hpp>
@@ -427,12 +428,26 @@ RectangleAndPart RectangleAndPart::Create(const 
std::string& rPayload)
     {
         aRet.m_aRectangle = tools::Rectangle(0, 0, SfxLokHelper::MaxTwips, 
SfxLokHelper::MaxTwips);
         if (comphelper::LibreOfficeKit::isPartInInvalidation())
-            aRet.m_nPart = std::stol(rPayload.substr(6));
+        {
+            int nSeparatorPos = rPayload.find(',', 6);
+            bool bHasMode = nSeparatorPos > 0;
+            if (bHasMode)
+            {
+                aRet.m_nPart = std::stol(rPayload.substr(6, nSeparatorPos - 
6));
+                assert(rPayload.length() > o3tl::make_unsigned(nSeparatorPos));
+                aRet.m_nMode = std::stol(rPayload.substr(nSeparatorPos + 1));
+            }
+            else
+            {
+                aRet.m_nPart = std::stol(rPayload.substr(6));
+                aRet.m_nMode = 0;
+            }
+        }
 
         return aRet;
     }
 
-    // Read '<left>, <top>, <width>, <height>[, <part>]'. C++ streams are 
simpler but slower.
+    // Read '<left>, <top>, <width>, <height>[, <part>, <mode>]'. C++ streams 
are simpler but slower.
     const char* pos = rPayload.c_str();
     const char* end = rPayload.c_str() + rPayload.size();
     tools::Long nLeft = rtl_str_toInt64_WithLength(pos, 10, end - pos);
@@ -452,6 +467,7 @@ RectangleAndPart RectangleAndPart::Create(const 
std::string& rPayload)
     assert(pos < end);
     tools::Long nHeight = rtl_str_toInt64_WithLength(pos, 10, end - pos);
     tools::Long nPart = INT_MIN;
+    tools::Long nMode = 0;
     if (comphelper::LibreOfficeKit::isPartInInvalidation())
     {
         while( *pos != ',' )
@@ -459,10 +475,20 @@ RectangleAndPart RectangleAndPart::Create(const 
std::string& rPayload)
         ++pos;
         assert(pos < end);
         nPart = rtl_str_toInt64_WithLength(pos, 10, end - pos);
+
+        while( *pos && *pos != ',' )
+            ++pos;
+        if (*pos)
+        {
+            ++pos;
+            assert(pos < end);
+            nMode = rtl_str_toInt64_WithLength(pos, 10, end - pos);
+        }
     }
 
     aRet.m_aRectangle = SanitizedRectangle(nLeft, nTop, nWidth, nHeight);
     aRet.m_nPart = nPart;
+    aRet.m_nMode = nMode;
     return aRet;
 }
 
@@ -1465,9 +1491,9 @@ void 
CallbackFlushHandler::libreOfficeKitViewCallbackWithViewId(int nType, const
     queue(nType, callbackData);
 }
 
-void CallbackFlushHandler::libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart)
+void CallbackFlushHandler::libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart, int nMode)
 {
-    CallbackData callbackData(pRect, nPart);
+    CallbackData callbackData(pRect, nPart, nMode);
     queue(LOK_CALLBACK_INVALIDATE_TILES, callbackData);
 }
 
@@ -1803,14 +1829,15 @@ bool 
CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
     {
         auto pos2 = toQueue2(pos);
         const RectangleAndPart& rcOld = pos2->getRectangleAndPart();
-        if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == 
rcNew.m_nPart))
+        if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == 
rcNew.m_nPart) &&
+            (rcOld.m_nMode == rcNew.m_nMode))
         {
             SAL_INFO("lok", "Skipping queue [" << type << "]: [" << 
aCallbackData.getPayload()
                                                << "] since all tiles need to 
be invalidated.");
             return true;
         }
 
-        if (rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart)
+        if ((rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart) && 
(rcOld.m_nMode == rcNew.m_nMode))
         {
             // If fully overlapping.
             if (rcOld.m_aRectangle.Contains(rcNew.m_aRectangle))
@@ -1828,7 +1855,8 @@ bool 
CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
                                        << "] 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.
-            return (rcNew.m_nPart == -1 || rcNew.m_nPart == 
elemData.getRectangleAndPart().m_nPart);
+            return ((rcNew.m_nPart == -1 || rcNew.m_nPart == 
elemData.getRectangleAndPart().m_nPart)
+                && (rcNew.m_nMode == elemData.getRectangleAndPart().m_nMode));
         });
     }
     else
@@ -1838,7 +1866,8 @@ bool 
CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
         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)
+            if (rcNew.m_nPart != -1 && rcOld.m_nPart != -1 &&
+                (rcOld.m_nPart != rcNew.m_nPart || rcOld.m_nMode != 
rcNew.m_nMode))
             {
                 SAL_INFO("lok", "Nothing to merge between new: "
                                     << rcNew.toString() << ", and old: " << 
rcOld.toString());
@@ -1850,7 +1879,7 @@ bool 
CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
                 // Don't merge unless fully overlapped.
                 SAL_INFO("lok", "New " << rcNew.toString() << " has " << 
rcOld.toString()
                                        << "?");
-                if (rcNew.m_aRectangle.Contains(rcOld.m_aRectangle))
+                if (rcNew.m_aRectangle.Contains(rcOld.m_aRectangle) && 
rcOld.m_nMode == rcNew.m_nMode)
                 {
                     SAL_INFO("lok", "New " << rcNew.toString() << " engulfs 
old "
                                            << rcOld.toString() << ".");
@@ -1862,7 +1891,7 @@ bool 
CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
                 // Don't merge unless fully overlapped.
                 SAL_INFO("lok", "Old " << rcOld.toString() << " has " << 
rcNew.toString()
                                        << "?");
-                if (rcOld.m_aRectangle.Contains(rcNew.m_aRectangle))
+                if (rcOld.m_aRectangle.Contains(rcNew.m_aRectangle) && 
rcOld.m_nMode == rcNew.m_nMode)
                 {
                     SAL_INFO("lok", "New " << rcNew.toString() << " engulfs 
old "
                                            << rcOld.toString() << ".");
@@ -1873,7 +1902,7 @@ bool 
CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& a
             {
                 const tools::Rectangle rcOverlap
                     = rcNew.m_aRectangle.GetIntersection(rcOld.m_aRectangle);
-                const bool bOverlap = !rcOverlap.IsEmpty();
+                const bool bOverlap = !rcOverlap.IsEmpty() && rcOld.m_nMode == 
rcNew.m_nMode;
                 SAL_INFO("lok", "Merging " << rcNew.toString() << " & " << 
rcOld.toString()
                                            << " => " << rcOverlap.toString()
                                            << " Overlap: " << bOverlap);
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index c8890a89a72f..e45d00558378 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -370,7 +370,7 @@ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
 public:
     virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) 
const = 0;
     virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* 
pPayload, int nViewId) const = 0;
-    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) const = 0;
+    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart, int nMode) const = 0;
     virtual void libreOfficeKitViewUpdatedCallback(int nType) const = 0;
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) const = 0;
     virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0;
diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx
index 1b90e6c938c5..a277d32a808c 100644
--- a/include/sfx2/lokcallback.hxx
+++ b/include/sfx2/lokcallback.hxx
@@ -41,7 +41,8 @@ public:
     // 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)
+    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart,
+                                                           int nMode)
         = 0;
     // A message of the given type should be sent, for performance purpose 
only a notification
     // is given here, details about the message should be queried from 
SfxViewShell when necessary.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 3fb70cd11719..34efd24aa094 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -345,7 +345,7 @@ public:
     /// Invokes the registered callback, if there are any.
     virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) 
const override;
     virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* 
pPayload, int nViewId) const override;
-    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) const override;
+    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart, int nMode) const override;
     virtual void libreOfficeKitViewUpdatedCallback(int nType) const override;
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) const override;
     // Performs any pending calls to 
libreOfficeKitViewInvalidateTilesCallback() as necessary.
diff --git a/include/test/lokcallback.hxx b/include/test/lokcallback.hxx
index 75a8977938bc..1908838a6cdf 100644
--- a/include/test/lokcallback.hxx
+++ b/include/test/lokcallback.hxx
@@ -34,8 +34,8 @@ public:
     virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) 
override;
     virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* 
pPayload,
                                                       int nViewId) override;
-    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect,
-                                                           int nPart) override;
+    virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart,
+                                                           int nMode) override;
     virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId,
                                                             int nSourceViewId) 
override;
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 41b885f1a525..7cebd398200c 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -613,6 +613,7 @@ public:
     std::vector<tools::Rectangle> m_aInvalidations;
     tools::Rectangle m_aCellCursorBounds;
     std::vector<int> m_aInvalidationsParts;
+    std::vector<int> m_aInvalidationsMode;
     bool m_bViewLock;
     OString m_sCellFormula;
     boost::property_tree::ptree m_aCommentCallbackResult;
@@ -712,15 +713,18 @@ public:
             else
             {
                 uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
-                CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+                CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 6);
                 tools::Rectangle aInvalidationRect;
                 aInvalidationRect.SetLeft(aSeq[0].toInt32());
                 aInvalidationRect.SetTop(aSeq[1].toInt32());
                 aInvalidationRect.setWidth(aSeq[2].toInt32());
                 aInvalidationRect.setHeight(aSeq[3].toInt32());
                 m_aInvalidations.push_back(aInvalidationRect);
-                if (aSeq.getLength() == 5)
+                if (aSeq.getLength() == 6)
+                {
                     m_aInvalidationsParts.push_back(aSeq[4].toInt32());
+                    m_aInvalidationsMode.push_back(aSeq[5].toInt32());
+                }
                 m_bInvalidateTiles = true;
             }
         }
@@ -2008,6 +2012,7 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
     aView1.m_bInvalidateTiles = false;
     aView1.m_aInvalidations.clear();
     aView1.m_aInvalidationsParts.clear();
+    aView1.m_aInvalidationsMode.clear();
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | 
KEY_MOD1);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | 
KEY_MOD1);
     Scheduler::ProcessEventsToIdle();
@@ -2021,6 +2026,9 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
     CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidationsParts.size());
     CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), 
aView1.m_aInvalidationsParts[0]);
     CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), 
aView1.m_aInvalidationsParts[1]);
+    CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidationsMode.size());
+    CPPUNIT_ASSERT_EQUAL(pModelObj->getEditMode(), 
aView1.m_aInvalidationsMode[0]);
+    CPPUNIT_ASSERT_EQUAL(pModelObj->getEditMode(), 
aView1.m_aInvalidationsMode[1]);
     comphelper::LibreOfficeKit::setPartInInvalidation(oldPartInInvalidation);
 }
 
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 5e6d7be6d392..a44f9f8b8455 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -347,7 +347,7 @@ void ScTabView::TabChanged( bool bSameTabButMoved )
 
     // Invalidate first
     tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
-    pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
aViewData.GetTabNo());
+    pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
aViewData.GetTabNo(), 0);
 
     ScModelObj* pModel = 
comphelper::getFromUnoTunnel<ScModelObj>(pViewShell->GetCurrentDocument());
     SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false);
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index ccd88eb5ff6b..d65303762e8a 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -551,7 +551,8 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell const* 
pThisView, tools::Rect
         return;
 
     const int nPart = comphelper::LibreOfficeKit::isPartInInvalidation() ? 
pThisView->getPart() : INT_MIN;
-    pThisView->libreOfficeKitViewInvalidateTilesCallback(pRect, nPart);
+    const int nMode = comphelper::LibreOfficeKit::isPartInInvalidation() ? 
pThisView->getEditMode() : 0;
+    pThisView->libreOfficeKitViewInvalidateTilesCallback(pRect, nPart, nMode);
 }
 
 void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, 
const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
@@ -564,7 +565,7 @@ void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell 
const* pThisView, cons
         for (int i = 0; i < pDoc->getParts(); ++i)
         {
             tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
-            pThisView->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
i);
+            pThisView->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
i, 0);
         }
     }
     pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, 
rPayload.getStr());
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 87e5a44fbe9b..71a5e6cf3db4 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1482,12 +1482,12 @@ static bool ignoreLibreOfficeKitViewCallback(int nType, 
const SfxViewShell_Impl*
     return false;
 }
 
-void SfxViewShell::libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) const
+void SfxViewShell::libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart, int nMode) const
 {
     if (ignoreLibreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, 
pImpl.get()))
         return;
     if (pImpl->m_pLibreOfficeKitViewCallback)
-        
pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewInvalidateTilesCallback(pRect,
 nPart);
+        
pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewInvalidateTilesCallback(pRect,
 nPart, nMode);
     else
         SAL_INFO(
             "sfx.view",
diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx
index d7500cb74443..5af844f089ad 100644
--- a/test/source/lokcallback.cxx
+++ b/test/source/lokcallback.cxx
@@ -59,7 +59,7 @@ void 
TestLokCallbackWrapper::libreOfficeKitViewCallbackWithViewId(int nType, con
 }
 
 void TestLokCallbackWrapper::libreOfficeKitViewInvalidateTilesCallback(
-    const tools::Rectangle* pRect, int nPart)
+    const tools::Rectangle* pRect, int nPart, int nMode)
 {
     OStringBuffer buf(64);
     if (pRect)
@@ -70,6 +70,8 @@ void 
TestLokCallbackWrapper::libreOfficeKitViewInvalidateTilesCallback(
     {
         buf.append(", ");
         buf.append(static_cast<sal_Int32>(nPart));
+        buf.append(", ");
+        buf.append(static_cast<sal_Int32>(nMode));
     }
     callCallback(LOK_CALLBACK_INVALIDATE_TILES, 
buf.makeStringAndClear().getStr(), NO_VIEWID);
 }

Reply via email to