include/sfx2/lokhelper.hxx | 2 + sc/source/core/data/document.cxx | 36 ++++++------------------------- sc/source/ui/docshell/docsh3.cxx | 9 +------ sd/source/core/drawdoc2.cxx | 18 +++------------ sd/source/ui/sidebar/SlideBackground.cxx | 5 +--- sfx2/source/view/lokhelper.cxx | 13 +++++++++++ 6 files changed, 31 insertions(+), 52 deletions(-)
New commits: commit 6e4a68189693626e1b79f675f1cfda846b5ebce8 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Thu Sep 26 11:35:39 2019 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Thu Sep 26 19:55:27 2019 +0200 lok: deduplicate code related to notifyDocumentSizeChanged() call co-author: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/79498 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit e9260633df07b6796b19bc92523671cb345597a1) Change-Id: Ia4cef7b23fc682ec32aeb9be4dcdd582464c64e9 Reviewed-on: https://gerrit.libreoffice.org/79624 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 44664a43041b..f3fc023a290e 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -50,6 +50,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 41ee707ae31e..2d36b6e46f36 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -567,13 +567,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); } } @@ -738,13 +733,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; @@ -835,13 +825,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; @@ -887,13 +872,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 be2eb7bf0cbc..69b8100bf585 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -171,13 +171,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 e4053d5afff4..dd5cdc1d577d 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -413,13 +413,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); } } @@ -447,13 +442,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 fb4d58008cbb..5628d851597d 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -1026,11 +1026,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 96b41737425c..4473602e0484 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -241,6 +241,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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits