sc/inc/SheetView.hxx                        |   22 ------------
 sc/inc/SheetViewManager.hxx                 |   50 ++++++++++++++++++++++++++++
 sc/inc/SheetViewTypes.hxx                   |    3 +
 sc/inc/document.hxx                         |    2 -
 sc/qa/unit/tiledrendering/SheetViewTest.cxx |    1 
 sc/source/core/data/SheetViewManager.cxx    |    2 -
 sc/source/core/data/document10.cxx          |   24 +++++++------
 sc/source/core/data/table1.cxx              |    2 -
 sc/source/ui/view/hdrcont.cxx               |    7 ++-
 sc/source/ui/view/viewfun3.cxx              |   33 +++++++++---------
 sc/source/ui/view/viewfunc.cxx              |    2 -
 11 files changed, 94 insertions(+), 54 deletions(-)

New commits:
commit 3b89969c60e44110a07b12c92c538b310f17ab1b
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Aug 19 13:45:39 2025 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Sep 13 12:47:01 2025 +0200

    sc: make sheet view have different header colors
    
    So we can see when the sheet is using a sheet view. This also
    mimics the UI of MSO when a sheet view is used. The color was
    chosen arbitrarily. This has no effect in online os it's mostly
    for debugging purpuse only.
    
    Change-Id: Idb0a7c499ec4d87ea83ac5998d5ee7e17bd724d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189915
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 3aecfb9cc814..ad9984c48ba3 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -321,11 +321,13 @@ void ScHeaderControl::Paint( vcl::RenderContext& 
/*rRenderContext*/, const tools
     if ( nLineEnd * nLayoutSign >= nInitScrPos * nLayoutSign )
     {
         Color aFaceColor(rStyleSettings.GetFaceColor());
+        if (pTabView->GetViewData().GetSheetViewID() >= 0)
+            aFaceColor.Merge(COL_LIGHTBLUE, 220);
         if (bDark)
             aFaceColor.IncreaseLuminance(20);
         else
             aFaceColor.DecreaseLuminance(20);
-        GetOutDev()->SetFillColor( aFaceColor );
+        GetOutDev()->SetFillColor(aFaceColor);
         if ( bVertical )
             aFillRect = tools::Rectangle( 0, nInitScrPos, nBarSize-1, nLineEnd 
);
         else
@@ -335,7 +337,8 @@ void ScHeaderControl::Paint( vcl::RenderContext& 
/*rRenderContext*/, const tools
 
     if ( nLineEnd * nLayoutSign < nPEnd * nLayoutSign )
     {
-        GetOutDev()->SetFillColor( 
mod->GetColorConfig().GetColorValue(svtools::APPBACKGROUND).nColor );
+        Color aAppBackgroundColor = 
mod->GetColorConfig().GetColorValue(svtools::APPBACKGROUND).nColor;
+        GetOutDev()->SetFillColor(aAppBackgroundColor);
         if ( bVertical )
             aFillRect = tools::Rectangle( 0, nLineEnd+nLayoutSign, nBarSize-1, 
nPEnd );
         else
commit 9e062392a77c26ba7e39b90a689acf0d6a2cf7eb
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Aug 19 13:43:23 2025 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Sep 13 12:46:52 2025 +0200

    sc: move part of sheet view creation into ScDocument
    
    Instead of setting up in ScViewFunc, just create everything needed
    for adding a sheet view inside ScDocument::CreateNewSheetView.
    
    This will limit the functions we need to expose to the outside of
    ScDocument.
    
    Change-Id: Ie8c432b175e7bbb55fc5ae3c6fe3a2b822e6d619
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189914
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/inc/SheetViewTypes.hxx b/sc/inc/SheetViewTypes.hxx
index 51e676423d5f..b41e8b3cfac0 100644
--- a/sc/inc/SheetViewTypes.hxx
+++ b/sc/inc/SheetViewTypes.hxx
@@ -16,6 +16,9 @@ typedef sal_Int32 SheetViewID;
 
 /** Defines the value to identify the default view of the sheet */
 constexpr SheetViewID DefaultSheetViewID = -1;
+
+/** Invalid sheet view ID */
+constexpr SheetViewID InvalidSheetViewID = SAL_MIN_INT32;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 281618cd8115..f8a8e4f8340c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2397,7 +2397,7 @@ public:
     /* Sheet View */
 
     /** Creates a new sheet view for the table, using the sheet view table */
-    sal_Int32 CreateNewSheetView(SCTAB nMainTable, SCTAB nSheetViewTable);
+    std::pair<sc::SheetViewID, SCTAB> CreateNewSheetView(SCTAB nTab);
 
     /** Return the sheet view table for the ID */
     SCTAB GetSheetViewNumber(SCTAB nTab, sc::SheetViewID nID);
diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index edf4ae7878a1..51308e4981db 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -1132,20 +1132,24 @@ void ScDocument::SetSheetView(SCTAB nTab, bool 
bSheetView)
     }
 }
 
-sc::SheetViewID ScDocument::CreateNewSheetView(SCTAB nMainTable, SCTAB 
nSheetViewTable)
+
+std::pair<sc::SheetViewID, SCTAB> ScDocument::CreateNewSheetView(SCTAB nTab)
 {
-    if (ScTable* pTable = FetchTable(nMainTable))
+    if (ScTable* pTable = FetchTable(nTab))
     {
-        if (pTable->IsSheetView())
-            return -1;
-
-        if (ScTable* pSheetViewTable = FetchTable(nSheetViewTable))
+        SCTAB nSheetViewTab = nTab + 1;
+        if (CopyTab(nTab, nSheetViewTab))
         {
-            auto nSheetViewID = 
pTable->GetSheetViewManager()->create(pSheetViewTable);
-            return nSheetViewID;
+            if (ScTable* pSheetViewTable = FetchTable(nSheetViewTab))
+            {
+                auto nSheetViewID = 
pTable->GetSheetViewManager()->create(pSheetViewTable);
+                pSheetViewTable->SetVisible(false);
+                pSheetViewTable->SetSheetView(true);
+                return { nSheetViewID, nSheetViewTab };
+            }
         }
     }
-    return -1;
+    return { sc::InvalidSheetViewID, -1 };
 }
 
 bool ScDocument::HasSheetViews(SCTAB nTab) const
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 274bd0ac94c5..654ce1fcff53 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -2066,25 +2066,26 @@ void ScViewFunc::MakeNewSheetView()
     SCTAB nTab = GetViewData().GetTabNumber();
     ScDocument& rDocument = GetViewData().GetDocument();
 
-    SCTAB nSheetViewTab = nTab + 1;
-    if (rDocument.CopyTab(nTab, nSheetViewTab))
+    auto[nSheetViewID, nSheetViewTab] = rDocument.CreateNewSheetView(nTab);
+
+    if (nSheetViewID == sc::InvalidSheetViewID)
     {
-        GetViewData().GetDocShell().Broadcast(ScTablesHint(SC_TAB_INSERTED, 
nSheetViewTab));
-        SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScTablesChanged));
+        SAL_WARN("sc", "Sheet view couldn't be created");
+        return;
+    }
 
