office-gobmx/sc/inc/grouparealistener.hxx
Luboš Luňák 8406139062 process broadcasts for adjacent cells together (tdf#119083)
The problem in tdf#119083 is that it sets up listening for the range
of cells used by VLOOKUP, and when adding a new column changes all
those cells, it results in repeated SfxHintId::ScDataChanged
broadcasts to the cells with the VLOOKUP formula. This commit
makes ScHint include a row count, making it possible to group
adjacent rows for SfxHintId::ScDataChanged together and send
notifications just once for the range.

Change-Id: Ib3439de58a2b1e5e8f01b037a62608e38b8e9125
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126395
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2021-12-06 15:45:35 +01:00

71 lines
2.2 KiB
C++

/* -*- 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/.
*/
#pragma once
#include "address.hxx"
#include <svl/listener.hxx>
#include <vector>
class ScFormulaCell;
class ScDocument;
class ScColumn;
namespace sc {
class BulkDataHint;
class FormulaGroupAreaListener final : public SvtListener
{
ScRange maRange;
const ScDocument& mrDocument;
const ScColumn* mpColumn;
SCROW mnTopCellRow;
SCROW mnGroupLen;
bool mbStartFixed;
bool mbEndFixed;
public:
FormulaGroupAreaListener() = delete;
FormulaGroupAreaListener( const ScRange& rRange, const ScDocument& rDocument,
const ScAddress& rTopCellPos, SCROW nGroupLen, bool bStartFixed, bool bEndFixed );
virtual ~FormulaGroupAreaListener() override;
ScRange getListeningRange() const;
virtual void Notify( const SfxHint& rHint ) override;
virtual void Query( QueryBase& rQuery ) const override;
/**
* Given the row span of changed cells within a single column, collect all
* formula cells that need to be notified of the change.
*
* @param nTab sheet position of the changed cell span.
* @param nCol column position of the changed cell span.
* @param nRow1 top row position of the changed cell span.
* @param nRow2 bottom row position of the changed cell span.
* @param rCells all formula cells that need to be notified are put into
* this container.
*/
void collectFormulaCells( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, std::vector<ScFormulaCell*>& rCells ) const;
void collectFormulaCells( SCROW nRow1, SCROW nRow2, std::vector<ScFormulaCell*>& rCells ) const;
private:
void notifyCellChange( const SfxHint& rHint, const ScAddress& rPos, SCROW nNumRows );
void notifyBulkChange( const BulkDataHint& rHint );
const ScFormulaCell* getTopCell() const;
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */