xref: /aoo42x/main/sc/source/ui/undo/undodraw.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 // INCLUDE ---------------------------------------------------------------
28 
29 #include <svx/svdundo.hxx>
30 
31 #include "undodraw.hxx"
32 #include "docsh.hxx"
33 #include "tabvwsh.hxx"
34 
35 
36 // -----------------------------------------------------------------------
37 
38 TYPEINIT1(ScUndoDraw, SfxUndoAction);
39 
40 // -----------------------------------------------------------------------
41 
42 ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
43 	pDrawUndo( pUndo ),
44 	pDocShell( pDocSh )
45 {
46 }
47 
48 __EXPORT ScUndoDraw::~ScUndoDraw()
49 {
50 	delete pDrawUndo;
51 }
52 
53 void ScUndoDraw::ForgetDrawUndo()
54 {
55 	pDrawUndo = NULL;	// nicht loeschen (Draw-Undo muss dann von aussen gemerkt werden)
56 }
57 
58 String __EXPORT ScUndoDraw::GetComment() const
59 {
60 	if (pDrawUndo)
61 		return pDrawUndo->GetComment();
62 	else
63 		return String();
64 }
65 
66 String __EXPORT ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
67 {
68 	if (pDrawUndo)
69 		return pDrawUndo->GetRepeatComment(rTarget);
70 	else
71 		return String();
72 }
73 
74 sal_uInt16 __EXPORT ScUndoDraw::GetId() const
75 {
76 	if (pDrawUndo)
77 		return pDrawUndo->GetId();
78 	else
79 		return 0;
80 }
81 
82 sal_Bool __EXPORT ScUndoDraw::IsLinked()
83 {
84 	if (pDrawUndo)
85 		return pDrawUndo->IsLinked();
86 	else
87 		return sal_False;
88 }
89 
90 void __EXPORT ScUndoDraw::SetLinked( sal_Bool bIsLinked )
91 {
92 	if (pDrawUndo)
93 		pDrawUndo->SetLinked(bIsLinked);
94 }
95 
96 sal_Bool  __EXPORT ScUndoDraw::Merge( SfxUndoAction* pNextAction )
97 {
98 	if (pDrawUndo)
99 		return pDrawUndo->Merge(pNextAction);
100 	else
101 		return sal_False;
102 }
103 
104 void ScUndoDraw::UpdateSubShell()
105 {
106     // #i26822# remove the draw shell if the selected object has been removed
107     ScTabViewShell* pViewShell = pDocShell->GetBestViewShell();
108     if (pViewShell)
109         pViewShell->UpdateDrawShell();
110 }
111 
112 void __EXPORT ScUndoDraw::Undo()
113 {
114 	if (pDrawUndo)
115 	{
116 		pDrawUndo->Undo();
117 		pDocShell->SetDrawModified();
118         UpdateSubShell();
119 	}
120 }
121 
122 void __EXPORT ScUndoDraw::Redo()
123 {
124 	if (pDrawUndo)
125 	{
126 		pDrawUndo->Redo();
127 		pDocShell->SetDrawModified();
128         UpdateSubShell();
129 	}
130 }
131 
132 void __EXPORT ScUndoDraw::Repeat(SfxRepeatTarget& rTarget)
133 {
134 	if (pDrawUndo)
135 		pDrawUndo->Repeat(rTarget);
136 }
137 
138 sal_Bool __EXPORT ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const
139 {
140 	if (pDrawUndo)
141 		return pDrawUndo->CanRepeat(rTarget);
142 	else
143 		return sal_False;
144 }
145 
146 
147 
148