23#include <osl/diagnose.h>
29#include <document.hxx>
35#include <drawview.hxx>
54 OSL_ENSURE( pDrawLayer && (pDrawLayer ==
pDrDoc),
"FuText::StopEditMode - missing or different drawing layers" );
60 aNotePos = pCaptData->maStart;
61 pNote = rDoc.
GetNote( aNotePos );
62 OSL_ENSURE( pNote && (pNote->
GetCaption() ==
pObject),
"FuText::StopEditMode - missing or invalid cell note" );
69 bool bNewNote =
false;
70 if( pNote && pUndoMgr )
74 std::unique_ptr<SdrUndoGroup> pCalcUndo = pDrawLayer->
GetCalcUndo();
78 const OUString aUndoStr =
ScResId( STR_UNDO_EDITNOTE );
84 bNewNote = (pCalcUndo->GetActionCount() > 0) &&
dynamic_cast< SdrUndoNewObj*
>(pCalcUndo->GetAction( 0 ));
88 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoReplaceNote>( *pDocShell, aNotePos, pNote->
GetNoteData(),
true, std::move(pCalcUndo) ) );
130 bool bDeleteNote = !pTextObject || !pTextObject->
HasText();
142 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoReplaceNote>( *pDocShell, aNotePos, aNoteData,
false, pDrawLayer->
GetCalcUndo() ) );
163 if( bNewNote && bDeleteNote )
172 else if( bNewNote || bDeleteNote )
175 OSL_ENSURE( pAction,
"FuText::StopEditMode - list undo action expected" );
177 pAction->
SetComment(
ScResId( bNewNote ? STR_UNDO_INSERTNOTE : STR_UNDO_DELETENOTE ) );
ScTabViewShell & rViewShell
VclPtr< vcl::Window > pWindow
virtual SfxUndoManager * GetUndoManager() override
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
SC_DLLPUBLIC std::unique_ptr< ScPostIt > ReleaseNote(const ScAddress &rPos)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
void LockStreamValid(bool bLock)
bool IsUndoEnabled() const
void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager)
std::unique_ptr< SdrUndoGroup > GetCalcUndo()
static ScDrawObjData * GetNoteCaptionData(SdrObject *pObj, SCTAB nTab)
Returns the object data, if the passed object is a cell note caption.
void LockInternalLayer(bool bLock=true)
Locks/unlocks the internal layer that contains caption objects of cell notes.
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Additional class containing cell annotation data.
const ScNoteData & GetNoteData() const
Returns the data struct containing all note settings.
void ShowCaptionTemp(const ScAddress &rPos, bool bShow=true)
Shows or hides the caption temporarily (does not change internal visibility state).
void AutoStamp()
Sets date and author from system settings.
SdrCaptionObj * GetCaption() const
Returns an existing note caption object.
void SetDrawTextUndo(SfxUndoManager *pUndoMgr)
static void OnLOKNoteStateChanged(const ScPostIt *pNote)
ScViewData & GetViewData()
ScDocument & GetDocument() const
ScDocShell * GetDocShell() const
void UpdateSelectionArea(const ScMarkData &rSel, ScPatternAttr *pAttr=nullptr)
SdrTextObj * GetTextEditObject() const
virtual bool HasText() const override
void SetComment(const OUString &rComment)
size_t GetMaxUndoActionCount() const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
void RemoveLastUndoAction()
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SfxUndoAction * GetUndoAction(size_t nNo=0) const
ViewShellId GetViewShellId() const override
EmbeddedObjectRef * pObject
constexpr SdrLayerID SC_LAYER_INTERN(2)
OUString ScResId(TranslateId aId)
Internal data for a cell annotation.
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)