include/svl/hint.hxx | 2 +- sc/Library_sc.mk | 1 - sc/inc/brdcst.hxx | 6 ++++-- sc/inc/column.hxx | 2 +- sc/inc/table.hxx | 2 +- sc/source/core/data/bcaslot.cxx | 7 +++---- sc/source/core/data/column.cxx | 25 +++++++++++-------------- sc/source/core/data/column3.cxx | 2 +- sc/source/core/data/documen7.cxx | 4 +--- sc/source/core/data/document.cxx | 7 ++++++- sc/source/core/data/table2.cxx | 10 ++++------ sc/source/core/tool/brdcst.cxx | 25 ------------------------- svl/Library_svl.mk | 1 - svl/source/notify/hint.cxx | 26 -------------------------- 14 files changed, 33 insertions(+), 87 deletions(-)
New commits: commit 11c2d56b290200fab69956d718f8c5f5c5f2b412 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Sun Dec 5 22:59:31 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Dec 6 22:19:12 2021 +0100 make it clearer that ScHint is modified It's somewhat confusing that an accessor is provided to give a reference to internal data and then the object is modified indirectly using the reference. It appears to be only for performance reasons, so I thought that inlining the ctor and ctor could help the compiler to optimize this, but apparently it can't move this outside of the loop, so at least make it clearer. Change-Id: I72cf15d1446daa559ac4079b9478e53694d7d198 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126394 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126447 diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 337930335a0f..ef1343a49fc8 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -213,7 +213,7 @@ private: public: SfxHint() : mnId(SfxHintId::NONE) {} explicit SfxHint( SfxHintId nId ) : mnId(nId) {} - virtual ~SfxHint() COVERITY_NOEXCEPT_FALSE; + virtual ~SfxHint() {}; SfxHint(SfxHint const &) = default; SfxHint(SfxHint &&) = default; diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index b3c63122f8f6..936ca33901ee 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -207,7 +207,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/core/tool/adiasync \ sc/source/core/tool/appoptio \ sc/source/core/tool/autoform \ - sc/source/core/tool/brdcst \ sc/source/core/tool/calcconfig \ sc/source/core/tool/callform \ sc/source/core/tool/cellform \ diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx index 0c29d29e607a..3d57e7644370 100644 --- a/sc/inc/brdcst.hxx +++ b/sc/inc/brdcst.hxx @@ -26,9 +26,11 @@ class ScHint final : public SfxHint ScAddress aAddress; public: - ScHint( SfxHintId n, const ScAddress& a ); + ScHint( SfxHintId n, const ScAddress& a ) : SfxHint(n), aAddress(a) {} const ScAddress& GetAddress() const { return aAddress; } - ScAddress& GetAddress() { return aAddress; } + void SetAddressTab(SCTAB nTab) { aAddress.SetTab(nTab); } + void SetAddressCol(SCCOL nCol) { aAddress.SetCol(nCol); } + void SetAddressRow(SCROW nRow) { aAddress.SetRow(nRow); } }; class ScAreaChangedHint final : public SfxHint diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 91e5b5c3fc22..384c12d52248 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -414,7 +414,7 @@ public: @param rHint address is modified to adapt to the actual broadcasted position on each iteration and upon return points to the last position broadcasted. */ - bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint ); + bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint ); bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ); diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 672d8431dfe4..fa8d6326d479 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -650,7 +650,7 @@ public: @param rHint address is modified to adapt to the actual broadcasted position on each iteration and upon return points to the last position broadcasted. */ - bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint ); + bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint ); bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ); diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 65dbb97a9450..2627bdf9b990 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -213,16 +213,15 @@ namespace { void broadcastRangeByCell( SvtBroadcaster& rBC, const ScRange& rRange, SfxHintId nHint ) { ScHint aHint(nHint, ScAddress()); - ScAddress& rPos = aHint.GetAddress(); for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab) { - rPos.SetTab(nTab); + aHint.SetAddressTab(nTab); for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol) { - rPos.SetCol(nCol); + aHint.SetAddressCol(nCol); for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow) { - rPos.SetRow(nRow); + aHint.SetAddressRow(nRow); rBC.Broadcast(aHint); } } diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 955f788c24e9..20cfc194b8b4 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2042,12 +2042,11 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) // Broadcast on moved ranges. Area-broadcast only. ScDocument& rDocument = GetDoc(); ScHint aHint(SfxHintId::ScDataChanged, ScAddress(nCol, 0, nTab)); - ScAddress& rPos = aHint.GetAddress(); for (const auto& rRange : aRanges) { for (SCROW nRow = rRange.mnRow1; nRow <= rRange.mnRow2; ++nRow) { - rPos.SetRow(nRow); + aHint.SetAddressRow(nRow); rDocument.AreaBroadcast(aHint); } } @@ -3263,22 +3262,20 @@ namespace { class BroadcastBroadcastersHandler { - ScHint& mrHint; - ScAddress& mrAddress; + ScHint maHint; bool mbBroadcasted; public: - explicit BroadcastBroadcastersHandler( ScHint& rHint ) - : mrHint(rHint) - , mrAddress(mrHint.GetAddress()) + explicit BroadcastBroadcastersHandler( SfxHintId nHint, SCTAB nTab, SCCOL nCol ) + : maHint(nHint, ScAddress(nCol, 0, nTab)) , mbBroadcasted(false) { } void operator() ( size_t nRow, SvtBroadcaster* pBroadcaster ) { - mrAddress.SetRow(nRow); - pBroadcaster->Broadcast(mrHint); + maHint.SetAddressRow(nRow); + pBroadcaster->Broadcast(maHint); mbBroadcasted = true; } @@ -3287,10 +3284,9 @@ public: } -bool ScColumn::BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint ) +bool ScColumn::BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint ) { - rHint.GetAddress().SetCol(nCol); - BroadcastBroadcastersHandler aBroadcasterHdl( rHint); + BroadcastBroadcastersHandler aBroadcasterHdl(nHint, nTab, nCol); sc::ProcessBroadcaster(maBroadcasters.begin(), maBroadcasters, nRow1, nRow2, aBroadcasterHdl); return aBroadcasterHdl.wasBroadcasted(); } @@ -3323,8 +3319,7 @@ void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode ) SetDirtyOnRangeHandler aHdl(*this); sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aHdl); // Broadcast all broadcasters in range. - ScHint aHint( SfxHintId::ScDataChanged, ScAddress( nCol, nRow1, nTab)); - if (BroadcastBroadcasters( nRow1, nRow2, aHint)) + if (BroadcastBroadcasters( nRow1, nRow2, SfxHintId::ScDataChanged)) { // SetDirtyOnRangeHandler implicitly tracks notified // formulas via ScDocument::Broadcast(), which diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 8361018c41c8..dfdd4e59e1bc 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -86,7 +86,7 @@ void ScColumn::BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint ScHint aHint(nHint, ScAddress(nCol, 0, nTab)); for (const auto& rRow : rRows) { - aHint.GetAddress().SetRow(rRow); + aHint.SetAddressRow(rRow); rDocument.Broadcast(aHint); } } diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index dbbbbcae7883..ab6ae63cb549 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -161,15 +161,13 @@ void ScDocument::BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bB if (bBroadcastSingleBroadcasters) { - ScHint aHint(nHint, ScAddress()); - for (SCTAB nTab = nTab1; nTab <= nTab2; ++nTab) { ScTable* pTab = FetchTable(nTab); if (!pTab) continue; - bIsBroadcasted |= pTab->BroadcastBroadcasters( nCol1, nRow1, nCol2, nRow2, aHint); + bIsBroadcasted |= pTab->BroadcastBroadcasters( nCol1, nRow1, nCol2, nRow2, nHint); } } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index c2652f3293a5..40c515b9b10b 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2074,14 +2074,13 @@ void ScTable::BroadcastRecalcOnRefMove() aCol[i].BroadcastRecalcOnRefMove(); } -bool ScTable::BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint ) +bool ScTable::BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint ) { bool bBroadcasted = false; sc::AutoCalcSwitch aSwitch(rDocument, false); - rHint.GetAddress().SetTab(nTab); nCol2 = ClampToAllocatedColumns(nCol2); for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) - bBroadcasted |= aCol[nCol].BroadcastBroadcasters( nRow1, nRow2, rHint); + bBroadcasted |= aCol[nCol].BroadcastBroadcasters( nRow1, nRow2, nHint); return bBroadcasted; } diff --git a/sc/source/core/tool/brdcst.cxx b/sc/source/core/tool/brdcst.cxx deleted file mode 100644 index bf852b36335e..000000000000 --- a/sc/source/core/tool/brdcst.cxx +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <brdcst.hxx> - -ScHint::ScHint( SfxHintId n, const ScAddress& a ) : - SfxHint(n), aAddress(a) {} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk index b81660089ea0..4e388ca0d471 100644 --- a/svl/Library_svl.mk +++ b/svl/Library_svl.mk @@ -168,7 +168,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\ svl/source/misc/urihelper \ svl/source/notify/SfxBroadcaster \ svl/source/notify/broadcast \ - svl/source/notify/hint \ svl/source/notify/isethint \ svl/source/notify/listener \ svl/source/notify/lstner \ diff --git a/svl/source/notify/hint.cxx b/svl/source/notify/hint.cxx deleted file mode 100644 index 72cac43ef9a9..000000000000 --- a/svl/source/notify/hint.cxx +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <svl/hint.hxx> - -// virtual dtor for the typical base-class Hint - -SfxHint::~SfxHint() COVERITY_NOEXCEPT_FALSE {} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 47198583da8e67e0178466205d82835c391c8d73 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Sun Dec 5 19:31:43 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Dec 6 22:18:59 2021 +0100 try to broadcast in bulk (tdf#119083) This somewhat improves the situation, but still a lot of time is spent repeatedly making the same cells dirty. Change-Id: I3444ca6dac4b3a40c6ac40a0b70cf5baeefa2f09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126391 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126426 diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 3b148dda6b88..955f788c24e9 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -43,6 +43,7 @@ #include <formulagroup.hxx> #include <drwlayer.hxx> #include <mtvelements.hxx> +#include <bcaslot.hxx> #include <svl/numformat.hxx> #include <svl/poolcach.hxx> @@ -3377,6 +3378,7 @@ void ScColumn::SetDirtyIfPostponed() { sc::AutoCalcSwitch aSwitch(GetDoc(), false); SetDirtyIfPostponedHandler aFunc; + ScBulkBroadcast aBulkBroadcast( GetDoc().GetBASM(), SfxHintId::ScDataChanged); sc::ProcessFormula(maCells, aFunc); } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 681d77e45c7c..9d2770522018 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1552,7 +1552,10 @@ bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab, // At least all cells using range names pointing relative to the // moved range must be recalculated, and all cells marked postponed // dirty. - std::for_each(maTabs.begin(), maTabs.end(), SetDirtyIfPostponedHandler()); + { + ScBulkBroadcast aBulkBroadcast(GetBASM(), SfxHintId::ScDataChanged); + std::for_each(maTabs.begin(), maTabs.end(), SetDirtyIfPostponedHandler()); + } // Cells containing functions such as CELL, COLUMN or ROW may have // changed their values on relocation. Broadcast them. { @@ -1590,6 +1593,7 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA } sc::AutoCalcSwitch aACSwitch(*this, false); // avoid multiple calculations + ScBulkBroadcast aBulkBroadcast(GetBASM(), SfxHintId::ScDataChanged); // handle chunks of consecutive selected sheets together SCTAB nTabRangeStart = nStartTab; @@ -2098,6 +2102,7 @@ void ScDocument::CopyToDocument(const ScRange& rRange, rDestDoc.aDocName = aDocName; sc::AutoCalcSwitch aACSwitch(rDestDoc, false); // avoid multiple calculations + ScBulkBroadcast aBulkBroadcast(rDestDoc.GetBASM(), SfxHintId::ScDataChanged); sc::CopyToDocContext aCxt(rDestDoc); aCxt.setStartListening(false); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 46dab0217c27..c2652f3293a5 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2061,11 +2061,10 @@ void ScTable::SetDirtyAfterLoad() void ScTable::SetDirtyIfPostponed() { - bool bOldAutoCalc = rDocument.GetAutoCalc(); - rDocument.SetAutoCalc( false ); // avoid multiple recalculations + sc::AutoCalcSwitch aSwitch(rDocument, false); + ScBulkBroadcast aBulkBroadcast( rDocument.GetBASM(), SfxHintId::ScDataChanged); for (SCCOL i=0; i < aCol.size(); i++) aCol[i].SetDirtyIfPostponed(); - rDocument.SetAutoCalc( bOldAutoCalc ); } void ScTable::BroadcastRecalcOnRefMove()