summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-06-12 11:15:09 -0400
committerJustin Luth <jluth@mail.com>2023-06-27 02:27:58 +0200
commitb0f55a04f081ff7f566c3ba5b6d6d6be3675e0f7 (patch)
tree0d07b932e249fa7f50dc2ab15c714e278d31391a
parent9951ffedd6941234447b9655fbc49ed6ca4cc64c (diff)
tdf#123026 sc xlsx: provide per-sheet optimal row height setting
This patch is a pre-requisite for a follow-up patch which will run SetOptimalRowHeight on all un-sized rows on FILEOPEN. XLSX sheets can provide a default height for all rows on that sheet. That imported/round-tripped well. However, if Calc optimizes these rows, the undefined rows likely will change height - since the default XLSX row height tends to be 300 twips, while Calc uses 256 (in ScGlobal::nStdRowHeight). This patch allows a sheet to define its optimal row height, so that running .uno:SetOptimalRowHeight doesn't change any row heights, and doesn't cause all kinds of new row definitions. make CppunitTest_sc_subsequent_filters_test2 \ CPPUNIT_TEST_NAME=testTdf123026_optimalRowHeight Change-Id: I35008107d71f66375c7e9469e559f3836cf14df5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152909 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/inc/table.hxx11
-rw-r--r--sc/qa/unit/data/xlsx/tdf123026_optimalRowHeight.xlsxbin0 -> 6128 bytes
-rw-r--r--sc/qa/unit/subsequent_filters_test2.cxx20
-rw-r--r--sc/source/core/data/column2.cxx28
-rw-r--r--sc/source/core/data/document.cxx9
-rw-r--r--sc/source/core/data/fillinfo.cxx4
-rw-r--r--sc/source/core/data/table1.cxx6
-rw-r--r--sc/source/core/data/table2.cxx16
-rw-r--r--sc/source/core/data/table7.cxx2
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx6
-rw-r--r--sc/source/ui/view/cellsh3.cxx4
-rw-r--r--sc/source/ui/view/viewdata.cxx3
-rw-r--r--sc/source/ui/view/viewfunc.cxx10
14 files changed, 90 insertions, 30 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 300d6f7817e0..27499ca9f105 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -990,6 +990,7 @@ public:
bool IsStreamValidLocked() const { return mbStreamValidLocked; }
bool IsPendingRowHeights( SCTAB nTab ) const;
void SetPendingRowHeights( SCTAB nTab, bool bSet );
+ sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const;
SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const;
SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 0662053cb89c..1a62a7e56321 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -186,6 +186,9 @@ private:
SCCOL mnEndCol;
SCROW mnEndRow;
+ // Standard row height for this sheet - benefits XLSX because default height defined per sheet
+ sal_uInt16 mnOptimalMinRowHeight; // in Twips
+
std::unique_ptr<ScTableProtection> pTabProtection;
std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
@@ -873,6 +876,14 @@ public:
// nPPT to test for modification
void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
+ sal_uInt16 GetOptimalMinRowHeight() const
+ {
+ if (!mnOptimalMinRowHeight)
+ return ScGlobal::nStdRowHeight;
+ return mnOptimalMinRowHeight;
+ };
+ void SetOptimalMinRowHeight(sal_uInt16 nSet) { mnOptimalMinRowHeight = nSet; }
+
sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
diff --git a/sc/qa/unit/data/xlsx/tdf123026_optimalRowHeight.xlsx b/sc/qa/unit/data/xlsx/tdf123026_optimalRowHeight.xlsx
new file mode 100644
index 000000000000..d4ea71e1a663
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf123026_optimalRowHeight.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx
index a0a4a92d299b..d5ce977b3a4e 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -44,8 +44,10 @@
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
+#include <comphelper/propertysequence.hxx>
#include <comphelper/scopeguard.hxx>
#include <tools/UnitConversion.hxx>
+#include <vcl/scheduler.hxx>
#include "helper/qahelper.hxx"
using namespace ::com::sun::star;
@@ -143,6 +145,24 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testOptimalHeightReset)
CPPUNIT_ASSERT_EQUAL(nOptimalHeight, nHeight);
}
+CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testTdf123026_optimalRowHeight)
+{
+ createScDoc("xlsx/tdf123026_optimalRowHeight.xlsx");
+
+ dispatchCommand(mxComponent, ".uno:SelectColumn", {});
+ dispatchCommand(
+ mxComponent, ".uno:SetOptimalRowHeight",
+ comphelper::InitPropertySequence({ { "aExtraHeight", uno::Any(sal_uInt16(0)) } }));
+ Scheduler::ProcessEventsToIdle();
+
+ SCTAB nTab = 0;
+ SCROW nRow = 4;
+ int nHeight = convertTwipToMm100(getScDoc()->GetRowHeight(nRow, nTab, false));
+
+ // Without the fix, this was 529 (300 twip). It should be 3210.
+ CPPUNIT_ASSERT_GREATER(2000, nHeight);
+}
+
CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testCustomNumFormatHybridCellODS)
{
createScDoc("ods/custom-numfmt-hybrid-cell.ods");
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 38cfe9d9ee41..d037685c66e4 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -855,7 +855,8 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
return nOldWidth;
}
-static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16 nFontHeightId )
+static sal_uInt16 lcl_GetAttribHeight(const ScPatternAttr& rPattern, sal_uInt16 nFontHeightId,
+ sal_uInt16 nMinHeight)
{
const SvxFontHeightItem& rFontHeight =
static_cast<const SvxFontHeightItem&>(rPattern.GetItem(nFontHeightId));
@@ -877,8 +878,8 @@ static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16
if (nHeight > STD_ROWHEIGHT_DIFF)
nHeight -= STD_ROWHEIGHT_DIFF;
- if (nHeight < ScGlobal::nStdRowHeight)
- nHeight = ScGlobal::nStdRowHeight;
+ if (nHeight < nMinHeight)
+ nHeight = nMinHeight;
return nHeight;
}
@@ -902,6 +903,7 @@ void ScColumn::GetOptimalHeight(
// with conditional formatting, always consider the individual cells
const ScPatternAttr* pPattern = aIter.Next(nStart,nEnd);
+ const sal_uInt16 nOptimalMinRowHeight = GetDoc().GetSheetOptimalMinRowHeight(nTab);
while ( pPattern )
{
const ScMergeAttr* pMerge = &pPattern->GetItem(ATTR_MERGE);
@@ -978,11 +980,14 @@ void ScColumn::GetOptimalHeight(
sal_uInt16 nDefHeight;
SvtScriptType nDefScript = ScGlobal::GetDefaultScriptType();
if ( nDefScript == SvtScriptType::ASIAN )
- nDefHeight = nCjkHeight = lcl_GetAttribHeight( *pPattern, ATTR_CJK_FONT_HEIGHT );
+ nDefHeight = nCjkHeight = lcl_GetAttribHeight(*pPattern, ATTR_CJK_FONT_HEIGHT,
+ nOptimalMinRowHeight);
else if ( nDefScript == SvtScriptType::COMPLEX )
- nDefHeight = nCtlHeight = lcl_GetAttribHeight( *pPattern, ATTR_CTL_FONT_HEIGHT );
+ nDefHeight = nCtlHeight = lcl_GetAttribHeight(*pPattern, ATTR_CTL_FONT_HEIGHT,
+ nOptimalMinRowHeight);
else
- nDefHeight = nLatHeight = lcl_GetAttribHeight( *pPattern, ATTR_FONT_HEIGHT );
+ nDefHeight = nLatHeight = lcl_GetAttribHeight(*pPattern, ATTR_FONT_HEIGHT,
+ nOptimalMinRowHeight);
// if everything below is already larger, the loop doesn't have to
// be run again
@@ -1023,21 +1028,26 @@ void ScColumn::GetOptimalHeight(
if ( nScript == SvtScriptType::ASIAN )
{
if ( nCjkHeight == 0 )
- nCjkHeight = lcl_GetAttribHeight( *pPattern, ATTR_CJK_FONT_HEIGHT );
+ nCjkHeight = lcl_GetAttribHeight(*pPattern,
+ ATTR_CJK_FONT_HEIGHT,
+ nOptimalMinRowHeight);
if (nCjkHeight > rHeights.GetValue(nRow))
rHeights.SetValue(nRow, nRow, nCjkHeight);
}
else if ( nScript == SvtScriptType::COMPLEX )
{
if ( nCtlHeight == 0 )
- nCtlHeight = lcl_GetAttribHeight( *pPattern, ATTR_CTL_FONT_HEIGHT );
+ nCtlHeight = lcl_GetAttribHeight(*pPattern,
+ ATTR_CTL_FONT_HEIGHT,
+ nOptimalMinRowHeight);
if (nCtlHeight > rHeights.GetValue(nRow))
rHeights.SetValue(nRow, nRow, nCtlHeight);
}
else
{
if ( nLatHeight == 0 )
- nLatHeight = lcl_GetAttribHeight( *pPattern, ATTR_FONT_HEIGHT );
+ nLatHeight = lcl_GetAttribHeight(*pPattern, ATTR_FONT_HEIGHT,
+ nOptimalMinRowHeight);
if (nLatHeight > rHeights.GetValue(nRow))
rHeights.SetValue(nRow, nRow, nLatHeight);
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a33784cb722f..0095e7dad744 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -956,6 +956,15 @@ void ScDocument::SetPendingRowHeights( SCTAB nTab, bool bSet )
maTabs[nTab]->SetPendingRowHeights( bSet );
}
+sal_uInt16 ScDocument::GetSheetOptimalMinRowHeight(SCTAB nTab) const
+{
+ const ScTable* pTab = FetchTable(nTab);
+ if (!pTab)
+ return ScGlobal::nStdRowHeight;
+
+ return pTab->GetOptimalMinRowHeight();
+}
+
void ScDocument::SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling)
{
if ( !(ValidTab(nTab) && nTab < static_cast<SCTAB> (maTabs.size()) && maTabs[nTab]) )
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 7c95701e9705..94d79da68031 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -192,7 +192,7 @@ bool isRotateItemUsed(const ScDocumentPool *pPool)
void initRowInfo(const ScDocument* pDoc, RowInfo* pRowInfo, const SCSIZE nMaxRow,
double fRowScale, SCROW nRow1, SCTAB nTab, SCROW& rYExtra, SCSIZE& rArrRow, SCROW& rRow2)
{
- sal_uInt16 nDocHeight = ScGlobal::nStdRowHeight;
+ sal_uInt16 nDocHeight = pDoc->GetSheetOptimalMinRowHeight(nTab);
SCROW nDocHeightEndRow = -1;
for (SCROW nSignedY=nRow1-1; nSignedY<=rYExtra; nSignedY++)
{
@@ -207,7 +207,7 @@ void initRowInfo(const ScDocument* pDoc, RowInfo* pRowInfo, const SCSIZE nMaxRow
if (pDoc->ValidRow(nY))
nDocHeight = pDoc->GetRowHeight( nY, nTab, nullptr, &nDocHeightEndRow );
else
- nDocHeight = ScGlobal::nStdRowHeight;
+ nDocHeight = pDoc->GetSheetOptimalMinRowHeight(nTab);
}
if ( rArrRow==0 || nDocHeight || nY > pDoc->MaxRow() )
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index c5d4de055f8d..3b33b7e242a3 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -248,6 +248,7 @@ ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
mbCellAreaEmpty( true ),
mnEndCol( -1 ),
mnEndRow( -1 ),
+ mnOptimalMinRowHeight(0),
mpRowHeights( static_cast<ScFlatUInt16RowSegments*>(nullptr) ),
mpHiddenCols(new ScFlatBoolColSegments(rDoc.MaxCol())),
mpHiddenRows(new ScFlatBoolRowSegments(rDoc.MaxRow())),
@@ -291,7 +292,7 @@ ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
if (bRowInfo)
{
- mpRowHeights.reset(new ScFlatUInt16RowSegments(rDocument.MaxRow(), ScGlobal::nStdRowHeight));
+ mpRowHeights.reset(new ScFlatUInt16RowSegments(rDocument.MaxRow(), GetOptimalMinRowHeight()));
pRowFlags.reset(new ScBitMaskCompressedArray<SCROW, CRFlags>( rDocument.MaxRow(), CRFlags::NONE));
}
@@ -309,7 +310,8 @@ ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
{
pDrawLayer->ScRenamePage( nTab, aName );
sal_uLong const nx = o3tl::convert((rDocument.MaxCol()+1) * STD_COL_WIDTH, o3tl::Length::twip, o3tl::Length::mm100);
- sal_uLong ny = o3tl::convert((rDocument.MaxRow()+1) * ScGlobal::nStdRowHeight, o3tl::Length::twip, o3tl::Length::mm10);
+ sal_uLong ny = o3tl::convert((rDocument.MaxRow() + 1) * GetOptimalMinRowHeight(),
+ o3tl::Length::twip, o3tl::Length::mm10);
pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false );
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index ee65a31ab6bf..cb1316ef9e35 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3316,7 +3316,7 @@ void ScTable::SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight )
if (!nNewHeight)
{
OSL_FAIL("SetRowHeight: Row height zero");
- nNewHeight = ScGlobal::nStdRowHeight;
+ nNewHeight = GetOptimalMinRowHeight();
}
sal_uInt16 nOldHeight = mpRowHeights->getValue(nRow);
@@ -3379,7 +3379,7 @@ bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNew
if (!nNewHeight)
{
OSL_FAIL("SetRowHeight: Row height zero");
- nNewHeight = ScGlobal::nStdRowHeight;
+ nNewHeight = GetOptimalMinRowHeight();
}
bool bSingle = false; // true = process every row for its own
@@ -3432,7 +3432,7 @@ void ScTable::SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewH
return;
if (!nNewHeight)
- nNewHeight = ScGlobal::nStdRowHeight;
+ nNewHeight = GetOptimalMinRowHeight();
mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight);
}
@@ -3588,7 +3588,7 @@ sal_uInt16 ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow,
*pStartRow = nRow;
if (pEndRow)
*pEndRow = nRow;
- return ScGlobal::nStdRowHeight;
+ return GetOptimalMinRowHeight();
}
}
@@ -3614,7 +3614,7 @@ tools::Long ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenA
return nHeight;
}
else
- return (nEndRow - nStartRow + 1) * static_cast<tools::Long>(ScGlobal::nStdRowHeight);
+ return (nEndRow - nStartRow + 1) * static_cast<tools::Long>(GetOptimalMinRowHeight());
}
tools::Long ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const
@@ -3655,7 +3655,7 @@ tools::Long ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double
return nHeight;
}
else
- return static_cast<tools::Long>((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale);
+ return static_cast<tools::Long>((nEndRow - nStartRow + 1) * GetOptimalMinRowHeight() * fScale);
}
sal_uInt16 ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if hidden
@@ -3665,7 +3665,7 @@ sal_uInt16 ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if
if (ValidRow(nRow) && mpRowHeights)
return mpRowHeights->getValue(nRow);
else
- return ScGlobal::nStdRowHeight;
+ return GetOptimalMinRowHeight();
}
// Column/Row -Flags
@@ -3941,7 +3941,7 @@ SCROW ScTable::GetLastChangedRowFlagsWidth() const
// Find the last row position where the height is NOT the standard row
// height.
// KOHEI: Test this to make sure it does what it's supposed to.
- SCROW nLastHeight = mpRowHeights->findLastTrue(ScGlobal::nStdRowHeight);
+ SCROW nLastHeight = mpRowHeights->findLastTrue(GetOptimalMinRowHeight());
if (!ValidRow(nLastHeight))
nLastHeight = 0;
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 49929f99da94..9df2d08cbea5 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -520,7 +520,7 @@ OString ScTable::dumpColumnRowSizes(bool bColumns)
static const OString aDefaultForCols
= OString::number(STD_COL_WIDTH) + ":" + OString::number(GetDoc().MaxCol()) + " ";
static const OString aDefaultForRows
- = OString::number(ScGlobal::nStdRowHeight) + ":" + OString::number(GetDoc().MaxRow()) + " ";
+ = OString::number(GetOptimalMinRowHeight()) + ":" + OString::number(GetDoc().MaxRow()) + " ";
// ScCompressedArray is a template class and we don't want to impose
// the restriction that its value type should be string serializable,
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index e34f5a47d190..495cc0ff7828 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -63,6 +63,7 @@
#include <scitems.hxx>
#include <editutil.hxx>
#include <tokenarray.hxx>
+#include <table.hxx>
#include <tablebuffer.hxx>
#include <documentimport.hxx>
#include <stlsheet.hxx>
@@ -956,6 +957,11 @@ void WorksheetGlobals::finalizeWorksheetImport()
ScDocument& rDoc = getScDocument();
std::vector<sc::ColRowSpan> aSpans;
SCTAB nTab = getSheetIndex();
+
+ ScTable* pTable = rDoc.FetchTable(nTab);
+ if (pTable)
+ pTable->SetOptimalMinRowHeight(maDefRowModel.mfHeight * 20); // in TWIPS
+
ScDBData* pDBData = rDoc.GetAnonymousDBData(nTab);
if (pDBData && pDBData->HasAutoFilter())
{
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 90a7d4b0a455..8b088e226d18 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -687,8 +687,8 @@ void ScCellShell::Execute( SfxRequest& rReq )
rData.GetTabNo() );
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
- pTabViewShell->GetFrameWeld(), "RowHeightDialog",
- nCurHeight, ScGlobal::nStdRowHeight,
+ pTabViewShell->GetFrameWeld(), "RowHeightDialog", nCurHeight,
+ rData.GetDocument().GetSheetOptimalMinRowHeight(rData.GetTabNo()),
eMetric, 2, MAX_ROW_HEIGHT));
pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index c3c79dadd343..0c0b2680e0b3 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -823,7 +823,8 @@ ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pVi
maMarkData.SelectOneTable(0); // Sync with nTabNo
aScrSize = Size( o3tl::convert(STD_COL_WIDTH * OLE_STD_CELLS_X, o3tl::Length::twip, o3tl::Length::px),
- o3tl::convert(ScGlobal::nStdRowHeight * OLE_STD_CELLS_Y, o3tl::Length::twip, o3tl::Length::px));
+ o3tl::convert(mrDoc.GetSheetOptimalMinRowHeight(nTabNo) * OLE_STD_CELLS_Y,
+ o3tl::Length::twip, o3tl::Length::px));
maTabData.emplace_back( new ScViewDataTable(nullptr) );
pThisTab = maTabData[nTabNo].get();
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index bc149f62b40e..13c4ce63c6e7 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2506,11 +2506,6 @@ void ScViewFunc::SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt
void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
{
- //! step size adjustable
- // step size is also minimum
- constexpr sal_uInt16 nStepX = STD_COL_WIDTH / 5;
- sal_uInt16 nStepY = ScGlobal::nStdRowHeight;
-
ScModule* pScMod = SC_MOD();
bool bAnyEdit = pScMod->IsInputMode();
SCCOL nCol = GetViewData().GetCurX();
@@ -2532,6 +2527,11 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
HideAllCursors();
+ //! step size adjustable
+ // step size is also minimum
+ constexpr sal_uInt16 nStepX = STD_COL_WIDTH / 5;
+ const sal_uInt16 nStepY = rDoc.GetSheetOptimalMinRowHeight(nTab);
+
sal_uInt16 nWidth = rDoc.GetColWidth( nCol, nTab );
sal_uInt16 nHeight = rDoc.GetRowHeight( nRow, nTab );
std::vector<sc::ColRowSpan> aRange(1, sc::ColRowSpan(0,0));