diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-14 09:49:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-14 13:05:39 +0200 |
commit | db12ecd5d77670db5a61fb16b9372d7fd7da858c (patch) | |
tree | eb9c7c44624a1686b04af8e15d369652bbfe03d1 /sc/source/core | |
parent | f2de8a282a131f0294c41fa994083df47d5d61f0 (diff) |
simplify calls to IsStreamValid/SetStreamValid
just add a short-circuit check inside SetStreamValid, and we can
simplify all of the call sites
Change-Id: Ib3d19455c60fe9569faf548b1fefbc274d03574c
Reviewed-on: https://gerrit.libreoffice.org/42267
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/attarray.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/documen7.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 33 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 50 | ||||
-rw-r--r-- | sc/source/core/data/table5.cxx | 23 | ||||
-rw-r--r-- | sc/source/core/tool/detfunc.cxx | 3 |
8 files changed, 49 insertions, 78 deletions
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 89cc629c6c4c..9109336115ca 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -147,8 +147,7 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern ) } mvData.resize(0); - if (pDocument->IsStreamValid(nTab)) - pDocument->SetStreamValid(nTab, false); + pDocument->SetStreamValid(nTab, false); mvData.resize(1); const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pDocPool->Put(*pPattern) ); @@ -597,8 +596,7 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern RemoveCellCharAttribs(nStartRow, nEndRow, pPattern, pDataArray); } - if (pDocument->IsStreamValid(nTab)) - pDocument->SetStreamValid(nTab, false); + pDocument->SetStreamValid(nTab, false); } } @@ -675,8 +673,7 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* } while ((nStart <= nEndRow) && (nPos < mvData.size())); - if (pDocument->IsStreamValid(nTab)) - pDocument->SetStreamValid(nTab, false); + pDocument->SetStreamValid(nTab, false); } #if DEBUG_SC_TESTATTRARRAY @@ -903,8 +900,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac } while (nStart <= nEndRow); - if (pDocument->IsStreamValid(nTab)) - pDocument->SetStreamValid(nTab, false); + pDocument->SetStreamValid(nTab, false); } #if DEBUG_SC_TESTATTRARRAY diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 299f5e70d089..8292a04deb27 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -75,7 +75,7 @@ void ScDocument::Broadcast( const ScHint& rHint ) if ( rHint.GetAddress() != BCA_BRDCST_ALWAYS ) { SCTAB nTab = rHint.GetAddress().Tab(); - if (nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && maTabs[nTab]->IsStreamValid()) + if (nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) maTabs[nTab]->SetStreamValid(false); } } diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 961f6456235d..8070b6f6df5c 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -248,7 +248,7 @@ void ScDocument::ModifyStyleSheet( SfxStyleSheetBase& rStyleSheet, InvalidateTextWidth( nullptr, nullptr, bNumFormatChanged ); for (SCTAB nTab=0; nTab<=MAXTAB; ++nTab) - if (maTabs[nTab] && maTabs[nTab]->IsStreamValid()) + if (maTabs[nTab]) maTabs[nTab]->SetStreamValid( false ); sal_uLong nOldFormat = diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 90d37f08485c..86b57f4077e6 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -911,7 +911,7 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc // but the XML stream must be re-generated. TableContainer::iterator it = maTabs.begin(); for (; it != maTabs.end(); ++it) - if ( *it && (*it)->IsStreamValid()) + if ( *it ) (*it)->SetStreamValid( false ); if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer()) diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index c2416406abb4..ced6c3474f95 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -386,7 +386,7 @@ const OUString& ScTable::GetUpperName() const void ScTable::SetVisible( bool bVis ) { - if (bVisible != bVis && IsStreamValid()) + if (bVisible != bVis) SetStreamValid(false); bVisible = bVis; @@ -394,6 +394,8 @@ void ScTable::SetVisible( bool bVis ) void ScTable::SetStreamValid( bool bSet, bool bIgnoreLock ) { + if (!bStreamValid && !bSet) + return; // shortcut if ( bIgnoreLock || !pDocument->IsStreamValidLocked() ) bStreamValid = bSet; } @@ -419,8 +421,7 @@ void ScTable::SetTabBgColor(const Color& rColor) { // The tab color has changed. Set this table 'modified'. aTabBgColor = rColor; - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } } @@ -440,8 +441,7 @@ void ScTable::SetLink( ScLinkMode nMode, aLinkTab = rTab; // Sheet name in source file nLinkRefreshDelay = nRefreshDelay; // refresh delay in seconds, 0==off - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } sal_uInt16 ScTable::GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev, @@ -1668,7 +1668,7 @@ void ScTable::UpdateReference( } } - if (bUpdated && IsStreamValid()) + if (bUpdated) SetStreamValid(false); if(mpCondFormatList) @@ -1717,8 +1717,7 @@ void ScTable::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) for (SCCOL i=0; i < aCol.size(); i++) aCol[i].UpdateInsertTab(rCxt); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } void ScTable::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) @@ -1747,8 +1746,7 @@ void ScTable::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) for (SCCOL i = 0; i < aCol.size(); ++i) aCol[i].UpdateDeleteTab(rCxt); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } void ScTable::UpdateMoveTab( @@ -1776,8 +1774,7 @@ void ScTable::UpdateMoveTab( pProgress->SetState(pProgress->GetState() + aCol[i].GetCodeCount()); } - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } void ScTable::UpdateCompile( bool bForceIfNameInUse ) @@ -2016,8 +2013,7 @@ void ScTable::SetRepeatColRange( const ScRange* pNew ) { setPrintRange( pRepeatColRange, pNew ); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); InvalidatePageBreaks(); } @@ -2026,8 +2022,7 @@ void ScTable::SetRepeatRowRange( const ScRange* pNew ) { setPrintRange( pRepeatRowRange, pNew ); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); InvalidatePageBreaks(); } @@ -2037,8 +2032,7 @@ void ScTable::ClearPrintRanges() aPrintRanges.clear(); bPrintEntireSheet = false; - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); InvalidatePageBreaks(); // #i117952# forget page breaks for an old print range } @@ -2049,8 +2043,7 @@ void ScTable::AddPrintRange( const ScRange& rNew ) if( aPrintRanges.size() < 0xFFFF ) aPrintRanges.push_back( rNew ); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); InvalidatePageBreaks(); } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index d14e699db9a3..bf6ca8ffae94 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -132,8 +132,7 @@ void ScTable::SetSheetEvents( const ScSheetEvents* pNew ) SetCalcNotification( false ); // discard notifications before the events were set - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } void ScTable::SetCalcNotification( bool bSet ) @@ -197,10 +196,9 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE InvalidatePageBreaks(); - if (IsStreamValid()) - // TODO: In the future we may want to check if the table has been - // really modified before setting the stream invalid. - SetStreamValid(false); + // TODO: In the future we may want to check if the table has been + // really modified before setting the stream invalid. + SetStreamValid(false); } void ScTable::DeleteRow( @@ -256,10 +254,9 @@ void ScTable::DeleteRow( InvalidatePageBreaks(); - if (IsStreamValid()) - // TODO: In the future we may want to check if the table has been - // really modified before setting the stream invalid. - SetStreamValid(false); + // TODO: In the future we may want to check if the table has been + // really modified before setting the stream invalid. + SetStreamValid(false); } bool ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const @@ -350,10 +347,9 @@ void ScTable::InsertCol( InvalidatePageBreaks(); - if (IsStreamValid()) - // TODO: In the future we may want to check if the table has been - // really modified before setting the stream invalid. - SetStreamValid(false); + // TODO: In the future we may want to check if the table has been + // really modified before setting the stream invalid. + SetStreamValid(false); } void ScTable::DeleteCol( @@ -419,10 +415,9 @@ void ScTable::DeleteCol( InvalidatePageBreaks(); - if (IsStreamValid()) - // TODO: In the future we may want to check if the table has been - // really modified before setting the stream invalid. - SetStreamValid(false); + // TODO: In the future we may want to check if the table has been + // really modified before setting the stream invalid. + SetStreamValid(false); } void ScTable::DeleteArea( @@ -452,10 +447,9 @@ void ScTable::DeleteArea( mpCondFormatList->DeleteArea( nCol1, nRow1, nCol2, nRow2 ); } - if (IsStreamValid()) - // TODO: In the future we may want to check if the table has been - // really modified before setting the stream invalid. - SetStreamValid(false); + // TODO: In the future we may want to check if the table has been + // really modified before setting the stream invalid. + SetStreamValid(false); } void ScTable::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast ) @@ -488,10 +482,9 @@ void ScTable::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMa ApplySelectionCache( &aCache, rMark ); } - if (IsStreamValid()) - // TODO: In the future we may want to check if the table has been - // really modified before setting the stream invalid. - SetStreamValid(false); + // TODO: In the future we may want to check if the table has been + // really modified before setting the stream invalid. + SetStreamValid(false); } // pTable = Clipboard @@ -3722,7 +3715,7 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos // #i102616# actions that modify the draw page size count as sheet modification // (exception: InitDrawLayer) - if (bResetStreamValid && IsStreamValid()) + if (bResetStreamValid) SetStreamValid(false); } @@ -3732,8 +3725,7 @@ void ScTable::SetRangeName(ScRangeName* pNew) mpRangeName = pNew; //fdo#39792: mark stream as invalid, otherwise new ScRangeName will not be written to file - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } ScRangeName* ScTable::GetRangeName() const diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index de411231e13e..7d66956eef23 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -307,8 +307,7 @@ void ScTable::RemoveManualBreaks() maColManualBreaks.clear(); InvalidatePageBreaks(); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } bool ScTable::HasManualBreaks() const @@ -320,16 +319,14 @@ void ScTable::SetRowManualBreaks( const ::std::set<SCROW>& rBreaks ) { maRowManualBreaks = rBreaks; InvalidatePageBreaks(); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } void ScTable::SetColManualBreaks( const ::std::set<SCCOL>& rBreaks ) { maColManualBreaks = rBreaks; InvalidatePageBreaks(); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } void ScTable::GetAllRowBreaks(set<SCROW>& rBreaks, bool bPage, bool bManual) const @@ -591,8 +588,7 @@ bool ScTable::SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden) if (bChanged) { - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); { // Scoped bulk broadcast. // Only subtotal formula cells will accept the notification of @@ -619,10 +615,7 @@ void ScTable::SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden) bChanged = mpHiddenCols->setFalse(nStartCol, nEndCol); if (bChanged) - { - if (IsStreamValid()) - SetStreamValid(false); - } + SetStreamValid(false); } void ScTable::CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol) @@ -1064,8 +1057,7 @@ void ScTable::SetProtection(const ScTableProtection* pProtect) else pTabProtection.reset(); - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } ScTableProtection* ScTable::GetProtection() @@ -1161,8 +1153,7 @@ void ScTable::SetPageStyle( const OUString& rName ) if ( pNewStyle ) // also without the old one (for UpdateStdNames) aPageStyle = aStrNew; - if (IsStreamValid()) - SetStreamValid(false); + SetStreamValid(false); } } } diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 57db80d0b553..c0ea9f4626d0 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -271,8 +271,7 @@ void ScCommentData::UpdateCaptionSet( const SfxItemSet& rItemSet ) void ScDetectiveFunc::Modified() { - if (pDoc->IsStreamValid(nTab)) - pDoc->SetStreamValid(nTab, false); + pDoc->SetStreamValid(nTab, false); } inline bool Intersect( SCCOL nStartCol1, SCROW nStartRow1, SCCOL nEndCol1, SCROW nEndRow1, |