sc/qa/unit/tiledrendering/data/split-panes.ods  |binary
 sc/qa/unit/tiledrendering/data/split-panes.xlsx |binary
 sc/qa/unit/tiledrendering/tiledrendering2.cxx   |   36 ++++++++++++++++++++++++
 sc/source/ui/view/viewdata.cxx                  |   26 ++++++++++++-----
 4 files changed, 54 insertions(+), 8 deletions(-)

New commits:
commit 7b8718414158b2ff2b7985b275d2c4842f1ac3f8
Author:     Aron Budea <aron.bu...@collabora.com>
AuthorDate: Tue Apr 22 04:53:57 2025 +0930
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Apr 30 15:44:37 2025 +0200

    cool#11475 lok: sc: correctly export frozen/split pane information
    
    As 7b4802070ac6fb930255536bf3ed2c52428b4181 noted,
    online only supports freeze panes, but preserves splits when saving.
    
    However, files could also end up with mixed frozen/split panes.
    In addition, even a single split was treated like two, with
    the other split being at the first row/column, which was incorrect.
    
    Change-Id: I974690b8877ad6d4eca1e046c3c352359a199706
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184421
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sc/qa/unit/tiledrendering/data/split-panes.ods 
b/sc/qa/unit/tiledrendering/data/split-panes.ods
new file mode 100644
index 000000000000..f34df2ebd901
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/split-panes.ods 
differ
diff --git a/sc/qa/unit/tiledrendering/data/split-panes.xlsx 
b/sc/qa/unit/tiledrendering/data/split-panes.xlsx
new file mode 100644
index 000000000000..5687f7c0872f
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/split-panes.xlsx 
differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering2.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering2.cxx
index 41fdcb17b936..ff6ed1881542 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering2.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering2.cxx
@@ -165,6 +165,42 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testCool11739LocaleDialogFieldUnit)
     CPPUNIT_ASSERT_EQUAL(FieldUnit::CM, eMetric);
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSplitPanes)
+{
+    createDoc("split-panes.ods");
+
+    save(u"calc8"_ustr);
+
+    xmlDocUniquePtr pSettings = parseExport(u"settings.xml"_ustr);
+    CPPUNIT_ASSERT(pSettings);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 0
+    // - Actual  : 2
+    assertXPathContent(pSettings,
+                       
"/office:document-settings/office:settings/config:config-item-set[1]/"
+                       
"config:config-item-map-indexed/config:config-item-map-entry/"
+                       
"config:config-item-map-named/config:config-item-map-entry/"
+                       "config:config-item[@config:name='VerticalSplitMode']",
+                       u"0");
+}
+
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSplitPanesXLSX)
+{
+    createDoc("split-panes.xlsx");
+
+    save(u"Calc Office Open XML"_ustr);
+
+    xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
+    CPPUNIT_ASSERT(pSheet);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: topRight
+    // - Actual  : bottomRight
+    // which also results in invalid XLSX
+    assertXPath(pSheet, "/x:worksheet/x:sheetViews/x:sheetView/x:pane", 
"activePane", u"topRight");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 45c49f294ba4..c0178f4ec025 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -4372,16 +4372,27 @@ void ScViewData::OverrideWithLOKFreeze(ScSplitMode& 
eExHSplitMode, ScSplitMode&
                                        SCCOL& nExFixPosX, SCROW& nExFixPosY,
                                        tools::Long& nExHSplitPos, tools::Long& 
nExVSplitPos, SCTAB nForTab) const
 {
-    SCCOL nFreezeCol = mrDoc.GetLOKFreezeCol(nForTab);
-    SCROW nFreezeRow = mrDoc.GetLOKFreezeRow(nForTab);
+    // split mode to potentially use based on original: if it was split, use 
split mode to preserve that, otherwise use freeze
+    // whether there is actual split/freeze will depend on GetLOKFreezeCol/Row
+    const ScSplitMode aExSplitMode = (eExHSplitMode == SC_SPLIT_NORMAL || 
eExVSplitMode == SC_SPLIT_NORMAL) ? SC_SPLIT_NORMAL : SC_SPLIT_FIX;
+
+    // initialize split modes and positions in case no split/freeze is set
+    eExHSplitMode = SC_SPLIT_NONE;
+    eExVSplitMode = SC_SPLIT_NONE;
+    nExFixPosX = 0;
+    nExFixPosY = 0;
+    nExHSplitPos = 0;
+    nExVSplitPos = 0;
 
     bool bConvertToScrPosX = false;
     bool bConvertToScrPosY = false;
 
-    if (nFreezeCol >= 0)
+    SCCOL nFreezeCol = mrDoc.GetLOKFreezeCol(nForTab);
+    SCROW nFreezeRow = mrDoc.GetLOKFreezeRow(nForTab);
+
+    if (nFreezeCol > 0)
     {
-        if (eExHSplitMode == SC_SPLIT_NONE)
-            eExHSplitMode = SC_SPLIT_FIX;
+        eExHSplitMode = aExSplitMode;
 
         if (eExHSplitMode == SC_SPLIT_FIX)
         {
@@ -4392,10 +4403,9 @@ void ScViewData::OverrideWithLOKFreeze(ScSplitMode& 
eExHSplitMode, ScSplitMode&
             bConvertToScrPosX = true;
     }
 
-    if (nFreezeRow >= 0)
+    if (nFreezeRow > 0)
     {
-        if (eExVSplitMode == SC_SPLIT_NONE)
-            eExVSplitMode = SC_SPLIT_FIX;
+        eExVSplitMode = aExSplitMode;
 
         if (eExVSplitMode == SC_SPLIT_FIX)
         {

Reply via email to