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 0004de149269ed2ab5423947b9930653f3da6038
Author:     Paris Oplopoios <paris.oplopo...@collabora.com>
AuthorDate: Wed Jul 26 17:20:59 2023 +0300
Commit:     Paris Oplopoios <parisop...@gmail.com>
CommitDate: Tue Aug 1 13:49:06 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>
    (cherry picked from commit eff5643dbc5bb9dfede530e8e07261bb9bdc98f0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155046
    Tested-by: Jenkins
    Reviewed-by: Paris Oplopoios <parisop...@gmail.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 66c2667a1a1f..fe1cf4dbe6b3 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 008c9459e1c4..e0fa051d8826 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 9f906dc404a0..789f419716f8 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2326,10 +2326,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 8af40e5e2447..6a4177f6e50d 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3431,10 +3431,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();

Reply via email to