sc/qa/unit/tiledrendering/tiledrendering.cxx | 74 +++++++++++++++++++++++++++ sc/source/ui/view/viewfunc.cxx | 26 ++++++++- 2 files changed, 98 insertions(+), 2 deletions(-)
New commits: commit 8cef808fb14c46d3f8467c56f3f89f21c041f2c4 Author: Henry Castro <hcas...@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 <c...@libreoffice.org> Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index bd4f00d..02ee497 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -66,6 +66,7 @@ public: void testTextEditViewInvalidations(); void testGraphicInvalidate(); void testAutoSum(); + void testHideColRow(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -83,6 +84,7 @@ public: CPPUNIT_TEST(testTextEditViewInvalidations); CPPUNIT_TEST(testGraphicInvalidate); CPPUNIT_TEST(testAutoSum); + CPPUNIT_TEST(testHideColRow); CPPUNIT_TEST_SUITE_END(); private: @@ -840,6 +842,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 2c2b194..c370320 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1830,6 +1830,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; @@ -1987,7 +1989,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 ) { @@ -2008,12 +2016,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), @@ -2040,6 +2052,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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits