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 3eec1925788387c7c5996052388f3fcac518dfe7
Author:     Jaume Pujantell <[email protected]>
AuthorDate: Fri Oct 11 20:23:01 2024 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Tue Oct 15 13:38:51 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 <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a29abeb1ac00..e1699f13bd3d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -628,20 +628,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;
@@ -4035,6 +4047,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 3591ca10f199..81423adc7b79 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 23e3eacfa901..85b7e4c89957 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1222,7 +1222,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)

Reply via email to