diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-29 20:45:33 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-30 11:38:39 +0100 |
commit | d9e9caf2ea2a42c09623d69c858921462aeac00e (patch) | |
tree | 0e70b112649f9a587e03dcef388f444cdd164081 | |
parent | baf36dc7caa10365f3dda87bc2dd6e85e0333e98 (diff) |
No kit notification of note position changes on insert/delete row
while there is for insert/delete col.
Inserting/Deleting a column will explicitly update comments as part of a
bulk operation and block the drawing layer from updating any existing
captions before that. A side-effect of this is that the note captions
are generated for all comments in the moved cols when this happens.
While with a row the drawing layer is allowed update existing caption
positions and doesn't generate any new captions.
Presumably there's a missed optimization for insert/delete cols to
not generate extra captions that didn't exist before the change, but
leave that aside for now and add a UpdateNoteCaptions that just
notifies of note position changes when rows are inserted/deleted and
continue to piggy back on the note caption update for insert/delete
cols.
Change-Id: I4d76d15aee1de9ea5553e90b2051354bce02b1db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160138
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | sc/inc/column.hxx | 1 | ||||
-rw-r--r-- | sc/inc/table.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 15 |
5 files changed, 40 insertions, 3 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index cefd03fd388e..27db1391472e 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -717,6 +717,7 @@ public: sc::ColumnBlockPosition& rDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest = 0) const; void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged = true ); + void CommentNotifyAddressChange( SCROW nRow1, SCROW nRow2 ); void UpdateDrawObjects( std::vector<std::vector<SdrObject*>>& pObjects, SCROW nRowStart, SCROW nRowEnd ); void UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL nTargetCol, SCROW nTargetRow ); diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 8907bde5a150..e81639ff6a53 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -522,6 +522,7 @@ public: SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const; void CreateAllNoteCaptions(); void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData ); + void CommentNotifyAddressChange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const; void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const; diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index c448f79ae996..26fbd5cbfa5c 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1811,11 +1811,13 @@ class NoteCaptionUpdater { const ScDocument& m_rDocument; const ScAddress m_aAddress; // 'incomplete' address consisting of tab, column + bool m_bUpdateCaptionPos; // false if we want to skip updating the caption pos, only useful in kit mode bool m_bAddressChanged; // false if the cell anchor address is unchanged public: - NoteCaptionUpdater(const ScDocument& rDocument, const ScAddress& rPos, bool bAddressChanged) + NoteCaptionUpdater(const ScDocument& rDocument, const ScAddress& rPos, bool bUpdateCaptionPos, bool bAddressChanged) : m_rDocument(rDocument) , m_aAddress(rPos) + , m_bUpdateCaptionPos(bUpdateCaptionPos) , m_bAddressChanged(bAddressChanged) { } @@ -1826,7 +1828,8 @@ public: ScAddress aAddr(m_aAddress); aAddr.SetRow(nRow); - p->UpdateCaptionPos(aAddr); + if (m_bUpdateCaptionPos) + p->UpdateCaptionPos(aAddr); // Notify our LOK clients if (m_bAddressChanged) @@ -1839,7 +1842,14 @@ public: void ScColumn::UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged ) { ScAddress aAddr(nCol, 0, nTab); - NoteCaptionUpdater aFunc(GetDoc(), aAddr, bAddressChanged); + NoteCaptionUpdater aFunc(GetDoc(), aAddr, true, bAddressChanged); + sc::ProcessNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc); +} + +void ScColumn::CommentNotifyAddressChange( SCROW nRow1, SCROW nRow2 ) +{ + ScAddress aAddr(nCol, 0, nTab); + NoteCaptionUpdater aFunc(GetDoc(), aAddr, false, true); sc::ProcessNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc); } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 0b4ae5ca0da8..1d253db1537a 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1304,8 +1304,13 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, SetNeedsListeningGroups(aGroupPos); for (i=nStartTab; i<=nEndTab && i < GetTableCount(); i++) + { if (maTabs[i] && (!pTabMark || pTabMark->GetTableSelect(i))) + { maTabs[i]->InsertRow( nStartCol, nEndCol, nStartRow, nSize ); + maTabs[i]->CommentNotifyAddressChange(nStartCol, nStartRow, nEndCol, MaxRow()); + } + } // UpdateRef for drawing layer must be after inserting, // when the new row heights are known. @@ -1425,8 +1430,13 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab, std::vector<ScAddress> aGroupPos; for ( i = nStartTab; i <= nEndTab && i < GetTableCount(); i++) + { if (maTabs[i] && (!pTabMark || pTabMark->GetTableSelect(i))) + { maTabs[i]->DeleteRow(aCxt.maRegroupCols, nStartCol, nEndCol, nStartRow, nSize, pUndoOutline, &aGroupPos); + maTabs[i]->CommentNotifyAddressChange(nStartCol, nStartRow, nEndCol, MaxRow()); + } + } // Newly joined groups have some of their members still listening. We // need to make sure none of them are listening. diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index d6c1eead2c48..52234b29b232 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1941,6 +1941,21 @@ void ScTable::ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n aCol[i].ForgetNoteCaptions(nRow1, nRow2, bPreserveData); } +void ScTable::CommentNotifyAddressChange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) +{ + // Only in use in kit mode for now, but looks to me a good idea to revisit why (since OOo times) + // on deleting/inserting a column that we generate all the captions, while on deleting/inserting + // a row we do not. Presumably we should skip generating captions if we don't have to. + if (!comphelper::LibreOfficeKit::isActive()) + return; + + if (!ValidCol(nCol1) || !ValidCol(nCol2)) + return; + if ( nCol2 >= aCol.size() ) nCol2 = aCol.size() - 1; + for (SCCOL i = nCol1; i <= nCol2; ++i) + aCol[i].CommentNotifyAddressChange(nRow1, nRow2); +} + void ScTable::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const { for (SCCOL nCol = 0; nCol < aCol.size(); ++nCol) |