24#include <osl/diagnose.h>
27#include <document.hxx>
43#include <progress.hxx>
53#include <LibreOfficeKit/LibreOfficeKitEnums.h>
61using ::std::unique_ptr;
70 sNewName(
std::move( aNewName )),
86 return ScResId( STR_UNDO_APPEND_TAB );
88 return ScResId( STR_UNDO_INSERT_TAB );
150 pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
151 Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD);
161 std::vector<OUString>&& newNameList) :
163 aNameList(
std::move(newNameList) ),
178 return ScResId( STR_UNDO_INSERT_TAB );
244 pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
245 Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD);
268 return ScResId( STR_UNDO_DELETE_TAB );
295 while ( nTab > 0 && !rDoc.
IsVisible( nTab ) )
337 pRefUndoDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
339 bool bActive =
pRefUndoDoc->IsActiveScenario( nTab );
344 auto pSheetEvents =
pRefUndoDoc->GetSheetEvents( nTab );
368 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScTablesChanged ) );
369 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScAreasChanged ) );
370 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScDbAreasChanged ) );
371 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScAreaLinksChanged ) );
416 const OUString& rOldName,
417 const OUString& rNewName) :
431 return ScResId( STR_UNDO_RENAME_TAB );
473 ScDocShell* pNewDocShell, std::unique_ptr<vector<SCTAB>> pOldTabs, std::unique_ptr<vector<SCTAB>> pNewTabs,
474 std::unique_ptr<vector<OUString>> pOldNames, std::unique_ptr<vector<OUString>> pNewNames) :
476 mpOldTabs(
std::move(pOldTabs)), mpNewTabs(
std::move(pNewTabs)),
477 mpOldNames(
std::move(pOldNames)), mpNewNames(
std::move(pNewNames))
491 return ScResId( STR_UNDO_MOVE_TAB );
506 SCTAB nDestTab = (*mpNewTabs)[
i-1];
507 SCTAB nOldTab = (*mpOldTabs)[
i-1];
511 rDoc.
MoveTab( nDestTab, nOldTab, &aProgress );
513 pViewShell->
SetTabNo( nOldTab,
true );
516 const OUString& rOldName = (*mpOldNames)[
i-1];
526 for (
size_t i = 0;
i <
n; ++
i)
528 SCTAB nDestTab = (*mpNewTabs)[
i];
529 SCTAB nNewTab = nDestTab;
530 SCTAB nOldTab = (*mpOldTabs)[
i];
534 rDoc.
MoveTab( nOldTab, nNewTab, &aProgress );
536 pViewShell->
SetTabNo( nDestTab,
true );
539 const OUString& rNewName = (*mpNewNames)[
i];
574 std::unique_ptr<vector<SCTAB>> pOldTabs, std::unique_ptr<vector<SCTAB>> pNewTabs,
575 std::unique_ptr<vector<OUString>> pNewNames) :
577 mpOldTabs(
std::move(pOldTabs)),
578 mpNewTabs(
std::move(pNewTabs)),
579 mpNewNames(
std::move(pNewNames))
594 return ScResId( STR_UNDO_COPY_TAB );
605 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScTablesChanged ) );
606 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScAreasChanged ) );
619 vector<SCTAB>::const_reverse_iterator itr, itrEnd =
mpNewTabs->rend();
620 for (itr =
mpNewTabs->rbegin(); itr != itrEnd; ++itr)
622 SCTAB nDestTab = *itr;
634 for (itr =
mpNewTabs->rbegin(); itr != itrEnd; ++itr)
636 SCTAB nDestTab = *itr;
654 nDestTab = (*mpNewTabs)[
i];
655 SCTAB nNewTab = nDestTab;
656 SCTAB nOldTab = (*mpOldTabs)[
i];
661 rDoc.
CopyTab( nOldTab, nNewTab );
666 SCTAB nAdjSource = nOldTab;
667 if ( nNewTab <= nOldTab )
689 const OUString& rName = (*mpNewNames)[
i];
696 pViewShell->
SetTabNo( nDestTab,
true );
726 aTabColorList(
std::move(rUndoTabColorList))
737 return ScResId(STR_UNDO_SET_MULTI_TAB_BG_COLOR);
738 return ScResId(STR_UNDO_SET_TAB_BG_COLOR);
746 for (
size_t i = 0;
i < nTabColorCount; ++
i)
780 OUString aN, OUString aC,
788 aComment(
std::move( aC )),
802 return ScResId( STR_UNDO_MAKESCENARIO );
880 return ScResId( STR_UNDO_INSERT_TAB );
923 rDoc.
GetName( nTabPos, aOldName );
924 xRedoDoc->RenameTab(nTabPos, aOldName);
929 xRedoDoc->SetScenario(nTabPos,
true);
934 xRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags);
936 xRedoDoc->SetActiveScenario(nTabPos, bActive);
961 OSL_FAIL(
"Where is my Redo Document?");
988 xRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
990 bool bActive =
xRedoDoc->IsActiveScenario(nTabPos);
996 if (
xRedoDoc->IsTabProtected(nTabPos))
1008 pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
1009 Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD);
1019 aDocName(
std::move( _aDocName )),
1027 pTabNames.reset(
new OUString[nTabCount] );
1045 "different Filter for a Document?");
1061 return ScResId( STR_UNDO_REMOVELINK );
1097 undoTabs(
std::move(newUndoTabs) ),
1135 pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
1137 SfxCallMode::SLOT | SfxCallMode::RECORD);
1150 pId =
bShow ? STR_UNDO_SHOWTABS : STR_UNDO_HIDETABS;
1154 pId =
bShow ? STR_UNDO_SHOWTAB : STR_UNDO_HIDETAB;
1162 mpProtectSettings(
std::move(pProtectSettings))
1178 pCopy->setProtected(
true);
1230 mpProtectSettings(
std::move(pProtectSettings))
1246 pCopy->setProtected(
true);
1259 pTabView->SetTabProtectionSymbol(
mnTab, bProtect);
1298 std::unique_ptr<ScPrintRangeSaver> pOld, std::unique_ptr<ScPrintRangeSaver> pNew ) :
1301 pOldRanges(
std::move(pOld) ),
1302 pNewRanges(
std::move(pNew) )
1367 return ScResId( STR_UNDO_PRINTRANGES );
1371 OUString aON, OUString aNN, OUString aOC, OUString aNC,
1375 aOldName (
std::move( aON )),
1376 aNewName (
std::move( aNN )),
1377 aOldComment (
std::move( aOC )),
1378 aNewComment (
std::move( aNC )),
1379 aOldColor ( rOCol ),
1380 aNewColor ( rNCol ),
1392 return ScResId( STR_UNDO_EDITSCENARIO );
1441 OUString aON, OUString aNN ) :
1443 aPersistName(
std::move( aPN )),
1444 aOldName (
std::move( aON )),
1445 aNewName (
std::move( aNN ))
1456 return ScResId(SCSTR_RENAMEOBJECT);
1466 for (sal_uInt16 nTab=0; nTab<
nCount; nTab++)
1469 assert(pPage &&
"Page ?");
1475 if (
pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
1485 OSL_FAIL(
"Object not found");
1556 pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
1557 Execute( FID_TAB_RTL, SfxCallMode::SLOT | SfxCallMode::RECORD);
1567 return ScResId( STR_UNDO_TAB_RTL );
SfxApplication * SfxGetpApp()
SC_DLLPUBLIC void AppendInsert(const ScRange &rRange, bool bEndOfList=false)
sal_uLong GetActionMax() const
SC_DLLPUBLIC void Undo(sal_uLong nStartAction, sal_uLong nEndAction, bool bMerge=false)
SC_DLLPUBLIC void AppendDeleteRange(const ScRange &, ScDocument *pRefDoc, SCTAB nDz, sal_uLong nRejectingInsert)
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
void SetDocumentModified()
const ScDocument & GetDocument() const
void SetInUndo(bool bSet)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
void UpdateLinks() override
SC_DLLPUBLIC bool InsertTab(SCTAB nPos, const OUString &rName, bool bExternalDocument=false, bool bUndoDeleteTab=false)
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
SC_DLLPUBLIC OUString GetLinkTab(SCTAB nTab) const
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
SC_DLLPUBLIC void SetLayoutRTL(SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling=ScObjectHandling::RecalcPosMode)
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
OUString GetLinkOpt(SCTAB nTab) const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest)
void RestorePrintRanges(const ScPrintRangeSaver &rSaver)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
SC_DLLPUBLIC bool CopyTab(SCTAB nOldPos, SCTAB nNewPos, const ScMarkData *pOnlyMarked=nullptr)
void SetSheetEvents(SCTAB nTab, std::unique_ptr< ScSheetEvents > pNew)
sal_uLong GetLinkRefreshDelay(SCTAB nTab) const
void SetLink(SCTAB nTab, ScLinkMode nMode, const OUString &rDoc, const OUString &rFilter, const OUString &rOptions, const OUString &rTabName, sal_uLong nRefreshDelay)
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
SC_DLLPUBLIC void SetDocProtection(const ScDocProtection *pProtect)
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
SC_DLLPUBLIC OUString GetLinkDoc(SCTAB nTab) const
SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection *pProtect)
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC bool DeleteTab(SCTAB nTab)
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
SC_DLLPUBLIC void SetTabBgColor(SCTAB nTab, const Color &rColor)
OUString GetLinkFlt(SCTAB nTab) const
sal_uInt64 GetCodeCount() const
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
bool MoveTab(SCTAB nOldPos, SCTAB nNewPos, ScProgress *pProgress=nullptr)
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
SC_DLLPUBLIC SCTAB GetTableCount() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
std::unique_ptr< SdrUndoAction > pDrawUndo
ScDocumentUniquePtr pRefUndoDoc
bool SetViewMarkData(const ScMarkData &rMarkData)
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
static ScTabViewShell * GetActiveViewShell()
ScViewData & GetViewData()
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
sheet protection state container
std::unique_ptr< SdrUndoAction > pDrawUndo
virtual void Undo() override
virtual void Repeat(SfxRepeatTarget &rTarget) override
ScUndoCopyTab(ScDocShell *pNewDocShell, std::unique_ptr< std::vector< SCTAB > > pOldTabs, std::unique_ptr< std::vector< SCTAB > > pNewTabs, std::unique_ptr< std::vector< OUString > > pNewNames=nullptr)
virtual ~ScUndoCopyTab() override
std::unique_ptr< ::std::vector< SCTAB > > mpOldTabs
std::unique_ptr< ::std::vector< OUString > > mpNewNames
virtual OUString GetComment() const override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Redo() override
std::unique_ptr< ::std::vector< SCTAB > > mpNewTabs
virtual OUString GetComment() const override
virtual ~ScUndoDeleteTab() override
ScUndoDeleteTab(ScDocShell *pNewDocShell, const std::vector< SCTAB > &theTabs, ScDocumentUniquePtr pUndoDocument, std::unique_ptr< ScRefUndoData > pRefData)
sal_uLong nStartChangeAction
virtual void Redo() override
virtual void Undo() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
std::vector< SCTAB > theTabs
sal_uLong nEndChangeAction
::std::unique_ptr< ScDocProtection > mpProtectSettings
virtual void Undo() override
virtual OUString GetComment() const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
ScUndoDocProtect(ScDocShell *pShell, ::std::unique_ptr< ScDocProtection > &&pProtectSettings)
void DoProtect(bool bProtect)
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual ~ScUndoDocProtect() override
virtual void Redo() override
virtual void Repeat(SfxRepeatTarget &rTarget) override
ScUndoImportTab(ScDocShell *pShell, SCTAB nNewTab, SCTAB nNewCount)
virtual void Undo() override
ScDocumentUniquePtr xRedoDoc
virtual void Redo() override
virtual ~ScUndoImportTab() override
virtual OUString GetComment() const override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
std::unique_ptr< SdrUndoAction > pDrawUndo
virtual void Undo() override
sal_uLong nEndChangeAction
virtual void Redo() override
std::unique_ptr< SdrUndoAction > pDrawUndo
virtual OUString GetComment() const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
ScUndoInsertTab(ScDocShell *pNewDocShell, SCTAB nTabNum, bool bApp, OUString aNewName)
virtual ~ScUndoInsertTab() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual ~ScUndoInsertTables() override
sal_uLong nEndChangeAction
ScUndoInsertTables(ScDocShell *pNewDocShell, SCTAB nTabNum, std::vector< OUString > &&newNameList)
std::vector< OUString > aNameList
sal_uLong nStartChangeAction
virtual void Undo() override
virtual OUString GetComment() const override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual void Redo() override
std::unique_ptr< SdrUndoAction > pDrawUndo
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual ~ScUndoLayoutRTL() override
virtual void Undo() override
virtual OUString GetComment() const override
ScUndoLayoutRTL(ScDocShell *pShell, SCTAB nNewTab, bool bNewRTL)
virtual void Redo() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual ~ScUndoMakeScenario() override
std::unique_ptr< SdrUndoAction > pDrawUndo
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual void Redo() override
ScUndoMakeScenario(ScDocShell *pNewDocShell, SCTAB nSrc, SCTAB nDest, OUString aN, OUString aC, const Color &rCol, ScScenarioFlags nF, const ScMarkData &rMark)
virtual OUString GetComment() const override
std::unique_ptr< ScMarkData > mpMarkData
virtual void Undo() override
virtual void Undo() override
std::unique_ptr< ::std::vector< SCTAB > > mpNewTabs
ScUndoMoveTab(ScDocShell *pNewDocShell, std::unique_ptr< std::vector< SCTAB > > pOldTabs, std::unique_ptr< std::vector< SCTAB > > pNewTabs, std::unique_ptr< std::vector< OUString > > pOldNames=nullptr, std::unique_ptr< std::vector< OUString > > pNewNames=nullptr)
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Redo() override
virtual ~ScUndoMoveTab() override
virtual void Repeat(SfxRepeatTarget &rTarget) override
std::unique_ptr< ::std::vector< OUString > > mpOldNames
std::unique_ptr< ::std::vector< OUString > > mpNewNames
virtual OUString GetComment() const override
std::unique_ptr< ::std::vector< SCTAB > > mpOldTabs
void DoChange(bool bUndo) const
void DoChange(bool bUndo)
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual void Undo() override
virtual void Redo() override
virtual OUString GetComment() const override
std::unique_ptr< ScPrintRangeSaver > pNewRanges
ScUndoPrintRange(ScDocShell *pShell, SCTAB nNewTab, std::unique_ptr< ScPrintRangeSaver > pOld, std::unique_ptr< ScPrintRangeSaver > pNew)
virtual ~ScUndoPrintRange() override
std::unique_ptr< ScPrintRangeSaver > pOldRanges
virtual void Undo() override
virtual void Repeat(SfxRepeatTarget &rTarget) override
void DoChange(bool bLink) const
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Redo() override
virtual ~ScUndoRemoveLink() override
std::unique_ptr< ScLinkMode[]> pModes
virtual OUString GetComment() const override
ScUndoRemoveLink(ScDocShell *pShell, OUString aDoc)
std::unique_ptr< OUString[]> pTabNames
std::unique_ptr< SCTAB[]> pTabs
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
ScUndoRenameObject(ScDocShell *pNewDocShell, OUString aPN, OUString aON, OUString aNN)
virtual void Undo() override
virtual ~ScUndoRenameObject() override
virtual void Redo() override
virtual OUString GetComment() const override
virtual void Redo() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Undo() override
ScScenarioFlags nOldFlags
virtual ~ScUndoScenarioFlags() override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual OUString GetComment() const override
ScUndoScenarioFlags(ScDocShell *pNewDocShell, SCTAB nT, OUString aON, OUString aNN, OUString aOC, OUString aNC, const Color &rOCol, const Color &rNCol, ScScenarioFlags nOF, ScScenarioFlags nNF)
ScScenarioFlags nNewFlags
virtual ~ScUndoShowHideTab() override
virtual OUString GetComment() const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual void Redo() override
ScUndoShowHideTab(ScDocShell *pShell, std::vector< SCTAB > &&newUndoTabs, bool bNewShow)
std::vector< SCTAB > undoTabs
virtual void Undo() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
void DoChange(bool bShow) const
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual void Redo() override
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual OUString GetComment() const override
virtual ~ScUndoTabColor() override
ScUndoTabColorInfo::List aTabColorList
void DoChange(bool bUndoType) const
virtual void Undo() override
ScUndoTabColor(ScDocShell *pNewDocShell, SCTAB nT, const Color &aOTabBgColor, const Color &aNTabBgColor)
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
virtual void Undo() override
virtual OUString GetComment() const override
virtual void Repeat(SfxRepeatTarget &rTarget) override
virtual ~ScUndoTabProtect() override
ScUndoTabProtect(ScDocShell *pShell, SCTAB nTab, std::unique_ptr< ScTableProtection > &&pProtectSettings)
::std::unique_ptr< ScTableProtection > mpProtectSettings
virtual void Redo() override
void DoProtect(bool bProtect)
ScDBFunc * GetView() const
void MoveTab(SCTAB nSrcTab, SCTAB nDestTab)
bool AppendTable(const OUString &rName, bool bRecord=true)
bool DeleteTables(const std::vector< SCTAB > &TheTabs, bool bRecord=true)
void DeleteTable(SCTAB nTabNr, bool bRecord=true)
void InsertTables(std::vector< OUString > &aNames, SCTAB nTab, SCTAB nCount, bool bRecord=true)
bool InsertTable(const OUString &rName, SCTAB nTabNr, bool bRecord=true)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
virtual void SetName(const OUString &rStr, const bool bSetChanged=true)
const OUString & GetPersistName() const
SfxViewShell * GetViewShell() const
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
EmbeddedObjectRef * pObject
OUString ScResId(TranslateId aId)
::std::vector< ScUndoTabColorInfo > List
std::unique_ptr< SdrUndoAction > GetSdrUndoAction(ScDocument *pDoc)
void DoSdrUndoAction(SdrUndoAction *pUndoAction, ScDocument *pDoc)
void RedoSdrUndoAction(SdrUndoAction *pUndoAction)
static SCTAB lcl_GetVisibleTabBefore(const ScDocument &rDoc, SCTAB nTab)