-        // Add and register the created sheet view
-        rDocument.SetSheetView(nSheetViewTab, true);
-        sc::SheetViewID nSheetViewID = rDocument.CreateNewSheetView(nTab, 
nSheetViewTab);
-        GetViewData().SetSheetViewID(nSheetViewID);
+    GetViewData().SetSheetViewID(nSheetViewID);
 
-        // Update
-        GetViewData().SetTabNo(nSheetViewTab); // force add the sheet view tab
-        GetViewData().SetTabNo(nTab); // then change back to the current tab
+    // Update
+    GetViewData().SetTabNo(nSheetViewTab); // force add the sheet view tab
+    GetViewData().SetTabNo(nTab); // then change back to the current tab
 
-        ScDocShell& rDocSh = GetViewData().GetDocShell();
-        rDocSh.PostPaintGridAll();
-        PaintExtras(); // update Tab Control
-    }
+    ScDocShell& rDocSh = GetViewData().GetDocShell();
+    rDocSh.PostPaintGridAll();
+    PaintExtras(); // update Tab Control
+
+    GetViewData().GetDocShell().Broadcast(ScTablesHint(SC_TAB_INSERTED, 
nSheetViewTab));
+    SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScTablesChanged));
 }
 
 void ScViewFunc::RemoveCurrentSheetView()
commit eb514bdac8850ef8b26bda68a5a39a0906ad83ce
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Aug 12 12:48:34 2025 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Sep 13 12:46:46 2025 +0200

    sc: move SheetViewManager into own header file, describe methods.
    
    No other functional change was made, just simplification.
    
    Change-Id: I9d34f1525470f6517b315be48f519f6a6e1b62f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189857
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/inc/SheetView.hxx b/sc/inc/SheetView.hxx
index b7db3e84b22a..2f381f1472e9 100644
--- a/sc/inc/SheetView.hxx
+++ b/sc/inc/SheetView.hxx
@@ -8,8 +8,6 @@
  */
 
 #pragma once
