diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-09-26 11:35:39 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-09-27 13:20:20 +0200 |
commit | 79e1e83e9c27e321280172fbf9a865ac4a40192a (patch) | |
tree | 39dc48da100831c407e7a0cce9e6f1d10094f88b | |
parent | 584222d0621969f082f032566cc10ddf35fa043e (diff) |
lok: deduplicate code related to notifyDocumentSizeChanged() call
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>
(cherry picked from commit e9260633df07b6796b19bc92523671cb345597a1)
Change-Id: Ia4cef7b23fc682ec32aeb9be4dcdd582464c64e9
Reviewed-on: https://gerrit.libreoffice.org/79624
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r-- | include/sfx2/lokhelper.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 36 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh3.cxx | 9 | ||||
-rw-r--r-- | sd/source/core/drawdoc2.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 13 |
6 files changed, 31 insertions, 52 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 8a5503d85c2c..2a7f36bfd9bc 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -51,6 +51,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 d7b973e88b4c..a2e149bc9a3d 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -592,13 +592,8 @@ bool ScDocument::InsertTab( if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer()) { - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) - { - ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + ScModelObj* pModel = ScModelObj::getImplementation(this->GetDocumentShell()->GetModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } } @@ -772,13 +767,8 @@ bool ScDocument::DeleteTab( SCTAB nTab ) if (comphelper::LibreOfficeKit::isActive()) { - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) - { - ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + ScModelObj* pModel = ScModelObj::getImplementation(this->GetDocumentShell()->GetModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } bValid = true; @@ -882,13 +872,8 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) if (comphelper::LibreOfficeKit::isActive()) { - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) - { - ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + ScModelObj* pModel = ScModelObj::getImplementation(this->GetDocumentShell()->GetModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } bValid = true; @@ -934,13 +919,8 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer()) { - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) - { - ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + ScModelObj* pModel = ScModelObj::getImplementation(this->GetDocumentShell()->GetModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } } } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 70a43e3def5a..bdda87803ffe 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -168,13 +168,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 = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + ScModelObj* pModel = ScModelObj::getImplementation(this->GetModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } } diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 7aabcc7007c4..689db17d3181 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -412,13 +412,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 = SdXImpressDocument::getImplementation(this->getUnoModel()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + SdXImpressDocument* pModel = SdXImpressDocument::getImplementation(this->getUnoModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } } @@ -446,13 +441,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 = SdXImpressDocument::getImplementation(this->getUnoModel()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } + SdXImpressDocument* pModel = SdXImpressDocument::getImplementation(this->getUnoModel()); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } return pPage; diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index af300693ccb3..3bc0c739600a 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -1021,11 +1021,10 @@ IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, ListBox&, void) if (comphelper::LibreOfficeKit::isActive()) { SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - while (pViewShell) + if (pViewShell) { SdXImpressDocument* pModel = SdXImpressDocument::getImplementation(pViewShell->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); - pViewShell = SfxViewShell::GetNext(*pViewShell); + SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel); } } } diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 4343c2633da8..dc1c7282fc16 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -221,6 +221,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; |