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 :
21 : #ifndef _SVDLAYER
22 : #include <svx/svdlayer.hxx>
23 : #endif
24 : #include <sfx2/dispatch.hxx>
25 : #include <sfx2/viewfrm.hxx>
26 :
27 :
28 : #include "strings.hrc"
29 : #include "glob.hxx"
30 : #include "glob.hrc" // STR_BCKGRND, STR_BCKGRNDOBJ
31 : #include "app.hrc" // SID_SWITCHPAGE
32 :
33 : #include "unmodpg.hxx"
34 : #include "sdpage.hxx"
35 : #include "sdresid.hxx"
36 : #include "drawdoc.hxx"
37 :
38 :
39 0 : TYPEINIT1(ModifyPageUndoAction, SdUndoAction);
40 :
41 :
42 :
43 0 : ModifyPageUndoAction::ModifyPageUndoAction(
44 : SdDrawDocument* pTheDoc,
45 : SdPage* pThePage,
46 : String aTheNewName,
47 : AutoLayout eTheNewAutoLayout,
48 : sal_Bool bTheNewBckgrndVisible,
49 : sal_Bool bTheNewBckgrndObjsVisible)
50 0 : : SdUndoAction(pTheDoc)
51 : {
52 : DBG_ASSERT(pThePage, "Undo without a page???");
53 :
54 0 : mpPage = pThePage;
55 0 : maNewName = aTheNewName;
56 0 : meNewAutoLayout = eTheNewAutoLayout;
57 0 : mbNewBckgrndVisible = bTheNewBckgrndVisible;
58 0 : mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
59 :
60 0 : meOldAutoLayout = mpPage->GetAutoLayout();
61 :
62 0 : if (!mpPage->IsMasterPage())
63 : {
64 0 : maOldName = mpPage->GetName();
65 0 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
66 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
67 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
68 0 : SetOfByte aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
69 :
70 0 : mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
71 0 : mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
72 : }
73 :
74 0 : maComment = String(SdResId(STR_UNDO_MODIFY_PAGE));
75 0 : }
76 :
77 : #include <svx/svdviter.hxx>
78 : #include <svx/svdview.hxx>
79 0 : void ModifyPageUndoAction::Undo()
80 : {
81 : // invalidate Selection, there could be objects deleted in this UNDO
82 : // which are no longer allowed to be selected then.
83 0 : SdrViewIter aIter(mpPage);
84 0 : SdrView* pView = aIter.FirstView();
85 :
86 0 : while(pView)
87 : {
88 0 : if(pView->AreObjectsMarked())
89 0 : pView->UnmarkAll();
90 0 : pView = aIter.NextView();
91 : }
92 :
93 0 : mpPage->SetAutoLayout( meOldAutoLayout );
94 :
95 0 : if (!mpPage->IsMasterPage())
96 : {
97 0 : if (mpPage->GetName() != maOldName)
98 : {
99 0 : mpPage->SetName(maOldName);
100 :
101 0 : if (mpPage->GetPageKind() == PK_STANDARD)
102 : {
103 0 : SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
104 0 : pNotesPage->SetName(maOldName);
105 : }
106 : }
107 :
108 0 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
109 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
110 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
111 0 : SetOfByte aVisibleLayers;
112 0 : aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
113 0 : aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
114 0 : mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
115 : }
116 :
117 : // Redisplay
118 : SfxViewFrame::Current()->GetDispatcher()->Execute(
119 0 : SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
120 0 : }
121 :
122 :
123 0 : void ModifyPageUndoAction::Redo()
124 : {
125 : // invalidate Selection, there could be objects deleted in this UNDO
126 : // which are no longer allowed to be selected then.
127 0 : SdrViewIter aIter(mpPage);
128 0 : SdrView* pView = aIter.FirstView();
129 :
130 0 : while(pView)
131 : {
132 0 : if(pView->AreObjectsMarked())
133 0 : pView->UnmarkAll();
134 0 : pView = aIter.NextView();
135 : }
136 :
137 0 : mpPage->meAutoLayout = meNewAutoLayout;
138 :
139 0 : if (!mpPage->IsMasterPage())
140 : {
141 0 : if (mpPage->GetName() != maNewName)
142 : {
143 0 : mpPage->SetName(maNewName);
144 :
145 0 : if (mpPage->GetPageKind() == PK_STANDARD)
146 : {
147 0 : SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
148 0 : pNotesPage->SetName(maNewName);
149 : }
150 : }
151 :
152 0 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
153 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
154 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
155 0 : SetOfByte aVisibleLayers;
156 0 : aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
157 0 : aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
158 0 : mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
159 : }
160 :
161 : // Redisplay
162 : SfxViewFrame::Current()->GetDispatcher()->Execute(
163 0 : SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
164 0 : }
165 :
166 :
167 0 : ModifyPageUndoAction::~ModifyPageUndoAction()
168 : {
169 0 : }
170 :
171 :
172 0 : OUString ModifyPageUndoAction::GetComment() const
173 : {
174 0 : return maComment;
175 : }
176 :
177 : // --------------------------------------------------------------------
178 :
179 0 : RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction( SdDrawDocument* pDocument, const String& rOldLayoutName, const String& rNewLayoutName )
180 : : SdUndoAction(pDocument)
181 : , maOldName( rOldLayoutName )
182 : , maNewName( rNewLayoutName )
183 0 : , maComment(SdResId(STR_TITLE_RENAMESLIDE))
184 : {
185 0 : sal_uInt16 nPos = maOldName.SearchAscii( SD_LT_SEPARATOR );
186 0 : if( nPos != (sal_uInt16)-1 )
187 0 : maOldName.Erase(nPos);
188 0 : }
189 :
190 0 : void RenameLayoutTemplateUndoAction::Undo()
191 : {
192 0 : String aLayoutName( maNewName );
193 0 : aLayoutName.AppendAscii( SD_LT_SEPARATOR );
194 0 : aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
195 :
196 0 : mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
197 0 : }
198 :
199 0 : void RenameLayoutTemplateUndoAction::Redo()
200 : {
201 0 : String aLayoutName( maOldName );
202 0 : aLayoutName.AppendAscii( SD_LT_SEPARATOR );
203 0 : aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
204 :
205 0 : mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
206 0 : }
207 :
208 0 : OUString RenameLayoutTemplateUndoAction::GetComment() const
209 : {
210 0 : return maComment;
211 33 : }
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|