-#include <vector>
-#include "SheetViewTypes.hxx"
 #include "types.hxx"
 
 class ScTable;
@@ -36,26 +34,6 @@ public:
     /** A sheet view is valid if the pointer to the table is set */
     bool isValid() const;
 };
-
-/** Manager and the holder of the sheet views for a sheet. */
-class SheetViewManager
-{
-private:
-    std::vector<SheetView> maViews;
-
-public:
-    SheetViewManager();
-
-    /** Creates a new sheet view. */
-    SheetViewID create(ScTable* pSheetViewTable);
-
-    /** Returns a sheet view for the ID. */
-    SheetView get(SheetViewID nID) const;
-    bool isEmpty() const { return maViews.empty(); }
-    bool remove(SheetViewID nID);
-    std::vector<SheetView> const& getSheetViews() const { return maViews; }
-    SheetViewID getNextSheetView(SheetViewID nID);
-};
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/SheetViewManager.hxx b/sc/inc/SheetViewManager.hxx
new file mode 100644
index 000000000000..e807cbd8fb57
--- /dev/null
+++ b/sc/inc/SheetViewManager.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+#include "SheetViewTypes.hxx"
+#include "SheetView.hxx"
+#include "types.hxx"
+
+#include <vector>
+
+class ScTable;
+
+namespace sc
+{
+/** Manager and the holder of the sheet views for a sheet. */
+class SheetViewManager
+{
+private:
+    std::vector<SheetView> maViews;
+
+public:
+    SheetViewManager();
+
+    /** Creates a new sheet view. */
+    SheetViewID create(ScTable* pSheetViewTable);
+
+    /** Returns a sheet view for the ID. */
+    SheetView get(SheetViewID nID) const;
+
+    /** True if there are no sheet views. */
+    bool isEmpty() const { return maViews.empty(); }
+
+    /** Remove the sheet view with the ID. True if successful. */
+    bool remove(SheetViewID nID);
+
+    /** Return the list of sheet views. */
+    std::vector<SheetView> const& getSheetViews() const { return maViews; }
+
+    /** Calculate the next sheet view ID from the current ID. */
+    SheetViewID getNextSheetView(SheetViewID nID);
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/tiledrendering/SheetViewTest.cxx 
b/sc/qa/unit/tiledrendering/SheetViewTest.cxx
index b11d898c4882..2ecfcfa3f13c 100644
--- a/sc/qa/unit/tiledrendering/SheetViewTest.cxx
+++ b/sc/qa/unit/tiledrendering/SheetViewTest.cxx
@@ -17,6 +17,7 @@
 #include <sctestviewcallback.hxx>
 #include <docuno.hxx>
 #include <SheetView.hxx>
+#include <SheetViewManager.hxx>
 
 using namespace css;
 
diff --git a/sc/source/core/data/SheetViewManager.cxx 
b/sc/source/core/data/SheetViewManager.cxx
index a57ea9666025..ffbd41c8f298 100644
--- a/sc/source/core/data/SheetViewManager.cxx
+++ b/sc/source/core/data/SheetViewManager.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <SheetView.hxx>
+#include <SheetViewManager.hxx>
 #include <table.hxx>
 
 namespace sc
diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 2e1c3b99e830..edf4ae7878a1 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -28,7 +28,7 @@
 #include <docsh.hxx>
 #include <bcaslot.hxx>
 #include <broadcast.hxx>
-#include <SheetView.hxx>
+#include <SheetViewManager.hxx>
 
 // Add totally brand-new methods to this source file.
 
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index fee2db6ef2e4..72f7eef0a9ec 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -53,7 +53,7 @@
 #include <rowheightcontext.hxx>
 #include <compressedarray.hxx>
 #include <tabvwsh.hxx>
-#include <SheetView.hxx>
+#include <SheetViewManager.hxx>
 #include <vcl/svapp.hxx>
 
 #include <formula/vectortoken.hxx>
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index b47865ec5ec7..274bd0ac94c5 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -63,7 +63,7 @@
 #include <cliputil.hxx>
 #include <clipoptions.hxx>
 #include <gridwin.hxx>
-#include <SheetView.hxx>
+#include <SheetViewManager.hxx>
 #include <uiitems.hxx>
 #include <com/sun/star/util/XCloneable.hpp>
 
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 6c8c43fc1cfd..b6c6458e61a5 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -77,7 +77,7 @@
 #include <columnspanset.hxx>
 #include <stringutil.hxx>
 #include <SparklineList.hxx>
-#include <SheetView.hxx>
+#include <SheetViewManager.hxx>
 
 #include <memory>
 

Reply via email to