Avoid unnecessary calls of AdjustRowHeight
Check if attribute changed during ApplyAttributes. If it did not change,
it is unnecessary to recalculate cell size, repaint etc.
Change-Id: Ic3a3fa24efa9ad3619b8979a67e972a7635311cc
Reviewed-on: https://gerrit.libreoffice.org/40198
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Bunth <btomi96@gmail.com>
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index d410e91..e6767a3 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -143,7 +143,7 @@ public:
bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr );
void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
ScEditDataArray* pDataArray = nullptr );
ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
void SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize);
void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 68784b9..e280e3c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -497,7 +497,7 @@ public:
void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
SCROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray );
SCROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged = nullptr );
void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a2d4965..76a4251 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1685,7 +1685,7 @@ public:
const OUString& sValStr, double& nX);
SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
ScEditDataArray* pDataArray = nullptr );
ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e34ed5f..440e0cc 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -696,7 +696,7 @@ public:
bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr );
void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 287ece9..2ecead9 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -850,12 +850,13 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
#undef SET_LINECOLOR
#undef SET_LINE
void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray )
void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray, bool* const pIsChanged )
{
#if DEBUG_SC_TESTATTRARRAY
TestData();
#endif
bool bChanged = false;
if (ValidRow(nStartRow) && ValidRow(nEndRow))
{
SCSIZE nPos;
@@ -880,6 +881,8 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
SCROW nY2 = pData[nPos].nRow;
nStart = pData[nPos].nRow + 1;
bChanged = true;
if ( nY1 < nStartRow || nY2 > nEndRow )
{
if (nY1 < nStartRow) nY1=nStartRow;
@@ -926,6 +929,9 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
pDocument->SetStreamValid(nTab, false);
}
if( pIsChanged)
*pIsChanged = bChanged;
#if DEBUG_SC_TESTATTRARRAY
TestData();
#endif
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index ecb0d5e..716007e 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -423,7 +423,7 @@ sal_uInt32 ScColumn::GetNumberFormat( SCROW nRow ) const
return pAttrArray->GetPattern( nRow )->GetNumberFormat( pDocument->GetFormatTable() );
}
SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray )
SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged )
{
SCROW nTop = 0;
SCROW nBottom = 0;
@@ -434,7 +434,7 @@ SCROW ScColumn::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData&
ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
while (aMultiIter.Next( nTop, nBottom ))
{
pAttrArray->ApplyCacheArea( nTop, nBottom, pCache, pDataArray );
pAttrArray->ApplyCacheArea( nTop, nBottom, pCache, pDataArray, pIsChanged );
bFound = true;
}
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 48dab01..5aa7298 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5775,7 +5775,7 @@ void ScDocument::ApplyFrameAreaTab(const ScRange& rRange,
rRange.aEnd.Col(), rRange.aEnd.Row());
}
void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark, ScEditDataArray* pDataArray )
void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged )
{
const SfxItemSet* pSet = &rAttr.GetItemSet();
bool bSet = false;
@@ -5801,7 +5801,7 @@ void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMark
ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
for (; itr != itrEnd && *itr < nMax; ++itr)
if (maTabs[*itr])
maTabs[*itr]->ApplySelectionCache( &aCache, rMark, pDataArray );
maTabs[*itr]->ApplySelectionCache( &aCache, rMark, pDataArray, pIsChanged );
}
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 8677c3f..ba78a9e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2746,10 +2746,10 @@ void ScTable::ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr )
}
void ScTable::ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark,
ScEditDataArray* pDataArray )
ScEditDataArray* pDataArray, bool* const pIsChanged )
{
for (SCCOL i=0; i < aCol.size(); i++)
aCol[i].ApplySelectionCache( pCache, rMark, pDataArray );
aCol[i].ApplySelectionCache( pCache, rMark, pDataArray, pIsChanged );
}
void ScTable::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark )
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 40a578e..e7f6af5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1367,16 +1367,22 @@ bool ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& r
sal_uInt16 nExtFlags = 0;
if ( !bImportingXML )
rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content before the change
rDoc.ApplySelectionPattern( rPattern, rMark );
if ( !bImportingXML )
rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content after the change
if (!AdjustRowHeight( aMultiRange ))
rDocShell.PostPaint( aMultiRange, PaintPartFlags::Grid, nExtFlags );
else if (nExtFlags & SC_PF_LINES)
lcl_PaintAbove( rDocShell, aMultiRange ); // because of lines above the range
bool bChanged = true;
rDoc.ApplySelectionPattern( rPattern, rMark, nullptr, &bChanged );
aModificator.SetDocumentModified();
if(bChanged)
{
if ( !bImportingXML )
rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content after the change
if (!AdjustRowHeight( aMultiRange ))
rDocShell.PostPaint( aMultiRange, PaintPartFlags::Grid, nExtFlags );
else if (nExtFlags & SC_PF_LINES)
lcl_PaintAbove( rDocShell, aMultiRange ); // because of lines above the range
aModificator.SetDocumentModified();
}
return true;
}