Grow or shrink a matrix formula's declared dimensions to match its interpreted result size. With this, clearing a blocker lets the array spill across its full range; shrinking the source data removes the stale trailing cells. Blocking an already-expanded array collapses it back to the origin with #SPILL!. Deferred resize queue: inserting or deleting cells inline from Interpret (or during grid-repaint iteration) would invalidate the caller's iterator. Queue resizes in the document and drain them from safe points, guarded by a MatrixResizeGuard helper around each cell-iteration scope. Change-Id: I74376427e707fd84c36034fe6a64105e4a5f74fa Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1817 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 76b6825e4d237869cb32889b250277be693a2c5f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205686 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
49 lines
1.2 KiB
C++
49 lines
1.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 "document.hxx"
|
|
|
|
namespace sc
|
|
{
|
|
/**
|
|
* Pushes a matrix-resize guard for the lifetime of this object, then drains
|
|
* any pending resizes queued during the guarded iteration when we go out of
|
|
* scope.
|
|
*
|
|
* Use at every scope that iterates the cell store while Interpret() may
|
|
* run on visited cells.
|
|
*/
|
|
class MatrixResizeGuard
|
|
{
|
|
ScDocument& mrDoc;
|
|
|
|
public:
|
|
explicit MatrixResizeGuard(ScDocument& rDoc)
|
|
: mrDoc(rDoc)
|
|
{
|
|
mrDoc.PushMatrixResizeGuard();
|
|
}
|
|
|
|
~MatrixResizeGuard()
|
|
{
|
|
mrDoc.PopMatrixResizeGuard();
|
|
if (mrDoc.HasPendingMatrixResizes() && !mrDoc.IsMatrixResizeGuarded())
|
|
mrDoc.ProcessPendingMatrixResizes();
|
|
}
|
|
|
|
MatrixResizeGuard(const MatrixResizeGuard&) = delete;
|
|
MatrixResizeGuard& operator=(const MatrixResizeGuard&) = delete;
|
|
};
|
|
|
|
} // namespace sc
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|