[Libreoffice-commits] core.git: Branch 'feature/sc_lok_invalidation' - 2 commits - include/sfx2 sc/source sd/qa sd/source sfx2/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 22 12:26:44 UTC 2019
include/sfx2/lokhelper.hxx | 2 +
sc/source/core/data/document.cxx | 36 +++++------------------
sc/source/ui/docshell/docsh3.cxx | 9 +----
sd/qa/unit/tiledrendering/tiledrendering.cxx | 42 +++++++++++++++++++++++++++
sd/source/core/drawdoc2.cxx | 18 ++---------
sd/source/ui/sidebar/SlideBackground.cxx | 7 +---
sfx2/source/view/lokhelper.cxx | 13 ++++++++
7 files changed, 74 insertions(+), 53 deletions(-)
New commits:
commit ab5be6ec9d1b28abba287e56aeea4d9d8d15065a
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Sep 22 13:21:46 2019 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sun Sep 22 13:33:04 2019 +0200
sd lok: Test invalidation after adding\removing slide
Change-Id: I4677d78b1bfad36a7b3bde4651b9900e617b6422
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 80d77b9fd04e..9422355835b2 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -121,6 +121,7 @@ public:
void testCutSelectionChange();
void testRegenerateDiagram();
void testLanguageAllText();
+ void testInsertDeletePageInvalidation();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testCreateDestroy);
@@ -171,6 +172,7 @@ public:
CPPUNIT_TEST(testCutSelectionChange);
CPPUNIT_TEST(testRegenerateDiagram);
CPPUNIT_TEST(testLanguageAllText);
+ CPPUNIT_TEST(testInsertDeletePageInvalidation);
CPPUNIT_TEST_SUITE_END();
@@ -972,6 +974,7 @@ public:
bool m_bCursorVisibleChanged;
bool m_bViewLock;
bool m_bTilesInvalidated;
+ std::vector<tools::Rectangle> m_aInvalidations;
std::map<int, bool> m_aViewCursorInvalidations;
std::map<int, bool> m_aViewCursorVisibilities;
bool m_bViewSelectionSet;
@@ -1009,6 +1012,18 @@ public:
case LOK_CALLBACK_INVALIDATE_TILES:
{
m_bTilesInvalidated = true;
+ OString text(pPayload);
+ if (!text.startsWith("EMPTY"))
+ {
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload));
+ CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+ tools::Rectangle aInvalidationRect;
+ aInvalidationRect.setX(aSeq[0].toInt32());
+ aInvalidationRect.setY(aSeq[1].toInt32());
+ aInvalidationRect.setWidth(aSeq[2].toInt32());
+ aInvalidationRect.setHeight(aSeq[3].toInt32());
+ m_aInvalidations.push_back(aInvalidationRect);
+ }
}
break;
case LOK_CALLBACK_GRAPHIC_SELECTION:
@@ -2271,6 +2286,33 @@ void SdTiledRenderingTest::testRegenerateDiagram()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), pActualPage->GetObj(0)->GetSubList()->GetObjCount());
}
+void SdTiledRenderingTest::testInsertDeletePageInvalidation()
+{
+ // Load the document.
+ comphelper::LibreOfficeKit::setActive();
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ ViewCallback aView1;
+ CPPUNIT_ASSERT_EQUAL(8, pXImpressDocument->getParts());
+
+ // Insert slide
+ aView1.m_bTilesInvalidated = false;
+ aView1.m_aInvalidations.clear();
+ comphelper::dispatchCommand(".uno:InsertPage", uno::Sequence<beans::PropertyValue>());
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
+ CPPUNIT_ASSERT_EQUAL(9, pXImpressDocument->getParts());
+ CPPUNIT_ASSERT_EQUAL(size_t(9), aView1.m_aInvalidations.size());
+
+ // Delete slide
+ aView1.m_bTilesInvalidated = false;
+ aView1.m_aInvalidations.clear();
+ comphelper::dispatchCommand(".uno:DeletePage", uno::Sequence<beans::PropertyValue>());
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
+ CPPUNIT_ASSERT_EQUAL(8, pXImpressDocument->getParts());
+ CPPUNIT_ASSERT_EQUAL(size_t(8), aView1.m_aInvalidations.size());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 20d2af7cb72d66fb2bcc60fdcd19f62b70acc7e8
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Sep 22 13:20:49 2019 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sun Sep 22 13:21:11 2019 +0200
lok: deduplicate code related to notifyDocumentSizeChanged() call
Change-Id: Ia4cef7b23fc682ec32aeb9be4dcdd582464c64e9
co-author: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index cae234e6a164..4973fba83e19 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -49,6 +49,8 @@ public:
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_DOCUMENT_SIZE_CHANGED for all views - if @bInvalidateAll - first invalidates all parts
+ static void notifyDocumentSizeChangedAllViews(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/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 81cdc056daf1..e94d0b4f0db5 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -584,13 +584,8 @@ bool ScDocument::InsertTab(
if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer())
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(this->GetDocumentShell()->GetModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
}
}
@@ -755,13 +750,8 @@ bool ScDocument::DeleteTab( SCTAB nTab )
if (comphelper::LibreOfficeKit::isActive())
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(this->GetDocumentShell()->GetModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
}
bValid = true;
@@ -852,13 +842,8 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
if (comphelper::LibreOfficeKit::isActive())
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(this->GetDocumentShell()->GetModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
}
bValid = true;
@@ -904,13 +889,8 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc
if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer())
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(this->GetDocumentShell()->GetModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
}
}
}
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index c9267f436ebe..cf0fecf46fd6 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -172,13 +172,8 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, sa
// the document size too - cell size affects that, obviously)
if ((nPart & (PaintPartFlags::Top | PaintPartFlags::Left)) && comphelper::LibreOfficeKit::isActive())
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(this->GetModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
}
}
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 8bde30f2380e..5fdde48063c3 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -398,13 +398,8 @@ void SdDrawDocument::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
if (comphelper::LibreOfficeKit::isActive() && static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard)
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
}
}
@@ -432,13 +427,8 @@ SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
if (comphelper::LibreOfficeKit::isActive() && static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard)
{
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(this->getUnoModel());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
}
return pPage;
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx
index 493c1984ed25..550fc741bf3c 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -1009,11 +1009,10 @@ IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, ListBox&, void)
if (comphelper::LibreOfficeKit::isActive())
{
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
+ if (pViewShell)
{
- SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(pViewShell->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
+ SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(pViewShell->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
}
}
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 60ff1e0fba1e..5aa3316c4c3f 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -242,6 +242,19 @@ void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, cons
pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, rPayload.getStr());
}
+void SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
+{
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, bInvalidateAll);
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+}
+
void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle)
{
OString sPayload;
More information about the Libreoffice-commits
mailing list