sc/inc/column.hxx | 1 + sc/inc/table.hxx | 1 + sc/source/core/data/column.cxx | 16 +++++++++++++--- sc/source/core/data/document.cxx | 10 ++++++++++ sc/source/core/data/table2.cxx | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-)
New commits: commit f0bf0a459718a910928d92fbf60eea7f2e0fc88e Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Nov 29 20:45:33 2023 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Nov 30 10:52:44 2023 +0100 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/+/160130 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 7a2bbc30ade9..c9546012ac34 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -715,6 +715,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 4f7407809115..0384def511fb 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -508,6 +508,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 45a307931347..716665a7cb8b 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1813,11 +1813,13 @@ class NoteCaptionUpdater { const ScDocument* m_pDocument; 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* pDocument, const ScAddress& rPos, bool bAddressChanged) + NoteCaptionUpdater(const ScDocument* pDocument, const ScAddress& rPos, bool bUpdateCaptionPos, bool bAddressChanged) : m_pDocument(pDocument) , m_aAddress(rPos) + , m_bUpdateCaptionPos(bUpdateCaptionPos) , m_bAddressChanged(bAddressChanged) { } @@ -1828,7 +1830,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) @@ -1841,7 +1844,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 fceaec1bb386..e07dcf146640 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1328,8 +1328,13 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, SetNeedsListeningGroups(aGroupPos); for (i=nStartTab; i<=nEndTab && i < static_cast<SCTAB>(maTabs.size()); 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. @@ -1449,8 +1454,13 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab, std::vector<ScAddress> aGroupPos; for ( i = nStartTab; i <= nEndTab && i < static_cast<SCTAB>(maTabs.size()); 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 21c33b222825..2374813dcb89 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1946,6 +1946,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)