/* -*- 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
bool ScSimpleUndo::Merge( SfxUndoAction *pNextAction )
{ // A SdrUndoGroup for updating detective arrows can belong // to each Undo-Action. // DetectiveRefresh is always called next, // the SdrUndoGroup is encapsulated in a ScUndoDraw action. // AddUndoAction is only called with bTryMerg=sal_True // for automatic update.
if ( !pDetectiveUndo && dynamic_cast<const ScUndoDraw*>( pNextAction) != nullptr )
{ // Take SdrUndoAction from ScUndoDraw Action, // ScUndoDraw is later deleted by the UndoManager
// tdf#161712 invoke ScSimpleUndo::EndUndo() before ShowBlock() // If this is an instance of ScUndoAutoFill, ShowBlock() will invoke // ScTabViewShell::MoveCursorAbs() which will delete this instance // so invoke ScSimpleUndo::EndUndo() first.
ScSimpleUndo::EndUndo();
ShowBlock();
}
void ScBlockUndo::EndRedo()
{ if (eMode == SC_UNDO_AUTOHEIGHT)
AdjustHeight();
void ScBlockUndo::ShowBlock()
{ if ( IsPaintLocked() ) return;
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (!pViewShell) return;
ShowTable( aBlockRange ); // with multiple sheets in range each of them is good
pViewShell->MoveCursorAbs( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(),
SC_FOLLOW_JUMP, false, false );
SCTAB nTab = pViewShell->GetViewData().GetTabNo();
ScRange aRange = aBlockRange;
aRange.aStart.SetTab( nTab );
aRange.aEnd.SetTab( nTab );
pViewShell->MarkRange( aRange );
// not through SetMarkArea to MarkData, due to possibly lacking paint
}
void ScDBFuncUndo::BeginRedo()
{
RedoSdrUndoAction( nullptr ); if ( pAutoDBRange )
{ // move the database range to this function's position again (see ScDocShell::GetDBData)
/** * Checks if the topmost undo action owned by pView is independent from the topmost action undo * action.
*/ bool ScUndoManager::IsViewUndoActionIndependent(const SfxViewShell* pView, sal_uInt16& rOffset) const
{ if (GetUndoActionCount() <= 1)
{ // Single or less undo, owned by another view. returnfalse;
}
if (!pView)
{ returnfalse;
}
// Last undo action that doesn't belong to the view. const SfxUndoAction* pTopAction = GetUndoAction();
ViewShellId nViewId = pView->GetViewShellId();
// Earlier undo action that belongs to the view, but is not the top one. const SfxUndoAction* pViewAction = nullptr;
size_t nOffset = 0; for (size_t i = 0; i < GetUndoActionCount(); ++i)
{ const SfxUndoAction* pAction = GetUndoAction(i); if (pAction->GetViewShellId() == nViewId)
{
pViewAction = pAction;
nOffset = i; break;
}
}
if (!pViewAction)
{ // Found no earlier undo action that belongs to the view. returnfalse;
}
std::optional<ScRange> topRange = getAffectedRangeFromUndo(pTopAction); if (!topRange) returnfalse;
std::optional<ScRange> viewRange = getAffectedRangeFromUndo(pViewAction); if (!viewRange) returnfalse;
if (topRange->Intersects(*viewRange)) returnfalse;
for (size_t i = 0; i < GetRedoActionCount(); ++i)
{ auto pRedoAction = getScSimpleUndo(GetRedoAction(i)); if (!pRedoAction)
{ returnfalse;
}
std::optional<ScRange> redoRange = getAffectedRangeFromUndo(pRedoAction); if (!redoRange || (redoRange->Intersects(*viewRange) && pRedoAction->GetViewShellId() != nViewId))
{ // Dependent redo action and owned by another view. returnfalse;
}
}
rOffset = nOffset; returntrue;
}
std::optional<ScRange> ScUndoManager::getAffectedRangeFromUndo(const SfxUndoAction* pAction)
{ auto pSimpleUndo = getScSimpleUndo(pAction); if (!pSimpleUndo) return std::nullopt; return pSimpleUndo->getAffectedRange();
}
const ScSimpleUndo* ScUndoManager::getScSimpleUndo(const SfxUndoAction* pAction)
{ const ScSimpleUndo* pSimpleUndo = dynamic_cast<const ScSimpleUndo*>(pAction); if (pSimpleUndo) return pSimpleUndo; auto pListAction = dynamic_cast<const SfxListUndoAction*>(pAction); if (!pListAction) return nullptr; if (pListAction->maUndoActions.size() > 1) return nullptr; returndynamic_cast<ScSimpleUndo*>(pListAction->maUndoActions[0].pAction.get());
}
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.