Skip to content

Commit

Permalink
tell client when the cell for the comment changed
Browse files Browse the repository at this point in the history
when a row/column is inserted/deleted, etc the cell the comments are
associated with changes, so broadcast that change to the clients.

CollaboraOnline/online#7334

Change-Id: I8a3e5fc151b6ba99e68b32c3fe8804de9ba2baf4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158720
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
  • Loading branch information
caolanm committed Oct 31, 2023
1 parent bfeb637 commit c15c1d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sc/inc/column.hxx
Expand Up @@ -714,7 +714,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 );
Expand Down
28 changes: 22 additions & 6 deletions sc/source/core/data/column.cxx
Expand Up @@ -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>
Expand Down Expand Up @@ -1808,22 +1809,37 @@ void resetColumnPosition(sc::CellStoreType& rCells, SCCOL nCol)

class NoteCaptionUpdater
{
SCCOL mnCol;
SCTAB mnTab;
const ScDocument& m_rDocument;
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& rDocument, const ScAddress& rPos, bool bAddressChanged)
: m_rDocument(rDocument)
, 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_rDocument, 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);
}

Expand Down
2 changes: 1 addition & 1 deletion sc/source/core/data/table2.cxx
Expand Up @@ -1491,7 +1491,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 */);
}
}

Expand Down

0 comments on commit c15c1d8

Please sign in to comment.