[Libreoffice-commits] core.git: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Mar 17 23:00:39 UTC 2019
sc/inc/column.hxx | 2 -
sc/source/core/data/column3.cxx | 49 +++++++++++++++++++++++++++++++++-------
2 files changed, 42 insertions(+), 9 deletions(-)
New commits:
commit de024e572dd7a588f82b84c68daa2051ec6b20e9
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Sun Mar 17 19:55:20 2019 +0100
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Mon Mar 18 00:00:18 2019 +0100
Listening when grouping in ScColumn::AttachNewFormulaCells(), (tdf#123736)
Not directly related to tdf#123736 but similar approach.
Setting a vector with ScColumn::SetFormulaCells() is currently
only done for Undo documents, but implementation provided
listening as only single cell listening for not-undo/clip
documents, which wouldn't work if actually used in grouping
context. The upcoming unit tests will use SetFormulaCells() for
checks.
Change-Id: I990e6a5d6e1efcf70a2661b3a9a39c37d9e4c2e6
Reviewed-on: https://gerrit.libreoffice.org/69371
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index da635280c71d..b8b4db6b76d6 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -717,7 +717,7 @@ private:
bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
void AttachNewFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength,
- const std::vector<SCROW>& rNewSharedRows );
+ std::vector<SCROW>& rNewSharedRows );
void BroadcastNewCell( SCROW nRow );
bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellStoreType::iterator& itr );
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index fe78809a829a..d46bf4630576 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -625,7 +625,7 @@ void ScColumn::AttachNewFormulaCell(
}
void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength,
- const std::vector<SCROW>& rNewSharedRows )
+ std::vector<SCROW>& rNewSharedRows )
{
// Make sure the whole length consists of formula cells.
if (aPos.first->type != sc::element_type_formula)
@@ -636,17 +636,50 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP
return;
// Join the top and bottom cells only.
- ScFormulaCell* pCell = sc::formula_block::at(*aPos.first->data, aPos.second);
- JoinNewFormulaCell(aPos, *pCell);
+ ScFormulaCell* pCell1 = sc::formula_block::at(*aPos.first->data, aPos.second);
+ JoinNewFormulaCell(aPos, *pCell1);
sc::CellStoreType::position_type aPosLast = aPos;
aPosLast.second += nLength - 1;
- pCell = sc::formula_block::at(*aPosLast.first->data, aPosLast.second);
- JoinNewFormulaCell(aPosLast, *pCell);
+ ScFormulaCell* pCell2 = sc::formula_block::at(*aPosLast.first->data, aPosLast.second);
+ JoinNewFormulaCell(aPosLast, *pCell2);
ScDocument* pDocument = GetDoc();
if (!pDocument->IsClipOrUndo() && !pDocument->IsInsertingFromOtherDoc())
{
+ const bool bShared = pCell1->IsShared() || pCell2->IsShared();
+ if (bShared)
+ {
+ const SCROW nTopRow = (pCell1->IsShared() ? pCell1->GetSharedTopRow() : pCell1->aPos.Row());
+ const SCROW nBotRow = (pCell2->IsShared() ?
+ pCell2->GetSharedTopRow() + pCell2->GetSharedLength() - 1 : pCell2->aPos.Row());
+ if (rNewSharedRows.empty())
+ {
+ rNewSharedRows.push_back( nTopRow);
+ rNewSharedRows.push_back( nBotRow);
+ }
+ else if (rNewSharedRows.size() == 2)
+ {
+ // Combine into one span.
+ if (rNewSharedRows[0] > nTopRow)
+ rNewSharedRows[0] = nTopRow;
+ if (rNewSharedRows[1] < nBotRow)
+ rNewSharedRows[1] = nBotRow;
+ }
+ else if (rNewSharedRows.size() == 4)
+ {
+ // Merge into one span.
+ // The original two spans are ordered from top to bottom.
+ std::vector<SCROW> aRows(2);
+ aRows[0] = std::min( rNewSharedRows[0], nTopRow);
+ aRows[1] = std::max( rNewSharedRows[3], nBotRow);
+ rNewSharedRows.swap( aRows);
+ }
+ else
+ {
+ assert(!"rNewSharedRows?");
+ }
+ }
StartListeningUnshared( rNewSharedRows);
sc::StartListeningContext aCxt(*pDocument);
@@ -654,10 +687,10 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP
ScFormulaCell** ppEnd = pp + nLength;
for (; pp != ppEnd; ++pp)
{
- pCell = *pp;
- pCell->StartListeningTo(aCxt);
+ if (!bShared)
+ (*pp)->StartListeningTo(aCxt);
if (!pDocument->IsCalcingAfterLoad())
- pCell->SetDirty();
+ (*pp)->SetDirty();
}
}
}
More information about the Libreoffice-commits
mailing list