summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-12-10 18:15:17 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-12-14 14:47:23 +0100
commit18470cb6bff9f682b3b86495d80e9ad54c9b5567 (patch)
tree7fffa6aa0597dba876f9f8debf505ab8cfe64ac0 /desktop
parent70e6d969dcbece69bc9bd5e3a0bc5d878a33ca6a (diff)
fix handling of the "EMPTY" LOK tile invalidation
The LOK_CALLBACK_INVALIDATE_TILES documentation says that invalidate-all message should say "EMPTY", which wasn't converted properly from the MaxTwips rectangle representation. Doing that now needs also changing the testTileInvalidationCompression() test, but that should be a fix of the test, and conceptually it should be the same. Change-Id: I58fcc56ee56d9f6fcdb9298938e8aa7e3609d6db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126651 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/inc/lib/init.hxx12
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx18
2 files changed, 25 insertions, 5 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 5ebda0a245d6..1ba7e54ff976 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -42,13 +42,18 @@ namespace desktop {
tools::Rectangle m_aRectangle;
int m_nPart;
+ // This is the "EMPTY" rectangle, which somewhat confusingly actually means
+ // to drop all rectangles (see LOK_CALLBACK_INVALIDATE_TILES documentation),
+ // and so it is actually an infinite rectangle and not an empty one.
+ constexpr static tools::Rectangle emptyAllRectangle = {0, 0, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips};
+
RectangleAndPart()
: m_nPart(INT_MIN) // -1 is reserved to mean "all parts".
{
}
RectangleAndPart(const tools::Rectangle* pRect, int nPart)
- : m_aRectangle( pRect ? *pRect : tools::Rectangle(0, 0, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips))
+ : m_aRectangle( pRect ? *pRect : emptyAllRectangle)
, m_nPart(nPart)
{
}
@@ -56,9 +61,10 @@ namespace desktop {
OString toString() const
{
if (m_nPart >= -1)
- return m_aRectangle.toString() + ", " + OString::number(m_nPart);
+ return (isInfinite() ? "EMPTY" : m_aRectangle.toString())
+ + ", " + OString::number(m_nPart);
else
- return m_aRectangle.toString();
+ return (isInfinite() ? "EMPTY" : m_aRectangle.toString());
}
/// Infinite Rectangle is both sides are
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 5c17f880e2de..c1b1cc34cbf9 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1764,7 +1764,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, 1000000000, 1000000000, 0"), std::get<1>(notifs[i++]));
+ CPPUNIT_ASSERT_EQUAL(std::string("EMPTY, 0"), std::get<1>(notifs[i++]));
}
}
@@ -1855,7 +1855,7 @@ void DesktopLOKTest::testBinaryCallback()
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.
+ // Verify 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));
@@ -1882,6 +1882,20 @@ void DesktopLOKTest::testBinaryCallback()
CPPUNIT_ASSERT_EQUAL(int(LOK_CALLBACK_INVALIDATE_TILES), std::get<0>(notifs[0]));
CPPUNIT_ASSERT_EQUAL(rect1String, std::get<1>(notifs[0]));
}
+ // Verify that the "EMPTY" invalidation gets converted properly.
+ {
+ std::vector<std::tuple<int, std::string>> notifs;
+ std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackBinaryCallbackTest, &notifs));
+ handler->setViewId(SfxLokHelper::getView());
+
+ handler->libreOfficeKitViewInvalidateTilesCallback(nullptr, 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(std::string("EMPTY"), std::get<1>(notifs[0]));
+ }
}
void DesktopLOKTest::testDialogInput()