sc/qa/unit/tiledrendering/data/split-panes.ods |binary sc/qa/unit/tiledrendering/data/split-panes.xlsx |binary sc/qa/unit/tiledrendering/tiledrendering2.cxx | 37 ++++++++++++++++++++++++ sc/source/ui/view/viewdata.cxx | 26 +++++++++++----- 4 files changed, 55 insertions(+), 8 deletions(-)
New commits: commit cbd4b05b4f474cdde6fae6d53cf8c58bd434771a Author: Aron Budea <aron.bu...@collabora.com> AuthorDate: Tue Apr 22 04:53:57 2025 +0930 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Mon May 5 08:46:09 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> (cherry picked from commit 7b8718414158b2ff2b7985b275d2c4842f1ac3f8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184869 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 14f57779e026..12fbea20b520 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering2.cxx @@ -222,6 +222,43 @@ CPPUNIT_TEST_FIXTURE(Test, testCool11739LocaleDialogFieldUnit) } } +CPPUNIT_TEST_FIXTURE(Test, testSplitPanes) +{ + createDoc("split-panes.ods"); + + save("calc8"); + + xmlDocUniquePtr pSettings = parseExport("settings.xml"); + 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']"_ostr, + u"0"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Test, testSplitPanesXLSX) +{ + createDoc("split-panes.xlsx"); + + save("Calc Office Open XML"); + + xmlDocUniquePtr pSheet = parseExport("xl/worksheets/sheet1.xml"); + 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"_ostr, "activePane"_ostr, + u"topRight"_ustr); +} + 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 3499eed62f35..d124f9683870 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -4368,16 +4368,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) { @@ -4388,10 +4399,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) {