Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <svx/svdundo.hxx>
21 :
22 : #include "undodraw.hxx"
23 : #include "docsh.hxx"
24 : #include "tabvwsh.hxx"
25 :
26 0 : TYPEINIT1(ScUndoDraw, SfxUndoAction);
27 :
28 0 : ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
29 : pDrawUndo( pUndo ),
30 0 : pDocShell( pDocSh )
31 : {
32 0 : }
33 :
34 0 : ScUndoDraw::~ScUndoDraw()
35 : {
36 0 : delete pDrawUndo;
37 0 : }
38 :
39 0 : void ScUndoDraw::ForgetDrawUndo()
40 : {
41 0 : pDrawUndo = NULL; // do not delete (DrawUndo has to be remembered from outside)
42 0 : }
43 :
44 0 : OUString ScUndoDraw::GetComment() const
45 : {
46 0 : if (pDrawUndo)
47 0 : return pDrawUndo->GetComment();
48 0 : return OUString();
49 : }
50 :
51 0 : OUString ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
52 : {
53 0 : if (pDrawUndo)
54 0 : return pDrawUndo->GetRepeatComment(rTarget);
55 0 : return OUString();
56 : }
57 :
58 0 : sal_uInt16 ScUndoDraw::GetId() const
59 : {
60 0 : if (pDrawUndo)
61 0 : return pDrawUndo->GetId();
62 : else
63 0 : return 0;
64 : }
65 :
66 0 : void ScUndoDraw::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
67 : {
68 0 : if (pDrawUndo)
69 0 : pDrawUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
70 : else
71 0 : SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
72 0 : }
73 :
74 0 : bool ScUndoDraw::Merge( SfxUndoAction* pNextAction )
75 : {
76 0 : if (pDrawUndo)
77 0 : return pDrawUndo->Merge(pNextAction);
78 : else
79 0 : return false;
80 : }
81 :
82 0 : void ScUndoDraw::UpdateSubShell()
83 : {
84 : // #i26822# remove the draw shell if the selected object has been removed
85 0 : ScTabViewShell* pViewShell = pDocShell->GetBestViewShell();
86 0 : if (pViewShell)
87 0 : pViewShell->UpdateDrawShell();
88 0 : }
89 :
90 0 : void ScUndoDraw::Undo()
91 : {
92 0 : if (pDrawUndo)
93 : {
94 0 : pDrawUndo->Undo();
95 0 : pDocShell->SetDrawModified();
96 0 : UpdateSubShell();
97 : }
98 0 : }
99 :
100 0 : void ScUndoDraw::Redo()
101 : {
102 0 : if (pDrawUndo)
103 : {
104 0 : pDrawUndo->Redo();
105 0 : pDocShell->SetDrawModified();
106 0 : UpdateSubShell();
107 : }
108 0 : }
109 :
110 0 : void ScUndoDraw::Repeat(SfxRepeatTarget& rTarget)
111 : {
112 0 : if (pDrawUndo)
113 0 : pDrawUndo->Repeat(rTarget);
114 0 : }
115 :
116 0 : bool ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const
117 : {
118 0 : if (pDrawUndo)
119 0 : return pDrawUndo->CanRepeat(rTarget);
120 : else
121 0 : return false;
122 0 : }
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|