summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-09-22 13:20:49 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-09-25 12:34:40 +0200
commite9260633df07b6796b19bc92523671cb345597a1 (patch)
tree88ec562b1fc57bf49deabed28166079c5880d53a
parentdb0e7e3715bdef7ad6c1f536e9cf1ea84773fbe8 (diff)
lok: deduplicate code related to notifyDocumentSizeChanged() call
Change-Id: Ia4cef7b23fc682ec32aeb9be4dcdd582464c64e9 co-author: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/79498 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--sc/source/core/data/document.cxx36
-rw-r--r--sc/source/ui/docshell/docsh3.cxx9
-rw-r--r--sd/source/core/drawdoc2.cxx18
-rw-r--r--sd/source/ui/sidebar/SlideBackground.cxx7
-rw-r--r--sfx2/source/view/lokhelper.cxx13
6 files changed, 32 insertions, 53 deletions
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;