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