xref: /trunk/main/sd/source/ui/func/undolayer.cxx (revision 79aad27f)
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_sd.hxx"
26 
27 #include "undolayer.hxx"
28 
29 #include "DrawDocShell.hxx"
30 #include "drawdoc.hxx"
31 #include "DrawViewShell.hxx"
32 #include "strings.hrc"
33 #include "sdresid.hxx"
34 
35 TYPEINIT1(SdLayerModifyUndoAction, SdUndoAction);
36 
SdLayerModifyUndoAction(SdDrawDocument * _pDoc,SdrLayer * pLayer,const String & rOldLayerName,const String & rOldLayerTitle,const String & rOldLayerDesc,bool bOldIsVisible,bool bOldIsLocked,bool bOldIsPrintable,const String & rNewLayerName,const String & rNewLayerTitle,const String & rNewLayerDesc,bool bNewIsVisible,bool bNewIsLocked,bool bNewIsPrintable)37 SdLayerModifyUndoAction::SdLayerModifyUndoAction(
38 	SdDrawDocument* _pDoc, SdrLayer* pLayer,
39 	const String& rOldLayerName, const String& rOldLayerTitle, const String& rOldLayerDesc, bool bOldIsVisible, bool bOldIsLocked, bool bOldIsPrintable,
40 	const String& rNewLayerName, const String& rNewLayerTitle, const String& rNewLayerDesc, bool bNewIsVisible, bool bNewIsLocked, bool bNewIsPrintable )
41 :	SdUndoAction( _pDoc ),
42 	mpLayer( pLayer ),
43 	maOldLayerName( rOldLayerName ),
44 	maOldLayerTitle( rOldLayerTitle ),
45 	maOldLayerDesc( rOldLayerDesc ),
46 	mbOldIsVisible( bOldIsVisible ),
47 	mbOldIsLocked( bOldIsLocked ),
48 	mbOldIsPrintable( bOldIsPrintable ),
49 	maNewLayerName( rNewLayerName ),
50 	maNewLayerTitle( rNewLayerTitle ),
51 	maNewLayerDesc( rNewLayerDesc ),
52 	mbNewIsVisible( bNewIsVisible ),
53 	mbNewIsLocked( bNewIsLocked ),
54 	mbNewIsPrintable( bNewIsPrintable )
55 {
56 	String aString(SdResId(STR_MODIFYLAYER));
57 	SetComment(aString);
58 }
59 
Undo()60 void SdLayerModifyUndoAction::Undo()
61 {
62 	::sd::DrawDocShell* mpDocSh = mpDoc->GetDocSh();
63 	if( mpDocSh )
64 	{
65 		::sd::DrawViewShell* pDrViewSh =
66               PTR_CAST(::sd::DrawViewShell, mpDocSh->GetViewShell() );
67 		if( pDrViewSh )
68 		{
69 			pDrViewSh->ModifyLayer( mpLayer, maOldLayerName, maOldLayerTitle, maOldLayerDesc, mbOldIsVisible, mbOldIsLocked, mbOldIsPrintable );
70 		}
71 	}
72 }
73 
Redo()74 void SdLayerModifyUndoAction::Redo()
75 {
76 	::sd::DrawDocShell* mpDocSh = mpDoc->GetDocSh();
77 	if( mpDocSh )
78 	{
79 		::sd::DrawViewShell* pDrViewSh =
80               PTR_CAST(::sd::DrawViewShell, mpDocSh->GetViewShell() );
81 		if( pDrViewSh )
82 		{
83 			pDrViewSh->ModifyLayer( mpLayer, maNewLayerName, maNewLayerTitle, maNewLayerDesc, mbNewIsVisible, mbNewIsLocked, mbNewIsPrintable );
84 		}
85 	}
86 }
87