// Editing of Note-Key-Objects has to be stopped always via StopEditMode, // so that changes are taken over into the document! // (Fontwork-Execute in drawsh and drtxtob does not happen for Key-Objects)
// relock the internal layer that has been unlocked in FuText::SetInEditMode() if ( pObject->GetLayer() == SC_LAYER_INTERN )
pView->LockInternalLayer();
ScDocShell& rDocShell = rViewData.GetDocShell();
SfxUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? rDocShell.GetUndoManager() : nullptr; if (pUndoMgr && !pUndoMgr->GetMaxUndoActionCount()) // tdf#134308 if max undo is 0, treat as if no undo
pUndoMgr = nullptr; bool bNewNote = false; if( pNote && pUndoMgr )
{ /* Put all undo actions already collected (e.g. create caption object)
and all following undo actions (text changed) together into a ListAction. */
std::unique_ptr<SdrUndoGroup> pCalcUndo = pDrawLayer->GetCalcUndo();
/* Note has been created before editing, if first undo action is aninsertaction.Neededbelowtodecidewhethertodropthe
undo if editing a new note has been cancelled. */
bNewNote = (pCalcUndo->GetActionCount() > 0) && dynamic_cast< SdrUndoNewObj* >(pCalcUndo->GetAction( 0 ));
if( pNote )
rDoc.LockStreamValid(true); // only the affected sheet is invalidated below
/* Unset the outliner undo manager before the call to SdrEndTextEdit. SdrObjEditView::SdrEndTextEditdestroysit,butthenScDrawView::SdrEndTextEdit
initiates some UI update which might try to access the now invalid pointer. */
rViewShell.SetDrawTextUndo( nullptr );
/* SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing object,ifitdoesnotcontaintextandhasinvisibleborderandfill. Thismustnothappenfornotecaptionobjects.Theywillberemoved belowtogetherwiththecellnoteifthetextisempty(independentof borderandareaformatting).Itispossibletopreventautomatic deletionbypassingsal_Truetothisfunction.Thereturnvaluechanges fromSdrEndTextEditKind::DeletedtoSdrEndTextEditKind::ShouldBeDeletedinthis
case. */ /*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != nullptr );
// hide the caption object if it is in hidden state
pNote->ShowCaptionTemp( aNotePos, false );
// update author and date
pNote->AutoStamp();
/* If the entire text has been cleared, the cell note and its caption
object have to be removed. */
SdrTextObj* pTextObject = DynCastSdrTextObj( pObject ); bool bDeleteNote = !pTextObject || !pTextObject->HasText(); if( bDeleteNote )
{ if( pUndoMgr )
{ // collect the "remove object" drawing undo action created by DeleteNote()
pDrawLayer->BeginCalcUndo(false); // rescue note data before deletion
ScNoteData aNoteData( pNote->GetNoteData() ); // delete note from document (removes caption, but does not delete it)
rDoc.ReleaseNote(aNotePos); // create undo action for removed note
pUndoMgr->AddUndoAction( std::make_unique<ScUndoReplaceNote>( rDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
} else
{
rDoc.ReleaseNote(aNotePos);
} // ScDocument::DeleteNote has deleted the note that pNote points to
pNote = nullptr;
}
// finalize the undo list action if( pUndoMgr )
{
pUndoMgr->LeaveListAction();
/* #i94039# Update the default name "Edit Note" of the undo action ifthenotehasbeencreatedbeforeeditingorisdeleteddue todeletedtext.Ifthenotehasbeencreated*and*isdeleted, thelastundoactioncanberemovedcompletely.Note:The functionLeaveListAction()removesthelastactionbyitself,
if it is empty (when result is SdrEndTextEditKind::Unchanged). */ if( bNewNote && bDeleteNote )
{
pUndoMgr->RemoveLastUndoAction();
// Make sure the former area of the note anchor is invalidated.
ScRangeList aRangeList((ScRange(aNotePos)));
ScMarkData aMarkData(rDoc.GetSheetLimits(), aRangeList);
rViewShell.UpdateSelectionArea(aMarkData);
} elseif( bNewNote || bDeleteNote )
{
SfxListUndoAction* pAction = dynamic_cast< SfxListUndoAction* >( pUndoMgr->GetUndoAction() );
OSL_ENSURE( pAction, "FuText::StopEditMode - list undo action expected" ); if( pAction )
pAction->SetComment( ScResId( bNewNote ? STR_UNDO_INSERTNOTE : STR_UNDO_DELETENOTE ) );
}
}
// invalidate stream positions only for the affected sheet
rDoc.LockStreamValid(false);
rDoc.SetStreamValid(aNotePos.Tab(), false);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.