[Libreoffice-commits] core.git: Branch 'feature/sc_lok_invalidation' - include/LibreOfficeKit include/sfx2 sc/qa sc/source sd/qa sd/source sfx2/source sw/qa sw/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sat Sep 14 15:21:53 UTC 2019
include/LibreOfficeKit/LibreOfficeKitEnums.h | 4 ++++
include/sfx2/lokhelper.hxx | 3 +++
sc/qa/unit/tiledrendering/tiledrendering.cxx | 8 ++++----
sc/source/core/data/document.cxx | 13 +++++++++----
sc/source/ui/docshell/docsh3.cxx | 4 +++-
sc/source/ui/view/tabview.cxx | 7 ++++---
sc/source/ui/view/tabview3.cxx | 3 ++-
sc/source/ui/view/tabview5.cxx | 3 ++-
sd/qa/unit/tiledrendering/tiledrendering.cxx | 2 +-
sd/source/core/drawdoc2.cxx | 8 ++++++--
sd/source/ui/sidebar/SlideBackground.cxx | 5 ++++-
sfx2/source/view/lokhelper.cxx | 20 ++++++++++++++++++++
sw/qa/extras/tiledrendering/tiledrendering.cxx | 2 +-
sw/source/core/view/viewsh.cxx | 6 +++++-
14 files changed, 68 insertions(+), 20 deletions(-)
New commits:
commit 636e264a182a9d89aad38e0db164a7636d0fb30c
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Sep 14 13:22:45 2019 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 14 17:21:02 2019 +0200
lok: send an invalidation by document size change
It was sent by the kit code earlier. Now we move it
to the LO core code, so we can optimize it later.
Change-Id: Id0a8991016dbe8d13891071e2d5b4c9250720da9
co-author: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 44bf83eab205..3839c6fa8e2e 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -262,6 +262,10 @@ typedef enum
*
* Payload format is "width, height", i.e. clients get the new size without
* having to do an explicit lok::Document::getDocumentSize() call.
+ *
+ * A size change is always preceeded by a series of
+ * LOK_CALLBACK_INVALIDATE_TILES events invalidating any areas
+ * need re-rendering to adapt.
*/
LOK_CALLBACK_DOCUMENT_SIZE_CHANGED = 13,
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index b45a06b95766..cae234e6a164 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -11,6 +11,7 @@
#define INCLUDED_SFX2_LOKHELPER_HXX
#include <vcl/IDialogRenderable.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <vcl/event.hxx>
#include <sfx2/dllapi.h>
#include <sfx2/viewsh.hxx>
@@ -46,6 +47,8 @@ public:
vcl::LOKWindowId nWindowId,
const OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
+ /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED - if @bInvalidateAll - first invalidates all parts
+ static void notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true);
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
/// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it according to setOptionalFeatures() if needed.
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 29437d8e91b9..000050262011 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -527,7 +527,7 @@ public:
else
{
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
tools::Rectangle aInvalidationRect;
aInvalidationRect.setX(aSeq[0].toInt32());
aInvalidationRect.setY(aSeq[1].toInt32());
@@ -1014,7 +1014,7 @@ void ScTiledRenderingTest::testInvalidateOnInserRowCol()
comphelper::dispatchCommand(".uno:InsertRows", aArgs);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
- CPPUNIT_ASSERT_EQUAL(size_t(1), aView.m_aInvalidations.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aView.m_aInvalidations.size());
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(-75, 50985, 32212230, 63990), aView.m_aInvalidations[0]);
// move on the right
@@ -1031,7 +1031,7 @@ void ScTiledRenderingTest::testInvalidateOnInserRowCol()
comphelper::dispatchCommand(".uno:InsertColumns", aArgs);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
- CPPUNIT_ASSERT_EQUAL(size_t(1), aView.m_aInvalidations.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aView.m_aInvalidations.size());
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(253650, -15, 32212230, 63990), aView.m_aInvalidations[0]);
}
@@ -1692,7 +1692,7 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | KEY_MOD1);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
- CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(3), aView1.m_aInvalidations.size());
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1310720, 268435456), aView1.m_aInvalidations[0]);
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9e9a3f0a25c7..81cdc056daf1 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -98,6 +98,7 @@
#include <vcl/uitest/eventdescription.hxx>
#include <mtvelements.hxx>
+#include <sfx2/lokhelper.hxx>
using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
@@ -586,7 +587,8 @@ bool ScDocument::InsertTab(
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -756,7 +758,8 @@ bool ScDocument::DeleteTab( SCTAB nTab )
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -852,7 +855,8 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -903,7 +907,8 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index bd648ada28cb..c9267f436ebe 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -69,6 +69,7 @@
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <sfx2/lokhelper.hxx>
// Redraw - Notifications
@@ -174,7 +175,8 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, sa
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 0005a3b2da07..5116fd17e6fc 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2560,7 +2560,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
std::stringstream ss;
ss << aNewSize.Width() << ", " << aNewSize.Height();
OString sSize = ss.str().c_str();
- aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(aViewData.GetViewShell()->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel);
// New area extended to the bottom of the sheet after last row
// excluding overlapping area with aNewColArea
@@ -2703,8 +2704,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
std::stringstream ss;
ss << aNewSize.Width() << ", " << aNewSize.Height();
OString sSize = ss.str().c_str();
- aViewData.GetViewShell()->libreOfficeKitViewCallback(
- LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(aViewData.GetViewShell()->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel);
}
// New area extended to the right of the sheet after last column
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f9dbc14bbd76..c5228c7ab0a7 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -404,7 +404,8 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
std::stringstream ss;
ss << aNewSize.Width() << ", " << aNewSize.Height();
OString sSize = ss.str().c_str();
- aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(aViewData.GetViewShell()->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel);
// New area extended to the right of the sheet after last column
// including overlapping area with aNewRowArea
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 84afe610ff35..3ece4d760efb 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -327,7 +327,8 @@ void ScTabView::TabChanged( bool bSameTabButMoved )
ss << aDocSize.Width() << ", " << aDocSize.Height();
OString sRect = ss.str().c_str();
ScTabViewShell* pViewShell = aViewData.GetViewShell();
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr());
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel);
}
}
}
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index e5783a1731b3..80d77b9fd04e 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -262,7 +262,7 @@ static std::vector<OUString> lcl_convertSeparated(const OUString& rString, sal_U
static void lcl_convertRectangle(const OUString& rString, ::tools::Rectangle& rRectangle)
{
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(rString);
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
rRectangle.setX(aSeq[0].toInt32());
rRectangle.setY(aSeq[1].toInt32());
rRectangle.setWidth(aSeq[2].toInt32());
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index b7c1ae455d42..8bde30f2380e 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -53,6 +53,8 @@
#include <stlpool.hxx>
#include <anminfo.hxx>
#include <undo/undomanager.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <unomodel.hxx>
#include <DrawDocShell.hxx>
@@ -399,7 +401,8 @@ void SdDrawDocument::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
@@ -432,7 +435,8 @@ SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx
index 066a6c6f8a90..493c1984ed25 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -57,6 +57,8 @@
#include <editeng/sizeitem.hxx>
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <unomodel.hxx>
+#include <sfx2/lokhelper.hxx>
using namespace ::com::sun::star;
@@ -1009,7 +1011,8 @@ IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, ListBox&, void)
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 55b157ef6cb2..60ff1e0fba1e 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -222,6 +222,26 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OStri
pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, aBuf.makeStringAndClear().getStr());
}
+void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
+{
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
+ if (!pDoc)
+ return;
+
+ if (bInvalidateAll)
+ {
+ for (int i = 0; i < pDoc->getParts(); ++i)
+ {
+ tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
+ OString sPayload = aRectangle.toString() + OString(", ") + OString::number(i);
+ pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr());
+ }
+ }
+ pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, rPayload.getStr());
+}
+
void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle)
{
OString sPayload;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index b7d7c5d2bd28..35eca8185934 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -264,7 +264,7 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
if (OString("EMPTY") == pPayload)
return;
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
m_aInvalidation.setX(aSeq[0].toInt32());
m_aInvalidation.setY(aSeq[1].toInt32());
m_aInvalidation.setWidth(aSeq[2].toInt32());
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index e20d7de4a4a1..6ec563446366 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -74,6 +74,7 @@
#include <wrtsh.hxx>
#include <DocumentSettingManager.hxx>
+#include <unotxdoc.hxx>
#include <view.hxx>
#include <PostItMgr.hxx>
#include <unotools/configmgr.hxx>
@@ -85,6 +86,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
#include <prevwpage.hxx>
+#include <sfx2/lokhelper.hxx>
#if !HAVE_FEATURE_DESKTOP
#include <vcl/sysdata.hxx>
@@ -1065,7 +1067,9 @@ void SwViewShell::SizeChgNotify()
std::stringstream ss;
ss << aDocSize.Width() + 2 * DOCUMENTBORDER << ", " << aDocSize.Height() + 2 * DOCUMENTBORDER;
OString sSize = ss.str().c_str();
- GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
+
+ SwXTextDocument* pModel = comphelper::getUnoTunnelImplementation<SwXTextDocument>(GetSfxViewShell()->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(GetSfxViewShell(), sSize, pModel);
}
}
}
More information about the Libreoffice-commits
mailing list