desktop/inc/lib/init.hxx | 12 +++++++++--- desktop/qa/desktop_lib/test_desktop_lib.cxx | 16 +++++++++++++++- include/tools/gen.hxx | 15 +++++++-------- 3 files changed, 31 insertions(+), 12 deletions(-)
New commits: commit 46aef6ae1a450c218b80b7e5bfe31b710217245d Author: Luboš Luňák <[email protected]> AuthorDate: Fri Dec 10 18:15:17 2021 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Wed Dec 15 04:46:31 2021 +0100 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/+/126650 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Meeks <[email protected]> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 4499914839a0..5e1e23b2cdb5 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -41,13 +41,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) { } @@ -55,9 +60,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 6eb1f73bfcc7..bee2c2aab765 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1852,7 +1852,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++])); } } @@ -1970,6 +1970,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])); } + // Very that the "EMPTY" invalidation gets converted properly. + { + std::vector<std::tuple<int, std::string>> notifs; + std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackBinaryCallbackTest, ¬ifs)); + 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() diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 13372a916d76..7087bc3ffc18 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -382,7 +382,7 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Rectangle final public: Rectangle(); Rectangle( const Point& rLT, const Point& rRB ); - Rectangle( tools::Long nLeft, tools::Long nTop, + constexpr Rectangle( tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom ); /// Constructs an empty Rectangle, with top/left at the specified params Rectangle( tools::Long nLeft, tools::Long nTop ); @@ -504,14 +504,13 @@ inline tools::Rectangle::Rectangle( const Point& rLT, const Point& rRB ) nBottom = rRB.Y(); } -inline tools::Rectangle::Rectangle( tools::Long _nLeft, tools::Long _nTop, +constexpr inline tools::Rectangle::Rectangle( tools::Long _nLeft, tools::Long _nTop, tools::Long _nRight, tools::Long _nBottom ) -{ - nLeft = _nLeft; - nTop = _nTop; - nRight = _nRight; - nBottom = _nBottom; -} + : nLeft( _nLeft ) + , nTop( _nTop ) + , nRight( _nRight ) + , nBottom( _nBottom ) +{} inline tools::Rectangle::Rectangle( tools::Long _nLeft, tools::Long _nTop ) {
