cid#1607171 Data race condition
[LibreOffice.git] / sc / source / ui / undo / undodraw.cxx
blob7204f16437df6eabc4ddd04376d1f18985573538
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <undodraw.hxx>
21 #include <docsh.hxx>
22 #include <tabvwsh.hxx>
25 ScUndoDraw::ScUndoDraw( std::unique_ptr<SfxUndoAction> pUndo, ScDocShell* pDocSh ) :
26 pDrawUndo( std::move(pUndo) ),
27 pDocShell( pDocSh ),
28 mnViewShellId( -1 )
30 if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
31 mnViewShellId = pViewShell->GetViewShellId();
34 ScUndoDraw::~ScUndoDraw()
38 OUString ScUndoDraw::GetComment() const
40 if (pDrawUndo)
41 return pDrawUndo->GetComment();
42 return OUString();
45 ViewShellId ScUndoDraw::GetViewShellId() const
47 return mnViewShellId;
50 OUString ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
52 if (pDrawUndo)
53 return pDrawUndo->GetRepeatComment(rTarget);
54 return OUString();
57 bool ScUndoDraw::Merge( SfxUndoAction* pNextAction )
59 if (pDrawUndo)
60 return pDrawUndo->Merge(pNextAction);
61 else
62 return false;
65 void ScUndoDraw::UpdateSubShell()
67 // #i26822# remove the draw shell if the selected object has been removed
68 ScTabViewShell* pViewShell = pDocShell->GetBestViewShell();
69 if (pViewShell)
70 pViewShell->UpdateDrawShell();
73 void ScUndoDraw::Undo()
75 if (pDrawUndo)
77 pDrawUndo->Undo();
78 pDocShell->SetDrawModified();
79 UpdateSubShell();
83 void ScUndoDraw::Redo()
85 if (pDrawUndo)
87 pDrawUndo->Redo();
88 pDocShell->SetDrawModified();
89 UpdateSubShell();
93 void ScUndoDraw::Repeat(SfxRepeatTarget& rTarget)
95 if (pDrawUndo)
96 pDrawUndo->Repeat(rTarget);
99 bool ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const
101 if (pDrawUndo)
102 return pDrawUndo->CanRepeat(rTarget);
103 else
104 return false;
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */