sc/qa/unit/tiledrendering/tiledrendering.cxx | 70 +++++++++++++++++++++++---- sc/sdi/scalc.sdi | 4 - sc/source/ui/view/tabvwsh3.cxx | 2 3 files changed, 64 insertions(+), 12 deletions(-)
New commits: commit 02d1b4923a9d8d859a299b59ff07aa312da2270c Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Fri Oct 11 20:23:01 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 22 10:33:42 2024 +0200 sc: change how .uno:FreezePanesColumn/Row get the index On commit "sc: fix freeze row/column panes" 44362e588686e33ff60ddcb6c1cd0c6082073fb0 the type of FreezePanesColumn and FreezePanesRow was changed from Int32 to Point. Since then, calls trying to set the frozen panes with this commands sending an index fail, setting the index to 1. This change allows again a way to set them passing only an index of type Int32. Change-Id: I9de12af5ec7dbb4e49b057c7c19c063424265581 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174825 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 3eec1925788387c7c5996052388f3fcac518dfe7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174956 Tested-by: Jenkins diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 1c7e649d2e96..43569fa4fa47 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -617,20 +617,32 @@ public: case LOK_CALLBACK_STATE_CHANGED: { std::stringstream aStream(pPayload); - if (!aStream.str().starts_with("{")) + boost::property_tree::ptree aTree; + std::string aCommandName; + + if (aStream.str().starts_with("{")) { - break; - } + boost::property_tree::read_json(aStream, aTree); + auto it = aTree.find("commandName"); + if (it == aTree.not_found()) + { + break; + } - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - auto it = aTree.find("commandName"); - if (it == aTree.not_found()) + aCommandName = it->second.get_value<std::string>(); + } + else { - break; + std::string aState = aStream.str(); + auto it = aState.find("="); + if (it == std::string::npos) + { + break; + } + aCommandName = aState.substr(0, it); + aTree.put("state", aState.substr(it + 1)); } - std::string aCommandName = it->second.get_value<std::string>(); m_aStateChanges[aCommandName] = aTree; } break; @@ -3992,6 +4004,46 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testLeftOverflowEdit) CPPUNIT_ASSERT_EQUAL(tools::Long(20), aView.m_aTextSelectionResult.m_aRefPoint.getX()); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testFreezeRowOrColumn) +{ + createDoc("empty.ods"); + ViewCallback aView; + SfxViewShell* pView = SfxViewShell::Current(); + + // Freeze panes on a column and receive the proper state back + aView.m_aStateChanges.clear(); + uno::Sequence<beans::PropertyValue> aPropertyValues = { + comphelper::makePropertyValue("Index", uno::Any(static_cast<sal_Int32>(8))), + }; + comphelper::dispatchCommand(".uno:FreezePanesColumn", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + pView->GetViewFrame().GetBindings().GetTimer().Invoke(); + pView->GetViewFrame().GetBindings().GetTimer().Invoke(); + auto it = aView.m_aStateChanges.find(".uno:FreezePanesColumn"); + CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); + std::string values = it->second.get<std::string>("state"); + std::string index = values.substr(0, values.find(' ')); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 8 + // - Actual : 1 + CPPUNIT_ASSERT_EQUAL(std::string("8"), index); + + // Freeze panes on a row and receive the proper state back + aView.m_aStateChanges.clear(); + comphelper::dispatchCommand(".uno:FreezePanesRow", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + pView->GetViewFrame().GetBindings().GetTimer().Invoke(); + pView->GetViewFrame().GetBindings().GetTimer().Invoke(); + it = aView.m_aStateChanges.find(".uno:FreezePanesRow"); + CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); + values = it->second.get<std::string>("state"); + index = values.substr(0, values.find(' ')); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 8 + // - Actual : 1 + CPPUNIT_ASSERT_EQUAL(std::string("8"), index); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index d43d4ceea390..b8f8aa2dd505 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -1979,7 +1979,7 @@ SfxVoidItem FreezePanes SID_WINDOW_FIX ] SfxPointItem FreezePanesColumn SID_WINDOW_FIX_COL - +(SfxInt32Item Index FN_PARAM_1) [ AutoUpdate = FALSE, FastCall = FALSE, @@ -1996,7 +1996,7 @@ SfxPointItem FreezePanesColumn SID_WINDOW_FIX_COL ] SfxPointItem FreezePanesRow SID_WINDOW_FIX_ROW - +(SfxInt32Item Index FN_PARAM_1) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index 4702091e82dc..44813b6c53bc 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -1334,7 +1334,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { bool bIsCol = (nSlot == SID_WINDOW_FIX_COL); sal_Int32 nFreezeIndex = 1; - if (const SfxInt32Item* pItem = rReq.GetArg<SfxInt32Item>(nSlot)) + if (const SfxInt32Item* pItem = rReq.GetArg<SfxInt32Item>(FN_PARAM_1)) { nFreezeIndex = pItem->GetValue(); if (nFreezeIndex < 0)