summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-01-29 16:03:29 +0200
committerMichael Meeks <michael.meeks@collabora.com>2021-02-01 21:14:04 +0100
commitfac1dbc160321dcfebfd2ce3346199f2a6ea12f7 (patch)
tree7fe0dfe6a27c25e290190b4dd1d2f989b4cda1d0
parent6aba07610969f34df006413b093c8bfcfee7eb12 (diff)
Don't bother shrinking row height when changing just one row interactively
I.e. when interactively entering a new value. This used to happen at least for a sample document in .xlsx format for cells with automatic wrap turned on. After entering a value, the row height was annoyingly shrunk by a few pixels, which looked weird and pointless, and caused unnecessary invalidation thrash in the online collaborative editing context. We assume that the call to ScDocFunc::SetNormalString() in ScViewFunc::EnterData() is the result of interactivity. Change-Id: I3c77f7fb4e575f02e1dd7cdc18f2919f5eb3426e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110245 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/inc/table.hxx4
-rw-r--r--sc/source/core/data/dociter.cxx4
-rw-r--r--sc/source/core/data/document.cxx6
-rwxr-xr-xsc/source/core/data/table1.cxx23
-rw-r--r--sc/source/core/data/table2.cxx25
-rw-r--r--sc/source/filter/rtf/eeimpars.cxx2
-rw-r--r--sc/source/ui/docshell/docfunc.cxx50
-rw-r--r--sc/source/ui/docshell/docsh5.cxx2
-rw-r--r--sc/source/ui/inc/docfunc.hxx2
-rw-r--r--sc/source/ui/inc/viewfunc.hxx2
-rw-r--r--sc/source/ui/undo/undobase.cxx2
-rw-r--r--sc/source/ui/undo/undoblk.cxx6
-rw-r--r--sc/source/ui/undo/undoblk3.cxx6
-rw-r--r--sc/source/ui/view/viewfun2.cxx6
-rw-r--r--sc/source/ui/view/viewfun3.cxx2
-rw-r--r--sc/source/ui/view/viewfun4.cxx2
-rw-r--r--sc/source/ui/view/viewfunc.cxx10
18 files changed, 82 insertions, 74 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9d7bd94d8764..4d385e97d0c9 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1888,7 +1888,7 @@ public:
const ScColWidthParam* pParam = nullptr );
SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow,
- SCROW nEndRow, SCTAB nTab );
+ SCROW nEndRow, SCTAB nTab, bool bApi );
void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 93003911f8ae..8fa962081a05 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -776,7 +776,7 @@ public:
bool bFormula, const ScMarkData* pMarkData,
const ScColWidthParam* pParam );
bool SetOptimalHeight(
- sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
+ sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
void SetOptimalHeightOnly(
@@ -793,7 +793,7 @@ public:
void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
- double nPPTY );
+ double nPPTY, bool bApi );
/**
* Set specified row height to specified ranges. Don't check for drawing
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 5331e8ac33ae..eeeeb9f1cc69 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2730,7 +2730,7 @@ void ScDocRowHeightUpdater::update()
continue;
mrDoc.maTabs[nTab]->SetOptimalHeight(
- aCxt, aData.mnRow1, aData.mnRow2, &aProgress, nProgressStart);
+ aCxt, aData.mnRow1, aData.mnRow2, true, &aProgress, nProgressStart);
nProgressStart += mrDoc.maTabs[nTab]->GetWeightedCount(aData.mnRow1, aData.mnRow2);
}
@@ -2758,7 +2758,7 @@ void ScDocRowHeightUpdater::updateAll()
if (!ValidTab(nTab) || !mrDoc.maTabs[nTab])
continue;
- mrDoc.maTabs[nTab]->SetOptimalHeight(aCxt, 0, mrDoc.MaxRow(), &aProgress, nProgressStart);
+ mrDoc.maTabs[nTab]->SetOptimalHeight(aCxt, 0, mrDoc.MaxRow(), true, &aProgress, nProgressStart);
nProgressStart += mrDoc.maTabs[nTab]->GetWeightedCount();
}
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 296da798cb4b..470ac4909854 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4089,7 +4089,7 @@ void ScDocument::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
{
if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
maTabs[nTab]->SetRowHeightRange
- ( nStartRow, nEndRow, nNewHeight, 1.0 );
+ ( nStartRow, nEndRow, nNewHeight, 1.0, true );
}
void ScDocument::SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nNewHeight )
@@ -4250,13 +4250,13 @@ long ScDocument::GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
return 0;
}
-bool ScDocument::SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
+bool ScDocument::SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi )
{
ScTable* pTab = FetchTable(nTab);
if (!pTab)
return false;
- return pTab->SetOptimalHeight(rCxt, nStartRow, nEndRow);
+ return pTab->SetOptimalHeight(rCxt, nStartRow, nEndRow, bApi);
}
void ScDocument::UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark )
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 98f2cd8b0fd7..0310ed566dfa 100755
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -124,7 +124,7 @@ void GetOptimalHeightsInColumn(
struct OptimalHeightsFuncObjBase
{
virtual ~OptimalHeightsFuncObjBase() {}
- virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight) = 0;
+ virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight, bool bApi) = 0;
};
struct SetRowHeightOnlyFunc : public OptimalHeightsFuncObjBase
@@ -134,7 +134,7 @@ struct SetRowHeightOnlyFunc : public OptimalHeightsFuncObjBase
mpTab(pTab)
{}
- virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight) override
+ virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight, bool /* bApi */) override
{
mpTab->SetRowHeightOnly(nStartRow, nEndRow, nHeight);
return false;
@@ -151,16 +151,17 @@ struct SetRowHeightRangeFunc : public OptimalHeightsFuncObjBase
mnPPTY(nPPTY)
{}
- virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight) override
+ virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight, bool bApi) override
{
- return mpTab->SetRowHeightRange(nStartRow, nEndRow, nHeight, mnPPTY);
+ return mpTab->SetRowHeightRange(nStartRow, nEndRow, nHeight, mnPPTY, bApi);
}
};
bool SetOptimalHeightsToRows(
sc::RowHeightContext& rCxt,
OptimalHeightsFuncObjBase& rFuncObj,
- ScBitMaskCompressedArray<SCROW, CRFlags>* pRowFlags, SCROW nStartRow, SCROW nEndRow )
+ ScBitMaskCompressedArray<SCROW, CRFlags>* pRowFlags, SCROW nStartRow, SCROW nEndRow,
+ bool bApi )
{
bool bChanged = false;
SCROW nRngStart = 0;
@@ -200,7 +201,7 @@ bool SetOptimalHeightsToRows(
}
else
{
- bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
+ bChanged |= rFuncObj(nRngStart, nRngEnd, nLast, bApi);
nLast = 0;
}
}
@@ -215,13 +216,13 @@ bool SetOptimalHeightsToRows(
else
{
if (nLast)
- bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
+ bChanged |= rFuncObj(nRngStart, nRngEnd, nLast, bApi);
nLast = 0;
}
i += nMoreRows; // already handled - skip
}
if (nLast)
- bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
+ bChanged |= rFuncObj(nRngStart, nRngEnd, nLast, bApi);
return bChanged;
}
@@ -447,7 +448,7 @@ long ScTable::GetNeededSize( SCCOL nCol, SCROW nRow,
}
bool ScTable::SetOptimalHeight(
- sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
+ sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
ScProgress* pOuterProgress, sal_uLong nProgressStart )
{
assert(nStartRow <= nEndRow);
@@ -468,7 +469,7 @@ bool ScTable::SetOptimalHeight(
rCxt.getHeightArray().enableTreeSearch(true);
SetRowHeightRangeFunc aFunc(this, rCxt.getPPTY());
- bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow);
+ bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow, bApi);
if ( pProgress != pOuterProgress )
delete pProgress;
@@ -495,7 +496,7 @@ void ScTable::SetOptimalHeightOnly(
SetRowHeightOnlyFunc aFunc(this);
rCxt.getHeightArray().enableTreeSearch(true);
- SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow);
+ SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow, true);
if ( pProgress != pOuterProgress )
delete pProgress;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 971c8ad7cd31..20efb9d1dd93 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
@@ -2848,7 +2848,7 @@ void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRem
SCROW nEndRow = aData.mnRow2;
if (aData.mbValue)
- SetOptimalHeight(aCxt, nRow, nEndRow);
+ SetOptimalHeight(aCxt, nRow, nEndRow, true);
nRow = nEndRow + 1;
}
@@ -2986,7 +2986,7 @@ namespace {
*/
bool lcl_pixelSizeChanged(
ScFlatUInt16RowSegments& rRowHeights, SCROW nStartRow, SCROW nEndRow,
- sal_uInt16 nNewHeight, double nPPTY)
+ sal_uInt16 nNewHeight, double nPPTY, bool bApi)
{
long nNewPix = static_cast<long>(nNewHeight * nPPTY);
@@ -2999,7 +2999,11 @@ bool lcl_pixelSizeChanged(
if (nHeight != nNewHeight)
{
- bool bChanged = (nNewPix != static_cast<long>(nHeight * nPPTY));
+ long nOldPix = static_cast<long>(nHeight * nPPTY);
+
+ // Heuristic: Don't bother when handling interactive input, if changing just one row and
+ // the height will shrink.
+ bool bChanged = (nNewPix != nOldPix) && (bApi || nEndRow - nStartRow > 0 || nNewPix > nOldPix);
if (bChanged)
return true;
}
@@ -3013,7 +3017,7 @@ bool lcl_pixelSizeChanged(
}
bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
- double nPPTY )
+ double nPPTY, bool bApi )
{
bool bChanged = false;
if (ValidRow(nStartRow) && ValidRow(nEndRow) && mpRowHeights)
@@ -3040,17 +3044,20 @@ bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNew
}
}
+ // No idea why 20 is used here
if (!bSingle || nEndRow - nStartRow < 20)
{
- bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY);
- mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight);
+ bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY, bApi);
+ if (bChanged)
+ mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight);
}
else
{
SCROW nMid = (nStartRow + nEndRow) / 2;
- if (SetRowHeightRange(nStartRow, nMid, nNewHeight, 1.0))
+ // No idea why nPPTY is ignored in these recursive calls and instead 1.0 is used
+ if (SetRowHeightRange(nStartRow, nMid, nNewHeight, 1.0, bApi))
bChanged = true;
- if (SetRowHeightRange(nMid + 1, nEndRow, nNewHeight, 1.0))
+ if (SetRowHeightRange(nMid + 1, nEndRow, nNewHeight, 1.0, bApi))
bChanged = true;
}
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 368c99fa3bd6..abb920faa075 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -448,7 +448,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
ScopedVclPtrInstance< VirtualDevice > pVirtDev;
sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoom, aZoom, pVirtDev);
aCxt.setExtraHeight(ScGlobal::nLastRowHeightExtra);
- mpDoc->SetOptimalHeight(aCxt, 0, nEndRow, 0);
+ mpDoc->SetOptimalHeight(aCxt, 0, nEndRow, 0, true);
if ( !maRowHeights.empty() )
{
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 493a5e59d6b6..c016d3083b63 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -133,7 +133,7 @@ static void lcl_PaintAbove( ScDocShell& rDocShell, const ScRange& rRange )
}
}
-bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
+bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint, bool bApi )
{
ScDocument& rDoc = rDocShell.GetDocument();
SfxViewShell* pSomeViewForThisDoc = rDocShell.GetBestViewShell(false);
@@ -155,7 +155,7 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
Fraction aOne(1,1);
sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, aProv.GetDevice());
- bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab);
+ bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab, bApi);
// tdf#76183: recalculate objects' positions
if (bChanged)
{
@@ -647,7 +647,7 @@ bool ScDocFunc::DeleteContents(
std::move(pUndoDoc), nFlags, pDataSpans, bMulti, bDrawUndo);
}
- if (!AdjustRowHeight( aExtendedRange ))
+ if (!AdjustRowHeight( aExtendedRange, true, bApi ))
rDocShell.PostPaint( aExtendedRange, PaintPartFlags::Grid, nExtFlags );
else if (nExtFlags & SC_PF_LINES)
lcl_PaintAbove( rDocShell, aExtendedRange ); // for lines above the range
@@ -714,7 +714,7 @@ bool ScDocFunc::DeleteCell(
nFlags, pDataSpans, false, bDrawUndo);
}
- if (!AdjustRowHeight(rPos))
+ if (!AdjustRowHeight(rPos, true, true))
rDocShell.PostPaint(
rPos.Col(), rPos.Row(), rPos.Tab(), rPos.Col(), rPos.Row(), rPos.Tab(),
PaintPartFlags::Grid, nExtFlags);
@@ -775,7 +775,7 @@ bool ScDocFunc::TransliterateText( const ScMarkData& rMark, TransliterationFlags
rDoc.TransliterateText( aMultiMark, nType );
- if (!AdjustRowHeight( aMarkRange ))
+ if (!AdjustRowHeight( aMarkRange, true, true ))
rDocShell.PostPaint( aMarkRange, PaintPartFlags::Grid );
aModificator.SetDocumentModified();
@@ -831,7 +831,7 @@ bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, con
}
if ( bEditDeleted || rDoc.HasAttrib( ScRange(rPos), HasAttrFlags::NeedHeight ) )
- AdjustRowHeight( ScRange(rPos) );
+ AdjustRowHeight( ScRange(rPos), true, bApi );
rDocShell.PostPaintCell( rPos );
aModificator.SetDocumentModified();
@@ -866,7 +866,7 @@ bool ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteract
}
if (bHeight)
- AdjustRowHeight(rPos);
+ AdjustRowHeight(rPos, true, !bInteraction);
rDocShell.PostPaintCell( rPos );
aModificator.SetDocumentModified();
@@ -937,7 +937,7 @@ bool ScDocFunc::SetStringCell( const ScAddress& rPos, const OUString& rStr, bool
}
if (bHeight)
- AdjustRowHeight(rPos);
+ AdjustRowHeight(rPos, true, !bInteraction);
rDocShell.PostPaintCell( rPos );
aModificator.SetDocumentModified();
@@ -972,7 +972,7 @@ bool ScDocFunc::SetEditCell( const ScAddress& rPos, const EditTextObject& rStr,
}
if (bHeight)
- AdjustRowHeight(rPos);
+ AdjustRowHeight(rPos, true, !bInteraction);
rDocShell.PostPaintCell( rPos );
aModificator.SetDocumentModified();
@@ -1036,7 +1036,7 @@ bool ScDocFunc::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, boo
}
if (bHeight)
- AdjustRowHeight(rPos);
+ AdjustRowHeight(rPos, true, !bInteraction);
rDocShell.PostPaintCell( rPos );
aModificator.SetDocumentModified();
@@ -1465,7 +1465,7 @@ bool ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& r
if ( !bImportingXML )
rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content after the change
- if (!AdjustRowHeight( aMultiRange ))
+ if (!AdjustRowHeight( aMultiRange, true, bApi ))
rDocShell.PostPaint( aMultiRange, PaintPartFlags::Grid, nExtFlags );
else if (nExtFlags & SC_PF_LINES)
lcl_PaintAbove( rDocShell, aMultiRange ); // because of lines above the range
@@ -1538,7 +1538,7 @@ bool ScDocFunc::ApplyStyle( const ScMarkData& rMark, const OUString& rStyleName,
rDoc.ApplySelectionStyle( *pStyleSheet, rMark );
- if (!AdjustRowHeight( aMultiRange ))
+ if (!AdjustRowHeight( aMultiRange, true, bApi ))
rDocShell.PostPaint( aMultiRange, PaintPartFlags::Grid );
aModificator.SetDocumentModified();
@@ -2187,8 +2187,8 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
nScenarioCount ++;
bool bAdjusted = ( eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSROWS_AFTER ) ?
- AdjustRowHeight(ScRange(0, nStartRow, i, rDoc.MaxCol(), nEndRow, i+nScenarioCount )) :
- AdjustRowHeight(ScRange(0, nPaintStartRow, i, rDoc.MaxCol(), nPaintEndRow, i+nScenarioCount ));
+ AdjustRowHeight(ScRange(0, nStartRow, i, rDoc.MaxCol(), nEndRow, i+nScenarioCount ), true, bApi) :
+ AdjustRowHeight(ScRange(0, nPaintStartRow, i, rDoc.MaxCol(), nPaintEndRow, i+nScenarioCount ), true, bApi);
if (bAdjusted)
{
// paint only what is not done by AdjustRowHeight
@@ -2799,7 +2799,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
nScenarioCount ++;
// delete entire rows: do not adjust
- if ( eCmd == DelCellCmd::Rows || !AdjustRowHeight(ScRange( 0, nPaintStartRow, rTab, rDoc.MaxCol(), nPaintEndRow, rTab+nScenarioCount )) )
+ if ( eCmd == DelCellCmd::Rows || !AdjustRowHeight(ScRange( 0, nPaintStartRow, rTab, rDoc.MaxCol(), nPaintEndRow, rTab+nScenarioCount ), true, bApi) )
rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, rTab, nPaintEndCol, nPaintEndRow, rTab+nScenarioCount, nPaintFlags, nExtFlags );
else
{
@@ -3025,7 +3025,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
return false;
}
- bSourceHeight = AdjustRowHeight( rSource, false );
+ bSourceHeight = AdjustRowHeight( rSource, false, bApi );
}
ScRange aPasteDest( nDestCol, nDestRow, nDestTab, nDestEndCol, nDestEndRow, nDestEndTab );
@@ -3050,7 +3050,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
bool bDestHeight = AdjustRowHeight(
ScRange( 0,nDestRow,nDestTab, rDoc.MaxCol(),nDestEndRow,nDestEndTab ),
- false );
+ false, bApi );
/* Paste drawing objects after adjusting formula references
and row heights. There are no cell notes or drawing objects, if the
@@ -3716,7 +3716,7 @@ bool ScDocFunc::SetWidthOrHeight(
Fraction aOne(1,1);
sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, aProv.GetDevice());
aCxt.setForceAutoSize(bAll);
- rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab);
+ rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, bApi);
if (bAll)
rDoc.ShowRows( nStartNo, nEndNo, nTab, true );
@@ -4288,7 +4288,7 @@ bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
break;
bool bAdj = AdjustRowHeight( ScRange(nStartCol, nStartRow, rTab,
- nEndCol, nEndRow, rTab), false );
+ nEndCol, nEndRow, rTab), false, bApi );
if (bAdj)
rDocShell.PostPaint( 0,nStartRow,rTab, rDoc.MaxCol(),rDoc.MaxRow(),rTab,
PaintPartFlags::Grid | PaintPartFlags::Left );
@@ -4634,7 +4634,7 @@ bool ScDocFunc::FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
rDoc.Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), &aProgress,
aMark, nCount, eDir, FILL_SIMPLE );
- AdjustRowHeight(aRange);
+ AdjustRowHeight(aRange, true, bApi);
if ( bRecord ) // only now is Draw-Undo available
{
@@ -4765,7 +4765,7 @@ bool ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
rDoc.Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), &aProgress,
aMark, nCount, eDir, eCmd, eDateCmd, fStep, fMax );
- AdjustRowHeight(rRange);
+ AdjustRowHeight(rRange, true, bApi);
rDocShell.PostPaintGridAll();
aModificator.SetDocumentModified();
@@ -4912,7 +4912,7 @@ bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir e
aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), &aProgress,
aMark, nCount, eDir, eCmd, eDateCmd, fStep, fMax );
- AdjustRowHeight(aDestArea);
+ AdjustRowHeight(aDestArea, true, bApi);
if ( bRecord ) // only now is Draw-Undo available
{
@@ -5013,7 +5013,7 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
rDoc.ApplyAttr( nStartCol, nStartRow, nTab, SvxVerJustifyItem( SvxCellVerJustify::Center, ATTR_VER_JUSTIFY ) );
}
- if ( !AdjustRowHeight( ScRange( 0,nStartRow,nTab, rDoc.MaxCol(),nEndRow,nTab ) ) )
+ if ( !AdjustRowHeight( ScRange( 0,nStartRow,nTab, rDoc.MaxCol(),nEndRow,nTab ), true, bApi ) )
rDocShell.PostPaint( nStartCol, nStartRow, nTab,
nEndCol, nEndRow, nTab, PaintPartFlags::Grid );
if (bNeedContents || rOption.mbCenter)
@@ -5105,7 +5105,7 @@ bool ScDocFunc::UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, Sc
rDoc.ExtendMerge( aRefresh, true );
- if ( !AdjustRowHeight( aExtended ) )
+ if ( !AdjustRowHeight( aExtended, true, true ) )
rDocShell.PostPaint( aExtended, PaintPartFlags::Grid );
}
@@ -5451,7 +5451,7 @@ bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, bool bApi )
std::move(pUndoDoc), std::move(pRedoDoc) ) );
}
- if (!AdjustRowHeight(ScRange(0,nStartRow,nTab,rDoc.MaxCol(),nEndRow,nTab)))
+ if (!AdjustRowHeight(ScRange(0,nStartRow,nTab,rDoc.MaxCol(),nEndRow,nTab), true, true))
rDocShell.PostPaint( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab, PaintPartFlags::Grid );
aModificator.SetDocumentModified();
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index ea851d9b9d1b..374922b968f8 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -408,7 +408,7 @@ bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
ScSizeDeviceProvider aProv(this);
Fraction aZoom(1,1);
sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
- bool bChange = m_aDocument.SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab);
+ bool bChange = m_aDocument.SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab, true);
if (bChange)
{
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index ca0f03e0318c..af8e23fc3124 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -59,7 +59,7 @@ class ScDocFunc
protected:
ScDocShell& rDocShell;
- bool AdjustRowHeight( const ScRange& rRange, bool bPaint = true );
+ bool AdjustRowHeight( const ScRange& rRange, bool bPaint, bool bApi );
void CreateOneName( ScRangeName& rList,
SCCOL nPosX, SCROW nPosY, SCTAB nTab,
SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index a22575e48971..44a34fb72156 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -214,7 +214,7 @@ public:
void SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips );
bool AdjustBlockHeight( bool bPaint = true, ScMarkData* pMarkData = nullptr );
- bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow );
+ bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, bool bApi );
void ModifyCellSize( ScDirection eDir, bool bOptimal );
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 7181b10d01ee..001aa69acc20 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -305,7 +305,7 @@ bool ScBlockUndo::AdjustHeight()
sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, pVirtDev);
bool bRet = rDoc.SetOptimalHeight(
- aCxt, aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), aBlockRange.aStart.Tab());
+ aCxt, aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), aBlockRange.aStart.Tab(), true);
if (bRet)
{
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 2e431a067251..63a06166702b 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1267,7 +1267,7 @@ void ScUndoDragDrop::PaintArea( ScRange aRange, sal_uInt16 nExtFlags ) const
rViewData.GetPPTX(), rViewData.GetPPTY(), rViewData.GetZoomX(), rViewData.GetZoomY(),
pVirtDev);
- if (rDoc.SetOptimalHeight(aCxt, aRange.aStart.Row(), aRange.aEnd.Row(), aRange.aStart.Tab()))
+ if (rDoc.SetOptimalHeight(aCxt, aRange.aStart.Row(), aRange.aEnd.Row(), aRange.aStart.Tab(), true))
{
// tdf#76183: recalculate objects' positions
rDoc.SetDrawPageSize(aRange.aStart.Tab());
@@ -2269,7 +2269,7 @@ void ScUndoRemoveMerge::Undo()
if ( pViewShell )
{
pViewShell->SetTabNo(rTab);
- bDidPaint = pViewShell->AdjustRowHeight(rOption.mnStartRow, rOption.mnEndRow);
+ bDidPaint = pViewShell->AdjustRowHeight(rOption.mnStartRow, rOption.mnEndRow, true);
}
if (!bDidPaint)
ScUndoUtil::PaintMore(pDocShell, aRange);
@@ -2315,7 +2315,7 @@ void ScUndoRemoveMerge::Redo()
if ( pViewShell )
{
pViewShell->SetTabNo(nTab);
- bDidPaint = pViewShell->AdjustRowHeight(rOption.mnStartRow, rOption.mnEndRow);
+ bDidPaint = pViewShell->AdjustRowHeight(rOption.mnStartRow, rOption.mnEndRow, true);
}
if (!bDidPaint)
ScUndoUtil::PaintMore(pDocShell, aRange);
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index dbf07d4daabe..dbeca5b3b240 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -161,7 +161,7 @@ void ScUndoDeleteContents::DoChange( const bool bUndo )
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
if ( !( pViewShell && pViewShell->AdjustRowHeight(
- aRange.aStart.Row(), aRange.aEnd.Row() ) ) )
+ aRange.aStart.Row(), aRange.aEnd.Row(), true ) ) )
/*A*/ pDocShell->PostPaint( aRange, PaintPartFlags::Grid | PaintPartFlags::Extras, nExtFlags );
if (pViewShell)
@@ -720,7 +720,7 @@ void ScUndoMerge::DoChange( bool bUndo ) const
if ( pViewShell )
{
pViewShell->SetTabNo(nTab);
- bDidPaint = pViewShell->AdjustRowHeight(maOption.mnStartRow, maOption.mnEndRow);
+ bDidPaint = pViewShell->AdjustRowHeight(maOption.mnStartRow, maOption.mnEndRow, true);
}
if (!bDidPaint)
@@ -873,7 +873,7 @@ void ScUndoAutoFormat::Redo()
rDoc.SetRowFlags( nRow, nTab, nOld & ~CRFlags::ManualSize );
}
- bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartY, nEndY, nTab);
+ bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartY, nEndY, nTab, true);
for (SCCOL nCol=nStartX; nCol<=nEndX; nCol++)
if (!rDoc.ColHidden(nCol, nTab))
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 5b631f209fee..7a04846cfd3b 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -156,7 +156,7 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
SCROW nEndNo = rRow.mnEnd;
ScAddress aTopLeft(0, nStartNo, nTab);
rDoc.UpdateScriptTypes(aTopLeft, MAXCOLCOUNT, nEndNo-nStartNo+1);
- if (rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab))
+ if (rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true))
{
if (!bChanged)
nPaintY = nStartNo;
@@ -188,7 +188,7 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
return bAnyChanged;
}
-bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow )
+bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, bool bApi )
{
if (comphelper::LibreOfficeKit::isActive())
{
@@ -214,7 +214,7 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow )
aZoomX = aZoomY = Fraction( 1, 1 );
}
sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
- bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab);
+ bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab, bApi);
// tdf#76183: recalculate objects' positions
if (bChanged)
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index a1656d15c0eb..42395787792a 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -139,7 +139,7 @@ void ScViewFunc::CutToClip()
pDoc->DeleteObjectsInSelection( rMark );
rMark.MarkToSimple();
- if ( !AdjustRowHeight( aRange.aStart.Row(), aRange.aEnd.Row() ) )
+ if ( !AdjustRowHeight( aRange.aStart.Row(), aRange.aEnd.Row(), true ) )
pDocSh->PostPaint( aRange, PaintPartFlags::Grid, nExtFlags );
if ( bRecord ) // Draw-Undo now available
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 0778c2b5a710..7b1218a2f7e3 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -173,7 +173,7 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
else if ( aDataHelper.GetString( SotClipboardFormatId::RICHTEXT, aStr ) )
aImpEx.ImportString( aStr, SotClipboardFormatId::RICHTEXT );
- AdjustRowHeight( nStartRow, aImpEx.GetRange().aEnd.Row() );
+ AdjustRowHeight( nStartRow, aImpEx.GetRange().aEnd.Row(), true );
pDocSh->UpdateOle(&GetViewData());
ShowAllCursors();
}
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index e8ac749a9ae8..06241ecb4cf7 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -709,7 +709,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
if (bSimple)
{
if (bCommon)
- AdjustRowHeight(nRow,nRow);
+ AdjustRowHeight(nRow,nRow,true);
EnterData(nCol,nRow,nTab,aString);
}
@@ -729,7 +729,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
HideAllCursors();
- AdjustRowHeight(nRow,nRow);
+ AdjustRowHeight(nRow,nRow,true);
for (const auto& rTab : rMark)
pDocSh->PostPaintCell( nCol, nRow, rTab );
@@ -1905,7 +1905,7 @@ void ScViewFunc::DeleteMulti( bool bRows )
pDocSh, bRows, bNeedRefresh, nTab, aSpans, std::move(pUndoDoc), std::move(pUndoData)));
}
- if (!AdjustRowHeight(0, rDoc.MaxRow()))
+ if (!AdjustRowHeight(0, rDoc.MaxRow(), true))
{
if (bRows)
{
@@ -2176,7 +2176,7 @@ void ScViewFunc::SetWidthOrHeight(
sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
aCxt.setForceAutoSize(bAll);
aCxt.setExtraHeight(nSizeTwips);
- rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab);
+ rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true);
if (bAll)
rDoc.ShowRows( nStartNo, nEndNo, nTab, true );
@@ -2454,7 +2454,7 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
pPattern->GetItem( ATTR_LINEBREAK ).GetValue() ||
pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue() == SvxCellHorJustify::Block;
if (bNeedHeight)
- AdjustRowHeight( nRow, nRow );
+ AdjustRowHeight( nRow, nRow, true );
}
}
else