xref: /aoo42x/main/sc/source/ui/undo/undodraw.cxx (revision 01300968)
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 
ScUndoDraw(SfxUndoAction * pUndo,ScDocShell * pDocSh)42 ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
43 	pDrawUndo( pUndo ),
44 	pDocShell( pDocSh )
45 {
46 }
47 
~ScUndoDraw()48 __EXPORT ScUndoDraw::~ScUndoDraw()
49 {
50 	delete pDrawUndo;
51 }
52 
ForgetDrawUndo()53 void ScUndoDraw::ForgetDrawUndo()
54 {
55 	pDrawUndo = NULL;	// nicht loeschen (Draw-Undo muss dann von aussen gemerkt werden)
56 }
57 
GetComment() const58 String __EXPORT ScUndoDraw::GetComment() const
59 {
60 	if (pDrawUndo)
61 		return pDrawUndo->GetComment();
62 	else
63 		return String();
64 }
65 
GetRepeatComment(SfxRepeatTarget & rTarget) const66 String __EXPORT ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
67 {
68 	if (pDrawUndo)
69 		return pDrawUndo->GetRepeatComment(rTarget);
70 	else
71 		return String();
72 }
73 
GetId() const74 sal_uInt16 __EXPORT ScUndoDraw::GetId() const
75 {
76 	if (pDrawUndo)
77 		return pDrawUndo->GetId();
78 	else
79 		return 0;
80 }
81 
SetLinkToSfxLinkUndoAction(SfxLinkUndoAction * pSfxLinkUndoAction)82 void __EXPORT ScUndoDraw::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
83 {
84 	if (pDrawUndo)
85 		pDrawUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
86     else
87         SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
88 }
89 
Merge(SfxUndoAction * pNextAction)90 sal_Bool  __EXPORT ScUndoDraw::Merge( SfxUndoAction* pNextAction )
91 {
92 	if (pDrawUndo)
93 		return pDrawUndo->Merge(pNextAction);
94 	else
95 		return sal_False;
96 }
97 
UpdateSubShell()98 void ScUndoDraw::UpdateSubShell()
99 {
100     // #i26822# remove the draw shell if the selected object has been removed
101     ScTabViewShell* pViewShell = pDocShell->GetBestViewShell();
102     if (pViewShell)
103         pViewShell->UpdateDrawShell();
104 }
105 
Undo()106 void __EXPORT ScUndoDraw::Undo()
107 {
108 	if (pDrawUndo)
109 	{
110 		pDrawUndo->Undo();
111 		pDocShell->SetDrawModified();
112         UpdateSubShell();
113 	}
114 }
115 
Redo()116 void __EXPORT ScUndoDraw::Redo()
117 {
118 	if (pDrawUndo)
119 	{
120 		pDrawUndo->Redo();
121 		pDocShell->SetDrawModified();
122         UpdateSubShell();
123 	}
124 }
125 
Repeat(SfxRepeatTarget & rTarget)126 void __EXPORT ScUndoDraw::Repeat(SfxRepeatTarget& rTarget)
127 {
128 	if (pDrawUndo)
129 		pDrawUndo->Repeat(rTarget);
130 }
131 
CanRepeat(SfxRepeatTarget & rTarget) const132 sal_Bool __EXPORT ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const
133 {
134 	if (pDrawUndo)
135 		return pDrawUndo->CanRepeat(rTarget);
136 	else
137 		return sal_False;
138 }
139 
140 
141 
142