[Libreoffice-commits] core.git: sc/qa sc/source

Henry Castro hcastro at collabora.com
Sun Oct 23 13:32:05 UTC 2016


 sc/qa/unit/tiledrendering/tiledrendering.cxx |   74 +++++++++++++++++++++++++++
 sc/source/ui/view/viewfunc.cxx               |   26 ++++++++-
 2 files changed, 98 insertions(+), 2 deletions(-)

New commits:
commit 8dc495c93239739629683bb29e4110f5c57c94f0
Author: Henry Castro <hcastro at collabora.com>
Date:   Sat Oct 22 16:25:57 2016 -0400

    sc lok: fix cell cursor when hide column/row
    
    Change-Id: Icfa7debe06f6dfae3efcbd9d878d3b2d5aecf92f
    Reviewed-on: https://gerrit.libreoffice.org/30169
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 83db147..9aa5115 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -67,6 +67,7 @@ public:
     void testTextEditViewInvalidations();
     void testGraphicInvalidate();
     void testAutoSum();
+    void testHideColRow();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -85,6 +86,7 @@ public:
     CPPUNIT_TEST(testTextEditViewInvalidations);
     CPPUNIT_TEST(testGraphicInvalidate);
     CPPUNIT_TEST(testAutoSum);
+    CPPUNIT_TEST(testHideColRow);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -863,6 +865,78 @@ void ScTiledRenderingTest::testAutoSum()
     mxComponent.clear();
     comphelper::LibreOfficeKit::setActive(false);
 }
+
+void ScTiledRenderingTest::testHideColRow()
+{
+    // Load a document
+    comphelper::LibreOfficeKit::setActive();
+    createDoc("small.ods");
+    {
+        uno::Sequence<beans::PropertyValue> aArgs(2);
+
+        aArgs[0].Name = OUString::fromUtf8("Col");
+        aArgs[0].Value <<= static_cast<sal_Int32>(2 - 1);
+        aArgs[1].Name = OUString::fromUtf8("Modifier");
+        aArgs[1].Value <<= static_cast<sal_uInt16>(KEY_SHIFT);
+
+        comphelper::dispatchCommand(".uno:SelectColumn", aArgs);
+
+        aArgs[0].Name = OUString::fromUtf8("Col");
+        aArgs[0].Value <<= static_cast<sal_Int32>(3 - 1);
+        aArgs[1].Name = OUString::fromUtf8("Modifier");
+        aArgs[1].Value <<= static_cast<sal_uInt16>(0);
+
+        comphelper::dispatchCommand(".uno:SelectColumn", aArgs);
+        Scheduler::ProcessEventsToIdle();
+    }
+
+    SCCOL nOldCurX = ScDocShell::GetViewData()->GetCurX();
+    SCROW nOldCurY = ScDocShell::GetViewData()->GetCurY();
+    {
+        uno::Sequence<beans::PropertyValue> aArgs;
+        comphelper::dispatchCommand(".uno:HideColumn", aArgs);
+        Scheduler::ProcessEventsToIdle();
+    }
+
+    SCCOL nNewCurX = ScDocShell::GetViewData()->GetCurX();
+    SCROW nNewCurY = ScDocShell::GetViewData()->GetCurY();
+    CPPUNIT_ASSERT(nNewCurX > nOldCurX);
+    CPPUNIT_ASSERT_EQUAL(nOldCurY, nNewCurY);
+    {
+        uno::Sequence<beans::PropertyValue> aArgs(2);
+
+        aArgs[0].Name = OUString::fromUtf8("Row");
+        aArgs[0].Value <<= static_cast<sal_Int32>(6 - 1);
+        aArgs[1].Name = OUString::fromUtf8("Modifier");
+        aArgs[1].Value <<= static_cast<sal_uInt16>(KEY_SHIFT);
+
+        comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+        aArgs[0].Name = OUString::fromUtf8("Row");
+        aArgs[0].Value <<= static_cast<sal_Int32>(7 - 1);
+        aArgs[1].Name = OUString::fromUtf8("Modifier");
+        aArgs[1].Value <<= static_cast<sal_uInt16>(0);
+
+        comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+        Scheduler::ProcessEventsToIdle();
+    }
+
+    nOldCurX = ScDocShell::GetViewData()->GetCurX();
+    nOldCurY = ScDocShell::GetViewData()->GetCurY();
+    {
+        uno::Sequence<beans::PropertyValue> aArgs;
+        comphelper::dispatchCommand(".uno:HideRow", aArgs);
+        Scheduler::ProcessEventsToIdle();
+    }
+    nNewCurX = ScDocShell::GetViewData()->GetCurX();
+    nNewCurY = ScDocShell::GetViewData()->GetCurY();
+    CPPUNIT_ASSERT(nNewCurY > nOldCurY);
+    CPPUNIT_ASSERT_EQUAL(nOldCurX, nNewCurX);
+
+    mxComponent->dispose();
+    mxComponent.clear();
+    comphelper::LibreOfficeKit::setActive(false);
+}
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 4c475a7..ef317d7 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1832,6 +1832,8 @@ void ScViewFunc::SetWidthOrHeight(
 
     ScDocShell* pDocSh = GetViewData().GetDocShell();
     ScDocument& rDoc = pDocSh->GetDocument();
+    SCCOL nCurX = GetViewData().GetCurX();
+    SCROW nCurY = GetViewData().GetCurY();
     SCTAB nFirstTab = aMarkData.GetFirstSelected();
     SCTAB nCurTab = GetViewData().GetTabNo();
     SCTAB nTab;
@@ -1989,7 +1991,13 @@ void ScViewFunc::SetWidthOrHeight(
                         rDoc.SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
                         rDoc.SetManualHeight( nStartNo, nEndNo, nTab, true );          // height was set manually
                     }
+
                     rDoc.ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
+
+                    if (!bShow && nStartNo <= nCurY && nCurY <= nEndNo && nTab == nCurTab)
+                    {
+                        nCurY = -1;
+                    }
                 }
                 else if ( eMode==SC_SIZE_SHOW )
                 {
@@ -2010,12 +2018,16 @@ void ScViewFunc::SetWidthOrHeight(
                             rDoc.SetColWidth( nCol, nTab, nThisSize );
 
                         rDoc.ShowCol( nCol, nTab, bShow );
+
+                        if (!bShow && nCol == nCurX && nTab == nCurTab)
+                        {
+                            nCurX = -1;
+                        }
                     }
                 }
             }
 
-                                    //  adjust outline
-
+            //  adjust outline
             if (bWidth)
             {
                 if ( rDoc.UpdateOutlineCol( static_cast<SCCOL>(nStartNo),
@@ -2042,6 +2054,16 @@ void ScViewFunc::SetWidthOrHeight(
                 pUndoDoc, aUndoRanges, pUndoTab, eMode, nSizeTwips, bWidth));
     }
 
+    if (nCurX < 0)
+    {
+        MoveCursorRel( 1, 0, SC_FOLLOW_LINE, false );
+    }
+
+    if (nCurY < 0)
+    {
+        MoveCursorRel( 0, 1, SC_FOLLOW_LINE, false );
+    }
+
     // fdo#36247 Ensure that the drawing layer's map mode scaling factors match
     // the new heights and widths.
     GetViewData().GetView()->RefreshZoom();


More information about the Libreoffice-commits mailing list