desktop/source/lib/init.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 069032433a46ce3cdf0962f195baa6cac360317f
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Jul 25 16:04:04 2025 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Jul 25 21:17:44 2025 +0200

    use SfxLokHelper::getViewId to get view of this document
    
    get ObjectShell from the ViewShell
    
    Change-Id: I257ebf83d9f05c2fafecd92886a853fcb995abdb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188354
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2a1be6c5bcf4..491d8517829c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5394,7 +5394,6 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
     SolarMutexGuard aGuard;
     SetLastExceptionMsg();
 
-    SfxObjectShell* pDocSh = SfxObjectShell::Current();
     OUString aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8);
 
     if (!isCommandAllowed(aCommand))
@@ -5415,9 +5414,12 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
         aPropertyValuesVector.push_back(aSynchronMode);
     }
 
-    int nView = SfxLokHelper::getCurrentView();
-    if (nView < 0)
+    const int nView = SfxLokHelper::getViewId(pDocument->mnDocumentId);
+    SfxViewShell* pViewShell = SfxLokHelper::getViewOfId(nView);
+    if (!pViewShell)
         return;
+    assert(nView == pViewShell->GetViewShellId().get() && "otherwise we 
couldn't have found it");
+    SfxObjectShell* pDocSh = pViewShell->GetObjectShell();
 
     if (gImpl && aCommand == ".uno:ToggleOrientation")
     {
@@ -5487,7 +5489,6 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
     else if (gImpl && aCommand == ".uno:TransformDialog")
     {
         bool bNeedConversion = false;
-        SfxViewShell* pViewShell = SfxViewShell::Current();
         LokChartHelper aChartHelper(pViewShell);
 
         if (aChartHelper.GetWindow() )

Reply via email to