sc lok: fix cell cursor when hide column/row
Change-Id: Icfa7debe06f6dfae3efcbd9d878d3b2d5aecf92f Reviewed-on: https://gerrit.libreoffice.org/30169 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Henry Castro <hcastro@collabora.com>
This commit is contained in:
@@ -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);
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user