Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / undo / undodraw.cxx
blobb46825de8bdc6ae1e7fb37f9c0b07a47600727d1
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 <svx/svdundo.hxx>
22 #include "undodraw.hxx"
23 #include "docsh.hxx"
24 #include "tabvwsh.hxx"
26 TYPEINIT1(ScUndoDraw, SfxUndoAction);
28 ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
29 pDrawUndo( pUndo ),
30 pDocShell( pDocSh )
34 ScUndoDraw::~ScUndoDraw()
36 delete pDrawUndo;
39 void ScUndoDraw::ForgetDrawUndo()
41 pDrawUndo = NULL; // do not delete (DrawUndo has to be remembered from outside)
44 OUString ScUndoDraw::GetComment() const
46 if (pDrawUndo)
47 return pDrawUndo->GetComment();
48 return OUString();
51 OUString ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
53 if (pDrawUndo)
54 return pDrawUndo->GetRepeatComment(rTarget);
55 return OUString();
58 sal_uInt16 ScUndoDraw::GetId() const
60 if (pDrawUndo)
61 return pDrawUndo->GetId();
62 else
63 return 0;
66 void ScUndoDraw::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
68 if (pDrawUndo)
69 pDrawUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
70 else
71 SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
74 bool ScUndoDraw::Merge( SfxUndoAction* pNextAction )
76 if (pDrawUndo)
77 return pDrawUndo->Merge(pNextAction);
78 else
79 return false;
82 void ScUndoDraw::UpdateSubShell()
84 // #i26822# remove the draw shell if the selected object has been removed
85 ScTabViewShell* pViewShell = pDocShell->GetBestViewShell();
86 if (pViewShell)
87 pViewShell->UpdateDrawShell();
90 void ScUndoDraw::Undo()
92 if (pDrawUndo)
94 pDrawUndo->Undo();
95 pDocShell->SetDrawModified();
96 UpdateSubShell();
100 void ScUndoDraw::Redo()
102 if (pDrawUndo)
104 pDrawUndo->Redo();
105 pDocShell->SetDrawModified();
106 UpdateSubShell();
110 void ScUndoDraw::Repeat(SfxRepeatTarget& rTarget)
112 if (pDrawUndo)
113 pDrawUndo->Repeat(rTarget);
116 bool ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const
118 if (pDrawUndo)
119 return pDrawUndo->CanRepeat(rTarget);
120 else
121 return false;
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */