sc/source/ui/inc/viewdata.hxx  |    2 ++
 sc/source/ui/unoobj/docuno.cxx |   19 +++++++++++++++++--
 sc/source/ui/view/tabvwshc.cxx |    2 +-
 sc/source/ui/view/viewdata.cxx |   12 ++++++++++++
 4 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 344c12e11d79bef5da9d5a4e6dd35b8072b69d67
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Mon Oct 6 23:50:29 2025 +0900
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Oct 9 08:55:54 2025 +0200

    sc: send sheet view information as part properties via LOKit
    
    This sends the information needed for online to handle show the
    sheets are using the sheet view functionality and to show if the
    sheet view is synched with the default view or not.
    
    Change getPart to return GetTabNumber instead of CurrentTabForData
    or the code will select the wrong sheet when we create or switch to
    a sheet view.
    
    Change-Id: I6990af757f60a9a33594e3991dec8b5b3b278b54
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191977
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 9ca329fbd47e..74858604b3dc 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -424,6 +424,8 @@ public:
         return pThisTab->mnSheetViewID;
     }
 
+    sc::SheetViewID GetSheetViewIDForSheet(SCTAB nTab) const;
+
     SCCOL           MaxCol() const                          { return 
mrDoc.MaxCol(); }
     SCROW           MaxRow() const                          { return 
mrDoc.MaxRow(); }
     ScSplitPos      GetActivePart() const                   { return 
pThisTab->eWhichActive; }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 770eb46f37ea..2b96bc70d4fd 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -137,6 +137,7 @@
 #include <formulaopt.hxx>
 #include <output.hxx>
 #include <stlpool.hxx>
+#include <SheetViewManager.hxx>
 
 #include <strings.hrc>
 
@@ -644,9 +645,21 @@ OUString ScModelObj::getPartInfo( int nPart )
     ScViewData* pViewData = ScDocShell::GetViewData();
     if (!pViewData)
         return OUString();
+    ScDocument& rDocument = pViewData->GetDocument();
+    const bool bIsVisible = rDocument.IsVisible(nPart);
+    const bool bIsProtected = rDocument.IsTabProtected(nPart);
+    const sc::SheetViewID nSheetViewID = 
pViewData->GetSheetViewIDForSheet(nPart);
+
+    bool nSheetViewSynced = true;
+
+    if (auto pSheetViewManager = rDocument.GetSheetViewManager(nPart))
+    {
+        if (auto pSheetView = pSheetViewManager->get(nSheetViewID))
+        {
+            nSheetViewSynced = pSheetView->isSynced();
+        }
+    }
 
-    const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
-    const bool bIsProtected = pViewData->GetDocument().IsTabProtected(nPart);
     //FIXME: Implement IsSelected().
     const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
     const bool bIsRTLLayout = pViewData->GetDocument().IsLayoutRTL(nPart);
@@ -655,6 +668,8 @@ OUString ScModelObj::getPartInfo( int nPart )
     jsonWriter.put("visible", static_cast<unsigned int>(bIsVisible));
     jsonWriter.put("rtllayout", static_cast<unsigned int>(bIsRTLLayout));
     jsonWriter.put("protected", static_cast<unsigned int>(bIsProtected));
+    jsonWriter.put("sheetviewid", int32_t(nSheetViewID));
+    jsonWriter.put("sheetviewsynced", uint32_t(nSheetViewSynced));
     jsonWriter.put("selected", static_cast<unsigned int>(bIsSelected));
 
     OUString tabName;
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 1347f1b8aaaa..3a9d5cae1c4a 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -454,7 +454,7 @@ std::shared_ptr<SfxModelessDialogController> 
ScTabViewShell::CreateRefDialogCont
 
 int ScTabViewShell::getPart() const
 {
-    return GetViewData().CurrentTabForData();
+    return GetViewData().GetTabNumber();
 }
 
 void ScTabViewShell::afterCallbackRegistered()
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 6f9c24c4840b..e8426bdfae32 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -4502,4 +4502,16 @@ SCTAB ScViewData::CurrentTabForData() const
     return GetTabNumber();
 }
 
+sc::SheetViewID ScViewData::GetSheetViewIDForSheet(SCTAB nTab) const
+{
+    if (!IsValidTabNumber(nTab))
+        return sc::InvalidSheetViewID;
+
+    if (!maTabData[nTab])
+        return sc::InvalidSheetViewID;
+
+    return maTabData[nTab]->mnSheetViewID;
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to