Files
odfstudio/sc/source/ui/operation/SetNoteTextOperation.cxx
T
Tomaž Vajngerl b0273b521e sc: Add sheet view sync support and test for SetNoteTextOperation
Added sync support to SetNoteTextOperation and written a
test case for this.

Change-Id: Iad97d05a1957f7b0468d535d32513bdf4aaac40e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201334
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202090
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 4acc310f083705a0bf8c95d97f6d9b1079f8e0c9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205437
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-05-22 11:50:40 +02:00

66 lines
1.7 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <operation/SetNoteTextOperation.hxx>
#include <docsh.hxx>
#include <editable.hxx>
#include <postit.hxx>
#include <osl/endian.h>
#include <tools/lineend.hxx>
namespace sc
{
SetNoteTextOperation::SetNoteTextOperation(ScDocShell& rDocShell, const ScAddress& rPos,
const OUString& rText, bool bApi)
: Operation(OperationType::SetNoteText, false, bApi)
, mrDocShell(rDocShell)
, maPos(rPos)
, maText(rText)
{
}
bool SetNoteTextOperation::runImplementation()
{
ScDocShellModificator aModificator(mrDocShell);
ScDocument& rDoc = mrDocShell.GetDocument();
ScAddress aPos = convertAddress(maPos);
ScEditableTester aTester = ScEditableTester::CreateAndTestBlock(
rDoc, aPos.Tab(), aPos.Col(), aPos.Row(), aPos.Col(), aPos.Row());
if (!aTester.IsEditable())
{
if (!mbApi)
mrDocShell.ErrorMessage(aTester.GetMessageId());
return false;
}
OUString aNewText = convertLineEnd(maText, GetSystemLineEnd()); //! is this necessary ???
if (ScPostIt* pNote = (!aNewText.isEmpty()) ? rDoc.GetOrCreateNote(aPos) : rDoc.GetNote(aPos))
pNote->SetText(aPos, aNewText);
//! Undo !!!
rDoc.SetStreamValid(aPos.Tab(), false);
syncSheetViews();
mrDocShell.PostPaintCell(aPos);
aModificator.SetDocumentModified();
return true;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */