summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-31 11:33:56 +0000
committerMichael Meeks <michael.meeks@collabora.com>2023-10-31 19:08:23 +0100
commit981061e0870ac7d963d496a51238fe1f4d5d2b7c (patch)
treea23c457792748747ce1af36900f4f76128841d1d /sc
parentf183050bb13de924ab008d68cdcb0b1a4bf24a8b (diff)
tell client when the cell for the comment changed
when a row/column is inserted/deleted, etc the cell the comments are associated with changes, so broadcast that change to the clients. https://github.com/CollaboraOnline/online/issues/7334 Change-Id: I8a3e5fc151b6ba99e68b32c3fe8804de9ba2baf4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158718 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/column.hxx2
-rw-r--r--sc/source/core/data/column.cxx28
-rw-r--r--sc/source/core/data/table2.cxx2
3 files changed, 24 insertions, 8 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 87d3dc730a9f..cbdf82edecbc 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -712,7 +712,7 @@ public:
void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
sc::ColumnBlockPosition& rDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest = 0) const;
- void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 );
+ void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged = true );
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/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d2506074070b..45a307931347 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -20,6 +20,7 @@
#include <column.hxx>
#include <scitems.hxx>
#include <formulacell.hxx>
+#include <docsh.hxx>
#include <document.hxx>
#include <table.hxx>
#include <docpool.hxx>
@@ -1810,22 +1811,37 @@ void resetColumnPosition(sc::CellStoreType& rCells, SCCOL nCol)
class NoteCaptionUpdater
{
- SCCOL mnCol;
- SCTAB mnTab;
+ const ScDocument* m_pDocument;
+ const ScAddress m_aAddress; // 'incomplete' address consisting of tab, column
+ bool m_bAddressChanged; // false if the cell anchor address is unchanged
public:
- NoteCaptionUpdater( SCCOL nCol, SCTAB nTab ) : mnCol(nCol), mnTab(nTab) {}
+ NoteCaptionUpdater(const ScDocument* pDocument, const ScAddress& rPos, bool bAddressChanged)
+ : m_pDocument(pDocument)
+ , m_aAddress(rPos)
+ , m_bAddressChanged(bAddressChanged)
+ {
+ }
void operator() ( size_t nRow, ScPostIt* p )
{
- p->UpdateCaptionPos(ScAddress(mnCol,nRow,mnTab));
+ // Create a 'complete' address object
+ ScAddress aAddr(m_aAddress);
+ aAddr.SetRow(nRow);
+
+ p->UpdateCaptionPos(aAddr);
+
+ // Notify our LOK clients
+ if (m_bAddressChanged)
+ ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Modify, m_pDocument, aAddr, p);
}
};
}
-void ScColumn::UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 )
+void ScColumn::UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged )
{
- NoteCaptionUpdater aFunc(nCol, nTab);
+ ScAddress aAddr(nCol, 0, nTab);
+ NoteCaptionUpdater aFunc(&GetDoc(), aAddr, bAddressChanged);
sc::ProcessNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 53ba083929c4..21c33b222825 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1496,7 +1496,7 @@ void ScTable::CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW
for (SCCOL i = nCol1; i <= nCol2; i++)
{
aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->CreateColumnIfNotExists(i), bCloneCaption);
- pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2);
+ pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2, false /* address unchanged from initial create */);
}
}