include/vcl/ITiledRenderable.hxx | 4 +++- sc/inc/docuno.hxx | 2 +- sc/source/ui/unoobj/docuno.cxx | 15 +++++++++++++-- sd/source/ui/inc/unomodel.hxx | 2 +- sd/source/ui/unoidl/unomodel.cxx | 15 +++++++++++++-- sw/inc/unotxdoc.hxx | 2 +- sw/source/uibase/uno/unotxdoc.cxx | 4 ++-- 7 files changed, 34 insertions(+), 10 deletions(-)
New commits: commit 8920dddd8096888a22274d4c3e9ab79d897d40ac Author: Paris Oplopoios <paris.oplopo...@collabora.com> AuthorDate: Wed Jul 26 17:20:59 2023 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 31 09:33:11 2023 +0200 Allow getViewRenderState to get from a specific view getViewRenderState would get its output from the current view, make it so that it's possible to specify a specific view Change-Id: I279b215f8311b079c220c79b8b41c76bc0210154 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154943 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index 9fa61258fc7a..9b76eb11200e 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -10,6 +10,7 @@ #pragma once +#include <sfx2/viewsh.hxx> #include <tools/gen.hxx> #include <rtl/ustring.hxx> #include <vcl/dllapi.h> @@ -380,8 +381,9 @@ public: /** * Returns an opaque string reflecting the render state of a component * eg. 'PD' - P for non-printing-characters, D for dark-mode. + * @param pViewShell the view to get the options from, if nullptr the current view shell is used */ - virtual OString getViewRenderState() { return rtl::OString(); } + virtual OString getViewRenderState(SfxViewShell* = nullptr) { return rtl::OString(); } }; } // namespace vcl diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index a75afa2834df..611b0c22d2b9 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -396,7 +396,7 @@ public: virtual void completeFunction(const OUString& rFunctionName) override; /// @see vcl::ITiledRenderable::getViewRenderState(). - OString getViewRenderState() override; + OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override; private: Size getDocumentSize(SCCOL& rnTiledRenderingAreaEndCol, SCROW& rnTiledRenderingAreaEndRow ); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index ca5f80eee2c0..971c75b22c22 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1254,10 +1254,21 @@ void ScModelObj::completeFunction(const OUString& rFunctionName) } } -OString ScModelObj::getViewRenderState() +OString ScModelObj::getViewRenderState(SfxViewShell* pViewShell) { OStringBuffer aState; - ScViewData* pViewData = ScDocShell::GetViewData(); + ScViewData* pViewData = nullptr; + + if (pViewShell) + { + ScTabViewShell* pTabViewShell = dynamic_cast< ScTabViewShell*>(pViewShell); + if (pTabViewShell) + pViewData = &pTabViewShell->GetViewData(); + } + else + { + pViewData = ScDocShell::GetViewData(); + } if (pViewData) { diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 3b00f1cb8d90..a2fe9415afa4 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -285,7 +285,7 @@ public: virtual void setPaintTextEdit(bool bPaint) override { mbPaintTextEdit = bPaint; } /// @see vcl::ITiledRenderable::getViewRenderState(). - OString getViewRenderState() override; + OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override; // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 438d2a81faa0..6fc250ec8895 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2325,10 +2325,21 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, comphelper::LibreOfficeKit::setTiledPainting(false); } -OString SdXImpressDocument::getViewRenderState() +OString SdXImpressDocument::getViewRenderState(SfxViewShell* pViewShell) { OStringBuffer aState; - DrawViewShell* pView = GetViewShell(); + DrawViewShell* pView = nullptr; + + if (pViewShell) + { + ViewShellBase* pShellBase = dynamic_cast<ViewShellBase*>(pViewShell); + pView = dynamic_cast<DrawViewShell*>(pShellBase->GetMainViewShell().get()); + } + else + { + pView = GetViewShell(); + } + if (pView) { const SdViewOptions& pVOpt = pView->GetViewOptions(); diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 056013d75056..01619df1d382 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -463,7 +463,7 @@ public: void getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) override; /// @see vcl::ITiledRenderable::getViewRenderState(). - OString getViewRenderState() override; + OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override; /// @see vcl::ITiledRenderable::supportsCommand(). bool supportsCommand(std::u16string_view rCommand) override; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 1e85e0106369..a4d953d4326a 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3435,10 +3435,10 @@ SwXTextDocument::getSearchResultRectangles(const char* pPayload) return std::vector<basegfx::B2DRange>(); } -OString SwXTextDocument::getViewRenderState() +OString SwXTextDocument::getViewRenderState(SfxViewShell* pViewShell) { OStringBuffer aState; - SwView* pView = m_pDocShell->GetView(); + SwView* pView = pViewShell ? dynamic_cast<SwView*>(pViewShell) : m_pDocShell->GetView(); if (pView && pView->GetWrtShellPtr()) { const SwViewOption* pVOpt = pView->GetWrtShell().GetViewOptions();